Subversion Repositories VORC

Rev

Rev 274 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 274 Rev 278
Line 1... Line 1...
1
#!/usr/bin/perl
1
#!/usr/bin/perl
Line 2... Line 2...
2
 
2
 
3
use strict;
3
use strict;
4
use cPanelUserConfig;
4
use cPanelUserConfig;
5
#use RollerCon;
5
use RollerCon;
6
use DBI;
6
use DBI;
7
use WebDB;
7
use WebDB;
8
use REST::Client;
8
use REST::Client;
-
 
9
use JSON;
Line 9... Line 10...
9
use JSON;
10
use Data::Dumper;
10
 
11
 
Line 11... Line 12...
11
my $dbh = WebDB::connect ();
12
my $dbh = WebDB::connect ();
Line -... Line 13...
-
 
13
my $headers = { Authorization => getSetting ("WRSTBND_API_KEY") };
-
 
14
 
-
 
15
print "Bulk adding class registrations...\n";
-
 
16
 
-
 
17
my $sql = <<sqlstatement;
-
 
18
  select class.id, v_class_signup_new.RCid, wrstbnd_id, wrstbnd_accountid
-
 
19
  from v_class_signup_new
-
 
20
  left join class on v_class_signup_new.id = class.id
-
 
21
  left join RCid_ticket_link on v_class_signup_new.RCid = RCid_ticket_link.RCid and year = year(now())
12
my $headers = { Authorization => getSetting ("WRSTBND_API_KEY") };
22
  left join ticket on MVPid = ticket.id
-
 
23
  where year(class.date) = year(now()) and isnull(wb_ticket_act) = 1 and isnull(v_class_signup_new.RCid) = 0
13
 
24
sqlstatement
Line 14... Line 25...
14
print "Bulk adding class registrations...\n";
25
 
Line 15... Line 26...
15
 
26
#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())");
Line 34... Line 45...
34
    '/rest/core/v1/ticket', 
45
    '/rest/core/v1/ticket', 
35
    $json_body,
46
    $json_body,
36
    $headers
47
    $headers
37
  );
48
  );
38
  my $response = from_json($client->responseContent());
49
  my $response = from_json($client->responseContent());
39
 
50
  
40
  #print Dumper $response;
-
 
41
  my $activationCode = $response->{activationCode};
51
  my $activationCode = $response->{activationCode};
42
  print $activationCode."...";
52
  print $activationCode."...";
43
  my $api_key = getSetting ("WRSTBND_API_KEY");
53
  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'`;
54
  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'`;
45
  print $add_response; chomp $add_response;
55
  print $add_response; chomp $add_response;
46
  $assignment->execute ($activationCode, $id, $rcid, 'CLA-%') unless $add_response ne "200";
56
  $assignment->execute ($activationCode, $id, $rcid, 'CLA-%') unless $add_response ne "200";
-
 
57
  print Dumper $add_response unless $add_response eq "200";
47
}
58
}
Line 48... Line 59...
48
 
59
 
49
 
60