Class: SibApiV3Sdk::FoldersApi

Inherits:
Object
  • Object
show all
Defined in:
lib/sib-api-v3-sdk/api/folders_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ FoldersApi

Returns a new instance of FoldersApi.



19
20
21
# File 'lib/sib-api-v3-sdk/api/folders_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/sib-api-v3-sdk/api/folders_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#create_folder(create_folder, opts = {}) ⇒ CreateModel

Create a folder

Parameters:

  • create_folder

    Name of the folder

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

    the optional parameters

Returns:



36
37
38
39
# File 'lib/sib-api-v3-sdk/api/folders_api.rb', line 36

def create_folder(create_folder, opts = {})
  data, _status_code, _headers = create_folder_with_http_info(create_folder, opts)
  data
end

#create_folder_with_http_info(create_folder, opts = {}) ⇒ Array<(CreateModel, Fixnum, Hash)>

Create a folder

Parameters:

  • create_folder

    Name of the folder

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

    the optional parameters

Returns:

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

    CreateModel 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/sib-api-v3-sdk/api/folders_api.rb', line 45

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

  # 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_folder)
  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 => 'CreateModel')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: FoldersApi#create_folder\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_folder(folder_id, opts = {}) ⇒ nil

Delete a folder (and all its lists)

Parameters:

  • folder_id

    Id of the folder

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

    the optional parameters

Returns:

  • (nil)


88
89
90
91
# File 'lib/sib-api-v3-sdk/api/folders_api.rb', line 88

def delete_folder(folder_id, opts = {})
  delete_folder_with_http_info(folder_id, opts)
  nil
end

#delete_folder_with_http_info(folder_id, opts = {}) ⇒ Array<(nil, Fixnum, Hash)>

Delete a folder (and all its lists)

Parameters:

  • folder_id

    Id of the folder

  • 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/sib-api-v3-sdk/api/folders_api.rb', line 97

def delete_folder_with_http_info(folder_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: FoldersApi.delete_folder ...'
  end
  # verify the required parameter 'folder_id' is set
  if @api_client.config.client_side_validation && folder_id.nil?
    fail ArgumentError, "Missing the required parameter 'folder_id' when calling FoldersApi.delete_folder"
  end
  # resource path
  local_var_path = '/contacts/folders/{folderId}'.sub('{' + 'folderId' + '}', folder_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(:DELETE, 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: FoldersApi#delete_folder\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_folder(folder_id, opts = {}) ⇒ GetFolder

Returns a folder’s details

Parameters:

  • folder_id

    id of the folder

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

    the optional parameters

Returns:



139
140
141
142
# File 'lib/sib-api-v3-sdk/api/folders_api.rb', line 139

def get_folder(folder_id, opts = {})
  data, _status_code, _headers = get_folder_with_http_info(folder_id, opts)
  data
end

#get_folder_lists(folder_id, opts = {}) ⇒ GetFolderLists

Get lists in a folder

Parameters:

  • folder_id

    Id of the folder

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

    the optional parameters

Options Hash (opts):

  • :limit (Integer)

    Number of documents per page (default to 10)

  • :offset (Integer)

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

  • :sort (String)

    Sort the results in the ascending/descending order of record creation. Default order is descending if &#x60;sort&#x60; is not passed (default to desc)

Returns:



194
195
196
197
# File 'lib/sib-api-v3-sdk/api/folders_api.rb', line 194

def get_folder_lists(folder_id, opts = {})
  data, _status_code, _headers = get_folder_lists_with_http_info(folder_id, opts)
  data
end

#get_folder_lists_with_http_info(folder_id, opts = {}) ⇒ Array<(GetFolderLists, Fixnum, Hash)>

Get lists in a folder

Parameters:

  • folder_id

    Id of the folder

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

    the optional parameters

Options Hash (opts):

  • :limit (Integer)

    Number of documents per page

  • :offset (Integer)

    Index of the first document of the page

  • :sort (String)

    Sort the results in the ascending/descending order of record creation. Default order is descending if &#x60;sort&#x60; is not passed

Returns:

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

    GetFolderLists data, response status code and response headers



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
# File 'lib/sib-api-v3-sdk/api/folders_api.rb', line 206

def get_folder_lists_with_http_info(folder_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: FoldersApi.get_folder_lists ...'
  end
  # verify the required parameter 'folder_id' is set
  if @api_client.config.client_side_validation && folder_id.nil?
    fail ArgumentError, "Missing the required parameter 'folder_id' when calling FoldersApi.get_folder_lists"
  end
  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 50
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling FoldersApi.get_folder_lists, must be smaller than or equal to 50.'
  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 = '/contacts/folders/{folderId}/lists'.sub('{' + 'folderId' + '}', folder_id.to_s)

  # 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 => 'GetFolderLists')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: FoldersApi#get_folder_lists\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_folder_with_http_info(folder_id, opts = {}) ⇒ Array<(GetFolder, Fixnum, Hash)>

Returns a folder&#39;s details

Parameters:

  • folder_id

    id of the folder

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

    the optional parameters

Returns:

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

    GetFolder 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/sib-api-v3-sdk/api/folders_api.rb', line 148

def get_folder_with_http_info(folder_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: FoldersApi.get_folder ...'
  end
  # verify the required parameter 'folder_id' is set
  if @api_client.config.client_side_validation && folder_id.nil?
    fail ArgumentError, "Missing the required parameter 'folder_id' when calling FoldersApi.get_folder"
  end
  # resource path
  local_var_path = '/contacts/folders/{folderId}'.sub('{' + 'folderId' + '}', folder_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 => 'GetFolder')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: FoldersApi#get_folder\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_folders(limit, offset, opts = {}) ⇒ GetFolders

Get all folders

Parameters:

  • limit

    Number of documents per page

  • offset

    Index of the first document of the page

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

    the optional parameters

Options Hash (opts):

  • :sort (String)

    Sort the results in the ascending/descending order of record creation. Default order is descending if &#x60;sort&#x60; is not passed (default to desc)

Returns:



261
262
263
264
# File 'lib/sib-api-v3-sdk/api/folders_api.rb', line 261

def get_folders(limit, offset, opts = {})
  data, _status_code, _headers = get_folders_with_http_info(limit, offset, opts)
  data
end

#get_folders_with_http_info(limit, offset, opts = {}) ⇒ Array<(GetFolders, Fixnum, Hash)>

Get all folders

Parameters:

  • limit

    Number of documents per page

  • offset

    Index of the first document of the page

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

    the optional parameters

Options Hash (opts):

  • :sort (String)

    Sort the results in the ascending/descending order of record creation. Default order is descending if &#x60;sort&#x60; is not passed

Returns:

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

    GetFolders 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
315
316
317
318
319
320
321
322
323
324
# File 'lib/sib-api-v3-sdk/api/folders_api.rb', line 272

def get_folders_with_http_info(limit, offset, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: FoldersApi.get_folders ...'
  end
  # verify the required parameter 'limit' is set
  if @api_client.config.client_side_validation && limit.nil?
    fail ArgumentError, "Missing the required parameter 'limit' when calling FoldersApi.get_folders"
  end
  if @api_client.config.client_side_validation && limit > 50
    fail ArgumentError, 'invalid value for "limit" when calling FoldersApi.get_folders, must be smaller than or equal to 50.'
  end

  # verify the required parameter 'offset' is set
  if @api_client.config.client_side_validation && offset.nil?
    fail ArgumentError, "Missing the required parameter 'offset' when calling FoldersApi.get_folders"
  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 = '/contacts/folders'

  # query parameters
  query_params = {}
  query_params[:'limit'] = limit
  query_params[:'offset'] = offset
  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 => 'GetFolders')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: FoldersApi#get_folders\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/sib-api-v3-sdk/api/folders_api.rb', line 25

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

#update_folder(folder_id, update_folder, opts = {}) ⇒ nil

Update a folder

Parameters:

  • folder_id

    Id of the folder

  • update_folder

    Name of the folder

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

    the optional parameters

Returns:

  • (nil)


330
331
332
333
# File 'lib/sib-api-v3-sdk/api/folders_api.rb', line 330

def update_folder(folder_id, update_folder, opts = {})
  update_folder_with_http_info(folder_id, update_folder, opts)
  nil
end

#update_folder_with_http_info(folder_id, update_folder, opts = {}) ⇒ Array<(nil, Fixnum, Hash)>

Update a folder

Parameters:

  • folder_id

    Id of the folder

  • update_folder

    Name of the folder

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

    the optional parameters

Returns:

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

    nil, response status code and response headers



340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
# File 'lib/sib-api-v3-sdk/api/folders_api.rb', line 340

def update_folder_with_http_info(folder_id, update_folder, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: FoldersApi.update_folder ...'
  end
  # verify the required parameter 'folder_id' is set
  if @api_client.config.client_side_validation && folder_id.nil?
    fail ArgumentError, "Missing the required parameter 'folder_id' when calling FoldersApi.update_folder"
  end
  # verify the required parameter 'update_folder' is set
  if @api_client.config.client_side_validation && update_folder.nil?
    fail ArgumentError, "Missing the required parameter 'update_folder' when calling FoldersApi.update_folder"
  end
  # resource path
  local_var_path = '/contacts/folders/{folderId}'.sub('{' + 'folderId' + '}', folder_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_folder)
  auth_names = ['api-key', 'partner-key']
  data, status_code, headers = @api_client.call_api(:PUT, 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: FoldersApi#update_folder\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end