Apple-AppStoreConnect
view release on metacpan or search on metacpan
is(
$mock->call_tracking->[6]->{args},
array {
item object {prop blessed => 'LWP::UserAgent'; etc};
item "${base}apps/1/builds";
item 'Authorization';
item match(qr/^Bearer ey[^.]+\.ey[^.]+\.[^.]+/);
end
},
'get_apps call correct with id and path'
);
$out = $asc->get_apps(platform=>'IOS');
is($out, $ref2, 'Received response');
is(
$mock->call_tracking->[7]->{args},
array {
item object {prop blessed => 'LWP::UserAgent'; etc};
item "${base}apps?filter[platform]=IOS";
item 'Authorization';
item match(qr/^Bearer ey[^.]+\.ey[^.]+\.[^.]+/);
end
},
'get_apps call correct with platform'
);
};
subtest 'Optional parameters' => sub {
my ($fh, $filename) = tempfile();
print $fh $key;
close $fh;
my $ua = LWP::UserAgent->new();
$asc = Apple::AppStoreConnect->new(
%params,
key_file => $filename,
timeout => 10,
expiration => 1000,
scope => ["GET /v1/apps?filter[platform]=IOS"],
ua => $ua,
jwt_payload => {bid => 'com.Id.Bundle'}
);
my $out = $asc->get(url => 'apps', raw => 1);
is($out, $json, 'Received JSON response');
is(
$mock->call_tracking->[8]->{args},
array {
item $ua;
item "${base}apps";
item 'Authorization';
item match(qr/^Bearer ey[^.]+\.ey[^.]+\.[^.]+/);
end
},
'get call correct'
);
};
subtest 'get_app_store_versions' => sub {
my $ua = TestUA->new(
'{"data":[{"type":"appStoreVersions","id":"v1","attributes":{"versionString":"1.0","platform":"IOS"}}],"links":{"next":"'.$base.'apps/1/appStoreVersions?cursor=abc"}}',
'{"data":[{"type":"appStoreVersions","id":"v2","attributes":{"versionString":"1.1","platform":"IOS"}}]}',
'{"data":[{"type":"appStoreVersionLocalizations","id":"l1","attributes":{"locale":"en-US","whatsNew":"One"}},{"type":"appStoreVersionLocalizations","id":"l2","attributes":{"locale":"fr-FR","whatsNew":"Un"}}]}',
'{"data":[]}'
);
my $asc3 = Apple::AppStoreConnect->new(%params, key => $key, ua => $ua);
my $out = $asc3->get_app_store_versions(
id => 1,
platform => 'IOS',
localizations => 1,
);
is(
$out,
[
{
id => 'v1',
type => 'appStoreVersions',
versionString => '1.0',
platform => 'IOS',
localizations => [
{
id => 'l1',
type => 'appStoreVersionLocalizations',
locale => 'en-US',
whatsNew => 'One',
},
{
id => 'l2',
type => 'appStoreVersionLocalizations',
locale => 'fr-FR',
whatsNew => 'Un',
},
],
},
{
id => 'v2',
type => 'appStoreVersions',
versionString => '1.1',
platform => 'IOS',
localizations => [],
},
],
'Versions and localizations returned'
);
like(
$ua->{calls}->[0]->[0],
qr#^\Q${base}apps/1/appStoreVersions\E\?(limit=200&filter\[platform\]=IOS|filter\[platform\]=IOS&limit=200)$#,
'Version request uses platform filter and limit'
);
is(
$ua->{calls}->[1]->[0],
"${base}apps/1/appStoreVersions?cursor=abc",
'Version request follows next link'
);
is(
$ua->{calls}->[2]->[0],
"${base}appStoreVersions/v1/appStoreVersionLocalizations?limit=200",
'Localizations request fetches all locales'
);
is(
$ua->{calls}->[3]->[0],
"${base}appStoreVersions/v2/appStoreVersionLocalizations?limit=200",
'Localizations request is made for each version'
);
};
subtest 'get_app_store_versions with locale' => sub {
my $ua = TestUA->new(
'{"data":[{"type":"appStoreVersions","id":"v1","attributes":{"versionString":"1.0"}}]}',
'{"data":[{"type":"appStoreVersionLocalizations","id":"l1","attributes":{"locale":"en-US","whatsNew":"One"}}]}'
);
my $asc3 = Apple::AppStoreConnect->new(%params, key => $key, ua => $ua);
my $out = $asc3->get_app_store_versions(id => 1, localizations => 'en-US');
is(
$out->[0]->{localizations},
[
{
id => 'l1',
type => 'appStoreVersionLocalizations',
locale => 'en-US',
whatsNew => 'One',
},
],
'Only requested locale returned'
);
like(
$ua->{calls}->[1]->[0],
qr#^\Q${base}appStoreVersions/v1/appStoreVersionLocalizations\E\?(limit=200&filter\[locale\]=en-US|filter\[locale\]=en-US&limit=200)$#,
'Locale filter passed to localizations request'
);
};
subtest 'get_app_store_versions localization fields' => sub {
my $ua = TestUA->new(
'{"data":[{"type":"appStoreVersions","id":"v1","attributes":{"versionString":"1.0"}}]}',
'{"data":[{"type":"appStoreVersionLocalizations","id":"l1","attributes":{"locale":"en-US","whatsNew":"One"}}]}'
);
my $asc3 = Apple::AppStoreConnect->new(%params, key => $key, ua => $ua);
my $out = $asc3->get_app_store_versions(
id => 1,
localization_fields => 'locale,whatsNew',
);
is(
$out->[0]->{localizations},
[
{
id => 'l1',
type => 'appStoreVersionLocalizations',
( run in 1.477 second using v1.01-cache-2.11-cpan-6aa56a78535 )