Class: NewStoreApi::DeviceSubscriptionsController

Inherits:
BaseController show all
Defined in:
lib/new_store_api/controllers/device_subscriptions_controller.rb

Overview

DeviceSubscriptionsController

Constant Summary

Constants inherited from BaseController

BaseController::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseController

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseController

#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent

Constructor Details

This class inherits a constructor from NewStoreApi::BaseController

Instance Method Details

#create_subscription(body: nil) ⇒ SubscriptionResponse

🚧 BETA: This endpoint is in beta and may change.
See API Lifecycle Documentation for details.
Creates a subscription for push notifications description here

Parameters:

Returns:



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/new_store_api/controllers/device_subscriptions_controller.rb', line 68

def create_subscription(body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/retail-org/devices/subscriptions',
                                 Server::API)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('oauth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(SubscriptionResponse.method(:from_hash)))
    .execute
end

#destroy_subscriptionvoid

This method returns an undefined value.

🚧 BETA: This endpoint is in beta and may change.
See API Lifecycle Documentation for details.
Delete subscriptions for push notifications


20
21
22
23
24
25
26
27
28
29
# File 'lib/new_store_api/controllers/device_subscriptions_controller.rb', line 20

def destroy_subscription
  @api_call
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/retail-org/devices/subscriptions',
                                 Server::API)
               .auth(Single.new('oauth')))
    .response(new_response_handler
                .is_response_void(true))
    .execute
end

#list_subscriptionsSubscriptionsResponse

🚧 BETA: This endpoint is in beta and may change.
See API Lifecycle Documentation for details.
Reads subscriptions for push notifications

Returns:



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/new_store_api/controllers/device_subscriptions_controller.rb', line 42

def list_subscriptions
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/retail-org/devices/subscriptions',
                                 Server::API)
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('oauth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(SubscriptionsResponse.method(:from_hash)))
    .execute
end