Rev 176 | 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.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())");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_Y5567UWwS5","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 --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`;print $add_response;$assignment->execute ($activationCode, $id, $rcid, 'CLA-%') unless $add_response ne "200";}print "\nDone.\n";