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