Subversion Repositories VORC

Rev

Rev 172 | Rev 236 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

#!/usr/bin/perl

use 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);
        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 => '601037851507c624' };
        my $wb_event_id = "event_893C6u5olU";
        my $client = REST::Client->new();
        
        $client->setHost('https://core.wrstbnd.io');
        $client->GET(
    '/rest/core/v1/ticket?eventid='.$wb_event_id.'&barcode='.$eventsReg,
    $headers
        );
        my $response = from_json($client->responseContent());

        warn Dumper $response if $DEBUG;

        return $response->{accountId};
}