Subversion Repositories VORC

Rev

Rev 235 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
172 - 1
#!/usr/bin/perl
2
 
3
use strict;
4
use cPanelUserConfig;
5
use RollerCon;
6
use DBI;
7
use WebDB;
8
use REST::Client;
9
use JSON;
10
my $DEBUG = 0;
11
 
12
my $dbh = WebDB::connect ();
13
 
14
my $sth = $dbh->prepare ("update ticket set wrstbnd_accountid = ? where id = ?");
15
my @REGIDS;
16
push @REGIDS, map { @{$_} } @{ $dbh->selectall_arrayref ("select id from ticket where event_name = ?", undef, "RollerCon 2024") };
17
foreach (@REGIDS) {
18
  my $regid = $_;
19
  print "Updating RegID: $regid - ";
20
	my $wbdid = getAccountId ($regid);
21
	print "$wbdid";
22
	$sth->execute ($wbdid, $regid);
23
	print " - Done.\n";
24
}
25
 
26
 
27
 
28
sub toList {
29
   my $data = shift;
30
   my $key = shift;
31
   if (ref($data->{$key}) eq 'ARRAY') {
32
       $data->{$key};
33
   } elsif (ref($data->{$key}) eq 'HASH') {
34
       [$data->{$key}];
35
   } else {
36
       [];
37
   }
38
}
39
 
40
sub getAccountId {
41
	my $eventsReg = shift // "";
42
	warn "ERROR: No Events.com Regstration provided to getAccountId()!" and return "" unless $eventsReg;
43
 
44
	my $headers = { Authorization => '601037851507c624' };
45
	my $wb_event_id = "event_Y5567UWwS5";
46
	my $client = REST::Client->new();
47
 
48
	$client->setHost('https://core.wrstbnd.io');
49
	$client->GET(
50
    '/rest/core/v1/ticket?eventid='.$wb_event_id.'&barcode='.$eventsReg,
51
    $headers
52
	);
53
	my $response = from_json($client->responseContent());
54
 
55
	warn Dumper $response if $DEBUG;
56
 
57
	return $response->{accountId};
58
}