Class: HubSpotSDK::Resources::Crm::Objects::Companies
- Inherits:
-
Object
- Object
- HubSpotSDK::Resources::Crm::Objects::Companies
- Defined in:
- lib/hubspot_sdk/resources/crm/objects/companies.rb,
lib/hubspot_sdk/resources/crm/objects/companies/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 single company.
-
#delete(company_id, request_options: {}) ⇒ nil
Delete a company by ID.
-
#get(company_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::CompanyGetParams for more details.
-
#initialize(client:) ⇒ Companies
constructor
private
A new instance of Companies.
-
#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::CompanyListParams for more details.
-
#merge(object_id_to_merge:, primary_object_id:, request_options: {}) ⇒ HubSpotSDK::Models::Crm::SimplePublicObject
Merge two company records.
-
#search(after:, filter_groups:, limit:, properties:, sorts:, query: nil, request_options: {}) ⇒ HubSpotSDK::Models::Crm::CollectionResponseWithTotalSimplePublicObject
Search for companies by filtering on properties, searching through associations, and sorting results.
-
#update(company_id, properties:, id_property: nil, request_options: {}) ⇒ HubSpotSDK::Models::Crm::SimplePublicObject
Some parameter documentations has been truncated, see Models::Crm::Objects::CompanyUpdateParams for more details.
Constructor Details
#initialize(client:) ⇒ Companies
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 Companies.
236 237 238 239 |
# File 'lib/hubspot_sdk/resources/crm/objects/companies.rb', line 236 def initialize(client:) @client = client @batch = HubSpotSDK::Resources::Crm::Objects::Companies::Batch.new(client: client) end |
Instance Attribute Details
#batch ⇒ HubSpotSDK::Resources::Crm::Objects::Companies::Batch (readonly)
9 10 11 |
# File 'lib/hubspot_sdk/resources/crm/objects/companies.rb', line 9 def batch @batch end |
Instance Method Details
#create(associations:, properties:, request_options: {}) ⇒ HubSpotSDK::Models::Crm::SimplePublicObject
Create a single company. Include a ‘properties` object to define [property values](developers.hubspot.com/docs/guides/api/crm/properties) for the company, along with an `associations` array to define [associations](developers.hubspot.com/docs/guides/api/crm/associations/associations-v4) with other CRM records.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/hubspot_sdk/resources/crm/objects/companies.rb', line 28 def create(params) parsed, = HubSpotSDK::Crm::Objects::CompanyCreateParams.dump_request(params) @client.request( method: :post, path: "crm/objects/2026-03/companies", body: parsed, model: HubSpotSDK::Crm::SimplePublicObject, options: ) end |
#delete(company_id, request_options: {}) ⇒ nil
Delete a company by ID. Deleted companies can be restored within 90 days of deletion. Learn more about [restoring records](knowledge.hubspot.com/records/restore-deleted-records).
124 125 126 127 128 129 130 131 |
# File 'lib/hubspot_sdk/resources/crm/objects/companies.rb', line 124 def delete(company_id, params = {}) @client.request( method: :delete, path: ["crm/objects/2026-03/companies/%1$s", company_id], model: NilClass, options: params[:request_options] ) end |
#get(company_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::CompanyGetParams for more details.
Retrieve a company by its ID (‘companyId`) or by a unique property (`idProperty`). You can specify what is returned using the `properties` query parameter.
159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/hubspot_sdk/resources/crm/objects/companies.rb', line 159 def get(company_id, params = {}) parsed, = HubSpotSDK::Crm::Objects::CompanyGetParams.dump_request(params) query = HubSpotSDK::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: ["crm/objects/2026-03/companies/%1$s", company_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::CompanyListParams for more details.
Retrieve all companies, using query parameters to control the information that gets returned.
99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/hubspot_sdk/resources/crm/objects/companies.rb', line 99 def list(params = {}) parsed, = HubSpotSDK::Crm::Objects::CompanyListParams.dump_request(params) query = HubSpotSDK::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "crm/objects/2026-03/companies", 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 company records. Learn more about [merging records](knowledge.hubspot.com/records/merge-records).
188 189 190 191 192 193 194 195 196 197 |
# File 'lib/hubspot_sdk/resources/crm/objects/companies.rb', line 188 def merge(params) parsed, = HubSpotSDK::Crm::Objects::CompanyMergeParams.dump_request(params) @client.request( method: :post, path: "crm/objects/2026-03/companies/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 companies 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).
222 223 224 225 226 227 228 229 230 231 |
# File 'lib/hubspot_sdk/resources/crm/objects/companies.rb', line 222 def search(params) parsed, = HubSpotSDK::Crm::Objects::CompanySearchParams.dump_request(params) @client.request( method: :post, path: "crm/objects/2026-03/companies/search", body: parsed, model: HubSpotSDK::Crm::CollectionResponseWithTotalSimplePublicObject, options: ) end |
#update(company_id, properties:, id_property: nil, request_options: {}) ⇒ HubSpotSDK::Models::Crm::SimplePublicObject
Some parameter documentations has been truncated, see Models::Crm::Objects::CompanyUpdateParams for more details.
Update a company by ID (‘companyId`) or unique property value (`idProperty`). 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.
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/hubspot_sdk/resources/crm/objects/companies.rb', line 60 def update(company_id, params) query_params = [:id_property] parsed, = HubSpotSDK::Crm::Objects::CompanyUpdateParams.dump_request(params) query = HubSpotSDK::Internal::Util.encode_query_params(parsed.slice(*query_params)) @client.request( method: :patch, path: ["crm/objects/2026-03/companies/%1$s", company_id], query: query.transform_keys(id_property: "idProperty"), body: parsed.except(*query_params), model: HubSpotSDK::Crm::SimplePublicObject, options: ) end |