AgentPushKit-Client

 view release on metacpan or  search on metacpan

lib/AgentPushKit/Client/DevicesApi.pm  view on Meta::CPAN

#
package AgentPushKit::Client::DevicesApi;

require 5.6.0;
use strict;
use warnings;
use utf8;
use Exporter;
use Carp qw( croak );
use Log::Any qw($log);

use AgentPushKit::Client::ApiClient;

use base "Class::Data::Inheritable";

__PACKAGE__->mk_classdata('method_documentation' => {});

sub new {
    my $class = shift;
    my $api_client;

    if ($_[0] && ref $_[0] && ref $_[0] eq 'AgentPushKit::Client::ApiClient' ) {
        $api_client = $_[0];
    } else {
        $api_client = AgentPushKit::Client::ApiClient->new(@_);
    }

    bless { api_client => $api_client }, $class;

}


#
# get_web_push_configuration
#
# Get browser push availability and its public VAPID key
#
{
    my $params = {
    };
    __PACKAGE__->method_documentation->{ 'get_web_push_configuration' } = {
        summary => 'Get browser push availability and its public VAPID key',
        params => $params,
        returns => 'WebPushConfiguration',
        };
}
# @return WebPushConfiguration
#
sub get_web_push_configuration {
    my ($self, %args) = @_;

    # parse inputs
    my $_resource_path = '/web-push/configuration';

    my $_method = 'GET';
    my $query_params = {};
    my $header_params = {};
    my $form_params = {};

    # 'Accept' and 'Content-Type' header
    my $_header_accept = $self->{api_client}->select_header_accept('application/json');
    if ($_header_accept) {
        $header_params->{'Accept'} = $_header_accept;
    }
    $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();

    my $_body_data;
    # authentication setting, if any
    my $auth_settings = [qw(UserOrAgent )];

    # make the API Call
    my $response = $self->{api_client}->call_api($_resource_path, $_method,
                                           $query_params, $form_params,
                                           $header_params, $_body_data, $auth_settings);
    if (!$response) {
        return;
    }
    my $_response_object = $self->{api_client}->deserialize('WebPushConfiguration', $response);
    return $_response_object;
}

#
# register_device
#
# Register or refresh an APNs device
#
# @param RegisterDeviceInput $register_device_input  (required)
{
    my $params = {
    'register_device_input' => {
        data_type => 'RegisterDeviceInput',
        description => '',
        required => '1',
    },
    };
    __PACKAGE__->method_documentation->{ 'register_device' } = {
        summary => 'Register or refresh an APNs device',
        params => $params,
        returns => 'Device',
        };
}
# @return Device
#
sub register_device {
    my ($self, %args) = @_;

    # verify the required parameter 'register_device_input' is set
    unless (exists $args{'register_device_input'}) {
      croak("Missing the required parameter 'register_device_input' when calling register_device");
    }

    # parse inputs
    my $_resource_path = '/devices';

    my $_method = 'POST';
    my $query_params = {};
    my $header_params = {};
    my $form_params = {};

    # 'Accept' and 'Content-Type' header
    my $_header_accept = $self->{api_client}->select_header_accept('application/json');
    if ($_header_accept) {
        $header_params->{'Accept'} = $_header_accept;
    }
    $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json');

    my $_body_data;
    # body params
    if ( exists $args{'register_device_input'}) {
        $_body_data = $args{'register_device_input'};
    }

    # authentication setting, if any
    my $auth_settings = [qw(UserOrAgent )];

    # make the API Call
    my $response = $self->{api_client}->call_api($_resource_path, $_method,
                                           $query_params, $form_params,
                                           $header_params, $_body_data, $auth_settings);
    if (!$response) {
        return;
    }
    my $_response_object = $self->{api_client}->deserialize('Device', $response);
    return $_response_object;
}

#
# register_web_push_subscription
#
# Register or refresh a browser push subscription
#
# @param RegisterWebPushSubscriptionInput $register_web_push_subscription_input  (required)
{
    my $params = {
    'register_web_push_subscription_input' => {
        data_type => 'RegisterWebPushSubscriptionInput',
        description => '',
        required => '1',
    },
    };
    __PACKAGE__->method_documentation->{ 'register_web_push_subscription' } = {
        summary => 'Register or refresh a browser push subscription',
        params => $params,
        returns => 'WebPushSubscription',
        };
}
# @return WebPushSubscription
#
sub register_web_push_subscription {
    my ($self, %args) = @_;

    # verify the required parameter 'register_web_push_subscription_input' is set
    unless (exists $args{'register_web_push_subscription_input'}) {
      croak("Missing the required parameter 'register_web_push_subscription_input' when calling register_web_push_subscription");
    }

    # parse inputs
    my $_resource_path = '/web-push/subscriptions';

    my $_method = 'POST';
    my $query_params = {};
    my $header_params = {};
    my $form_params = {};

    # 'Accept' and 'Content-Type' header
    my $_header_accept = $self->{api_client}->select_header_accept('application/json');
    if ($_header_accept) {
        $header_params->{'Accept'} = $_header_accept;
    }
    $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json');

    my $_body_data;
    # body params
    if ( exists $args{'register_web_push_subscription_input'}) {
        $_body_data = $args{'register_web_push_subscription_input'};
    }

    # authentication setting, if any
    my $auth_settings = [qw(UserOrAgent )];

    # make the API Call
    my $response = $self->{api_client}->call_api($_resource_path, $_method,
                                           $query_params, $form_params,
                                           $header_params, $_body_data, $auth_settings);
    if (!$response) {
        return;
    }
    my $_response_object = $self->{api_client}->deserialize('WebPushSubscription', $response);
    return $_response_object;
}

#
# remove_device
#
# Disable push delivery to one installation
#
# @param string $installation_id  (required)
{
    my $params = {
    'installation_id' => {
        data_type => 'string',
        description => '',
        required => '1',
    },
    };
    __PACKAGE__->method_documentation->{ 'remove_device' } = {
        summary => 'Disable push delivery to one installation',
        params => $params,
        returns => 'DisabledResponse',
        };
}
# @return DisabledResponse
#
sub remove_device {
    my ($self, %args) = @_;

    # verify the required parameter 'installation_id' is set
    unless (exists $args{'installation_id'}) {
      croak("Missing the required parameter 'installation_id' when calling remove_device");
    }

    # parse inputs
    my $_resource_path = '/devices/{installationId}';

    my $_method = 'DELETE';
    my $query_params = {};
    my $header_params = {};
    my $form_params = {};

    # 'Accept' and 'Content-Type' header
    my $_header_accept = $self->{api_client}->select_header_accept('application/json');
    if ($_header_accept) {
        $header_params->{'Accept'} = $_header_accept;
    }
    $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();

    # path params
    if ( exists $args{'installation_id'}) {
        my $_base_variable = "{" . "installationId" . "}";
        my $_base_value = $self->{api_client}->to_path_value($args{'installation_id'});
        $_resource_path =~ s/$_base_variable/$_base_value/g;
    }

    my $_body_data;
    # authentication setting, if any
    my $auth_settings = [qw(UserOrAgent )];

    # make the API Call
    my $response = $self->{api_client}->call_api($_resource_path, $_method,
                                           $query_params, $form_params,
                                           $header_params, $_body_data, $auth_settings);
    if (!$response) {
        return;
    }
    my $_response_object = $self->{api_client}->deserialize('DisabledResponse', $response);
    return $_response_object;
}

#
# remove_web_push_subscription
#
# Disable a browser push subscription
#
# @param string $subscription_id  (required)
{
    my $params = {
    'subscription_id' => {
        data_type => 'string',
        description => '',
        required => '1',
    },
    };
    __PACKAGE__->method_documentation->{ 'remove_web_push_subscription' } = {
        summary => 'Disable a browser push subscription',
        params => $params,
        returns => 'DisabledResponse',
        };
}
# @return DisabledResponse
#
sub remove_web_push_subscription {
    my ($self, %args) = @_;

    # verify the required parameter 'subscription_id' is set
    unless (exists $args{'subscription_id'}) {
      croak("Missing the required parameter 'subscription_id' when calling remove_web_push_subscription");
    }

    # parse inputs
    my $_resource_path = '/web-push/subscriptions/{subscriptionId}';

    my $_method = 'DELETE';
    my $query_params = {};
    my $header_params = {};
    my $form_params = {};

    # 'Accept' and 'Content-Type' header
    my $_header_accept = $self->{api_client}->select_header_accept('application/json');
    if ($_header_accept) {
        $header_params->{'Accept'} = $_header_accept;
    }
    $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();

    # path params
    if ( exists $args{'subscription_id'}) {
        my $_base_variable = "{" . "subscriptionId" . "}";
        my $_base_value = $self->{api_client}->to_path_value($args{'subscription_id'});
        $_resource_path =~ s/$_base_variable/$_base_value/g;
    }

    my $_body_data;
    # authentication setting, if any
    my $auth_settings = [qw(UserOrAgent )];

    # make the API Call
    my $response = $self->{api_client}->call_api($_resource_path, $_method,
                                           $query_params, $form_params,
                                           $header_params, $_body_data, $auth_settings);
    if (!$response) {
        return;
    }
    my $_response_object = $self->{api_client}->deserialize('DisabledResponse', $response);
    return $_response_object;
}

1;



( run in 0.720 second using v1.01-cache-2.11-cpan-e623d60df62 )