Apple-AppStoreConnect

 view release on metacpan or  search on metacpan

lib/Apple/AppStoreConnect.pm  view on Meta::CPAN

C<exp> argument.

=over 4
 
=item * C<iat> : Specify the token creation timestamp. Default is C<time()>.

=item * C<exp> : Specify the token expiration timestamp. Passing this parameter
will force the creation of a new token. Default is C<time()+900> (or what you
specified in the constructor).

=back

=head2 C<get_apps>

    my $res = $asc->get_apps(
        id       => $app_id?,
        path     => $path?,
        platform => $platform?,
        params   => \%query_params?
    );

Without arguments it is similar to C<get(url=E<gt>"apps">, fetching the list of apps,
but does some extra processing to return a Perl hash with app IDs as keys and the
app attributes as values.

There are optional arguments to get details of a specific app or app resource:

=over 4
 
=item * C<id> : The app ID. Specifying just the id will return the details for a
single app.

=item * C<path> : Requires C<id> and is similar to C<get(url=E<gt>"apps/$app_id/$path")>,
returning a specific resource type for an app, except it does the convenience processing
where a hash with the ids of this resource as keys are returned and the attributes
as values (unless the specific resource does not follow that pattern).
See API documentation for C<path> support (e.g. C<builds>, C<appAvailability>,
C<appPriceSchedule>, C<customerReviews> etc.).

=item * C<platform> : Optional shortcut for C<filter[platform]>, for example
C<IOS>, C<MAC_OS>, C<TV_OS>, or C<VISION_OS>.

=item * C<params> : Any other query params that you need to pass
(see L<API documentation|https://developer.apple.com/documentation/appstoreconnectapi>).

=back

=head2 C<get_app_store_versions>

    my $res = $asc->get_app_store_versions(
        id                  => $app_id,
        platform            => $platform?,
        localizations       => $localizations?,
        localization_fields => $localization_fields?,
        params              => \%query_params?
    );

    my $versions = $asc->get_app_store_versions(
        id                  => $app_id,
        platform            => 'IOS',
        localization_fields => 'locale,whatsNew',
        params              => {
            'fields[appStoreVersions]' => 'platform,versionString,appVersionState'
        }
    );

Returns an arrayref of App Store versions for the app, automatically fetching
all pages. Each entry is a hash of the resource attributes, with C<id> and
C<type> added.

When C<localizations> is requested, one additional API call is made per
version to fetch its localizations.

=over 4

=item * C<id> : The app ID.

=item * C<platform> : Optional shortcut for C<filter[platform]>, for example
C<IOS>, C<MAC_OS>, C<TV_OS>, or C<VISION_OS>.

=item * C<localizations> : If true, each version entry will include a
C<localizations> arrayref. Passing C<1> fetches all localizations. Passing a
locale string, for example C<en-US>, fetches only that locale.

=item * C<localization_fields> : Optional fields to return for each
C<appStoreVersionLocalizations> resource, for example C<locale,whatsNew>. If
specified, C<localizations> defaults to C<1>.

=item * C<params> : Any other query params to pass to the
C<apps/$app_id/appStoreVersions> request.

=back

=head2 C<get_beta_feedback_screenshot_submissions>

    my $res = $asc->get_beta_feedback_screenshot_submissions(
        id       => $app_id,
        platform => $platform?,
        limit    => $limit?,
        sort     => $sort?,
        params   => \%query_params?
    );

Returns an arrayref of beta feedback screenshot submissions for the app. By
default, results are sorted newest first using C<-createdDate>, with C<limit>
set to C<50>. Only up to C<limit> results are returned; pagination is not
performed.

=over 4

=item * C<id> : The app ID.

=item * C<platform> : Optional shortcut for C<filter[appPlatform]>, for example
C<IOS>, C<MAC_OS>, C<TV_OS>, or C<VISION_OS>.

=item * C<limit> : Optional maximum number of results to return. Default C<50>.

=item * C<sort> : Optional sort order. Default C<-createdDate>.

=item * C<params> : Any other query params to pass to the
C<apps/$app_id/betaFeedbackScreenshotSubmissions> request, for example
C<fields[betaFeedbackScreenshotSubmissions]> or C<include>.

=back

=head2 C<get_beta_feedback_crash_submissions>

    my $res = $asc->get_beta_feedback_crash_submissions(
        id               => $app_id,
        platform         => $platform?,
        limit            => $limit?,
        sort             => $sort?,
        crash_log        => $crash_log?,
        crash_log_fields => $crash_log_fields?,
        params           => \%query_params?
    );

Returns an arrayref of beta feedback crash submissions for the app. By default,
results are sorted newest first using C<-createdDate>, with C<limit> set to
C<50>. Only up to C<limit> results are returned; pagination is not performed.
If C<crash_log> is true, each returned crash submission includes a C<crashLog>
hashref with the linked crash log; one additional API call is made per
submission to fetch it.

=over 4

lib/Apple/AppStoreConnect.pm  view on Meta::CPAN


    return $args{raw} ? $resp : JSON::decode_json($resp);
}

sub get_response {
    my $self = shift;
    my %args = @_;

    croak("url required") unless $args{url};
    $args{url} = $self->{base_url}.$args{url} unless $args{url} =~ /^http/;

    my $jwt = $self->jwt;
    my $url = _build_url(%args);

    unless ($self->{curl} || $self->{ua}) {
        require LWP::UserAgent;
        $self->{ua} = LWP::UserAgent->new(
            agent   => "libwww-perl Apple::AppStoreConnect/$VERSION",
            timeout => $self->{timeout}
        );
    }

    return _fetch($self->{ua}, $url, $jwt);
}

sub get_apps {
    my $self = shift;
    my %args = @_;
    my %params = $args{params} ? %{$args{params}} : ();
    $params{'filter[platform]'} = $args{platform} if $args{platform};
    $args{params} = \%params if %params;

    $args{url} = $self->{base_url} . 'apps';
    $args{url} .= "/$args{id}" if $args{id};
    $args{url} .= "/$args{path}" if $args{path};
    my $res = $self->get(%args);

    return _process_data($res);
}

sub get_app_store_versions {
    my $self = shift;
    my %args = @_;

    croak("id required") unless $args{id};

    my %params = $args{params} ? %{$args{params}} : ();
    $params{'filter[platform]'} = $args{platform} if $args{platform};
    $params{limit} ||= 200;
    my $localizations = $args{localizations};
    $localizations ||= 1 if $args{localization_fields};

    my $versions = _flatten_resources($self->_get_all_pages(
        url    => "apps/$args{id}/appStoreVersions",
        params => \%params,
    ));

    if ($localizations) {
        foreach my $version (@$versions) {
            my %localization_params = (limit => 200);
            $localization_params{'filter[locale]'} = $localizations
                unless $localizations eq '1';
            $localization_params{'fields[appStoreVersionLocalizations]'} = $args{localization_fields}
                if $args{localization_fields};

            $version->{localizations} = _flatten_resources($self->_get_all_pages(
                url    => "appStoreVersions/$version->{id}/appStoreVersionLocalizations",
                params => \%localization_params,
            ));
        }
    }

    return $versions;
}

sub get_beta_feedback_screenshot_submissions {
    my $self = shift;
    return $self->_get_beta_feedback_submissions(
        resource => 'betaFeedbackScreenshotSubmissions',
        @_,
    );
}

sub get_beta_feedback_crash_submissions {
    my $self = shift;
    my %args = @_;

    my %params = $args{params} ? %{$args{params}} : ();
    my $crash_log_fields = $args{crash_log_fields};
    $crash_log_fields ||= delete $params{'fields[betaCrashLogs]'};
    $args{params} = \%params;

    my $crashes = $self->_get_beta_feedback_submissions(
        resource => 'betaFeedbackCrashSubmissions',
        %args,
    );

    if ($args{crash_log}) {
        foreach my $crash (@$crashes) {
            my %params;
            $params{'fields[betaCrashLogs]'} = $crash_log_fields
                if $crash_log_fields;

            my $res = $self->get(
                url    => "betaFeedbackCrashSubmissions/$crash->{id}/crashLog",
                params => \%params,
            );
            $crash->{crashLog} = _flatten_resource($res->{data});
        }
    }

    return $crashes;
}

sub jwt {
    my $self = shift;
    my %args = @_;

    # Return cached one
    return $self->{jwt}
        if !$args{exp} && $self->{jwt_exp} && $self->{jwt_exp} >= time() + 300;



( run in 1.840 second using v1.01-cache-2.11-cpan-817d5f8af8b )