Class: Bfwd::CouponsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/bf_ruby2/api/coupons_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ CouponsApi

Returns a new instance of CouponsApi.



19
20
21
# File 'lib/bf_ruby2/api/coupons_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/bf_ruby2/api/coupons_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#create_coupon(code, opts = {}) ⇒ CouponPagedMetadata

Create a coupon. a new coupon","request":"createCouponRequest.html","response":"createCouponResponse.html"

Parameters:

  • code

    The coupon object to be created.

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

    the optional parameters

Returns:



28
29
30
31
# File 'lib/bf_ruby2/api/coupons_api.rb', line 28

def create_coupon(code, opts = {})
  data, _status_code, _headers = create_coupon_with_http_info(code, opts)
  return data
end

#create_coupon_unique_codes(code, opts = {}) ⇒ CouponUniqueCodesResponsePagedMetadata

Create a list of unique coupon codes that can be applied to a subscription. { "nickname":"Create unique coupon codes","request":"createUniqueCodesRequest.html","response":"createUniqueCodesResponse.html"}

Parameters:

  • code

    The coupon code to use in the generation of the unique codes.

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

    the optional parameters

Options Hash (opts):

Returns:



84
85
86
87
# File 'lib/bf_ruby2/api/coupons_api.rb', line 84

def create_coupon_unique_codes(code, opts = {})
  data, _status_code, _headers = create_coupon_unique_codes_with_http_info(code, opts)
  return data
end

#create_coupon_unique_codes_with_http_info(code, opts = {}) ⇒ Array<(CouponUniqueCodesResponsePagedMetadata, Fixnum, Hash)>

Create a list of unique coupon codes that can be applied to a subscription. { &quot;nickname&quot;:&quot;Create unique coupon codes&quot;,&quot;request&quot;:&quot;createUniqueCodesRequest.html&quot;,&quot;response&quot;:&quot;createUniqueCodesResponse.html&quot;}

Parameters:

  • code

    The coupon code to use in the generation of the unique codes.

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

    the optional parameters

Options Hash (opts):

Returns:



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/bf_ruby2/api/coupons_api.rb', line 95

def create_coupon_unique_codes_with_http_info(code, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: CouponsApi.create_coupon_unique_codes ..."
  end
  # verify the required parameter 'code' is set
  if @api_client.config.client_side_validation && code.nil?
    fail ArgumentError, "Missing the required parameter 'code' when calling CouponsApi.create_coupon_unique_codes"
  end
  # resource path
  local_var_path = "/coupons/{code}/codes".sub('{' + 'code' + '}', code.to_s)

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json; charset=utf-8'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json; charset=utf-8'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(opts[:'request'])
  auth_names = []
  data, status_code, headers = @api_client.call_api(:POST, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'CouponUniqueCodesResponsePagedMetadata')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: CouponsApi#create_coupon_unique_codes\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_coupon_with_http_info(code, opts = {}) ⇒ Array<(CouponPagedMetadata, Fixnum, Hash)>

Create a coupon. a new coupon&quot;,&quot;request&quot;:&quot;createCouponRequest.html&quot;,&quot;response&quot;:&quot;createCouponResponse.html&quot;

Parameters:

  • code

    The coupon object to be created.

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

    the optional parameters

Returns:

  • (Array<(CouponPagedMetadata, Fixnum, Hash)>)

    CouponPagedMetadata data, response status code and response headers



38
39
40
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
# File 'lib/bf_ruby2/api/coupons_api.rb', line 38

def create_coupon_with_http_info(code, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: CouponsApi.create_coupon ..."
  end
  # verify the required parameter 'code' is set
  if @api_client.config.client_side_validation && code.nil?
    fail ArgumentError, "Missing the required parameter 'code' when calling CouponsApi.create_coupon"
  end
  # resource path
  local_var_path = "/coupons"

  # query parameters
  query_params = {}

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json; charset=utf-8'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json; charset=utf-8'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(code)
  auth_names = []
  data, status_code, headers = @api_client.call_api(:POST, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'CouponPagedMetadata')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: CouponsApi#create_coupon\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_all_coupons(opts = {}) ⇒ CouponPagedMetadata

Returns a collection of all coupons. By default 10 values are returned. Records are returned in natural order. { "nickname":"Retrieve all coupons","response":"getCouponAll.html"}

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :organizations (Array<String>)

    A list of organization-IDs used to restrict the scope of API calls.

  • :offset (Integer)

    The offset from the first subscription to return. (default to 0)

  • :records (Integer)

    The maximum number of subscriptions to return. (default to 10)

  • :order_by (String)

    Specify a field used to order the result set. (default to created)

  • :order (String)

    Ihe direction of any ordering, either ASC or DESC. (default to DESC)

  • :include_retired (BOOLEAN)

    Whether retired subscriptions should be returned. (default to false)

Returns:



145
146
147
148
# File 'lib/bf_ruby2/api/coupons_api.rb', line 145

def get_all_coupons(opts = {})
  data, _status_code, _headers = get_all_coupons_with_http_info(opts)
  return data
end

#get_all_coupons_with_http_info(opts = {}) ⇒ Array<(CouponPagedMetadata, Fixnum, Hash)>

Returns a collection of all coupons. By default 10 values are returned. Records are returned in natural order. { &quot;nickname&quot;:&quot;Retrieve all coupons&quot;,&quot;response&quot;:&quot;getCouponAll.html&quot;}

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :organizations (Array<String>)

    A list of organization-IDs used to restrict the scope of API calls.

  • :offset (Integer)

    The offset from the first subscription to return.

  • :records (Integer)

    The maximum number of subscriptions to return.

  • :order_by (String)

    Specify a field used to order the result set.

  • :order (String)

    Ihe direction of any ordering, either ASC or DESC.

  • :include_retired (BOOLEAN)

    Whether retired subscriptions should be returned.

Returns:

  • (Array<(CouponPagedMetadata, Fixnum, Hash)>)

    CouponPagedMetadata data, response status code and response headers



160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/bf_ruby2/api/coupons_api.rb', line 160

def get_all_coupons_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: CouponsApi.get_all_coupons ..."
  end
  if @api_client.config.client_side_validation && opts[:'order'] && !['ASC', 'DESC'].include?(opts[:'order'])
    fail ArgumentError, 'invalid value for "order", must be one of ASC, DESC'
  end
  # resource path
  local_var_path = "/coupons"

  # query parameters
  query_params = {}
  query_params[:'organizations'] = @api_client.build_collection_param(opts[:'organizations'], :multi) if !opts[:'organizations'].nil?
  query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
  query_params[:'records'] = opts[:'records'] if !opts[:'records'].nil?
  query_params[:'order_by'] = opts[:'order_by'] if !opts[:'order_by'].nil?
  query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil?
  query_params[:'include_retired'] = opts[:'include_retired'] if !opts[:'include_retired'].nil?

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json; charset=utf-8'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = []
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'CouponPagedMetadata')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: CouponsApi#get_all_coupons\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_applied_coupons(code, opts = {}) ⇒ CouponPagedMetadata

Returns a list of unique coupons which have been applied. { "nickname":"Retrieve used unique coupons","response":"getAppliedCodesForCode.html"}

Parameters:

  • code

    The base code to use in the generation of the unique codes.

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

    the optional parameters

Options Hash (opts):

  • :organizations (Array<String>)

    A list of organization-IDs used to restrict the scope of API calls.

  • :offset (Integer)

    The offset from the first subscription to return. (default to 0)

  • :records (Integer)

    The maximum number of subscriptions to return. (default to 10)

  • :order_by (String)

    Specify a field used to order the result set. (default to created)

  • :order (String)

    Ihe direction of any ordering, either ASC or DESC. (default to DESC)

  • :include_retired (BOOLEAN)

    Whether retired subscriptions should be returned. (default to false)

Returns:



214
215
216
217
# File 'lib/bf_ruby2/api/coupons_api.rb', line 214

def get_applied_coupons(code, opts = {})
  data, _status_code, _headers = get_applied_coupons_with_http_info(code, opts)
  return data
end

#get_applied_coupons_with_http_info(code, opts = {}) ⇒ Array<(CouponPagedMetadata, Fixnum, Hash)>

Returns a list of unique coupons which have been applied. { &quot;nickname&quot;:&quot;Retrieve used unique coupons&quot;,&quot;response&quot;:&quot;getAppliedCodesForCode.html&quot;}

Parameters:

  • code

    The base code to use in the generation of the unique codes.

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

    the optional parameters

Options Hash (opts):

  • :organizations (Array<String>)

    A list of organization-IDs used to restrict the scope of API calls.

  • :offset (Integer)

    The offset from the first subscription to return.

  • :records (Integer)

    The maximum number of subscriptions to return.

  • :order_by (String)

    Specify a field used to order the result set.

  • :order (String)

    Ihe direction of any ordering, either ASC or DESC.

  • :include_retired (BOOLEAN)

    Whether retired subscriptions should be returned.

Returns:

  • (Array<(CouponPagedMetadata, Fixnum, Hash)>)

    CouponPagedMetadata data, response status code and response headers



230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
# File 'lib/bf_ruby2/api/coupons_api.rb', line 230

def get_applied_coupons_with_http_info(code, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: CouponsApi.get_applied_coupons ..."
  end
  # verify the required parameter 'code' is set
  if @api_client.config.client_side_validation && code.nil?
    fail ArgumentError, "Missing the required parameter 'code' when calling CouponsApi.get_applied_coupons"
  end
  if @api_client.config.client_side_validation && opts[:'order'] && !['ASC', 'DESC'].include?(opts[:'order'])
    fail ArgumentError, 'invalid value for "order", must be one of ASC, DESC'
  end
  # resource path
  local_var_path = "/coupons/{code}/applied".sub('{' + 'code' + '}', code.to_s)

  # query parameters
  query_params = {}
  query_params[:'organizations'] = @api_client.build_collection_param(opts[:'organizations'], :multi) if !opts[:'organizations'].nil?
  query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
  query_params[:'records'] = opts[:'records'] if !opts[:'records'].nil?
  query_params[:'order_by'] = opts[:'order_by'] if !opts[:'order_by'].nil?
  query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil?
  query_params[:'include_retired'] = opts[:'include_retired'] if !opts[:'include_retired'].nil?

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json; charset=utf-8'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['text/plain'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = []
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'CouponPagedMetadata')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: CouponsApi#get_applied_coupons\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_available_coupon_codes_for_code(code, opts = {}) ⇒ CouponUniqueCodesResponsePagedMetadata

Returns a list of available unique coupon codes for the specified parent coupon code that can be applied to a subscription. { "nickname":"Retrieve unused unique coupons","response":"getAvailableCodesForCode.html"}

Parameters:

  • code

    The base code to use in the generation of the unique codes.

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

    the optional parameters

Options Hash (opts):

  • :organizations (Array<String>)

    A list of organization-IDs used to restrict the scope of API calls.

  • :offset (Integer)

    The offset from the first subscription to return. (default to 0)

  • :records (Integer)

    The maximum number of subscriptions to return. (default to 10)

  • :order_by (String)

    Specify a field used to order the result set. (default to created)

  • :order (String)

    Ihe direction of any ordering, either ASC or DESC. (default to DESC)

  • :include_retired (BOOLEAN)

    Whether retired subscriptions should be returned. (default to false)

Returns:



290
291
292
293
# File 'lib/bf_ruby2/api/coupons_api.rb', line 290

def get_available_coupon_codes_for_code(code, opts = {})
  data, _status_code, _headers = get_available_coupon_codes_for_code_with_http_info(code, opts)
  return data
end

#get_available_coupon_codes_for_code_with_http_info(code, opts = {}) ⇒ Array<(CouponUniqueCodesResponsePagedMetadata, Fixnum, Hash)>

Returns a list of available unique coupon codes for the specified parent coupon code that can be applied to a subscription. { &quot;nickname&quot;:&quot;Retrieve unused unique coupons&quot;,&quot;response&quot;:&quot;getAvailableCodesForCode.html&quot;}

Parameters:

  • code

    The base code to use in the generation of the unique codes.

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

    the optional parameters

Options Hash (opts):

  • :organizations (Array<String>)

    A list of organization-IDs used to restrict the scope of API calls.

  • :offset (Integer)

    The offset from the first subscription to return.

  • :records (Integer)

    The maximum number of subscriptions to return.

  • :order_by (String)

    Specify a field used to order the result set.

  • :order (String)

    Ihe direction of any ordering, either ASC or DESC.

  • :include_retired (BOOLEAN)

    Whether retired subscriptions should be returned.

Returns:



306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
# File 'lib/bf_ruby2/api/coupons_api.rb', line 306

def get_available_coupon_codes_for_code_with_http_info(code, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: CouponsApi.get_available_coupon_codes_for_code ..."
  end
  # verify the required parameter 'code' is set
  if @api_client.config.client_side_validation && code.nil?
    fail ArgumentError, "Missing the required parameter 'code' when calling CouponsApi.get_available_coupon_codes_for_code"
  end
  if @api_client.config.client_side_validation && opts[:'order'] && !['ASC', 'DESC'].include?(opts[:'order'])
    fail ArgumentError, 'invalid value for "order", must be one of ASC, DESC'
  end
  # resource path
  local_var_path = "/coupons/{code}/codes".sub('{' + 'code' + '}', code.to_s)

  # query parameters
  query_params = {}
  query_params[:'organizations'] = @api_client.build_collection_param(opts[:'organizations'], :multi) if !opts[:'organizations'].nil?
  query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
  query_params[:'records'] = opts[:'records'] if !opts[:'records'].nil?
  query_params[:'order_by'] = opts[:'order_by'] if !opts[:'order_by'].nil?
  query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil?
  query_params[:'include_retired'] = opts[:'include_retired'] if !opts[:'include_retired'].nil?

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json; charset=utf-8'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['text/plain'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = []
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'CouponUniqueCodesResponsePagedMetadata')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: CouponsApi#get_available_coupon_codes_for_code\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_coupon_code(code, opts = {}) ⇒ CouponUniqueCodesResponsePagedMetadata

Returns the coupon for the specified code that can be applied to a subscription. { "nickname":"Retrieve coupon","response":"getCouponByCode.html"}

Parameters:

  • code

    The parent coupon code to use in the generation of the unique codes.

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

    the optional parameters

Options Hash (opts):

  • :organizations (Array<String>)

    A list of organization-IDs used to restrict the scope of API calls.

Returns:



361
362
363
364
# File 'lib/bf_ruby2/api/coupons_api.rb', line 361

def get_coupon_code(code, opts = {})
  data, _status_code, _headers = get_coupon_code_with_http_info(code, opts)
  return data
end

#get_coupon_code_with_http_info(code, opts = {}) ⇒ Array<(CouponUniqueCodesResponsePagedMetadata, Fixnum, Hash)>

Returns the coupon for the specified code that can be applied to a subscription. { &quot;nickname&quot;:&quot;Retrieve coupon&quot;,&quot;response&quot;:&quot;getCouponByCode.html&quot;}

Parameters:

  • code

    The parent coupon code to use in the generation of the unique codes.

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

    the optional parameters

Options Hash (opts):

  • :organizations (Array<String>)

    A list of organization-IDs used to restrict the scope of API calls.

Returns:



372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
# File 'lib/bf_ruby2/api/coupons_api.rb', line 372

def get_coupon_code_with_http_info(code, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: CouponsApi.get_coupon_code ..."
  end
  # verify the required parameter 'code' is set
  if @api_client.config.client_side_validation && code.nil?
    fail ArgumentError, "Missing the required parameter 'code' when calling CouponsApi.get_coupon_code"
  end
  # resource path
  local_var_path = "/coupons/{code}".sub('{' + 'code' + '}', code.to_s)

  # query parameters
  query_params = {}
  query_params[:'organizations'] = @api_client.build_collection_param(opts[:'organizations'], :multi) if !opts[:'organizations'].nil?

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json; charset=utf-8'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['text/plain'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = []
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'CouponUniqueCodesResponsePagedMetadata')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: CouponsApi#get_coupon_code\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_subscription_applications_of_coupons(code, opts = {}) ⇒ SubscriptionPagedMetadata

Retrieves a collection of the coupons by this coupon code which have been applied. { "nickname":"Retrieve subscriptions to which the given coupon code has been applied.","response":"getSubscriptionApplications.html"}

Parameters:

  • code

    Base code of the coupon.

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

    the optional parameters

Options Hash (opts):

  • :organizations (Array<String>)

    A list of organization-IDs used to restrict the scope of API calls.

  • :offset (Integer)

    The offset from the first subscription to return. (default to 0)

  • :records (Integer)

    The maximum number of subscriptions to return. (default to 10)

  • :order_by (String)

    Specify a field used to order the result set. (default to created)

  • :order (String)

    Ihe direction of any ordering, either ASC or DESC. (default to DESC)

  • :include_retired (BOOLEAN)

    Whether retired subscriptions should be returned. (default to false)

Returns:



424
425
426
427
# File 'lib/bf_ruby2/api/coupons_api.rb', line 424

def get_subscription_applications_of_coupons(code, opts = {})
  data, _status_code, _headers = get_subscription_applications_of_coupons_with_http_info(code, opts)
  return data
end

#get_subscription_applications_of_coupons_with_http_info(code, opts = {}) ⇒ Array<(SubscriptionPagedMetadata, Fixnum, Hash)>

Retrieves a collection of the coupons by this coupon code which have been applied. { &quot;nickname&quot;:&quot;Retrieve subscriptions to which the given coupon code has been applied.&quot;,&quot;response&quot;:&quot;getSubscriptionApplications.html&quot;}

Parameters:

  • code

    Base code of the coupon.

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

    the optional parameters

Options Hash (opts):

  • :organizations (Array<String>)

    A list of organization-IDs used to restrict the scope of API calls.

  • :offset (Integer)

    The offset from the first subscription to return.

  • :records (Integer)

    The maximum number of subscriptions to return.

  • :order_by (String)

    Specify a field used to order the result set.

  • :order (String)

    Ihe direction of any ordering, either ASC or DESC.

  • :include_retired (BOOLEAN)

    Whether retired subscriptions should be returned.

Returns:

  • (Array<(SubscriptionPagedMetadata, Fixnum, Hash)>)

    SubscriptionPagedMetadata data, response status code and response headers



440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
# File 'lib/bf_ruby2/api/coupons_api.rb', line 440

def get_subscription_applications_of_coupons_with_http_info(code, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: CouponsApi.get_subscription_applications_of_coupons ..."
  end
  # verify the required parameter 'code' is set
  if @api_client.config.client_side_validation && code.nil?
    fail ArgumentError, "Missing the required parameter 'code' when calling CouponsApi.get_subscription_applications_of_coupons"
  end
  if @api_client.config.client_side_validation && opts[:'order'] && !['ASC', 'DESC'].include?(opts[:'order'])
    fail ArgumentError, 'invalid value for "order", must be one of ASC, DESC'
  end
  # resource path
  local_var_path = "/coupons/{code}/subscriptions".sub('{' + 'code' + '}', code.to_s)

  # query parameters
  query_params = {}
  query_params[:'organizations'] = @api_client.build_collection_param(opts[:'organizations'], :multi) if !opts[:'organizations'].nil?
  query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
  query_params[:'records'] = opts[:'records'] if !opts[:'records'].nil?
  query_params[:'order_by'] = opts[:'order_by'] if !opts[:'order_by'].nil?
  query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil?
  query_params[:'include_retired'] = opts[:'include_retired'] if !opts[:'include_retired'].nil?

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json; charset=utf-8'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['text/plain'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = []
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'SubscriptionPagedMetadata')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: CouponsApi#get_subscription_applications_of_coupons\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#retire_coupon(code, organizations, opts = {}) ⇒ CouponPagedMetadata

<p>This method has 2 main behaviours depending on what is passed in. If the parent coupon code, for example SUMMER, is given no new coupons can be issued or claimed from this code. Deleting will result in the deleted property being set to true.</p><p>If a unique coupon code, for example SUMMER-AGH8, is given this will stop the coupon from being applied to the subscription from that point onwards. When a coupon is deleted the validUntil property is set which is the date/time it stopped applying to the target.</p> { "nickname":"Retire coupon","response":"retireCoupon.html"}

Parameters:

  • code

    ID of the coupon to remove.

  • organizations

    A list of organization-IDs used to restrict the scope of API calls.

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

    the optional parameters

Returns:



495
496
497
498
# File 'lib/bf_ruby2/api/coupons_api.rb', line 495

def retire_coupon(code, organizations, opts = {})
  data, _status_code, _headers = retire_coupon_with_http_info(code, organizations, opts)
  return data
end

#retire_coupon_with_http_info(code, organizations, opts = {}) ⇒ Array<(CouponPagedMetadata, Fixnum, Hash)>

&lt;p&gt;This method has 2 main behaviours depending on what is passed in. If the parent coupon code, for example SUMMER, is given no new coupons can be issued or claimed from this code. Deleting will result in the deleted property being set to true.&lt;/p&gt;&lt;p&gt;If a unique coupon code, for example SUMMER-AGH8, is given this will stop the coupon from being applied to the subscription from that point onwards. When a coupon is deleted the validUntil property is set which is the date/time it stopped applying to the target.&lt;/p&gt; { &quot;nickname&quot;:&quot;Retire coupon&quot;,&quot;response&quot;:&quot;retireCoupon.html&quot;}

Parameters:

  • code

    ID of the coupon to remove.

  • organizations

    A list of organization-IDs used to restrict the scope of API calls.

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

    the optional parameters

Returns:

  • (Array<(CouponPagedMetadata, Fixnum, Hash)>)

    CouponPagedMetadata data, response status code and response headers



506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
# File 'lib/bf_ruby2/api/coupons_api.rb', line 506

def retire_coupon_with_http_info(code, organizations, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: CouponsApi.retire_coupon ..."
  end
  # verify the required parameter 'code' is set
  if @api_client.config.client_side_validation && code.nil?
    fail ArgumentError, "Missing the required parameter 'code' when calling CouponsApi.retire_coupon"
  end
  # verify the required parameter 'organizations' is set
  if @api_client.config.client_side_validation && organizations.nil?
    fail ArgumentError, "Missing the required parameter 'organizations' when calling CouponsApi.retire_coupon"
  end
  # resource path
  local_var_path = "/coupons/{code}".sub('{' + 'code' + '}', code.to_s)

  # query parameters
  query_params = {}
  query_params[:'organizations'] = @api_client.build_collection_param(organizations, :multi)

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json; charset=utf-8'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['text/plain'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = []
  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => 'CouponPagedMetadata')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: CouponsApi#retire_coupon\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end