Class: ConstantContactClient::ContactsCustomFieldsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/constant_contact_client/api/contacts_custom_fields_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ ContactsCustomFieldsApi

Returns a new instance of ContactsCustomFieldsApi.



19
20
21
# File 'lib/constant_contact_client/api/contacts_custom_fields_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/constant_contact_client/api/contacts_custom_fields_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#create_custom_fields(update_custom_field_request, opts = {}) ⇒ GetCustomField200Response

POST (create) a custom_field This POST request adds a new ‘custom_field` to the user’s account. A user can configure up to 100 ‘custom_fields` in their account.

Parameters:

  • update_custom_field_request (UpdateCustomFieldRequest)

    The JSON payload required to create a new `custom_field`

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

    the optional parameters

Returns:



27
28
29
30
# File 'lib/constant_contact_client/api/contacts_custom_fields_api.rb', line 27

def create_custom_fields(update_custom_field_request, opts = {})
  data, _status_code, _headers = create_custom_fields_with_http_info(update_custom_field_request, opts)
  data
end

#create_custom_fields_with_http_info(update_custom_field_request, opts = {}) ⇒ Array<(GetCustomField200Response, Integer, Hash)>

POST (create) a custom_field This POST request adds a new &#x60;custom_field&#x60; to the user&#39;s account. A user can configure up to 100 &#x60;custom_fields&#x60; in their account.

Parameters:

  • update_custom_field_request (UpdateCustomFieldRequest)

    The JSON payload required to create a new &#x60;custom_field&#x60;

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

    the optional parameters

Returns:

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

    GetCustomField200Response data, response status code and response headers



37
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
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/constant_contact_client/api/contacts_custom_fields_api.rb', line 37

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

  # 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'])
  # 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(update_custom_field_request)

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

  # auth_names
  auth_names = opts[:debug_auth_names] || ['oauth2_access_code', 'oauth2_implicit']

  new_options = opts.merge(
    :operation => :"ContactsCustomFieldsApi.create_custom_fields",
    :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: ContactsCustomFieldsApi#create_custom_fields\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_custom_field(custom_field_id, opts = {}) ⇒ nil

DELETE a custom_field This DELETE request deletes a custom_field from the user’s account

Parameters:

  • custom_field_id (String)

    Unique ID of the custom_field on which to operate.

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

    the optional parameters

Returns:

  • (nil)


95
96
97
98
# File 'lib/constant_contact_client/api/contacts_custom_fields_api.rb', line 95

def delete_custom_field(custom_field_id, opts = {})
  delete_custom_field_with_http_info(custom_field_id, opts)
  nil
end

#delete_custom_field_with_http_info(custom_field_id, opts = {}) ⇒ Array<(nil, Integer, Hash)>

DELETE a custom_field This DELETE request deletes a custom_field from the user&#39;s account

Parameters:

  • custom_field_id (String)

    Unique ID of the custom_field on which to operate.

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

    the optional parameters

Returns:

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

    nil, response status code and response headers



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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/constant_contact_client/api/contacts_custom_fields_api.rb', line 105

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

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

  # header parameters
  header_params = opts[:header_params] || {}

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

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

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || ['oauth2_access_code', 'oauth2_implicit']

  new_options = opts.merge(
    :operation => :"ContactsCustomFieldsApi.delete_custom_field",
    :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(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ContactsCustomFieldsApi#delete_custom_field\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_all_custom_fields(opts = {}) ⇒ GetAllCustomFields200Response

GET custom_fields Collection This GET request returns all ‘custom_fields` defined in the user’s account. <div class="Msg"><p class="note-text">This method does not currently support filtering results using the custom field update date.</p></div>

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :limit (Integer)

    Specifies the number of results displayed per page of output, from 1 - 100, default &#x3D; 50. (default to 50)

Returns:



156
157
158
159
# File 'lib/constant_contact_client/api/contacts_custom_fields_api.rb', line 156

def get_all_custom_fields(opts = {})
  data, _status_code, _headers = get_all_custom_fields_with_http_info(opts)
  data
end

#get_all_custom_fields_with_http_info(opts = {}) ⇒ Array<(GetAllCustomFields200Response, Integer, Hash)>

GET custom_fields Collection This GET request returns all &#x60;custom_fields&#x60; defined in the user&#39;s account. &lt;div class&#x3D;&quot;Msg&quot;&gt;&lt;p class&#x3D;&quot;note-text&quot;&gt;This method does not currently support filtering results using the custom field update date.&lt;/p&gt;&lt;/div&gt;

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :limit (Integer)

    Specifies the number of results displayed per page of output, from 1 - 100, default &#x3D; 50. (default to 50)

Returns:



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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/constant_contact_client/api/contacts_custom_fields_api.rb', line 166

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

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

  # resource path
  local_var_path = '/contact_custom_fields'

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

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

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

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

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

  # auth_names
  auth_names = opts[:debug_auth_names] || ['oauth2_access_code', 'oauth2_implicit']

  new_options = opts.merge(
    :operation => :"ContactsCustomFieldsApi.get_all_custom_fields",
    :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: ContactsCustomFieldsApi#get_all_custom_fields\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_custom_field(custom_field_id, opts = {}) ⇒ GetCustomField200Response

GET a custom_field This GET call retrieves a ‘custom_field` resource, specified by `custom_field_id`.

Parameters:

  • custom_field_id (String)

    Unique ID of the &#x60;custom_field&#x60; on which to operate.

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

    the optional parameters

Returns:



224
225
226
227
# File 'lib/constant_contact_client/api/contacts_custom_fields_api.rb', line 224

def get_custom_field(custom_field_id, opts = {})
  data, _status_code, _headers = get_custom_field_with_http_info(custom_field_id, opts)
  data
end

#get_custom_field_with_http_info(custom_field_id, opts = {}) ⇒ Array<(GetCustomField200Response, Integer, Hash)>

GET a custom_field This GET call retrieves a &#x60;custom_field&#x60; resource, specified by &#x60;custom_field_id&#x60;.

Parameters:

  • custom_field_id (String)

    Unique ID of the &#x60;custom_field&#x60; on which to operate.

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

    the optional parameters

Returns:

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

    GetCustomField200Response data, response status code and response headers



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
278
279
280
# File 'lib/constant_contact_client/api/contacts_custom_fields_api.rb', line 234

def get_custom_field_with_http_info(custom_field_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ContactsCustomFieldsApi.get_custom_field ...'
  end
  # verify the required parameter 'custom_field_id' is set
  if @api_client.config.client_side_validation && custom_field_id.nil?
    fail ArgumentError, "Missing the required parameter 'custom_field_id' when calling ContactsCustomFieldsApi.get_custom_field"
  end
  # resource path
  local_var_path = '/contact_custom_fields/{custom_field_id}'.sub('{' + 'custom_field_id' + '}', CGI.escape(custom_field_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'])

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

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

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

  # auth_names
  auth_names = opts[:debug_auth_names] || ['oauth2_access_code', 'oauth2_implicit']

  new_options = opts.merge(
    :operation => :"ContactsCustomFieldsApi.get_custom_field",
    :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: ContactsCustomFieldsApi#get_custom_field\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_custom_field(custom_field_id, update_custom_field_request, opts = {}) ⇒ GetCustomField200Response

PUT (update) a custom_field This PUT request updates an existing ‘custom_field` object.

Parameters:

  • custom_field_id (String)

    Unique ID of the &#x60;custom_field&#x60; on which to operate.

  • update_custom_field_request (UpdateCustomFieldRequest)

    The JSON payload used to update an existing custom field. Any properties omitted in the PUT request are overwritten with a null value.

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

    the optional parameters

Returns:



288
289
290
291
# File 'lib/constant_contact_client/api/contacts_custom_fields_api.rb', line 288

def update_custom_field(custom_field_id, update_custom_field_request, opts = {})
  data, _status_code, _headers = update_custom_field_with_http_info(custom_field_id, update_custom_field_request, opts)
  data
end

#update_custom_field_with_http_info(custom_field_id, update_custom_field_request, opts = {}) ⇒ Array<(GetCustomField200Response, Integer, Hash)>

PUT (update) a custom_field This PUT request updates an existing &#x60;custom_field&#x60; object.

Parameters:

  • custom_field_id (String)

    Unique ID of the &#x60;custom_field&#x60; on which to operate.

  • update_custom_field_request (UpdateCustomFieldRequest)

    The JSON payload used to update an existing custom field. Any properties omitted in the PUT request are overwritten with a null value.

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

    the optional parameters

Returns:

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

    GetCustomField200Response data, response status code and response headers



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
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
354
# File 'lib/constant_contact_client/api/contacts_custom_fields_api.rb', line 299

def update_custom_field_with_http_info(custom_field_id, update_custom_field_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ContactsCustomFieldsApi.update_custom_field ...'
  end
  # verify the required parameter 'custom_field_id' is set
  if @api_client.config.client_side_validation && custom_field_id.nil?
    fail ArgumentError, "Missing the required parameter 'custom_field_id' when calling ContactsCustomFieldsApi.update_custom_field"
  end
  # verify the required parameter 'update_custom_field_request' is set
  if @api_client.config.client_side_validation && update_custom_field_request.nil?
    fail ArgumentError, "Missing the required parameter 'update_custom_field_request' when calling ContactsCustomFieldsApi.update_custom_field"
  end
  # resource path
  local_var_path = '/contact_custom_fields/{custom_field_id}'.sub('{' + 'custom_field_id' + '}', CGI.escape(custom_field_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'])
  # 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(update_custom_field_request)

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

  # auth_names
  auth_names = opts[:debug_auth_names] || ['oauth2_access_code', 'oauth2_implicit']

  new_options = opts.merge(
    :operation => :"ContactsCustomFieldsApi.update_custom_field",
    :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(:PUT, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ContactsCustomFieldsApi#update_custom_field\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end