| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Webservice::GAMSTOP::Response; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 1 |  |  | 1 |  | 6 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 26 |  | 
| 4 | 1 |  |  | 1 |  | 5 | use warnings; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 324 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  | our $VERSION = '0.003';    # VERSION | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | =head1 NAME | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | Webservice::GAMSTOP::Response - Response object for get_exclusion_for sub | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | =head1 VERSION | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | version 0.003 | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | use Webservice::GAMSTOP; | 
| 19 |  |  |  |  |  |  | my $instance = Webservice::GAMSTOP->new( | 
| 20 |  |  |  |  |  |  | api_url => 'gamstop_api_url', | 
| 21 |  |  |  |  |  |  | api_key => 'gamstop_api_key', | 
| 22 |  |  |  |  |  |  | # optional (defaults to 5 seconds) | 
| 23 |  |  |  |  |  |  | timeout => 10, | 
| 24 |  |  |  |  |  |  | ); | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | my $response = $instance->get_exclusion_for( | 
| 27 |  |  |  |  |  |  | first_name    => 'Harry', | 
| 28 |  |  |  |  |  |  | last_name     => 'Potter', | 
| 29 |  |  |  |  |  |  | email         => 'harry.potter@example.com', | 
| 30 |  |  |  |  |  |  | date_of_birth => '1970-01-01', | 
| 31 |  |  |  |  |  |  | postcode      => 'hp11aa', | 
| 32 |  |  |  |  |  |  | ); | 
| 33 |  |  |  |  |  |  |  | 
| 34 |  |  |  |  |  |  | $response->is_excluded; | 
| 35 |  |  |  |  |  |  | $response->get_date; | 
| 36 |  |  |  |  |  |  | $response->get_unique_id; | 
| 37 |  |  |  |  |  |  | $response->get_exclusion; | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | This object is returned as response for get_exclusion_for. | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | =cut | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | =head1 METHODS | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  | Constructor | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | =head2 new | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | use Webservice::GAMSTOP::Response; | 
| 52 |  |  |  |  |  |  | my $response = Webservice::GAMSTOP::Response->new( | 
| 53 |  |  |  |  |  |  | exclusion => '', | 
| 54 |  |  |  |  |  |  | date      => '', | 
| 55 |  |  |  |  |  |  | unique_id => '', | 
| 56 |  |  |  |  |  |  | ); | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | =head3 Return value | 
| 59 |  |  |  |  |  |  |  | 
| 60 |  |  |  |  |  |  | A new Webservice::GAMSTOP::Response object | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  | =cut | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | sub new { | 
| 65 | 4 |  |  | 4 | 1 | 2533 | my ($class, %args) = @_; | 
| 66 |  |  |  |  |  |  |  | 
| 67 | 4 | 100 |  |  |  | 14 | return bless {}, $class unless %args; | 
| 68 |  |  |  |  |  |  |  | 
| 69 | 3 |  |  |  |  | 19 | return bless \%args, $class; | 
| 70 |  |  |  |  |  |  | } | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | =head2 get_exclusion | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | Exclusion flag provided in response headers | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | GAMSTOP Response: | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | - When GAMSTOP returns a Y response the user is registered with the GAMSTOP | 
| 79 |  |  |  |  |  |  | service with a valid current self-exclusion. | 
| 80 |  |  |  |  |  |  |  | 
| 81 |  |  |  |  |  |  | - When GAMSTOP returns an N response the user is not registered with the GAMSTOP | 
| 82 |  |  |  |  |  |  | service. | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  | - When GAMSTOP returns a P response the user was previously self-excluded using | 
| 85 |  |  |  |  |  |  | the GAMSTOP service but their chosen minimum period of exclusion has lapsed | 
| 86 |  |  |  |  |  |  | and they have requested to have their self-exclusion removed | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  | =head3 Return value | 
| 89 |  |  |  |  |  |  |  | 
| 90 |  |  |  |  |  |  | returns GAMSTOP exclusion flag or undef if not present | 
| 91 |  |  |  |  |  |  |  | 
| 92 |  |  |  |  |  |  | =over 4 | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  | =back | 
| 95 |  |  |  |  |  |  |  | 
| 96 |  |  |  |  |  |  | =cut | 
| 97 |  |  |  |  |  |  |  | 
| 98 |  |  |  |  |  |  | sub get_exclusion { | 
| 99 | 4 |  |  | 4 | 1 | 23 | return shift->{exclusion}; | 
| 100 |  |  |  |  |  |  | } | 
| 101 |  |  |  |  |  |  |  | 
| 102 |  |  |  |  |  |  | =head2 get_unique_id | 
| 103 |  |  |  |  |  |  |  | 
| 104 |  |  |  |  |  |  | Unique id provided in response headers | 
| 105 |  |  |  |  |  |  |  | 
| 106 |  |  |  |  |  |  | =head3 Return value | 
| 107 |  |  |  |  |  |  |  | 
| 108 |  |  |  |  |  |  | =over 4 | 
| 109 |  |  |  |  |  |  |  | 
| 110 |  |  |  |  |  |  | returns GAMSTOP unique id for request or undef if not present | 
| 111 |  |  |  |  |  |  |  | 
| 112 |  |  |  |  |  |  | =back | 
| 113 |  |  |  |  |  |  |  | 
| 114 |  |  |  |  |  |  | =cut | 
| 115 |  |  |  |  |  |  |  | 
| 116 |  |  |  |  |  |  | sub get_unique_id { | 
| 117 | 4 |  |  | 4 | 1 | 17 | return shift->{unique_id}; | 
| 118 |  |  |  |  |  |  | } | 
| 119 |  |  |  |  |  |  |  | 
| 120 |  |  |  |  |  |  | =head2 get_date | 
| 121 |  |  |  |  |  |  |  | 
| 122 |  |  |  |  |  |  | Date provided in response headers. Format: Tue, 27 Feb 2018 02:42:01 GMT | 
| 123 |  |  |  |  |  |  |  | 
| 124 |  |  |  |  |  |  | =head3 Return value | 
| 125 |  |  |  |  |  |  |  | 
| 126 |  |  |  |  |  |  | =over 4 | 
| 127 |  |  |  |  |  |  |  | 
| 128 |  |  |  |  |  |  | returns GAMSTOP response date or undef if not present | 
| 129 |  |  |  |  |  |  |  | 
| 130 |  |  |  |  |  |  | =back | 
| 131 |  |  |  |  |  |  |  | 
| 132 |  |  |  |  |  |  | =cut | 
| 133 |  |  |  |  |  |  |  | 
| 134 |  |  |  |  |  |  | sub get_date { | 
| 135 | 4 |  |  | 4 | 1 | 20 | return shift->{date}; | 
| 136 |  |  |  |  |  |  | } | 
| 137 |  |  |  |  |  |  |  | 
| 138 |  |  |  |  |  |  | =head2 is_excluded | 
| 139 |  |  |  |  |  |  |  | 
| 140 |  |  |  |  |  |  | Indicates whether user is self excluded or not | 
| 141 |  |  |  |  |  |  |  | 
| 142 |  |  |  |  |  |  | =head3 Return value | 
| 143 |  |  |  |  |  |  |  | 
| 144 |  |  |  |  |  |  | =over 4 | 
| 145 |  |  |  |  |  |  |  | 
| 146 |  |  |  |  |  |  | True if user is excluded on GAMSTOP i.e GAMSTOP return a Y response else false | 
| 147 |  |  |  |  |  |  |  | 
| 148 |  |  |  |  |  |  | =back | 
| 149 |  |  |  |  |  |  |  | 
| 150 |  |  |  |  |  |  | =cut | 
| 151 |  |  |  |  |  |  |  | 
| 152 |  |  |  |  |  |  | sub is_excluded { | 
| 153 | 4 |  |  | 4 | 1 | 20 | my $flag = shift->{exclusion}; | 
| 154 |  |  |  |  |  |  |  | 
| 155 | 4 | 100 | 100 |  |  | 29 | return ($flag // '') eq 'Y' ? 1 : 0; | 
| 156 |  |  |  |  |  |  | } | 
| 157 |  |  |  |  |  |  |  | 
| 158 |  |  |  |  |  |  | 1; | 
| 159 |  |  |  |  |  |  | __END__ |