Class: Solifyn::SubscriptionsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/solifyn/api/subscriptions_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ SubscriptionsApi

Returns a new instance of SubscriptionsApi.



19
20
21
# File 'lib/solifyn/api/subscriptions_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/solifyn/api/subscriptions_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#subscriptions_action(subscription_id, action, subscription_action, opts = {}) ⇒ SubscriptionsAction201Response

Subscription Action Cancel, pause, resume, or add free days to a customer subscription.

Parameters:

  • subscription_id (String)

    The customer subscription ID

  • action (String)

    The subscription task to execute

  • subscription_action (SubscriptionAction)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



29
30
31
32
# File 'lib/solifyn/api/subscriptions_api.rb', line 29

def subscriptions_action(subscription_id, action, subscription_action, opts = {})
  data, _status_code, _headers = subscriptions_action_with_http_info(subscription_id, action, subscription_action, opts)
  data
end

#subscriptions_action_with_http_info(subscription_id, action, subscription_action, opts = {}) ⇒ Array<(SubscriptionsAction201Response, Integer, Hash)>

Subscription Action Cancel, pause, resume, or add free days to a customer subscription.

Parameters:

  • subscription_id (String)

    The customer subscription ID

  • action (String)

    The subscription task to execute

  • subscription_action (SubscriptionAction)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/solifyn/api/subscriptions_api.rb', line 41

def subscriptions_action_with_http_info(subscription_id, action, subscription_action, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: SubscriptionsApi.subscriptions_action ...'
  end
  # verify the required parameter 'subscription_id' is set
  if @api_client.config.client_side_validation && subscription_id.nil?
    fail ArgumentError, "Missing the required parameter 'subscription_id' when calling SubscriptionsApi.subscriptions_action"
  end
  # verify the required parameter 'action' is set
  if @api_client.config.client_side_validation && action.nil?
    fail ArgumentError, "Missing the required parameter 'action' when calling SubscriptionsApi.subscriptions_action"
  end
  # verify enum value
  allowable_values = ["add_free_days", "cancel", "pause", "resume", "uncancel", "adjust_seats"]
  if @api_client.config.client_side_validation && !allowable_values.include?(action)
    fail ArgumentError, "invalid value for \"action\", must be one of #{allowable_values}"
  end
  # verify the required parameter 'subscription_action' is set
  if @api_client.config.client_side_validation && subscription_action.nil?
    fail ArgumentError, "Missing the required parameter 'subscription_action' when calling SubscriptionsApi.subscriptions_action"
  end
  # resource path
  local_var_path = '/v1/subscriptions/{subscriptionId}/{action}'.sub('{' + 'subscriptionId' + '}', CGI.escape(subscription_id.to_s)).sub('{' + 'action' + '}', CGI.escape(action.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(subscription_action)

  # return_type
  return_type = opts[:debug_return_type] || 'SubscriptionsAction201Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"SubscriptionsApi.subscriptions_action",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: SubscriptionsApi#subscriptions_action\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#subscriptions_get(id, opts = {}) ⇒ SubscriptionDetail

Retrieve Subscription Details Retrieve detailed information about a subscription and its billing history.

Parameters:

  • id (String)

    The customer subscription ID

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



112
113
114
115
# File 'lib/solifyn/api/subscriptions_api.rb', line 112

def subscriptions_get(id, opts = {})
  data, _status_code, _headers = subscriptions_get_with_http_info(id, opts)
  data
end

#subscriptions_get_with_http_info(id, opts = {}) ⇒ Array<(SubscriptionDetail, Integer, Hash)>

Retrieve Subscription Details Retrieve detailed information about a subscription and its billing history.

Parameters:

  • id (String)

    The customer subscription ID

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(SubscriptionDetail, Integer, Hash)>)

    SubscriptionDetail data, response status code and response headers



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/solifyn/api/subscriptions_api.rb', line 122

def subscriptions_get_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: SubscriptionsApi.subscriptions_get ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling SubscriptionsApi.subscriptions_get"
  end
  # resource path
  local_var_path = '/v1/subscriptions/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'SubscriptionDetail'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"SubscriptionsApi.subscriptions_get",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: SubscriptionsApi#subscriptions_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#subscriptions_list(opts = {}) ⇒ SubscriptionList

List Subscriptions Retrieve a list of customer subscriptions, optionally filtered by customer ID.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :customer_id (String)

    Filter subscriptions by customer ID.

Returns:



175
176
177
178
# File 'lib/solifyn/api/subscriptions_api.rb', line 175

def subscriptions_list(opts = {})
  data, _status_code, _headers = subscriptions_list_with_http_info(opts)
  data
end

#subscriptions_list_with_http_info(opts = {}) ⇒ Array<(SubscriptionList, Integer, Hash)>

List Subscriptions Retrieve a list of customer subscriptions, optionally filtered by customer ID.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :customer_id (String)

    Filter subscriptions by customer ID.

Returns:

  • (Array<(SubscriptionList, Integer, Hash)>)

    SubscriptionList data, response status code and response headers



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# File 'lib/solifyn/api/subscriptions_api.rb', line 185

def subscriptions_list_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: SubscriptionsApi.subscriptions_list ...'
  end
  # resource path
  local_var_path = '/v1/subscriptions'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'customerId'] = opts[:'customer_id'] if !opts[:'customer_id'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'SubscriptionList'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"SubscriptionsApi.subscriptions_list",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: SubscriptionsApi#subscriptions_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end