-
-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP [Bexley][WW] Cancel GGW subscription
- Loading branch information
1 parent
0c20788
commit d0cee9b
Showing
4 changed files
with
113 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
=head1 NAME | ||
Integrations::Agile - Agile Applications API integration | ||
=head1 DESCRIPTION | ||
This module provides an interface to the Agile Applications API | ||
=cut | ||
|
||
package Integrations::Agile; | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use HTTP::Request; | ||
use JSON::MaybeXS; | ||
use LWP::UserAgent; | ||
use Moo; | ||
use URI; | ||
|
||
has url => ( is => 'ro' ); | ||
|
||
# TODO Logging | ||
|
||
sub call { | ||
my ( $self, %args ) = @_; | ||
|
||
my $action = $args{action}; | ||
my $controller = $args{controller}; | ||
my $data = $args{data}; | ||
my $method = 'POST'; | ||
|
||
my $body = { | ||
Method => $method, | ||
Controller => $controller, | ||
Action => $action, | ||
Data => $data, | ||
}; | ||
my $body_json = encode_json($body); | ||
|
||
my $uri = URI->new( $self->{url} ); | ||
|
||
my $req = HTTP::Request->new( $method, $uri ); | ||
$req->content_type('application/json; charset=UTF-8'); | ||
$req->content($body_json); | ||
|
||
my $ua = LWP::UserAgent->new; | ||
my $res = $ua->request($req); | ||
|
||
if ( $res->is_success ) { | ||
return decode_json( $res->content ); | ||
} else { | ||
die $res->content; | ||
} | ||
} | ||
|
||
sub IsAddressFree { | ||
my ( $self, $uprn ) = @_; | ||
|
||
return $self->call( | ||
action => 'isaddressfree', | ||
controller => 'customer', | ||
data => { UPRN => $uprn }, | ||
); | ||
} | ||
|
||
1; |