Class: BrevoRuby::CouponsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/brevo-ruby/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/brevo-ruby/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/brevo-ruby/api/coupons_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#create_coupon_collection(create_coupon_collection, opts = {}) ⇒ InlineResponse2012

Create а coupon collection

Parameters:

  • create_coupon_collection

    Values to create a coupon collection

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

    the optional parameters

Returns:



36
37
38
39
# File 'lib/brevo-ruby/api/coupons_api.rb', line 36

def create_coupon_collection(create_coupon_collection, opts = {})
  data, _status_code, _headers = create_coupon_collection_with_http_info(create_coupon_collection, opts)
  data
end

#create_coupon_collection_with_http_info(create_coupon_collection, opts = {}) ⇒ Array<(InlineResponse2012, Fixnum, Hash)>

Create а coupon collection

Parameters:

  • create_coupon_collection

    Values to create a coupon collection

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

    the optional parameters

Returns:

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

    InlineResponse2012 data, response status code and response headers



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
# File 'lib/brevo-ruby/api/coupons_api.rb', line 45

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

  # query parameters
  query_params = {}

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

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(create_coupon_collection)
  auth_names = ['api-key', 'partner-key']
  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 => 'InlineResponse2012')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: CouponsApi#create_coupon_collection\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_coupons(create_coupons, opts = {}) ⇒ nil

Create coupons for a coupon collection

Parameters:

  • create_coupons

    Values to create coupons

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

    the optional parameters

Returns:

  • (nil)


88
89
90
91
# File 'lib/brevo-ruby/api/coupons_api.rb', line 88

def create_coupons(create_coupons, opts = {})
  create_coupons_with_http_info(create_coupons, opts)
  nil
end

#create_coupons_with_http_info(create_coupons, opts = {}) ⇒ Array<(nil, Fixnum, Hash)>

Create coupons for a coupon collection

Parameters:

  • create_coupons

    Values to create coupons

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

    the optional parameters

Returns:

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

    nil, response status code and response headers



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
134
# File 'lib/brevo-ruby/api/coupons_api.rb', line 97

def create_coupons_with_http_info(create_coupons, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CouponsApi.create_coupons ...'
  end
  # verify the required parameter 'create_coupons' is set
  if @api_client.config.client_side_validation && create_coupons.nil?
    fail ArgumentError, "Missing the required parameter 'create_coupons' when calling CouponsApi.create_coupons"
  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'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(create_coupons)
  auth_names = ['api-key', 'partner-key']
  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)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: CouponsApi#create_coupons\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_coupon_collection(id, opts = {}) ⇒ GetCouponCollection

Get a coupon collection by id

Parameters:

  • id

    Id of the collection to return

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

    the optional parameters

Returns:



139
140
141
142
# File 'lib/brevo-ruby/api/coupons_api.rb', line 139

def get_coupon_collection(id, opts = {})
  data, _status_code, _headers = get_coupon_collection_with_http_info(id, opts)
  data
end

#get_coupon_collection_with_http_info(id, opts = {}) ⇒ Array<(GetCouponCollection, Fixnum, Hash)>

Get a coupon collection by id

Parameters:

  • id

    Id of the collection to return

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

    the optional parameters

Returns:

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

    GetCouponCollection data, response status code and response headers



148
149
150
151
152
153
154
155
156
157
158
159
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
# File 'lib/brevo-ruby/api/coupons_api.rb', line 148

def get_coupon_collection_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CouponsApi.get_coupon_collection ...'
  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 CouponsApi.get_coupon_collection"
  end
  # resource path
  local_var_path = '/couponCollections/{id}'.sub('{' + 'id' + '}', id.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'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['api-key', 'partner-key']
  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 => 'GetCouponCollection')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: CouponsApi#get_coupon_collection\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_coupon_collections(opts = {}) ⇒ GetCouponCollection

Get all your coupon collections

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :limit (Integer)

    Number of documents returned per page (default to 50)

  • :offset (Integer)

    Index of the first document on the page (default to 0)

  • :sort (String)

    Sort the results by creation time in ascending/descending order (default to desc)

Returns:



193
194
195
196
# File 'lib/brevo-ruby/api/coupons_api.rb', line 193

def get_coupon_collections(opts = {})
  data, _status_code, _headers = get_coupon_collections_with_http_info(opts)
  data
end

#get_coupon_collections_with_http_info(opts = {}) ⇒ Array<(GetCouponCollection, Fixnum, Hash)>

Get all your coupon collections

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :limit (Integer)

    Number of documents returned per page

  • :offset (Integer)

    Index of the first document on the page

  • :sort (String)

    Sort the results by creation time in ascending/descending order

Returns:

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

    GetCouponCollection data, response status code and response headers



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
229
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
# File 'lib/brevo-ruby/api/coupons_api.rb', line 204

def get_coupon_collections_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CouponsApi.get_coupon_collections ...'
  end
  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling CouponsApi.get_coupon_collections, must be smaller than or equal to 100.'
  end

  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 0
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling CouponsApi.get_coupon_collections, must be greater than or equal to 0.'
  end

  if @api_client.config.client_side_validation && !opts[:'offset'].nil? && opts[:'offset'] < 0
    fail ArgumentError, 'invalid value for "opts[:"offset"]" when calling CouponsApi.get_coupon_collections, must be greater than or equal to 0.'
  end

  if @api_client.config.client_side_validation && opts[:'sort'] && !['asc', 'desc'].include?(opts[:'sort'])
    fail ArgumentError, 'invalid value for "sort", must be one of asc, desc'
  end
  # resource path
  local_var_path = '/couponCollections'

  # query parameters
  query_params = {}
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?

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

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['api-key', 'partner-key']
  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 => 'GetCouponCollection')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: CouponsApi#get_coupon_collections\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#setUserAgent(user_agent) ⇒ Object

Set custom user_agent if explicitly passed in api default will still remain Swagger-Codegen/#VERSION/ruby



25
26
27
28
29
30
# File 'lib/brevo-ruby/api/coupons_api.rb', line 25

def setUserAgent(user_agent)
  @user_agent = user_agent
  if user_agent.is_a?(String) && user_agent.downcase.start_with?('brevo_')
    @api_client.default_headers['User-Agent'] = @user_agent
  end
end

#update_coupon_collection(id, update_coupon_collection, opts = {}) ⇒ InlineResponse2001

Update a coupon collection by id

Parameters:

  • id

    Id of the collection to update

  • update_coupon_collection

    Values to update the coupon collection

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

    the optional parameters

Returns:



262
263
264
265
# File 'lib/brevo-ruby/api/coupons_api.rb', line 262

def update_coupon_collection(id, update_coupon_collection, opts = {})
  data, _status_code, _headers = update_coupon_collection_with_http_info(id, update_coupon_collection, opts)
  data
end

#update_coupon_collection_with_http_info(id, update_coupon_collection, opts = {}) ⇒ Array<(InlineResponse2001, Fixnum, Hash)>

Update a coupon collection by id

Parameters:

  • id

    Id of the collection to update

  • update_coupon_collection

    Values to update the coupon collection

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

    the optional parameters

Returns:

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

    InlineResponse2001 data, response status code and response headers



272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
# File 'lib/brevo-ruby/api/coupons_api.rb', line 272

def update_coupon_collection_with_http_info(id, update_coupon_collection, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CouponsApi.update_coupon_collection ...'
  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 CouponsApi.update_coupon_collection"
  end
  # verify the required parameter 'update_coupon_collection' is set
  if @api_client.config.client_side_validation && update_coupon_collection.nil?
    fail ArgumentError, "Missing the required parameter 'update_coupon_collection' when calling CouponsApi.update_coupon_collection"
  end
  # resource path
  local_var_path = '/couponCollections/{id}'.sub('{' + 'id' + '}', id.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'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = {}

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