Class: HubSpotSDK::Resources::Crm::Objects::Subscriptions

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

Defined Under Namespace

Classes: Batch

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Subscriptions

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

Parameters:



203
204
205
206
# File 'lib/hubspot_sdk/resources/crm/objects/subscriptions.rb', line 203

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

Instance Attribute Details

#batchHubSpotSDK::Resources::Crm::Objects::Subscriptions::Batch (readonly)



9
10
11
# File 'lib/hubspot_sdk/resources/crm/objects/subscriptions.rb', line 9

def batch
  @batch
end

Instance Method Details

#create(associations:, properties:, request_options: {}) ⇒ HubSpotSDK::Models::Crm::SimplePublicObject

Create a new subscription object with specified properties and optional associations.

Parameters:

Returns:

See Also:



25
26
27
28
29
30
31
32
33
34
# File 'lib/hubspot_sdk/resources/crm/objects/subscriptions.rb', line 25

def create(params)
  parsed, options = HubSpotSDK::Crm::Objects::SubscriptionCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "crm/objects/2026-03/subscriptions",
    body: parsed,
    model: HubSpotSDK::Crm::SimplePublicObject,
    options: options
  )
end

#delete(subscription_id, request_options: {}) ⇒ nil

Delete a specific subscription by its ID.

Parameters:

Returns:

  • (nil)

See Also:



116
117
118
119
120
121
122
123
# File 'lib/hubspot_sdk/resources/crm/objects/subscriptions.rb', line 116

def delete(subscription_id, params = {})
  @client.request(
    method: :delete,
    path: ["crm/objects/2026-03/subscriptions/%1$s", subscription_id],
    model: NilClass,
    options: params[:request_options]
  )
end

#get(subscription_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::SubscriptionGetParams for more details.

Retrieve a specific subscription by its ID, including its properties and associations.

Parameters:

  • subscription_id (String)
  • archived (Boolean)

    Whether to return only results that have been archived.

  • associations (Array<String>)

    A comma separated list of object types to retrieve associated IDs for. If any of

  • id_property (String)

    The name of a property whose values are unique for this object type

  • properties (Array<String>)

    A comma separated list of the properties to be returned in the response. If any

  • properties_with_history (Array<String>)

    A comma separated list of the properties to be returned along with their history

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

Returns:

See Also:



150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/hubspot_sdk/resources/crm/objects/subscriptions.rb', line 150

def get(subscription_id, params = {})
  parsed, options = HubSpotSDK::Crm::Objects::SubscriptionGetParams.dump_request(params)
  query = HubSpotSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["crm/objects/2026-03/subscriptions/%1$s", subscription_id],
    query: query.transform_keys(
      id_property: "idProperty",
      properties_with_history: "propertiesWithHistory"
    ),
    model: HubSpotSDK::Crm::SimplePublicObjectWithAssociations,
    options: 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::SubscriptionListParams for more details.

Retrieve a list of subscription objects, with options to filter by properties, associations, and archived status.

Parameters:

  • after (String)

    The paging cursor token of the last successfully read resource will be returned

  • archived (Boolean)

    Whether to return only results that have been archived.

  • associations (Array<String>)

    A comma separated list of object types to retrieve associated IDs for. If any of

  • limit (Integer)

    The maximum number of results to display per page.

  • properties (Array<String>)

    A comma separated list of the properties to be returned in the response. If any

  • properties_with_history (Array<String>)

    A comma separated list of the properties to be returned along with their history

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

Returns:

See Also:



93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/hubspot_sdk/resources/crm/objects/subscriptions.rb', line 93

def list(params = {})
  parsed, options = HubSpotSDK::Crm::Objects::SubscriptionListParams.dump_request(params)
  query = HubSpotSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "crm/objects/2026-03/subscriptions",
    query: query.transform_keys(properties_with_history: "propertiesWithHistory"),
    page: HubSpotSDK::Internal::Page,
    model: HubSpotSDK::Crm::SimplePublicObjectWithAssociations,
    options: options
  )
end

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

Execute a search for CRM commerce subscriptions based on defined filters, properties, and sorting options. This endpoint allows for complex queries to retrieve specific subscription data, supporting pagination and a variety of search parameters.

Parameters:

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



189
190
191
192
193
194
195
196
197
198
# File 'lib/hubspot_sdk/resources/crm/objects/subscriptions.rb', line 189

def search(params)
  parsed, options = HubSpotSDK::Crm::Objects::SubscriptionSearchParams.dump_request(params)
  @client.request(
    method: :post,
    path: "crm/objects/2026-03/subscriptions/search",
    body: parsed,
    model: HubSpotSDK::Crm::CollectionResponseWithTotalSimplePublicObject,
    options: options
  )
end

#update(subscription_id, properties:, id_property: nil, request_options: {}) ⇒ HubSpotSDK::Models::Crm::SimplePublicObject

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

Update a specific subscription by its ID with new property values.

Parameters:

  • subscription_id (String)

    Path param

  • properties (Hash{Symbol=>String})

    Body param: Key value pairs representing the properties of the object.

  • id_property (String)

    Query param: The name of a property whose values are unique for this object type

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

Returns:

See Also:



54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/hubspot_sdk/resources/crm/objects/subscriptions.rb', line 54

def update(subscription_id, params)
  query_params = [:id_property]
  parsed, options = HubSpotSDK::Crm::Objects::SubscriptionUpdateParams.dump_request(params)
  query = HubSpotSDK::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :patch,
    path: ["crm/objects/2026-03/subscriptions/%1$s", subscription_id],
    query: query.transform_keys(id_property: "idProperty"),
    body: parsed.except(*query_params),
    model: HubSpotSDK::Crm::SimplePublicObject,
    options: options
  )
end