| 176 |
- |
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 |
|
|
|
11 |
my $dbh = WebDB::connect ();
|
| 236 |
- |
12 |
my $headers = { Authorization => getSetting ("WRSTBND_API_KEY") };
|
| 176 |
- |
13 |
|
|
|
14 |
print "Bulk adding class registrations...\n";
|
|
|
15 |
|
| 208 |
- |
16 |
my $sth = $dbh->prepare ("select class.id, v_class_signup_new.RCid, wrstbnd_id, wrstbnd_accountid from v_class_signup_new left join class on v_class_signup_new.id = class.id left join RCid_ticket_link on v_class_signup_new.RCid = RCid_ticket_link.RCid and year = year(now()) left join ticket on MVPid = ticket.id where year(v_class_signup_new.date) = year(now())");
|
| 176 |
- |
17 |
my $assignment = $dbh->prepare ("update assignment set wb_ticket_act = ? where Gid = ? and RCid = ? and role like ?");
|
|
|
18 |
|
|
|
19 |
$sth->execute ();
|
|
|
20 |
|
|
|
21 |
while (my ($id, $rcid, $classid, $accountid) = $sth->fetchrow ()) {
|
|
|
22 |
print "Adding $classid to $accountid...";
|
|
|
23 |
my $client = REST::Client->new();
|
| 177 |
- |
24 |
$client->setHost('https://core.wrstbnd.io');
|
|
|
25 |
|
| 176 |
- |
26 |
my $body = {
|
| 235 |
- |
27 |
"eventId" => "event_893C6u5olU",
|
| 176 |
- |
28 |
"activeStatus" => "active",
|
|
|
29 |
"ticketTypeId" => $classid
|
|
|
30 |
};
|
|
|
31 |
my $json_body = encode_json $body;
|
|
|
32 |
|
|
|
33 |
$client->POST(
|
|
|
34 |
'/rest/core/v1/ticket',
|
|
|
35 |
$json_body,
|
|
|
36 |
$headers
|
|
|
37 |
);
|
|
|
38 |
my $response = from_json($client->responseContent());
|
|
|
39 |
|
|
|
40 |
#print Dumper $response;
|
|
|
41 |
my $activationCode = $response->{activationCode};
|
|
|
42 |
print $activationCode."...";
|
| 236 |
- |
43 |
my $api_key = getSetting ("WRSTBND_API_KEY");
|
|
|
44 |
my $add_response = `/bin/curl --location 'https://core.wrstbnd.io/rest/core/v1/assign' --header 'Authorization: $api_key' --form accountid=$accountid --form ticketactcode=$activationCode --output /dev/null --silent --write-out '%{http_code}\n'`;
|
| 176 |
- |
45 |
print $add_response;
|
|
|
46 |
$assignment->execute ($activationCode, $id, $rcid, 'CLA-%') unless $add_response ne "200";
|
|
|
47 |
}
|
|
|
48 |
|
|
|
49 |
|
|
|
50 |
print "\nDone.\n";
|