-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add statement/balance/term resources
- Loading branch information
Showing
8 changed files
with
213 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package Net::Payjp::Balance; | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use base 'Net::Payjp'; | ||
|
||
sub retrieve{ | ||
my $self = shift; | ||
my $id = shift; | ||
$self->id($id) if $id; | ||
|
||
$self->_request(method => 'GET', url => $self->_instance_url); | ||
} | ||
|
||
sub all{ | ||
my $self = shift; | ||
my %p = @_; | ||
|
||
$self->_request(method => 'GET', url => $self->_class_url, param => \%p); | ||
} | ||
|
||
1; |
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,29 @@ | ||
package Net::Payjp::Statement; | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use base 'Net::Payjp'; | ||
|
||
sub retrieve{ | ||
my $self = shift; | ||
my $id = shift; | ||
$self->id($id) if $id; | ||
|
||
$self->_request(method => 'GET', url => $self->_instance_url); | ||
} | ||
|
||
sub all{ | ||
my $self = shift; | ||
my %p = @_; | ||
|
||
$self->_request(method => 'GET', url => $self->_class_url, param => \%p); | ||
} | ||
|
||
sub statement_urls{ | ||
my $self = shift; | ||
|
||
$self->_request(method => 'POST', url => $self->_instance_url . '/statement_urls'); | ||
} | ||
|
||
1; |
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,23 @@ | ||
package Net::Payjp::Term; | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use base 'Net::Payjp'; | ||
|
||
sub retrieve{ | ||
my $self = shift; | ||
my $id = shift; | ||
$self->id($id) if $id; | ||
|
||
$self->_request(method => 'GET', url => $self->_instance_url); | ||
} | ||
|
||
sub all{ | ||
my $self = shift; | ||
my %p = @_; | ||
|
||
$self->_request(method => 'GET', url => $self->_class_url, param => \%p); | ||
} | ||
|
||
1; |
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,41 @@ | ||
#!/usr/bin/perl | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Test::Mock::LWP; | ||
use Test::More; | ||
|
||
use Net::Payjp; | ||
|
||
my $payjp = Net::Payjp->new(api_key => 'api_key'); | ||
|
||
isa_ok($payjp->balance, 'Net::Payjp::Balance'); | ||
can_ok($payjp->balance, qw(retrieve all)); | ||
ok(!$payjp->transfer->can('create')); | ||
ok(!$payjp->transfer->can('save')); | ||
ok(!$payjp->transfer->can('delete')); | ||
|
||
$Mock_resp->mock( content => sub { '{"object":"list"}' } ); | ||
$Mock_resp->mock( code => sub {200} ); | ||
$Mock_ua->mock( timeout => sub {} ); | ||
$Mock_ua->mock( default_header => sub {} ); | ||
|
||
#List | ||
my $res = $payjp->transfer->all(type => 'collecting'); | ||
is($Mock_req->{new_args}[1], 'GET'); | ||
is($Mock_req->{new_args}[2], 'https://api.pay.jp/v1/balances?type=collecting'); | ||
is($res->object, 'list'); | ||
|
||
#Set id. | ||
$payjp->id('req1'); | ||
|
||
#Retrieve | ||
$Mock_resp->mock( content => sub { '{"id":"req2"}' } ); | ||
my $balance = $payjp->balance; | ||
is($balance->id, 'req1'); | ||
$balance->retrieve; | ||
is($Mock_req->{new_args}[1], 'GET'); | ||
is($Mock_req->{new_args}[2], 'https://api.pay.jp/v1/balances/req1'); | ||
is($balance->id, 'req2'); | ||
is($payjp->id, 'req1'); |
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,40 @@ | ||
#!/usr/bin/perl | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Test::Mock::LWP; | ||
use Test::More; | ||
|
||
use Net::Payjp; | ||
|
||
my $payjp = Net::Payjp->new(api_key => 'api_key'); | ||
|
||
isa_ok($payjp->tenant, 'Net::Payjp::Statement'); | ||
can_ok($payjp->tenant, qw(retrieve all statement_urls)); | ||
|
||
$Mock_resp->mock( content => sub { '{"object":"list"}' } ); | ||
$Mock_resp->mock( code => sub {200} ); | ||
$Mock_ua->mock( timeout => sub {} ); | ||
$Mock_ua->mock( default_header => sub {} ); | ||
|
||
#List | ||
my $res = $payjp->statement->all(owner => merchant); | ||
Check failure on line 22 in t/statement.t GitHub Actions / Testing perl 5.30 on ubuntu-latest
|
||
is($Mock_req->{new_args}[1], 'GET'); | ||
is($Mock_req->{new_args}[2], 'https://api.pay.jp/v1/statements?owner=merchant'); | ||
is($res->object, 'list'); | ||
|
||
#Retrieve | ||
my $statement = $payjp->statement; | ||
$statement->retrieve('req1'); | ||
is($Mock_req->{new_args}[1], 'GET'); | ||
is($Mock_req->{new_args}[2], 'https://api.pay.jp/v1/statements/req1'); | ||
is($statement->id, 'req1'); | ||
|
||
$Mock_req->mock( content => sub { | ||
my $p = $_[1]; | ||
like($p, qr/platformer=true/); | ||
} ); | ||
$tenant->statement_urls(platformer => true); | ||
Check failure on line 38 in t/statement.t GitHub Actions / Testing perl 5.30 on ubuntu-latest
Check failure on line 38 in t/statement.t GitHub Actions / Testing perl 5.30 on ubuntu-latest
Check failure on line 38 in t/statement.t GitHub Actions / Testing perl 5.38 on ubuntu-latest
|
||
is($Mock_req->{new_args}[1], 'POST'); | ||
is($Mock_req->{new_args}[2], 'https://api.pay.jp/v1/statements/req1/application_urls'); |
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,41 @@ | ||
#!/usr/bin/perl | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Test::Mock::LWP; | ||
use Test::More; | ||
|
||
use Net::Payjp; | ||
|
||
my $payjp = Net::Payjp->new(api_key => 'api_key'); | ||
|
||
isa_ok($payjp->term, 'Net::Payjp::Term'); | ||
can_ok($payjp->term, qw(retrieve all)); | ||
ok(!$payjp->transfer->can('create')); | ||
ok(!$payjp->transfer->can('save')); | ||
ok(!$payjp->transfer->can('delete')); | ||
|
||
$Mock_resp->mock( content => sub { '{"object":"list"}' } ); | ||
$Mock_resp->mock( code => sub {200} ); | ||
$Mock_ua->mock( timeout => sub {} ); | ||
$Mock_ua->mock( default_header => sub {} ); | ||
|
||
#List | ||
my $res = $payjp->transfer->all(since_start_at => 1111111); | ||
is($Mock_req->{new_args}[1], 'GET'); | ||
is($Mock_req->{new_args}[2], 'https://api.pay.jp/v1/terms?since_start_at=11111111'); | ||
is($res->object, 'list'); | ||
|
||
#Set id. | ||
$payjp->id('req1'); | ||
|
||
#Retrieve | ||
$Mock_resp->mock( content => sub { '{"id":"req2"}' } ); | ||
my $term = $payjp->term; | ||
is($term->id, 'req1'); | ||
$term->retrieve; | ||
is($Mock_req->{new_args}[1], 'GET'); | ||
is($Mock_req->{new_args}[2], 'https://api.pay.jp/v1/terms/req1'); | ||
is($term->id, 'req2'); | ||
is($payjp->id, 'req1'); |