Class: SurgeAPI::Resources::Campaigns

Inherits:
Object
  • Object
show all
Defined in:
lib/surge_api/resources/campaigns.rb,
sig/surge_api/resources/campaigns.rbs

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:



137
138
139
# File 'lib/surge_api/resources/campaigns.rb', line 137

def initialize(client:)
  @client = client
end

Instance Method Details

#create(account_id, campaign_params:, request_options: {}) ⇒ SurgeAPI::Models::Campaign

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

Creates a campaign to register account to send text messages.

Parameters:

Returns:

See Also:



22
23
24
25
26
27
28
29
30
31
# File 'lib/surge_api/resources/campaigns.rb', line 22

def create(, params)
  parsed, options = SurgeAPI::CampaignCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["accounts/%1$s/campaigns", ],
    body: parsed[:campaign_params],
    model: SurgeAPI::Campaign,
    options: options
  )
end

#list(account_id, after: nil, before: nil, request_options: {}) ⇒ SurgeAPI::Internal::Cursor<SurgeAPI::Models::Campaign>

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

List all campaigns for an account with cursor-based pagination.

Parameters:

  • account_id (String)

    The account ID to list campaigns for.

  • after (String)

    Cursor for forward pagination. Use the next_cursor from a previous response.

  • before (String)

    Cursor for backward pagination. Use the previous_cursor from a previous response

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

Returns:

See Also:



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

def list(, params = {})
  parsed, options = SurgeAPI::CampaignListParams.dump_request(params)
  query = SurgeAPI::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["accounts/%1$s/campaigns", ],
    query: query,
    page: SurgeAPI::Internal::Cursor,
    model: SurgeAPI::Campaign,
    options: options
  )
end

#resend_brand_verification_message(account_id, request_options: {}) ⇒ SurgeAPI::Models::CampaignResendBrandVerificationMessageResponse

Enqueues an SMS OTP for a sole proprietor brand awaiting identity verification.

Parameters:

  • account_id (String)

    The account whose brand verification OTP should be sent.

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

Returns:

See Also:



125
126
127
128
129
130
131
132
# File 'lib/surge_api/resources/campaigns.rb', line 125

def resend_brand_verification_message(, params = {})
  @client.request(
    method: :post,
    path: ["accounts/%1$s/brand_verification_messages", ],
    model: SurgeAPI::Models::CampaignResendBrandVerificationMessageResponse,
    options: params[:request_options]
  )
end

#retrieve(id, request_options: {}) ⇒ SurgeAPI::Models::Campaign

Retrieves a Campaign object.

Parameters:

  • id (String)

    The ID of the campaign to retrieve.

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

Returns:

See Also:



44
45
46
47
48
49
50
51
# File 'lib/surge_api/resources/campaigns.rb', line 44

def retrieve(id, params = {})
  @client.request(
    method: :get,
    path: ["campaigns/%1$s", id],
    model: SurgeAPI::Campaign,
    options: params[:request_options]
  )
end

#update(id, campaign_params:, request_options: {}) ⇒ SurgeAPI::Models::Campaign

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

Updates a campaign that has not yet been approved. This can be used to fix issues flagged during review and resubmit the campaign. Returns an error if the campaign is currently in review, has already been approved, or has been deactivated.

Parameters:

Returns:

See Also:



72
73
74
75
76
77
78
79
80
81
# File 'lib/surge_api/resources/campaigns.rb', line 72

def update(id, params)
  parsed, options = SurgeAPI::CampaignUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["campaigns/%1$s", id],
    body: parsed[:campaign_params],
    model: SurgeAPI::Campaign,
    options: options
  )
end