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

Inherits:
Object
  • Object
show all
Defined in:
lib/hubspot_sdk/resources/marketing/campaigns.rb,
lib/hubspot_sdk/resources/marketing/campaigns/batch.rb,
lib/hubspot_sdk/resources/marketing/campaigns/spend.rb,
lib/hubspot_sdk/resources/marketing/campaigns/assets.rb,
lib/hubspot_sdk/resources/marketing/campaigns/budget.rb,
lib/hubspot_sdk/resources/marketing/campaigns/metrics.rb

Defined Under Namespace

Classes: Assets, Batch, Budget, Metrics, Spend

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Campaigns

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

Parameters:



169
170
171
172
173
174
175
176
# File 'lib/hubspot_sdk/resources/marketing/campaigns.rb', line 169

def initialize(client:)
  @client = client
  @assets = HubSpotSDK::Resources::Marketing::Campaigns::Assets.new(client: client)
  @batch = HubSpotSDK::Resources::Marketing::Campaigns::Batch.new(client: client)
  @budget = HubSpotSDK::Resources::Marketing::Campaigns::Budget.new(client: client)
  @metrics = HubSpotSDK::Resources::Marketing::Campaigns::Metrics.new(client: client)
  @spend = HubSpotSDK::Resources::Marketing::Campaigns::Spend.new(client: client)
end

Instance Attribute Details

#assetsHubSpotSDK::Resources::Marketing::Campaigns::Assets (readonly)



8
9
10
# File 'lib/hubspot_sdk/resources/marketing/campaigns.rb', line 8

def assets
  @assets
end

#batchHubSpotSDK::Resources::Marketing::Campaigns::Batch (readonly)



11
12
13
# File 'lib/hubspot_sdk/resources/marketing/campaigns.rb', line 11

def batch
  @batch
end

#budgetHubSpotSDK::Resources::Marketing::Campaigns::Budget (readonly)



14
15
16
# File 'lib/hubspot_sdk/resources/marketing/campaigns.rb', line 14

def budget
  @budget
end

#metricsHubSpotSDK::Resources::Marketing::Campaigns::Metrics (readonly)



17
18
19
# File 'lib/hubspot_sdk/resources/marketing/campaigns.rb', line 17

def metrics
  @metrics
end

#spendHubSpotSDK::Resources::Marketing::Campaigns::Spend (readonly)



20
21
22
# File 'lib/hubspot_sdk/resources/marketing/campaigns.rb', line 20

def spend
  @spend
end

Instance Method Details

#create(properties:, request_options: {}) ⇒ HubSpotSDK::Models::Marketing::PublicCampaign

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

Create a campaign with the specified properties and receive a copy of the campaign object, including its ID. Note that the ‘hs_goal’ property is deprecated and will be ignored if provided.

Parameters:

  • properties (Hash{Symbol=>String})

    A collection of key-value pairs representing the properties of the campaign. Eac

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

Returns:

See Also:



38
39
40
41
42
43
44
45
46
47
# File 'lib/hubspot_sdk/resources/marketing/campaigns.rb', line 38

def create(params)
  parsed, options = HubSpotSDK::Marketing::CampaignCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "marketing/campaigns/2026-03",
    body: parsed,
    model: HubSpotSDK::Marketing::PublicCampaign,
    options: options
  )
end

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

Delete a specified campaign from the system. This call will return a 204 No Content response regardless of whether the campaignGuid provided corresponds to an existing campaign or not.

Parameters:

Returns:

  • (nil)

See Also:



128
129
130
131
132
133
134
135
# File 'lib/hubspot_sdk/resources/marketing/campaigns.rb', line 128

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

#get(campaign_guid, end_date: nil, properties: nil, start_date: nil, request_options: {}) ⇒ HubSpotSDK::Models::Marketing::PublicCampaignWithAssets

Get a campaign identified by a specific campaignGuid with the given properties. Along with the campaign information, it also returns information about assets. Depending on the query parameters used, this can also be used to return information about the corresponding assets’ metrics. Metrics are available only if startDate and endDate are provided.

Parameters:

  • campaign_guid (String)
  • end_date (String)
  • properties (Array<String>)
  • start_date (String)
  • request_options (HubSpotSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



154
155
156
157
158
159
160
161
162
163
164
# File 'lib/hubspot_sdk/resources/marketing/campaigns.rb', line 154

def get(campaign_guid, params = {})
  parsed, options = HubSpotSDK::Marketing::CampaignGetParams.dump_request(params)
  query = HubSpotSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["marketing/campaigns/2026-03/%1$s", campaign_guid],
    query: query.transform_keys(end_date: "endDate", start_date: "startDate"),
    model: HubSpotSDK::Marketing::PublicCampaignWithAssets,
    options: options
  )
end

#list(after: nil, limit: nil, name: nil, properties: nil, sort: nil, request_options: {}) ⇒ HubSpotSDK::Internal::Page<HubSpotSDK::Models::Marketing::PublicCampaign>

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

Retrieve a paginated list of campaigns from your HubSpot account. This endpoint allows you to specify sorting, pagination, and filtering options to tailor the results to your needs.

Parameters:

  • after (String)

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

  • limit (Integer)

    The maximum number of results to display per page.

  • name (String)
  • properties (Array<String>)
  • sort (String)
  • request_options (HubSpotSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/hubspot_sdk/resources/marketing/campaigns.rb', line 103

def list(params = {})
  parsed, options = HubSpotSDK::Marketing::CampaignListParams.dump_request(params)
  query = HubSpotSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "marketing/campaigns/2026-03",
    query: query,
    page: HubSpotSDK::Internal::Page,
    model: HubSpotSDK::Marketing::PublicCampaign,
    options: options
  )
end

#update(campaign_guid, properties:, request_options: {}) ⇒ HubSpotSDK::Models::Marketing::PublicCampaign

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

Perform a partial update of a campaign identified by the specified campaignGuid. Provided property values will be overwritten. Read-only and non-existent properties will cause 400 error. If an empty string is passed for any property in the Batch Update, it will reset that property’s value.

Parameters:

  • campaign_guid (String)
  • properties (Hash{Symbol=>String})

    A collection of key-value pairs representing the properties of the campaign. Eac

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

Returns:

See Also:



68
69
70
71
72
73
74
75
76
77
# File 'lib/hubspot_sdk/resources/marketing/campaigns.rb', line 68

def update(campaign_guid, params)
  parsed, options = HubSpotSDK::Marketing::CampaignUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["marketing/campaigns/2026-03/%1$s", campaign_guid],
    body: parsed,
    model: HubSpotSDK::Marketing::PublicCampaign,
    options: options
  )
end