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 when creating a new contact: `first_name`, `last_name`, or `email_address` (`email_address` must be unique for each contact).

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 &#x60;create_source&#x60; property and at least one of the following properties when creating a new contact: &#x60;first_name&#x60;, &#x60;last_name&#x60;, or &#x60;email_address&#x60; (&#x60;email_address&#x60; must be unique for each contact).

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. This method uses the ‘email_address` string value you include in the request body to determine if it should create an new contact or update an existing contact. 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. <div class="Msg"><p class="note-text">Only use this method when a contact gives you their explicit permission to send them emails. It is a violation of US and Canadian anti-spam 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](knowledgebase.constantcontact.com/articles/KnowledgeBase/5533-obtain-permission-to-send-email-campaigns-to-your-contacts-by-using-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:

  • create_or_update_contact_request (CreateOrUpdateContactRequest)

    A JSON request body payload that contains the contact resource you are creating or updating. The request body must contain the &#x60;email_address&#x60; property and the &#x60;list_memberships&#x60; array.

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

    the optional 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. This method uses the &#x60;email_address&#x60; string value you include in the request body to determine if it should create an new contact or update an existing contact. 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 &#x60;list_memberships&#x60; or &#x60;custom_fields&#x60; arrays. &lt;div class&#x3D;&quot;Msg&quot;&gt;&lt;p class&#x3D;&quot;note-text&quot;&gt;Only use this method when a contact gives you their explicit permission to send them emails. It is a violation of US and Canadian anti-spam 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.&lt;/p&gt;&lt;/div&gt; 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&#39;s &#x60;permission_to_send&#x60; and &#x60;opt_in_source&#x60; properties depending on the [Confirmed Opt-In](knowledgebase.constantcontact.com/articles/KnowledgeBase/5533-obtain-permission-to-send-email-campaigns-to-your-contacts-by-using-confirmed-opt-in) Constant Contact account setting: If Confirmed Opt-in is enabled, this method automatically sets the &#x60;permission_to_send&#x60; property as pending_confirmation for new contacts. If Confirmed Opt-in is disabled, this method automatically sets the &#x60;permission_to_send&#x60; property as explicit and the &#x60;opt_in_source&#x60; property as &#x60;Contact&#x60; for new contacts. Updated contacts have their &#x60;permission_to_send&#x60; property set as explicit.

Parameters:

  • create_or_update_contact_request (CreateOrUpdateContactRequest)

    A JSON request body payload that contains the contact resource you are creating or updating. The request body must contain the &#x60;email_address&#x60; property and the &#x60;list_memberships&#x60; array.

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

    the optional 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](/api_guide/contacts_delete.html#revive).

Parameters:

  • contact_id (String)

    Unique ID of contact to DELETE

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

    the optional parameters

Returns:

  • (nil)


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&#39;t receive email from you, and they don&#39;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](/api_guide/contacts_delete.html#revive).

Parameters:

  • contact_id (String)

    Unique ID of contact to DELETE

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

    the optional parameters

Returns:

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

    nil, response status code and response headers



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 subresourse 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:

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

    the optional parameters

Options Hash (opts):

  • :status (String)

    Use the &#x60;status&#x60; query parameter to search for contacts by status. This parameter accepts one or more comma separated values: &#x60;all&#x60;, &#x60;active&#x60;, &#x60;deleted&#x60;, &#x60;not_set&#x60;, &#x60;pending_confirmation&#x60;, &#x60;temp_hold&#x60;, and &#x60;unsubscribed&#x60;.

  • :email (String)

    Use the &#x60;email&#x60; query parameter to search for a contact using a specific email address.

  • :lists (String)

    Use the &#x60;lists&#x60; query parameter to search for contacts that are members of one or more specified lists. Use a comma to separate multiple &#x60;list_id&#x60; values, up to a maximum of 25.

  • :segment_id (String)

    Use to get contacts that meet the segment criteria for a single specified &#x60;segment_id&#x60;. This query parameter can only be combined with the limit query parameter. When using the &#x60;segment_id&#x60; query parameter, the V3 API may return a 202 response code instead of a 200 response. The 202 response code indicates that your request has been accepted, but not fully completed. Retry sending your API request to return the completed results and a 200 response code.

  • :tags (String)

    Use to get contact details for up to 50 specified tags. Use a comma to separate each &#x60;tag_id&#x60;.

  • :updated_after (Time)

    Use &#x60;updated_after&#x60; to search for contacts that have been updated after the date you specify. To search for updated contacts within a date range, specify both &#x60;updated_after&#x60; and &#x60;updated_before&#x60; dates. Accepts ISO-8601 formatted dates.

  • :updated_before (Time)

    Use &#x60;updated_before&#x60; to search for contacts that have been updated before a specified date. To search for updated contacts within a date range, specify both &#x60;updated_after&#x60; and &#x60;updated_before&#x60; dates. Accepts ISO-8601 formatted dates.

  • :created_after (Time)

    Use &#x60;created_after&#x60; to search for contacts created after a specified date. To search for contacts created within a date range, specify both &#x60;created_after&#x60; and &#x60;created_before&#x60; dates. Accepts ISO-8601 formatted dates.

  • :created_before (Time)

    Use &#x60;created_before&#x60; to search for contacts created before a specified date. To search for contacts created within a date range, specify both &#x60;created_after&#x60; and &#x60;created_before&#x60; dates. Accepts ISO-8601 formatted dates.

  • :optout_after (Time)

    Use &#x60;optout_after&#x60; to search for contacts that unsubscribed after a specified date.

  • :optout_before (Time)

    Use &#x60;optout_before&#x60; to search for contacts that unsubscribed before a specified date.

  • :include (String)

    Use &#x60;include&#x60; to specify which contact sub-resources to include in the response. Use a comma to separate multiple sub-resources. Valid values: &#x60;custom_fields&#x60;, &#x60;list_memberships&#x60;, &#x60;taggings&#x60;, &#x60;notes&#x60;,&#x60;phone_numbers&#x60;, &#x60;street_addresses&#x60;, &#x60;sms_channel&#x60;.

  • :sms_status (String)

    Use to get contacts by their SMS status. This parameter accepts one or more comma separated values: &#x60;all&#x60;, &#x60;explicit&#x60;, &#x60;unsubscribed&#x60;, &#x60;pending_confirmation&#x60;, &#x60;not_set&#x60;.

  • :include_count (Boolean)

    Set &#x60;include_count&#x3D;true&#x60; to include the total number of contacts (&#x60;contacts_count&#x60;) that meet all search criteria in the response body.

  • :limit (Integer)

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

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 subresourse properties as criteria. For example, you can search using the contact&#39;s &#x60;email&#x60; address, &#x60;lists&#x60; memberships, and by the date range that a contact was created or updated. Use the &#x60;limit&#x60; query parameter to limit the number of results returned per page. Use the &#x60;include&#x60; query parameter to include contact sub-resources in the response and &#x60;include_count&#x60; 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 &#x60;status&#x60; query parameter with the value &#x60;all&#x60; to return all contacts including deleted contacts.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :status (String)

    Use the &#x60;status&#x60; query parameter to search for contacts by status. This parameter accepts one or more comma separated values: &#x60;all&#x60;, &#x60;active&#x60;, &#x60;deleted&#x60;, &#x60;not_set&#x60;, &#x60;pending_confirmation&#x60;, &#x60;temp_hold&#x60;, and &#x60;unsubscribed&#x60;.

  • :email (String)

    Use the &#x60;email&#x60; query parameter to search for a contact using a specific email address.

  • :lists (String)

    Use the &#x60;lists&#x60; query parameter to search for contacts that are members of one or more specified lists. Use a comma to separate multiple &#x60;list_id&#x60; values, up to a maximum of 25.

  • :segment_id (String)

    Use to get contacts that meet the segment criteria for a single specified &#x60;segment_id&#x60;. This query parameter can only be combined with the limit query parameter. When using the &#x60;segment_id&#x60; query parameter, the V3 API may return a 202 response code instead of a 200 response. The 202 response code indicates that your request has been accepted, but not fully completed. Retry sending your API request to return the completed results and a 200 response code.

  • :tags (String)

    Use to get contact details for up to 50 specified tags. Use a comma to separate each &#x60;tag_id&#x60;.

  • :updated_after (Time)

    Use &#x60;updated_after&#x60; to search for contacts that have been updated after the date you specify. To search for updated contacts within a date range, specify both &#x60;updated_after&#x60; and &#x60;updated_before&#x60; dates. Accepts ISO-8601 formatted dates.

  • :updated_before (Time)

    Use &#x60;updated_before&#x60; to search for contacts that have been updated before a specified date. To search for updated contacts within a date range, specify both &#x60;updated_after&#x60; and &#x60;updated_before&#x60; dates. Accepts ISO-8601 formatted dates.

  • :created_after (Time)

    Use &#x60;created_after&#x60; to search for contacts created after a specified date. To search for contacts created within a date range, specify both &#x60;created_after&#x60; and &#x60;created_before&#x60; dates. Accepts ISO-8601 formatted dates.

  • :created_before (Time)

    Use &#x60;created_before&#x60; to search for contacts created before a specified date. To search for contacts created within a date range, specify both &#x60;created_after&#x60; and &#x60;created_before&#x60; dates. Accepts ISO-8601 formatted dates.

  • :optout_after (Time)

    Use &#x60;optout_after&#x60; to search for contacts that unsubscribed after a specified date.

  • :optout_before (Time)

    Use &#x60;optout_before&#x60; to search for contacts that unsubscribed before a specified date.

  • :include (String)

    Use &#x60;include&#x60; to specify which contact sub-resources to include in the response. Use a comma to separate multiple sub-resources. Valid values: &#x60;custom_fields&#x60;, &#x60;list_memberships&#x60;, &#x60;taggings&#x60;, &#x60;notes&#x60;,&#x60;phone_numbers&#x60;, &#x60;street_addresses&#x60;, &#x60;sms_channel&#x60;.

  • :sms_status (String)

    Use to get contacts by their SMS status. This parameter accepts one or more comma separated values: &#x60;all&#x60;, &#x60;explicit&#x60;, &#x60;unsubscribed&#x60;, &#x60;pending_confirmation&#x60;, &#x60;not_set&#x60;.

  • :include_count (Boolean)

    Set &#x60;include_count&#x3D;true&#x60; to include the total number of contacts (&#x60;contacts_count&#x60;) that meet all search criteria in the response body.

  • :limit (Integer)

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

Returns:

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

    GetAllContacts200Response data, response status code and response headers



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", "sms_channel"]
  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:

  • contact_id (String)

    Unique ID of contact to GET

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

    the optional parameters

Options Hash (opts):

  • :include (String)

    Use &#x60;include&#x60; to specify which contact sub-resources to include in the response. Use a comma to separate multiple sub-resources. Valid values: &#x60;custom_fields&#x60;, &#x60;list_memberships&#x60;, &#x60;phone_numbers&#x60;, &#x60;street_addresses&#x60;, &#x60;notes&#x60;, &#x60;sms_channel&#x60;, and &#x60;taggings&#x60;.

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 &#x60;include&#x60; query parameter to add any of the available contact sub-resources to the response payload.

Parameters:

  • contact_id (String)

    Unique ID of contact to GET

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

    the optional parameters

Options Hash (opts):

  • :include (String)

    Use &#x60;include&#x60; to specify which contact sub-resources to include in the response. Use a comma to separate multiple sub-resources. Valid values: &#x60;custom_fields&#x60;, &#x60;list_memberships&#x60;, &#x60;phone_numbers&#x60;, &#x60;street_addresses&#x60;, &#x60;notes&#x60;, &#x60;sms_channel&#x60;, and &#x60;taggings&#x60;.

Returns:

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

    GetContactById200Response data, response status code and response headers



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:

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

    the optional parameters

Options Hash (opts):

  • :include (String)

    Use to return the total number of contacts that subscribed within the last 30 days in the results.

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 &#x60;new_subscribers&#x60; in the &#x60;include&#x60; query parameter. To optimize open rates, reduce spam reports, and help grow your business, you must value your contact&#39;s consent to receive or to not receive your emails.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :include (String)

    Use to return the total number of contacts that subscribed within the last 30 days in the results.

Returns:

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

    GetContactCounts200Response data, response status code and response headers



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 <div class="Msg Msg–warning"><p class="note-text">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](/api_guide/migration_overview.html) to learn more.

Parameters:

  • sequence_ids (String)

    Comma delimited list of V2 API contact &#x60;ids&#x60; to cross-reference with the V3 API &#x60;contact_id&#x60; value. Endpoint accepts a maximum of 500 ids at a time.

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

    the optional 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 &lt;div class&#x3D;&quot;Msg Msg–warning&quot;&gt;&lt;p class&#x3D;&quot;note-text&quot;&gt;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.&lt;/p&gt;&lt;/div&gt; This GET call retrieves a collection of cross-referenced contact sequence IDs (&#x60;id&#x60; used in the V2 API) and UUIDs (&#x60;contact_id&#x60; 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 &#x60;sequence_ids&#x60; query parameter to specify a set of comma delimited V2 contacts ids to cross-referenced with their V3 &#x60;contact_ids&#x60;. See [Migrating to V3](/api_guide/migration_overview.html) to learn more.

Parameters:

  • sequence_ids (String)

    Comma delimited list of V2 API contact &#x60;ids&#x60; to cross-reference with the V3 API &#x60;contact_id&#x60; value. Endpoint accepts a maximum of 500 ids at a time.

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

    the optional 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:

  • contact_id (String)

    The contact&#39;s unique ID.

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

    the optional 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:

  • contact_id (String)

    The contact&#39;s unique ID.

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

    the optional 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

#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.

Parameters:

  • contact_id (String)

    Unique ID of contact to update

  • update_contact_request (UpdateContactRequest)

    JSON payload defining the contact object, with updates. Any properties left blank or not included in the PUT payload are overwritten with null value - does not apply to contact subresources.

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

    the optional parameters

Returns:



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

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 &#x60;update_source&#x60; property in the PUT request payload. To restore a deleted contact you must specify the &#x60;update_source&#x60; as &#x60;Account&#x60;. 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.

Parameters:

  • contact_id (String)

    Unique ID of contact to update

  • update_contact_request (UpdateContactRequest)

    JSON payload defining the contact object, with updates. Any properties left blank or not included in the PUT payload are overwritten with null value - does not apply to contact subresources.

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

    the optional parameters

Returns:

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

    GetContactById200Response data, response status code and response headers



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
673
674
# File 'lib/constant_contact_client/api/contacts_api.rb', line 619

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