Subversion Repositories VORC

Rev

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

Rev Author Line No. Line
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 ();
12
my $headers = { Authorization => '601037851507c624' };
13
 
14
print "Bulk adding class registrations...\n";
15
 
16
my $sth = $dbh->prepare ("select class.id, v_class_signup.RCid, wrstbnd_id, wrstbnd_accountid from v_class_signup left join class on v_class_signup.id = class.id left join RCid_ticket_link on v_class_signup.RCid = RCid_ticket_link.RCid and year = year(now()) left join ticket on MVPid = ticket.id where year(v_class_signup.date) = year(now())");
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();
24
 
25
  my $body = {
26
    "eventId"      => "event_Y5567UWwS5",
27
    "activeStatus" => "active",
28
    "ticketTypeId" => $classid
29
  };
30
  my $json_body = encode_json $body;
31
 
32
  $client->POST(
33
    '/rest/core/v1/ticket',
34
    $json_body,
35
    $headers
36
  );
37
  my $response = from_json($client->responseContent());
38
 
39
  #print Dumper $response;
40
  my $activationCode = $response->{activationCode};
41
  print $activationCode."...";
42
 
43
  my $add_response = `/bin/curl --no-progress-meter -i --location 'https://core.wrstbnd.io/rest/core/v1/assign' --header 'Authorization: 601037851507c624' --form 'accountid="$accountid"' --form 'ticketactcode="$activationCode"' | /bin/grep HTTP | /bin/cut -d' ' -f2`;
44
  print $add_response;
45
  $assignment->execute ($activationCode, $id, $rcid, 'CLA-%') unless $add_response ne "200";
46
}
47
 
48
 
49
print "\nDone.\n";