Class: HubSpotSDK::Resources::Crm::Objects::Contacts
- Inherits:
-
Object
- Object
- HubSpotSDK::Resources::Crm::Objects::Contacts
- Defined in:
- lib/hubspot_sdk/resources/crm/objects/contacts.rb,
lib/hubspot_sdk/resources/crm/objects/contacts/batch.rb
Defined Under Namespace
Classes: Batch
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#create(associations:, properties:, request_options: {}) ⇒ HubSpotSDK::Models::Crm::SimplePublicObject
Create a contact.
-
#delete(contact_id, request_options: {}) ⇒ nil
Delete a contact by ID.
-
#gdpr_delete(object_id_:, id_property: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::Crm::Objects::ContactGdprDeleteParams for more details.
-
#get(contact_id, archived: nil, associations: nil, id_property: nil, properties: nil, properties_with_history: nil, request_options: {}) ⇒ HubSpotSDK::Models::Crm::SimplePublicObjectWithAssociations
Some parameter documentations has been truncated, see Models::Crm::Objects::ContactGetParams for more details.
-
#initialize(client:) ⇒ Contacts
constructor
private
A new instance of Contacts.
-
#list(after: nil, archived: nil, associations: nil, limit: nil, properties: nil, properties_with_history: nil, request_options: {}) ⇒ HubSpotSDK::Internal::Page<HubSpotSDK::Models::Crm::SimplePublicObjectWithAssociations>
Some parameter documentations has been truncated, see Models::Crm::Objects::ContactListParams for more details.
-
#merge(object_id_to_merge:, primary_object_id:, request_options: {}) ⇒ HubSpotSDK::Models::Crm::SimplePublicObject
Merge two contacts.
-
#search(after:, filter_groups:, limit:, properties:, sorts:, query: nil, request_options: {}) ⇒ HubSpotSDK::Models::Crm::CollectionResponseWithTotalSimplePublicObject
Search for contacts by filtering on properties, searching through associations, and sorting results.
-
#update(contact_id, properties:, id_property: nil, request_options: {}) ⇒ HubSpotSDK::Models::Crm::SimplePublicObject
Some parameter documentations has been truncated, see Models::Crm::Objects::ContactUpdateParams for more details.
Constructor Details
#initialize(client:) ⇒ Contacts
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Contacts.
254 255 256 257 |
# File 'lib/hubspot_sdk/resources/crm/objects/contacts.rb', line 254 def initialize(client:) @client = client @batch = HubSpotSDK::Resources::Crm::Objects::Contacts::Batch.new(client: client) end |
Instance Attribute Details
#batch ⇒ HubSpotSDK::Resources::Crm::Objects::Contacts::Batch (readonly)
9 10 11 |
# File 'lib/hubspot_sdk/resources/crm/objects/contacts.rb', line 9 def batch @batch end |
Instance Method Details
#create(associations:, properties:, request_options: {}) ⇒ HubSpotSDK::Models::Crm::SimplePublicObject
Create a contact
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/hubspot_sdk/resources/crm/objects/contacts.rb', line 24 def create(params) parsed, = HubSpotSDK::Crm::Objects::ContactCreateParams.dump_request(params) @client.request( method: :post, path: "crm/objects/2026-03/contacts", body: parsed, model: HubSpotSDK::Crm::SimplePublicObject, options: ) end |
#delete(contact_id, request_options: {}) ⇒ nil
Delete a contact by ID. Deleted contacts can be restored within 90 days of deletion. Learn more about the [data impacted by contact deletions](knowledge.hubspot.com/privacy-and-consent/understand-restorable-and-permanent-contact-deletions) and how to [restore archived records](knowledge.hubspot.com/records/restore-deleted-records).
122 123 124 125 126 127 128 129 |
# File 'lib/hubspot_sdk/resources/crm/objects/contacts.rb', line 122 def delete(contact_id, params = {}) @client.request( method: :delete, path: ["crm/objects/2026-03/contacts/%1$s", contact_id], model: NilClass, options: params[:request_options] ) end |
#gdpr_delete(object_id_:, id_property: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::Crm::Objects::ContactGdprDeleteParams for more details.
145 146 147 148 149 150 151 152 153 154 |
# File 'lib/hubspot_sdk/resources/crm/objects/contacts.rb', line 145 def gdpr_delete(params) parsed, = HubSpotSDK::Crm::Objects::ContactGdprDeleteParams.dump_request(params) @client.request( method: :post, path: "crm/objects/2026-03/contacts/gdpr-delete", body: parsed, model: NilClass, options: ) end |
#get(contact_id, archived: nil, associations: nil, id_property: nil, properties: nil, properties_with_history: nil, request_options: {}) ⇒ HubSpotSDK::Models::Crm::SimplePublicObjectWithAssociations
Some parameter documentations has been truncated, see Models::Crm::Objects::ContactGetParams for more details.
178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/hubspot_sdk/resources/crm/objects/contacts.rb', line 178 def get(contact_id, params = {}) parsed, = HubSpotSDK::Crm::Objects::ContactGetParams.dump_request(params) query = HubSpotSDK::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: ["crm/objects/2026-03/contacts/%1$s", contact_id], query: query.transform_keys( id_property: "idProperty", properties_with_history: "propertiesWithHistory" ), model: HubSpotSDK::Crm::SimplePublicObjectWithAssociations, options: ) end |
#list(after: nil, archived: nil, associations: nil, limit: nil, properties: nil, properties_with_history: nil, request_options: {}) ⇒ HubSpotSDK::Internal::Page<HubSpotSDK::Models::Crm::SimplePublicObjectWithAssociations>
Some parameter documentations has been truncated, see Models::Crm::Objects::ContactListParams for more details.
95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/hubspot_sdk/resources/crm/objects/contacts.rb', line 95 def list(params = {}) parsed, = HubSpotSDK::Crm::Objects::ContactListParams.dump_request(params) query = HubSpotSDK::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "crm/objects/2026-03/contacts", query: query.transform_keys(properties_with_history: "propertiesWithHistory"), page: HubSpotSDK::Internal::Page, model: HubSpotSDK::Crm::SimplePublicObjectWithAssociations, options: ) end |
#merge(object_id_to_merge:, primary_object_id:, request_options: {}) ⇒ HubSpotSDK::Models::Crm::SimplePublicObject
Merge two contacts
206 207 208 209 210 211 212 213 214 215 |
# File 'lib/hubspot_sdk/resources/crm/objects/contacts.rb', line 206 def merge(params) parsed, = HubSpotSDK::Crm::Objects::ContactMergeParams.dump_request(params) @client.request( method: :post, path: "crm/objects/2026-03/contacts/merge", body: parsed, model: HubSpotSDK::Crm::SimplePublicObject, options: ) end |
#search(after:, filter_groups:, limit:, properties:, sorts:, query: nil, request_options: {}) ⇒ HubSpotSDK::Models::Crm::CollectionResponseWithTotalSimplePublicObject
Search for contacts by filtering on properties, searching through associations, and sorting results. Learn more about [CRM search](developers.hubspot.com/docs/guides/api/crm/search#make-a-search-request).
240 241 242 243 244 245 246 247 248 249 |
# File 'lib/hubspot_sdk/resources/crm/objects/contacts.rb', line 240 def search(params) parsed, = HubSpotSDK::Crm::Objects::ContactSearchParams.dump_request(params) @client.request( method: :post, path: "crm/objects/2026-03/contacts/search", body: parsed, model: HubSpotSDK::Crm::CollectionResponseWithTotalSimplePublicObject, options: ) end |
#update(contact_id, properties:, id_property: nil, request_options: {}) ⇒ HubSpotSDK::Models::Crm::SimplePublicObject
Some parameter documentations has been truncated, see Models::Crm::Objects::ContactUpdateParams for more details.
Update an existing contact, identified by ID or email/unique property value. To identify a contact by ID, include the ID in the request URL path. To identify a contact by their email or other unique property, include the email/property value in the request URL path, and add the ‘idProperty` query parameter (`/crm/v3/objects/contacts/jon@website.com?idProperty=email`). Provided property values will be overwritten. Read-only and non-existent properties will result in an error. Properties values can be cleared by passing an empty string.
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/hubspot_sdk/resources/crm/objects/contacts.rb', line 59 def update(contact_id, params) query_params = [:id_property] parsed, = HubSpotSDK::Crm::Objects::ContactUpdateParams.dump_request(params) query = HubSpotSDK::Internal::Util.encode_query_params(parsed.slice(*query_params)) @client.request( method: :patch, path: ["crm/objects/2026-03/contacts/%1$s", contact_id], query: query.transform_keys(id_property: "idProperty"), body: parsed.except(*query_params), model: HubSpotSDK::Crm::SimplePublicObject, options: ) end |