Class: ConstantContactClient::ContactsApi

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ ContactsApi

Returns a new instance of ContactsApi.



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

def api_client
  @api_client
end

Instance Method Details

#create_contact(create_contact_request, opts = {}) ⇒ GetContactById200Response

POST (create) a Contact Creates a new contact resource. You must include the create_source property and at least one of the following properties: first_name, last_name, a unique email_address (specified using the EmailAddress object), or the sms_channel property (specified using the ContactSmsChannel object). <div class="Msg"><p class="note-text">If email_address is specified: **Only use this method when a contact gives you their explicit permission to send them an email. It is a violation of anti-spam and telemarketing laws, as well as a serious violation of the Constant Contact Terms of Service to use the Opt-in features of the API to opt a contact back in without his or her own action and consent.

If sms_channel is specified: <div class="Msg"><p class="note-text">Only use this method when a contact gives you their explicit permission to send them an SMS. It is a violation of anti-spam and telemarketing laws, as well as a serious violation of the Constant Contact Terms of Service to use the Opt-in features of the API to opt a contact back in without his or her own action and consent.

Parameters:

  • create_contact_request (CreateContactRequest)

    The JSON payload defining the contact

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

    the optional parameters

Returns:



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

def create_contact(create_contact_request, opts = {})
  data, _status_code, _headers = create_contact_with_http_info(create_contact_request, opts)
  data
end

#create_contact_with_http_info(create_contact_request, opts = {}) ⇒ Array<(GetContactById200Response, Integer, Hash)>

POST (create) a Contact Creates a new contact resource. You must include the `create_source` property and at least one of the following properties: `first_name`, `last_name`, a unique `email_address` (specified using the `EmailAddress` object), or the `sms_channel` property (specified using the `ContactSmsChannel` object). <div class=&quot;Msg&quot;><p class=&quot;note-text&quot;>If `email_address` is specified: **Only use this method when a contact gives you their explicit permission to send them an email. It is a violation of anti-spam and telemarketing laws, as well as a serious violation of the Constant Contact Terms of Service to use the Opt-in features of the API to opt a contact back in without his or her own action and consent.</p></div> If `sms_channel` is specified: <div class=&quot;Msg&quot;><p class=&quot;note-text&quot;>Only use this method when a contact gives you their explicit permission to send them an SMS. It is a violation of anti-spam and telemarketing laws, as well as a serious violation of the Constant Contact Terms of Service to use the Opt-in features of the API to opt a contact back in without his or her own action and consent.</p></div>

Parameters:

  • create_contact_request (CreateContactRequest)

    The JSON payload defining the contact

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

    the optional parameters

Returns:

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

    GetContactById200Response 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_api.rb', line 37

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

  # 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(create_contact_request)

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

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

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

#create_or_update_contact(create_or_update_contact_request, opts = {}) ⇒ CreateOrUpdateContact200Response

Create or Update a Contact Use this method to create a new contact or update an existing contact. In the request body, this method requires including the list_memberships array as well as either the contact's email_address string or sms_channel object which includes the contact's SMS number. The information you specify determines if a new contact is either created (the email address or SMS number does not already exist in the account), or if an existing contact is updated (the email address or SMS number already exists). The SMS product feature does not need to be enabled to include a contacts SMS details. Updates to existing contacts are partial updates. This method only updates the contact properties you include in the request body. Updates append new contact lists or custom fields to the existing list_memberships or custom_fields arrays. If email_address is specified: <div class="Msg"><p class="note-text">Only use this method when a contact gives you their explicit permission to send them an email. It is a violation of anti-spam and telemarketing laws, as well as a serious violation of the Constant Contact Terms of Service to use the Opt-in features of the API to opt a contact back in without his or her own action and consent.

If sms_channel is specified: <div class="Msg"><p class="note-text">Only use this method when a contact gives you their explicit permission to send them an SMS. It is a violation of anti-spam and telemarketing laws, as well as a serious violation of the Constant Contact Terms of Service to use the Opt-in features of the API to opt a contact back in without his or her own action and consent.

When this method creates a new contact, it returns a 201 response code.When this method updates an existing contact, it returns a 200 response code. Updating a deleted contact restores the contact. The method automatically modifies the contact's permission_to_send and opt_in_source properties depending on the Confirmed Opt-In Constant Contact account setting: If Confirmed Opt-in is enabled, this method automatically sets the permission_to_send property as pending_confirmation for new contacts. If Confirmed Opt-in is disabled, this method automatically sets the permission_to_send property as explicit and the opt_in_source property as Contact for new contacts. Updated contacts have their permission_to_send property set as explicit.

Parameters:

Returns:



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

def create_or_update_contact(create_or_update_contact_request, opts = {})
  data, _status_code, _headers = create_or_update_contact_with_http_info(create_or_update_contact_request, opts)
  data
end

#create_or_update_contact_with_http_info(create_or_update_contact_request, opts = {}) ⇒ Array<(CreateOrUpdateContact200Response, Integer, Hash)>

Create or Update a Contact Use this method to create a new contact or update an existing contact. In the request body, this method requires including the `list_memberships` array as well as either the contact's `email_address` string or `sms_channel` object which includes the contact's SMS number. The information you specify determines if a new contact is either created (the email address or SMS number does not already exist in the account), or if an existing contact is updated (the email address or SMS number already exists). The SMS product feature does not need to be enabled to include a contacts SMS details. Updates to existing contacts are partial updates. This method only updates the contact properties you include in the request body. Updates append new contact lists or custom fields to the existing `list_memberships` or `custom_fields` arrays. If `email_address` is specified: <div class=&quot;Msg&quot;><p class=&quot;note-text&quot;>Only use this method when a contact gives you their explicit permission to send them an email. It is a violation of anti-spam and telemarketing laws, as well as a serious violation of the Constant Contact Terms of Service to use the Opt-in features of the API to opt a contact back in without his or her own action and consent.</p></div> If `sms_channel` is specified: <div class=&quot;Msg&quot;><p class=&quot;note-text&quot;>Only use this method when a contact gives you their explicit permission to send them an SMS. It is a violation of anti-spam and telemarketing laws, as well as a serious violation of the Constant Contact Terms of Service to use the Opt-in features of the API to opt a contact back in without his or her own action and consent.</p></div> When this method creates a new contact, it returns a 201 response code.When this method updates an existing contact, it returns a 200 response code. Updating a deleted contact restores the contact. The method automatically modifies the contact's `permission_to_send` and `opt_in_source` properties depending on the Confirmed Opt-In Constant Contact account setting: If Confirmed Opt-in is enabled, this method automatically sets the `permission_to_send` property as `pending_confirmation` for new contacts. If Confirmed Opt-in is disabled, this method automatically sets the `permission_to_send` property as explicit and the `opt_in_source` property as `Contact` for new contacts. Updated contacts have their `permission_to_send` property set as explicit.

Parameters:

Returns:



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
150
151
152
153
154
155
156
# File 'lib/constant_contact_client/api/contacts_api.rb', line 105

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

  # 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(create_or_update_contact_request)

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

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

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

#delete_contact(contact_id, opts = {}) ⇒ nil

DELETE a Contact Deletes the contact identified by the contact_id path parameter. Deleted contacts won't receive email from you, and they don't count as active contacts. Unlike unsubscribed contacts, deleted contacts can be revived, or added back to an account. Learn how to revive deleted contacts.

Parameters:

Returns:



163
164
165
166
# File 'lib/constant_contact_client/api/contacts_api.rb', line 163

def delete_contact(contact_id, opts = {})
  delete_contact_with_http_info(contact_id, opts)
  nil
end

#delete_contact_with_http_info(contact_id, opts = {}) ⇒ Array<(nil, Integer, Hash)>

DELETE a Contact Deletes the contact identified by the contact_id path parameter. Deleted contacts won't receive email from you, and they don't count as active contacts. Unlike unsubscribed contacts, deleted contacts can be revived, or added back to an account. Learn how to revive deleted contacts.

Parameters:

Returns:



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_api.rb', line 173

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

#get_all_contacts(opts = {}) ⇒ GetAllContacts200Response

GET Contacts Collection Use this method to return a collection of contacts. Use the query parameters to search for contacts that match specific contact properties and sub-resource properties as criteria. For example, you can search using the contact's email address, lists memberships, and by the date range that a contact was created or updated. Use the limit query parameter to limit the number of results returned per page. Use the include query parameter to include contact sub-resources in the response and include_count to include the total number of contacts that meet your specified search criteria. By default, this method returns all contacts that are not deleted. Use the status query parameter with the value all to return all contacts including deleted contacts.

Parameters:

Options Hash (opts):

Returns:



238
239
240
241
# File 'lib/constant_contact_client/api/contacts_api.rb', line 238

def get_all_contacts(opts = {})
  data, _status_code, _headers = get_all_contacts_with_http_info(opts)
  data
end

#get_all_contacts_with_http_info(opts = {}) ⇒ Array<(GetAllContacts200Response, Integer, Hash)>

GET Contacts Collection Use this method to return a collection of contacts. Use the query parameters to search for contacts that match specific contact properties and sub-resource properties as criteria. For example, you can search using the contact's `email` address, `lists` memberships, and by the date range that a contact was created or updated. Use the `limit` query parameter to limit the number of results returned per page. Use the `include` query parameter to include contact sub-resources in the response and `include_count` to include the total number of contacts that meet your specified search criteria. By default, this method returns all contacts that are not deleted. Use the `status` query parameter with the value `all` to return all contacts including deleted contacts.

Parameters:

Options Hash (opts):

Returns:



262
263
264
265
266
267
268
269
270
271
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
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
# File 'lib/constant_contact_client/api/contacts_api.rb', line 262

def get_all_contacts_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ContactsApi.get_all_contacts ...'
  end
  allowable_values = ["all", "active", "deleted", "not_set", "pending_confirmation", "temp_hold", "unsubscribed"]
  if @api_client.config.client_side_validation && opts[:'status'] && !allowable_values.include?(opts[:'status'])
    fail ArgumentError, "invalid value for \"status\", must be one of #{allowable_values}"
  end
  allowable_values = ["custom_fields", "list_memberships", "phone_numbers", "street_addresses", "taggings", "notes"]
  if @api_client.config.client_side_validation && opts[:'include'] && !allowable_values.include?(opts[:'include'])
    fail ArgumentError, "invalid value for \"include\", must be one of #{allowable_values}"
  end
  allowable_values = ["all", "explicit", "unsubscribed", "pending_confirmation", "not_set"]
  if @api_client.config.client_side_validation && opts[:'sms_status'] && !allowable_values.include?(opts[:'sms_status'])
    fail ArgumentError, "invalid value for \"sms_status\", must be one of #{allowable_values}"
  end
  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 500
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ContactsApi.get_all_contacts, must be smaller than or equal to 500.'
  end

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

  # resource path
  local_var_path = '/contacts'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'status'] = opts[:'status'] if !opts[:'status'].nil?
  query_params[:'email'] = opts[:'email'] if !opts[:'email'].nil?
  query_params[:'lists'] = opts[:'lists'] if !opts[:'lists'].nil?
  query_params[:'segment_id'] = opts[:'segment_id'] if !opts[:'segment_id'].nil?
  query_params[:'tags'] = opts[:'tags'] if !opts[:'tags'].nil?
  query_params[:'updated_after'] = opts[:'updated_after'] if !opts[:'updated_after'].nil?
  query_params[:'updated_before'] = opts[:'updated_before'] if !opts[:'updated_before'].nil?
  query_params[:'created_after'] = opts[:'created_after'] if !opts[:'created_after'].nil?
  query_params[:'created_before'] = opts[:'created_before'] if !opts[:'created_before'].nil?
  query_params[:'optout_after'] = opts[:'optout_after'] if !opts[:'optout_after'].nil?
  query_params[:'optout_before'] = opts[:'optout_before'] if !opts[:'optout_before'].nil?
  query_params[:'include'] = opts[:'include'] if !opts[:'include'].nil?
  query_params[:'sms_status'] = opts[:'sms_status'] if !opts[:'sms_status'].nil?
  query_params[:'include_count'] = opts[:'include_count'] if !opts[:'include_count'].nil?
  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] || 'GetAllContacts200Response'

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

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

#get_contact_by_id(contact_id, opts = {}) ⇒ GetContactById200Response

GET a Contact This endpoint GETs a specific contact resource (contact_id). Use the include query parameter to add any of the available contact sub-resources to the response payload.

Parameters:

Options Hash (opts):

Returns:



347
348
349
350
# File 'lib/constant_contact_client/api/contacts_api.rb', line 347

def get_contact_by_id(contact_id, opts = {})
  data, _status_code, _headers = get_contact_by_id_with_http_info(contact_id, opts)
  data
end

#get_contact_by_id_with_http_info(contact_id, opts = {}) ⇒ Array<(GetContactById200Response, Integer, Hash)>

GET a Contact This endpoint GETs a specific contact resource (contact_id). Use the `include` query parameter to add any of the available contact sub-resources to the response payload.

Parameters:

Options Hash (opts):

Returns:



358
359
360
361
362
363
364
365
366
367
368
369
370
371
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
# File 'lib/constant_contact_client/api/contacts_api.rb', line 358

def get_contact_by_id_with_http_info(contact_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ContactsApi.get_contact_by_id ...'
  end
  # verify the required parameter 'contact_id' is set
  if @api_client.config.client_side_validation && contact_id.nil?
    fail ArgumentError, "Missing the required parameter 'contact_id' when calling ContactsApi.get_contact_by_id"
  end
  allowable_values = ["custom_fields", "list_memberships", "phone_numbers", "street_addresses", "taggings", "notes"]
  if @api_client.config.client_side_validation && opts[:'include'] && !allowable_values.include?(opts[:'include'])
    fail ArgumentError, "invalid value for \"include\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/contacts/{contact_id}'.sub('{' + 'contact_id' + '}', CGI.escape(contact_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'include'] = opts[:'include'] if !opts[:'include'].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] || 'GetContactById200Response'

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

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

#get_contact_counts(opts = {}) ⇒ GetContactCounts200Response

GET Contact Consent Counts Use to get the total contacts count for the account and the total contact-consent counts for each consent state. Optionally, to include the total number of contacts that subscribed within the last 30 days in the results, use new_subscribers in the include query parameter. To optimize open rates, reduce spam reports, and help grow your business, you must value your contact's consent to receive or to not receive your emails.

Parameters:

Options Hash (opts):

Returns:



416
417
418
419
# File 'lib/constant_contact_client/api/contacts_api.rb', line 416

def get_contact_counts(opts = {})
  data, _status_code, _headers = get_contact_counts_with_http_info(opts)
  data
end

#get_contact_counts_with_http_info(opts = {}) ⇒ Array<(GetContactCounts200Response, Integer, Hash)>

GET Contact Consent Counts Use to get the total contacts count for the account and the total contact-consent counts for each consent state. Optionally, to include the total number of contacts that subscribed within the last 30 days in the results, use `new_subscribers` in the `include` query parameter. To optimize open rates, reduce spam reports, and help grow your business, you must value your contact's consent to receive or to not receive your emails.

Parameters:

Options Hash (opts):

Returns:



426
427
428
429
430
431
432
433
434
435
436
437
438
439
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
# File 'lib/constant_contact_client/api/contacts_api.rb', line 426

def get_contact_counts_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ContactsApi.get_contact_counts ...'
  end
  allowable_values = ["new_subscriber"]
  if @api_client.config.client_side_validation && opts[:'include'] && !allowable_values.include?(opts[:'include'])
    fail ArgumentError, "invalid value for \"include\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/contacts/counts'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'include'] = opts[:'include'] if !opts[:'include'].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] || 'GetContactCounts200Response'

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

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

#get_contact_id_xrefs(sequence_ids, opts = {}) ⇒ GetContactIdXrefs200Response

GET a collection of V2 and V3 API contact IDs

Use this endpoint to migrate your locally stored V2 contact ids to the new V3 format. Developers are expected to use this endpoint sparingly. This endpoint is NOT intended for regular or repeated use. Constant Contact will eventually deprecate and remove this endpoint.

This GET call retrieves a collection of cross-referenced contact sequence IDs (`id` used in the V2 API) and UUIDs (`contact_id` used in the V3 API). This endpoint is intended for developers who have an existing V2 API integration, and are migrating their users to a new V3 API integration. The V2 and V3 APIs use different resource ID formats. Use the `sequence_ids` query parameter to specify a set of comma delimited V2 contacts ids to cross-referenced with their V3 `contact_ids`. See [Migrating to V3](/api_guide/migration_overview.html) to learn more.

Parameters:

Returns:



480
481
482
483
# File 'lib/constant_contact_client/api/contacts_api.rb', line 480

def get_contact_id_xrefs(sequence_ids, opts = {})
  data, _status_code, _headers = get_contact_id_xrefs_with_http_info(sequence_ids, opts)
  data
end

#get_contact_id_xrefs_with_http_info(sequence_ids, opts = {}) ⇒ Array<(GetContactIdXrefs200Response, Integer, Hash)>

GET a collection of V2 and V3 API contact IDs <div class=&quot;Msg Msg--warning&quot;><p class=&quot;note-text&quot;>Use this endpoint to migrate your locally stored V2 contact ids to the new V3 format. Developers are expected to use this endpoint sparingly. This endpoint is NOT intended for regular or repeated use. Constant Contact will eventually deprecate and remove this endpoint.</p></div> This GET call retrieves a collection of cross-referenced contact sequence IDs (`id` used in the V2 API) and UUIDs (`contact_id` used in the V3 API). This endpoint is intended for developers who have an existing V2 API integration, and are migrating their users to a new V3 API integration. The V2 and V3 APIs use different resource ID formats. Use the `sequence_ids` query parameter to specify a set of comma delimited V2 contacts ids to cross-referenced with their V3 `contact_ids`. See Migrating to V3 to learn more.

Parameters:

Returns:



490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
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
# File 'lib/constant_contact_client/api/contacts_api.rb', line 490

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

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

  # 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] || 'GetContactIdXrefs200Response'

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

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

#get_sms_engagement_history(contact_id, opts = {}) ⇒ Array<GetSmsEngagementHistory200ResponseInner>

GET SMS Engagement History for a Contact Use this method to return SMS engagement details for a contact, such as SMS consent and advertising frequency details.

Parameters:

Returns:



544
545
546
547
# File 'lib/constant_contact_client/api/contacts_api.rb', line 544

def get_sms_engagement_history(contact_id, opts = {})
  data, _status_code, _headers = get_sms_engagement_history_with_http_info(contact_id, opts)
  data
end

#get_sms_engagement_history_with_http_info(contact_id, opts = {}) ⇒ Array<(Array<GetSmsEngagementHistory200ResponseInner>, Integer, Hash)>

GET SMS Engagement History for a Contact Use this method to return SMS engagement details for a contact, such as SMS consent and advertising frequency details.

Parameters:

Returns:



554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
# File 'lib/constant_contact_client/api/contacts_api.rb', line 554

def get_sms_engagement_history_with_http_info(contact_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ContactsApi.get_sms_engagement_history ...'
  end
  # verify the required parameter 'contact_id' is set
  if @api_client.config.client_side_validation && contact_id.nil?
    fail ArgumentError, "Missing the required parameter 'contact_id' when calling ContactsApi.get_sms_engagement_history"
  end
  # resource path
  local_var_path = '/contacts/sms_engagement_history/{contact_id}'.sub('{' + 'contact_id' + '}', CGI.escape(contact_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] || 'Array<GetSmsEngagementHistory200ResponseInner>'

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

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

#resubscribe_contact(contact_id, resubscribe_contact_request, opts = {}) ⇒ nil

PUT Resubscribe a Contact Use this endpoint to send a confirmation resubscribe email to a contact in order to get their confirmation to resubscribe. This endpoint also adds the resubscribed contact to the contact lists you specify in the request body. You can only send a resubscribe email to the unsubscribed contact once. The contact is not resubscribed until after you receive their confirmation.

Parameters:

Returns:



608
609
610
611
# File 'lib/constant_contact_client/api/contacts_api.rb', line 608

def resubscribe_contact(contact_id, resubscribe_contact_request, opts = {})
  resubscribe_contact_with_http_info(contact_id, resubscribe_contact_request, opts)
  nil
end

#resubscribe_contact_with_http_info(contact_id, resubscribe_contact_request, opts = {}) ⇒ Array<(nil, Integer, Hash)>

PUT Resubscribe a Contact Use this endpoint to send a confirmation resubscribe email to a contact in order to get their confirmation to resubscribe. This endpoint also adds the resubscribed contact to the contact lists you specify in the request body. You can only send a resubscribe email to the unsubscribed contact once. The contact is not resubscribed until after you receive their confirmation.

Parameters:

Returns:



619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
# File 'lib/constant_contact_client/api/contacts_api.rb', line 619

def resubscribe_contact_with_http_info(contact_id, resubscribe_contact_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ContactsApi.resubscribe_contact ...'
  end
  # verify the required parameter 'contact_id' is set
  if @api_client.config.client_side_validation && contact_id.nil?
    fail ArgumentError, "Missing the required parameter 'contact_id' when calling ContactsApi.resubscribe_contact"
  end
  # verify the required parameter 'resubscribe_contact_request' is set
  if @api_client.config.client_side_validation && resubscribe_contact_request.nil?
    fail ArgumentError, "Missing the required parameter 'resubscribe_contact_request' when calling ContactsApi.resubscribe_contact"
  end
  # resource path
  local_var_path = '/contacts/resubscribe/{contact_id}'.sub('{' + 'contact_id' + '}', CGI.escape(contact_id.to_s))

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

  # header parameters
  header_params = opts[:header_params] || {}
  # 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(resubscribe_contact_request)

  # 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 => :"ContactsApi.resubscribe_contact",
    :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: ContactsApi#resubscribe_contact\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_contact(contact_id, update_contact_request, opts = {}) ⇒ GetContactById200Response

PUT (update) a Contact The PUT method updates an existing contact. You must include the update_source property in the PUT request payload. To restore a deleted contact you must specify the update_source as Account. When updating any resource using PUT, all properties are updated, overwriting all previous values. Any properties left blank or not included in the request are overwritten with null value - however this does not apply to contact subresources. Add or change any of the subresources by including them in the PUT request payload. Omitted subresources are not overwritten with null. If the contact being updated is deleted, the contact will be revived. If email_address is specified: <div class="Msg"><p class="note-text"> **Only use this method when a contact gives you their explicit permission to send them an email. It is a violation of anti-spam and telemarketing laws, as well as a serious violation of the Constant Contact Terms of Service to use the Opt-in features of the API to opt a contact back in without his or her own action and consent.

If sms_channel is specified: <div class="Msg"><p class="note-text">Only use this method when a contact gives you their explicit permission to send them an SMS. It is a violation of anti-spam and telemarketing laws, as well as a serious violation of the Constant Contact Terms of Service to use the Opt-in features of the API to opt a contact back in without his or her own action and consent.

Parameters:

Returns:



680
681
682
683
# File 'lib/constant_contact_client/api/contacts_api.rb', line 680

def update_contact(contact_id, update_contact_request, opts = {})
  data, _status_code, _headers = update_contact_with_http_info(contact_id, update_contact_request, opts)
  data
end

#update_contact_with_http_info(contact_id, update_contact_request, opts = {}) ⇒ Array<(GetContactById200Response, Integer, Hash)>

PUT (update) a Contact The PUT method updates an existing contact. You must include the `update_source` property in the PUT request payload. To restore a deleted contact you must specify the `update_source` as `Account`. When updating any resource using PUT, all properties are updated, overwriting all previous values. Any properties left blank or not included in the request are overwritten with null value - however this does not apply to contact subresources. Add or change any of the subresources by including them in the PUT request payload. Omitted subresources are not overwritten with null. If the contact being updated is deleted, the contact will be revived. If `email_address` is specified: <div class=&quot;Msg&quot;><p class=&quot;note-text&quot;> **Only use this method when a contact gives you their explicit permission to send them an email. It is a violation of anti-spam and telemarketing laws, as well as a serious violation of the Constant Contact Terms of Service to use the Opt-in features of the API to opt a contact back in without his or her own action and consent.</p></div> If `sms_channel` is specified: <div class=&quot;Msg&quot;><p class=&quot;note-text&quot;>Only use this method when a contact gives you their explicit permission to send them an SMS. It is a violation of anti-spam and telemarketing laws, as well as a serious violation of the Constant Contact Terms of Service to use the Opt-in features of the API to opt a contact back in without his or her own action and consent.</p></div>

Parameters:

Returns:



691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
# File 'lib/constant_contact_client/api/contacts_api.rb', line 691

def update_contact_with_http_info(contact_id, update_contact_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ContactsApi.update_contact ...'
  end
  # verify the required parameter 'contact_id' is set
  if @api_client.config.client_side_validation && contact_id.nil?
    fail ArgumentError, "Missing the required parameter 'contact_id' when calling ContactsApi.update_contact"
  end
  # verify the required parameter 'update_contact_request' is set
  if @api_client.config.client_side_validation && update_contact_request.nil?
    fail ArgumentError, "Missing the required parameter 'update_contact_request' when calling ContactsApi.update_contact"
  end
  # resource path
  local_var_path = '/contacts/{contact_id}'.sub('{' + 'contact_id' + '}', CGI.escape(contact_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_contact_request)

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

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

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