Class: Sentdm::Resources::Profiles::Campaigns

Inherits:
Object
  • Object
show all
Defined in:
lib/sentdm/resources/profiles/campaigns.rb

Overview

Manage organization profiles

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:



154
155
156
# File 'lib/sentdm/resources/profiles/campaigns.rb', line 154

def initialize(client:)
  @client = client
end

Instance Method Details

#create(profile_id, campaign:, sandbox: nil, idempotency_key: nil, x_profile_id: nil, request_options: {}) ⇒ Sentdm::Models::Profiles::APIResponseOfTcrCampaignWithUseCases

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

Creates a new campaign scoped under the brand of the specified profile. Each campaign must include at least one use case with sample messages.

Parameters:

  • profile_id (String)

    Path param: Profile ID from route

  • campaign (Sentdm::Models::Profiles::CampaignData)

    Body param: Campaign data for create or update operation

  • sandbox (Boolean)

    Body param: Sandbox flag - when true, the operation is simulated without side ef

  • idempotency_key (String)

    Header param: Unique key to ensure idempotent request processing. Must be 1-255

  • x_profile_id (String)

    Header param: Profile UUID to scope the request to a child profile. Only organiz

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

Returns:

See Also:



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/sentdm/resources/profiles/campaigns.rb', line 31

def create(profile_id, params)
  parsed, options = Sentdm::Profiles::CampaignCreateParams.dump_request(params)
  header_params = {idempotency_key: "idempotency-key", x_profile_id: "x-profile-id"}
  @client.request(
    method: :post,
    path: ["v3/profiles/%1$s/campaigns", profile_id],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Sentdm::Profiles::APIResponseOfTcrCampaignWithUseCases,
    options: options
  )
end

#delete(campaign_id, profile_id:, body:, x_profile_id: nil, request_options: {}) ⇒ nil

Some parameter documentations has been truncated, see Models::Profiles::CampaignDeleteParams for more details.

Deletes a campaign by ID from the brand of the specified profile. The profile must belong to the authenticated organization.

Parameters:

  • campaign_id (String)

    Path param: Campaign ID from route parameter

  • profile_id (String)

    Path param: Profile ID from route parameter

  • body (Sentdm::Models::Profiles::CampaignDeleteParams::Body)

    Body param: Request to delete a campaign from a brand

  • x_profile_id (String)

    Header param: Profile UUID to scope the request to a child profile. Only organiz

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

Returns:

  • (nil)

See Also:



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/sentdm/resources/profiles/campaigns.rb', line 135

def delete(campaign_id, params)
  parsed, options = Sentdm::Profiles::CampaignDeleteParams.dump_request(params)
  profile_id =
    parsed.delete(:profile_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["v3/profiles/%1$s/campaigns/%2$s", profile_id, campaign_id],
    headers: parsed.except(:body).transform_keys(x_profile_id: "x-profile-id"),
    body: parsed[:body],
    model: NilClass,
    options: options
  )
end

#list(profile_id, x_profile_id: nil, request_options: {}) ⇒ Sentdm::Models::Profiles::CampaignListResponse

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

Retrieves all campaigns linked to the profile’s brand, including use cases and sample messages. Returns inherited campaigns if inherit_tcr_campaign=true.

Parameters:

  • profile_id (String)

    Profile ID from route

  • x_profile_id (String)

    Profile UUID to scope the request to a child profile. Only organization API keys

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

Returns:

See Also:



103
104
105
106
107
108
109
110
111
112
# File 'lib/sentdm/resources/profiles/campaigns.rb', line 103

def list(profile_id, params = {})
  parsed, options = Sentdm::Profiles::CampaignListParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["v3/profiles/%1$s/campaigns", profile_id],
    headers: parsed.transform_keys(x_profile_id: "x-profile-id"),
    model: Sentdm::Models::Profiles::CampaignListResponse,
    options: options
  )
end

#update(campaign_id, profile_id:, campaign:, sandbox: nil, idempotency_key: nil, x_profile_id: nil, request_options: {}) ⇒ Sentdm::Models::Profiles::APIResponseOfTcrCampaignWithUseCases

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

Updates an existing campaign under the brand of the specified profile. Cannot update campaigns that have already been submitted to TCR.

Parameters:

  • campaign_id (String)

    Path param: Campaign ID from route

  • profile_id (String)

    Path param: Profile ID from route

  • campaign (Sentdm::Models::Profiles::CampaignData)

    Body param: Campaign data for create or update operation

  • sandbox (Boolean)

    Body param: Sandbox flag - when true, the operation is simulated without side ef

  • idempotency_key (String)

    Header param: Unique key to ensure idempotent request processing. Must be 1-255

  • x_profile_id (String)

    Header param: Profile UUID to scope the request to a child profile. Only organiz

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

Returns:

See Also:



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/sentdm/resources/profiles/campaigns.rb', line 69

def update(campaign_id, params)
  parsed, options = Sentdm::Profiles::CampaignUpdateParams.dump_request(params)
  profile_id =
    parsed.delete(:profile_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  header_params = {idempotency_key: "idempotency-key", x_profile_id: "x-profile-id"}
  @client.request(
    method: :put,
    path: ["v3/profiles/%1$s/campaigns/%2$s", profile_id, campaign_id],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Sentdm::Profiles::APIResponseOfTcrCampaignWithUseCases,
    options: options
  )
end