Class: HubSpotSDK::Resources::Crm::Associations

Inherits:
Object
  • Object
show all
Defined in:
lib/hubspot_sdk/resources/crm/associations.rb,
lib/hubspot_sdk/resources/crm/associations/batch.rb

Defined Under Namespace

Classes: Batch

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Associations

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

Parameters:



244
245
246
247
# File 'lib/hubspot_sdk/resources/crm/associations.rb', line 244

def initialize(client:)
  @client = client
  @batch = HubSpotSDK::Resources::Crm::Associations::Batch.new(client: client)
end

Instance Attribute Details

#batchHubSpotSDK::Resources::Crm::Associations::Batch (readonly)



8
9
10
# File 'lib/hubspot_sdk/resources/crm/associations.rb', line 8

def batch
  @batch
end

Instance Method Details

#create(to_object_id, from_object_type:, from_object_id:, to_object_type:, request_options: {}) ⇒ HubSpotSDK::Models::Crm::BatchResponsePublicDefaultAssociation

Create the default (most generic) association type between two object types

Parameters:

  • to_object_id (String)
  • from_object_type (String)
  • from_object_id (String)
  • to_object_type (String)
  • request_options (HubSpotSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/hubspot_sdk/resources/crm/associations.rb', line 23

def create(to_object_id, params)
  parsed, options = HubSpotSDK::Crm::AssociationCreateParams.dump_request(params)
  from_object_type =
    parsed.delete(:from_object_type) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  from_object_id =
    parsed.delete(:from_object_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  to_object_type =
    parsed.delete(:to_object_type) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :put,
    path: [
      "crm/objects/2026-03/%1$s/%2$s/associations/default/%3$s/%4$s",
      from_object_type,
      from_object_id,
      to_object_type,
      to_object_id
    ],
    model: HubSpotSDK::Crm::BatchResponsePublicDefaultAssociation,
    options: options
  )
end

#delete(to_object_id, object_type:, object_id_:, to_object_type:, request_options: {}) ⇒ nil

deletes all associations between two records.

Parameters:

  • to_object_id (String)
  • object_type (String)
  • object_id_ (String)
  • to_object_type (String)
  • request_options (HubSpotSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (nil)

See Also:



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
# File 'lib/hubspot_sdk/resources/crm/associations.rb', line 113

def delete(to_object_id, params)
  parsed, options = HubSpotSDK::Crm::AssociationDeleteParams.dump_request(params)
  object_type =
    parsed.delete(:object_type) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  object_id_ =
    parsed.delete(:object_id_) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  to_object_type =
    parsed.delete(:to_object_type) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: [
      "crm/objects/2026-03/%1$s/%2$s/associations/%3$s/%4$s",
      object_type,
      object_id_,
      to_object_type,
      to_object_id
    ],
    model: NilClass,
    options: options
  )
end

#list(to_object_type, object_type:, object_id_:, after: nil, limit: nil, request_options: {}) ⇒ HubSpotSDK::Internal::Page<HubSpotSDK::Models::Crm::MultiAssociatedObjectWithLabel>

Some parameter documentations has been truncated, see Models::Crm::AssociationListParams for more details.

Retrieve all associations between a specific record and an object type. Limit 500 per call.

Parameters:

  • to_object_type (String)

    Path param

  • object_type (String)

    Path param

  • object_id_ (String)

    Path param

  • after (String)

    Query param: The paging cursor token of the last successfully read resource will

  • limit (Integer)

    Query param: The maximum number of results to display per page.

  • request_options (HubSpotSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/hubspot_sdk/resources/crm/associations.rb', line 74

def list(to_object_type, params)
  parsed, options = HubSpotSDK::Crm::AssociationListParams.dump_request(params)
  query = HubSpotSDK::Internal::Util.encode_query_params(parsed)
  object_type =
    parsed.delete(:object_type) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  object_id_ =
    parsed.delete(:object_id_) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: [
      "crm/objects/2026-03/%1$s/%2$s/associations/%3$s",
      object_type,
      object_id_,
      to_object_type
    ],
    query: query,
    page: HubSpotSDK::Internal::Page,
    model: HubSpotSDK::Crm::MultiAssociatedObjectWithLabel,
    options: options
  )
end

#request_high_usage_report(user_id, request_options: {}) ⇒ HubSpotSDK::Models::Crm::ReportCreationResponse

Requests a report of all objects in the portal which have a high usage of associations

Parameters:

Returns:

See Also:



152
153
154
155
156
157
158
159
# File 'lib/hubspot_sdk/resources/crm/associations.rb', line 152

def request_high_usage_report(user_id, params = {})
  @client.request(
    method: :post,
    path: ["crm/associations/2026-03/usage/high-usage-report/%1$s", user_id],
    model: HubSpotSDK::Crm::ReportCreationResponse,
    options: params[:request_options]
  )
end

#search(object_type, after:, filter_groups:, limit:, properties:, sorts:, query: nil, request_options: {}) ⇒ HubSpotSDK::Models::Crm::CollectionResponseWithTotalSimplePublicObject

Parameters:

  • object_type (String)
  • after (String)

    A paging cursor token for retrieving subsequent pages.

  • filter_groups (Array<HubSpotSDK::Models::Crm::FilterGroup>)

    Up to 6 groups of filters defining additional query criteria.

  • limit (Integer)

    The maximum results to return, up to 200 objects.

  • properties (Array<String>)

    A list of property names to include in the response.

  • sorts (Array<String>)

    Specifies sorting order based on object properties.

  • query (String)

    The search query string, up to 3000 characters.

  • request_options (HubSpotSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



182
183
184
185
186
187
188
189
190
191
# File 'lib/hubspot_sdk/resources/crm/associations.rb', line 182

def search(object_type, params)
  parsed, options = HubSpotSDK::Crm::AssociationSearchParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["crm/objects/2026-03/%1$s/search", object_type],
    body: parsed,
    model: HubSpotSDK::Crm::CollectionResponseWithTotalSimplePublicObject,
    options: options
  )
end

#update_labels(to_object_id, object_type:, object_id_:, to_object_type:, body:, request_options: {}) ⇒ HubSpotSDK::Models::Crm::LabelsBetweenObjectPair

Set association labels between two records.

Parameters:

Returns:

See Also:



212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/hubspot_sdk/resources/crm/associations.rb', line 212

def update_labels(to_object_id, params)
  parsed, options = HubSpotSDK::Crm::AssociationUpdateLabelsParams.dump_request(params)
  object_type =
    parsed.delete(:object_type) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  object_id_ =
    parsed.delete(:object_id_) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  to_object_type =
    parsed.delete(:to_object_type) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :put,
    path: [
      "crm/objects/2026-03/%1$s/%2$s/associations/%3$s/%4$s",
      object_type,
      object_id_,
      to_object_type,
      to_object_id
    ],
    body: parsed[:body],
    model: HubSpotSDK::Crm::LabelsBetweenObjectPair,
    options: options
  )
end