Subversion Repositories VORC

Rev

Rev 235 | Rev 237 | Go to most recent revision | Details | Compare with Previous | 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;
235 - 16
push @REGIDS, map { @{$_} } @{ $dbh->selectall_arrayref ("select id from ticket where event_name = ?", undef, "RollerCon 2025") };
172 - 17
foreach (@REGIDS) {
18
  my $regid = $_;
19
  print "Updating RegID: $regid - ";
236 - 20
  my $wbdid = getAccountId ($regid);
21
  unless ($wbdid) { print "ERROR: No Wrstbnd ID found for ticket.\n" and next; }
22
  print "$wbdid";
23
  $sth->execute ($wbdid, $regid);
24
  print " - Done.\n";
172 - 25
}
26
 
27
 
28
 
29
sub toList {
30
   my $data = shift;
31
   my $key = shift;
32
   if (ref($data->{$key}) eq 'ARRAY') {
33
       $data->{$key};
34
   } elsif (ref($data->{$key}) eq 'HASH') {
35
       [$data->{$key}];
36
   } else {
37
       [];
38
   }
39
}
40
 
41
sub getAccountId {
236 - 42
  my $eventsReg = shift // "";
43
  warn "ERROR: No Events.com Regstration provided to getAccountId()!" and return "" unless $eventsReg;
44
 
45
  my $headers = { Authorization => getSetting ("WRSTBND_API_KEY") };
46
  my $wb_event_id = "event_893C6u5olU";
47
  my $client = REST::Client->new();
48
 
49
  $client->setHost('https://core.wrstbnd.io');
50
  $client->GET(
51
    '/rest/core/v1/ticket/actcode/'.$eventsReg'?eventid='.$wb_event_id,
172 - 52
    $headers
236 - 53
  );
54
  my $response = from_json($client->responseContent());
172 - 55
 
236 - 56
  warn Dumper $response if $DEBUG;
172 - 57
 
236 - 58
  return $response->{accountId};
172 - 59
}