Rev 235 | Rev 237 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
#!/usr/bin/perluse strict;use cPanelUserConfig;use RollerCon;use DBI;use WebDB;use REST::Client;use JSON;my $DEBUG = 0;my $dbh = WebDB::connect ();my $sth = $dbh->prepare ("update ticket set wrstbnd_accountid = ? where id = ?");my @REGIDS;push @REGIDS, map { @{$_} } @{ $dbh->selectall_arrayref ("select id from ticket where event_name = ?", undef, "RollerCon 2025") };foreach (@REGIDS) {my $regid = $_;print "Updating RegID: $regid - ";my $wbdid = getAccountId ($regid);unless ($wbdid) { print "ERROR: No Wrstbnd ID found for ticket.\n" and next; }print "$wbdid";$sth->execute ($wbdid, $regid);print " - Done.\n";}sub toList {my $data = shift;my $key = shift;if (ref($data->{$key}) eq 'ARRAY') {$data->{$key};} elsif (ref($data->{$key}) eq 'HASH') {[$data->{$key}];} else {[];}}sub getAccountId {my $eventsReg = shift // "";warn "ERROR: No Events.com Regstration provided to getAccountId()!" and return "" unless $eventsReg;my $headers = { Authorization => getSetting ("WRSTBND_API_KEY") };my $wb_event_id = "event_893C6u5olU";my $client = REST::Client->new();$client->setHost('https://core.wrstbnd.io');$client->GET('/rest/core/v1/ticket/actcode/'.$eventsReg'?eventid='.$wb_event_id,$headers);my $response = from_json($client->responseContent());warn Dumper $response if $DEBUG;return $response->{accountId};}