-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-person.pl
executable file
·58 lines (50 loc) · 1.68 KB
/
update-person.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/perl
use strict;
use warnings;
use FindBin qw($Bin);
use lib "$Bin/lib";
use Echo360;
use XML::Simple;
use Data::Dumper;
my $org_name = shift || die "No organization name";
my $person_name = shift || die "No name";
my $echo360 = Echo360->new(
USERNAME => 'kiel-test',
KEY => '123456',
SECRET => '7H/An2m9/oQV/znA6oqTFibhz8DiuOdw89Z6fCYM96YzuvSkmeDl2ODbEUUmHmDr6ZIZN2Frdv8BHVLdUF2V+Q==',
URL => 'https://ecessqa01.csumain.csu.edu.au:8443/ess/scheduleapi/v1',
DEBUG => 1,
);
my $org = $echo360->get(URI => 'organizations', MATCH => "^$org_name\$");
die "Could not find organization $org_name" unless $org;
my $person = $echo360->get(URI => 'people', PARAMS => "term=$person_name");
die "Could not find person $person_name" unless $person;
my %args = (
'title' => '<![CDATA[Mr]]>',
'first-name' => '<![CDATA[Kiel]]>',
'last-name' => '<![CDATA[Testing]]>',
'email-address' => '<![CDATA[[email protected]]]>',
'block-alerts' => '<![CDATA[true]]>',
'website' => '<![CDATA[https://test.com]]>',
'time-zone' => '<![CDATA[Australia/Sydney]]>',
'locale' => '<![CDATA[en_AU]]>',
'organization-roles' => {
'organization-role' => [
{
'organization-id' => "<![CDATA[$org->{$org_name}{id}]]>",
'role' => '<![CDATA[role-name-Admin]]>',
},
{
'organization-id' => "<![CDATA[$org->{$org_name}{id}]]>",
'role' => '<![CDATA[role-name-academic-staff]]>',
},
{
'organization-id' => "<![CDATA[$org->{$org_name}{id}]]>",
'role' => '<![CDATA[role-name-scheduler]]>',
},
],
},
);
my $p = XML::Simple->new(NoAttr => 1, KeyAttr => {});
my $xml = $p->XMLout(\%args, RootName=> 'person', NoEscape => 1);
my $ret = $echo360->update("people/$person->{id}", $xml);