class Hubspot::Crm::Contacts::AssociationsApi

Attributes

api_client[RW]

Public Class Methods

new(api_client = ApiClient.default) click to toggle source
# File lib/hubspot/codegen/crm/contacts/api/associations_api.rb, line 21
def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Public Instance Methods

archive_association(contact_id, to_object_type, to_object_id, association_type, opts = {}) click to toggle source

Remove an association between two contacts @param contact_id [String] @param to_object_type [String] @param to_object_id [String] @param association_type [String] @param [Hash] opts the optional parameters @return [nil]

# File lib/hubspot/codegen/crm/contacts/api/associations_api.rb, line 31
def archive_association(contact_id, to_object_type, to_object_id, association_type, opts = {})
  archive_association_with_http_info(contact_id, to_object_type, to_object_id, association_type, opts)
  nil
end
archive_association_with_http_info(contact_id, to_object_type, to_object_id, association_type, opts = {}) click to toggle source

Remove an association between two contacts @param contact_id [String] @param to_object_type [String] @param to_object_id [String] @param association_type [String] @param [Hash] opts the optional parameters @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers

# File lib/hubspot/codegen/crm/contacts/api/associations_api.rb, line 43
def archive_association_with_http_info(contact_id, to_object_type, to_object_id, association_type, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AssociationsApi.archive_association ...'
  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 AssociationsApi.archive_association"
  end
  # verify the required parameter 'to_object_type' is set
  if @api_client.config.client_side_validation && to_object_type.nil?
    fail ArgumentError, "Missing the required parameter 'to_object_type' when calling AssociationsApi.archive_association"
  end
  # verify the required parameter 'to_object_id' is set
  if @api_client.config.client_side_validation && to_object_id.nil?
    fail ArgumentError, "Missing the required parameter 'to_object_id' when calling AssociationsApi.archive_association"
  end
  # verify the required parameter 'association_type' is set
  if @api_client.config.client_side_validation && association_type.nil?
    fail ArgumentError, "Missing the required parameter 'association_type' when calling AssociationsApi.archive_association"
  end
  # resource path
  local_var_path = '/crm/v3/objects/contacts/{contactId}/associations/{toObjectType}/{toObjectId}/{associationType}'.sub('{' + 'contactId' + '}', CGI.escape(contact_id.to_s)).sub('{' + 'toObjectType' + '}', CGI.escape(to_object_type.to_s)).sub('{' + 'toObjectId' + '}', CGI.escape(to_object_id.to_s)).sub('{' + 'associationType' + '}', CGI.escape(association_type.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(['*/*'])

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

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

  # return_type
  return_type = opts[:return_type] 

  # auth_names
  auth_names = opts[:auth_names] || ['hapikey', 'oauth2']

  new_options = opts.merge(
    :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: AssociationsApi#archive_association\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
create_association(contact_id, to_object_type, to_object_id, association_type, opts = {}) click to toggle source

Associate two contacts @param contact_id [String] @param to_object_type [String] @param to_object_id [String] @param association_type [String] @param [Hash] opts the optional parameters @return [SimplePublicObject]

# File lib/hubspot/codegen/crm/contacts/api/associations_api.rb, line 109
def create_association(contact_id, to_object_type, to_object_id, association_type, opts = {})
  data, _status_code, _headers = create_association_with_http_info(contact_id, to_object_type, to_object_id, association_type, opts)
  data
end
create_association_with_http_info(contact_id, to_object_type, to_object_id, association_type, opts = {}) click to toggle source

Associate two contacts @param contact_id [String] @param to_object_type [String] @param to_object_id [String] @param association_type [String] @param [Hash] opts the optional parameters @return [Array<(SimplePublicObject, Integer, Hash)>] SimplePublicObject data, response status code and response headers

# File lib/hubspot/codegen/crm/contacts/api/associations_api.rb, line 121
def create_association_with_http_info(contact_id, to_object_type, to_object_id, association_type, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AssociationsApi.create_association ...'
  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 AssociationsApi.create_association"
  end
  # verify the required parameter 'to_object_type' is set
  if @api_client.config.client_side_validation && to_object_type.nil?
    fail ArgumentError, "Missing the required parameter 'to_object_type' when calling AssociationsApi.create_association"
  end
  # verify the required parameter 'to_object_id' is set
  if @api_client.config.client_side_validation && to_object_id.nil?
    fail ArgumentError, "Missing the required parameter 'to_object_id' when calling AssociationsApi.create_association"
  end
  # verify the required parameter 'association_type' is set
  if @api_client.config.client_side_validation && association_type.nil?
    fail ArgumentError, "Missing the required parameter 'association_type' when calling AssociationsApi.create_association"
  end
  # resource path
  local_var_path = '/crm/v3/objects/contacts/{contactId}/associations/{toObjectType}/{toObjectId}/{associationType}'.sub('{' + 'contactId' + '}', CGI.escape(contact_id.to_s)).sub('{' + 'toObjectType' + '}', CGI.escape(to_object_type.to_s)).sub('{' + 'toObjectId' + '}', CGI.escape(to_object_id.to_s)).sub('{' + 'associationType' + '}', CGI.escape(association_type.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[:body] 

  # return_type
  return_type = opts[:return_type] || 'SimplePublicObject' 

  # auth_names
  auth_names = opts[:auth_names] || ['hapikey', 'oauth2']

  new_options = opts.merge(
    :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: AssociationsApi#create_association\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
get_associations(contact_id, to_object_type, opts = {}) click to toggle source

List associations of a contact by type @param contact_id [String] @param to_object_type [String] @param [Hash] opts the optional parameters @return [CollectionResponseAssociatedId]

# File lib/hubspot/codegen/crm/contacts/api/associations_api.rb, line 185
def get_associations(contact_id, to_object_type, opts = {})
  data, _status_code, _headers = get_associations_with_http_info(contact_id, to_object_type, opts)
  data
end
get_associations_with_http_info(contact_id, to_object_type, opts = {}) click to toggle source

List associations of a contact by type @param contact_id [String] @param to_object_type [String] @param [Hash] opts the optional parameters @return [Array<(CollectionResponseAssociatedId, Integer, Hash)>] CollectionResponseAssociatedId data, response status code and response headers

# File lib/hubspot/codegen/crm/contacts/api/associations_api.rb, line 195
def get_associations_with_http_info(contact_id, to_object_type, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AssociationsApi.get_associations ...'
  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 AssociationsApi.get_associations"
  end
  # verify the required parameter 'to_object_type' is set
  if @api_client.config.client_side_validation && to_object_type.nil?
    fail ArgumentError, "Missing the required parameter 'to_object_type' when calling AssociationsApi.get_associations"
  end
  # resource path
  local_var_path = '/crm/v3/objects/contacts/{contactId}/associations/{toObjectType}'.sub('{' + 'contactId' + '}', CGI.escape(contact_id.to_s)).sub('{' + 'toObjectType' + '}', CGI.escape(to_object_type.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[:body] 

  # return_type
  return_type = opts[:return_type] || 'CollectionResponseAssociatedId' 

  # auth_names
  auth_names = opts[:auth_names] || ['hapikey', 'oauth2']

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