Class: HubSpotSDK::Resources::Marketing::Campaigns::Assets

Inherits:
Object
  • Object
show all
Defined in:
lib/hubspot_sdk/resources/marketing/campaigns/assets.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Assets

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

Parameters:



154
155
156
# File 'lib/hubspot_sdk/resources/marketing/campaigns/assets.rb', line 154

def initialize(client:)
  @client = client
end

Instance Method Details

#delete(asset_id, campaign_guid:, asset_type:, request_options: {}) ⇒ nil

Some parameter documentations has been truncated, see Models::Marketing::Campaigns::AssetDeleteParams for more details.

Disassociate a specified asset from a campaign. Using the API, you can remove associations for the following asset types: ads, blog posts, calls, case studies, CTAs, CTAs (legacy), external website pages, feedback surveys, forms, files, knowledge base articles, landing pages, marketing email, marketing events, meetings, playbooks, podcast episodes, sales documents, sales emails, sequences, SMS, social posts, static lists, videos, website pages, and workflows.

For other asset types, it is recommended to manage your associations directly in the campaign tool in HubSpot.

Parameters:

  • asset_id (String)

    The id of asset to disassociate, required

  • campaign_guid (String)

    The UUID of the campaign, required

  • asset_type (String)

    The type of asset to disassociate, required

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

Returns:

  • (nil)

See Also:



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/hubspot_sdk/resources/marketing/campaigns/assets.rb', line 128

def delete(asset_id, params)
  parsed, options = HubSpotSDK::Marketing::Campaigns::AssetDeleteParams.dump_request(params)
  campaign_guid =
    parsed.delete(:campaign_guid) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  asset_type =
    parsed.delete(:asset_type) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: [
      "marketing/campaigns/2026-03/%1$s/assets/%2$s/%3$s",
      campaign_guid,
      asset_type,
      asset_id
    ],
    model: NilClass,
    options: options
  )
end

#list(asset_type, campaign_guid:, after: nil, end_date: nil, limit: nil, start_date: nil, request_options: {}) ⇒ HubSpotSDK::Models::Marketing::CollectionResponsePublicCampaignAssetForwardPaging

Some parameter documentations has been truncated, see Models::Marketing::Campaigns::AssetListParams for more details.

This endpoint lists all assets of the campaign by asset type. The assetType parameter is required, and each request can only fetch assets of a single type. Asset metrics can also be fetched along with the assets; they are available only if start and end dates are provided.

Parameters:

  • asset_type (String)

    Path param: The type of asset to fetch, required

  • campaign_guid (String)

    Path param: The UUID of the campaign, required

  • after (String)

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

  • end_date (String)

    Query param: End date to fetch asset metrics, formatted as YYYY-MM-DD. This date

  • limit (String)

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

  • start_date (String)

    Query param: Start date to fetch asset metrics, formatted as YYYY-MM-DD. This da

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

Returns:

See Also:



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/hubspot_sdk/resources/marketing/campaigns/assets.rb', line 85

def list(asset_type, params)
  parsed, options = HubSpotSDK::Marketing::Campaigns::AssetListParams.dump_request(params)
  query = HubSpotSDK::Internal::Util.encode_query_params(parsed)
  campaign_guid =
    parsed.delete(:campaign_guid) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["marketing/campaigns/2026-03/%1$s/assets/%2$s", campaign_guid, asset_type],
    query: query.transform_keys(end_date: "endDate", start_date: "startDate"),
    model: HubSpotSDK::Marketing::CollectionResponsePublicCampaignAssetForwardPaging,
    options: options
  )
end

#update(asset_id, campaign_guid:, asset_type:, request_options: {}) ⇒ nil

Some parameter documentations has been truncated, see Models::Marketing::Campaigns::AssetUpdateParams for more details.

Associate a specified asset with a campaign. Using the API, you can create associations for the following asset types: ads, blog posts, calls, case studies, CTAs, CTAs (legacy), external website pages, feedback surveys, forms, files, knowledge base articles, landing pages, marketing email, marketing events, meetings, playbooks, podcast episodes, sales documents, sales emails, sequences, SMS, social posts, static lists, videos, website pages, and workflows.

For other asset types, it is recommended to manage your associations directly in the campaign tool in HubSpot.

Parameters:

  • asset_id (String)

    The id of asset to disassociate, required

  • campaign_guid (String)

    The UUID of the campaign, required

  • asset_type (String)

    The type of asset to disassociate, required

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

Returns:

  • (nil)

See Also:



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/hubspot_sdk/resources/marketing/campaigns/assets.rb', line 35

def update(asset_id, params)
  parsed, options = HubSpotSDK::Marketing::Campaigns::AssetUpdateParams.dump_request(params)
  campaign_guid =
    parsed.delete(:campaign_guid) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  asset_type =
    parsed.delete(:asset_type) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :put,
    path: [
      "marketing/campaigns/2026-03/%1$s/assets/%2$s/%3$s",
      campaign_guid,
      asset_type,
      asset_id
    ],
    model: NilClass,
    options: options
  )
end