| 1 | package Paws::Net::SigninCaller; | ||||||||||||||
| 2 | 3 | ▶ | use Moose::Role; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 3 | 3 | ▶ | use JSON::MaybeXS; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 3 | ▶ | use URI::Template; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | |||||||||||||||
| 6 | 3 | ▶ | use Paws::Net::JsonResponse; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | |||||||||||||||
| 8 | has response_to_object => ( | ||||||||||||||
| 9 | is => 'ro', | ||||||||||||||
| 10 | 3 | ▶ | default => sub { | ||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||
| 11 | 3 | Paws::Net::JsonResponse->new; | |||||||||||||
| 12 | } | ||||||||||||||
| 13 | 3 | ); | |||||||||||||
| 14 | |||||||||||||||
| 15 | 1 | ▶ | sub _call_uri { | ||||||||||||
|
Subroutine
_call_uri: called CC=1 SCAR=0.0
| |||||||||||||||
| 16 | 1 | my ($self, $call, $qparams) = @_; | |||||||||||||
| 17 | 1 | my $uri_template = $call->meta->name->_api_uri; | |||||||||||||
| 18 | 1 | my $t = URI::Template->new( $uri_template ); | |||||||||||||
| 19 | |||||||||||||||
| 20 | 1 | my $uri = $t->process({}); | |||||||||||||
| 21 | 1 | $uri->query_form(%$qparams); | |||||||||||||
| 22 | 1 | return $uri->as_string; | |||||||||||||
| 23 | } | ||||||||||||||
| 24 | |||||||||||||||
| 25 | 1 | ▶ | sub prepare_request_for_call { | ||||||||||||
|
Subroutine
prepare_request_for_call: called CC=4 SCAR=15.0
Pod
undocumented
| |||||||||||||||
| 26 | 1 | my ($self, $call) = @_; | |||||||||||||
| 27 | |||||||||||||||
| 28 | 1 | my $request = Paws::Net::APIRequest->new(); | |||||||||||||
| 29 | |||||||||||||||
| 30 | 1 | $request->method('GET'); | |||||||||||||
| 31 | |||||||||||||||
| 32 | 1 | my $qparams; | |||||||||||||
| 33 | 1 | ▶ | if ($call->_api_call eq 'getSigninToken') { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 34 | #Until we have a way to declare objects that get json-encoded to API calls, we | ||||||||||||||
| 35 | #will have to "hand-encode" the Session Parameter | ||||||||||||||
| 36 | 1 | ▶ | $qparams = { Action => $call->_api_call, | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 37 | SessionType => 'json', | ||||||||||||||
| 38 | (defined $call->SessionDuration)?(SessionDuration => $call->SessionDuration):(), | ||||||||||||||
| 39 | Session => encode_json({ | ||||||||||||||
| 40 | sessionId => $call->SessionId, | ||||||||||||||
| 41 | sessionKey => $call->SessionKey, | ||||||||||||||
| 42 | sessionToken => $call->SessionToken | ||||||||||||||
| 43 | }), | ||||||||||||||
| 44 | }; | ||||||||||||||
| 45 | } elsif ($call->_api_call eq 'login') { | ||||||||||||||
| 46 | 0 | $qparams = { Action => $call->_api_call, | |||||||||||||
| 47 | Destination => $call->Destination, | ||||||||||||||
| 48 | Issuer => $call->Issuer, | ||||||||||||||
| 49 | SigninToken => $call->SigninToken | ||||||||||||||
| 50 | }; | ||||||||||||||
| 51 | } else { | ||||||||||||||
| 52 | 0 | die "Don't know how to call " . $call->_api_call; | |||||||||||||
| 53 | } | ||||||||||||||
| 54 | |||||||||||||||
| 55 | 1 | my $uri = $self->_call_uri($call, $qparams); | |||||||||||||
| 56 | 1 | $request->url($self->_api_endpoint . $uri); | |||||||||||||
| 57 | 1 | $request->uri($uri); | |||||||||||||
| 58 | |||||||||||||||
| 59 | 1 | $self->sign($request); | |||||||||||||
| 60 | |||||||||||||||
| 61 | 1 | return $request; | |||||||||||||
| 62 | } | ||||||||||||||
| 63 | 3 | 1; | |||||||||||||