Rev 208 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
#!/usr/bin/perluse strict;use cPanelUserConfig;#use RollerCon;use DBI;use WebDB;use REST::Client;use JSON;my $dbh = WebDB::connect ();my $headers = { Authorization => '601037851507c624' };print "Bulk adding class registrations...\n";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())");my $assignment = $dbh->prepare ("update assignment set wb_ticket_act = ? where Gid = ? and RCid = ? and role like ?");$sth->execute ();while (my ($id, $rcid, $classid, $accountid) = $sth->fetchrow ()) {print "Adding $classid to $accountid...";my $client = REST::Client->new();$client->setHost('https://core.wrstbnd.io');my $body = {"eventId" => "event_893C6u5olU","activeStatus" => "active","ticketTypeId" => $classid};my $json_body = encode_json $body;$client->POST('/rest/core/v1/ticket',$json_body,$headers);my $response = from_json($client->responseContent());#print Dumper $response;my $activationCode = $response->{activationCode};print $activationCode."...";my $add_response = `/bin/curl --location 'https://core.wrstbnd.io/rest/core/v1/assign' --header 'Authorization: 601037851507c624' --form accountid=$accountid --form ticketactcode=$activationCode --output /dev/null --silent --write-out '%{http_code}\n'`;print $add_response;$assignment->execute ($activationCode, $id, $rcid, 'CLA-%') unless $add_response ne "200";}print "\nDone.\n";