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:



142
143
144
# File 'lib/hubspot_sdk/resources/marketing/campaigns/assets.rb', line 142

def initialize(client:)
  @client = client
end

Instance Method Details

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

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)
  • campaign_guid (String)
  • asset_type (String)
  • request_options (HubSpotSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (nil)

See Also:



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/hubspot_sdk/resources/marketing/campaigns/assets.rb', line 116

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

  • campaign_guid (String)

    Path param

  • after (String)

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

  • end_date (String)

    Query param

  • limit (String)

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

  • start_date (String)

    Query param

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

Returns:

See Also:



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/hubspot_sdk/resources/marketing/campaigns/assets.rb', line 79

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

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)
  • campaign_guid (String)
  • asset_type (String)
  • request_options (HubSpotSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (nil)

See Also:



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/hubspot_sdk/resources/marketing/campaigns/assets.rb', line 29

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