-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c678e17
commit 720c4aa
Showing
3 changed files
with
60 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,13 +10,5 @@ class Brand < APIResource | |
|
||
OBJECT_NAME = "brand".freeze | ||
RESOURCE_PATH = "brand".freeze | ||
def self.create(params = {}, opts = {}) | ||
params[:entityType] ||= "PRIVATE_PROFIT" | ||
params[:displayName] ||= "Default Display Name" | ||
params[:country] ||= "US" | ||
params[:email] ||= "[email protected]" | ||
params[:vertical] ||= "COMMUNICATION" | ||
super(params, opts) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# frozen_string_literal: true | ||
|
||
module Telnyx | ||
class Campaign < APIResource | ||
extend Telnyx::APIOperations::List | ||
extend Telnyx::APIOperations::Create | ||
include Telnyx::APIOperations::Delete | ||
include Telnyx::APIOperations::Save | ||
extend APIOperations::NestedResource | ||
|
||
ACTIONS = %w[mnoMetadata operationStatus].freeze | ||
ACTIONS.each do |action| | ||
nested_resource_class_methods action, | ||
path: %W[#{action}], | ||
operations: [:create], | ||
instance_methods: { create: action } | ||
end | ||
def self.create(params = {}, opts = {}) | ||
resp, opts = request(:post, "/10dlc/campaignBuilder", params, opts) | ||
Util.convert_to_telnyx_object(resp.data, opts) | ||
end | ||
|
||
def accept_sharing(params = {}, opts = {}) | ||
resp, opts = request(:post, "/10dlc/campaign/acceptSharing/#{campaignId.gsub(/\s+/, '+')}", params, opts) | ||
Util.convert_to_telnyx_object(resp.data, opts) | ||
end | ||
|
||
def sharing(params = {}, opts = {}) | ||
resp, opts = request(:get, "/10dlc/campaign/#{campaignId.gsub(/\s+/, '+')}/sharing", params, opts) | ||
Util.convert_to_telnyx_object(resp.data, opts) | ||
end | ||
|
||
def osr_attributes(params = {}, opts = {}) | ||
resp, opts = request(:get, "/10dlc/campaign/#{campaignId.gsub(/\s+/, '+')}/osr/attributes", params, opts) | ||
Util.convert_to_telnyx_object(resp.data, opts) | ||
end | ||
|
||
def self.retrieve(id, opts = {}) | ||
resp, opts = request(:get, resource_url(id), {}, opts) | ||
Util.convert_to_telnyx_object(resp.data, opts) | ||
end | ||
|
||
def self.resource_url(inner_id = nil) | ||
path_prefix = "/10dlc" | ||
object_path = "campaign" | ||
|
||
inner_id.nil? ? "#{path_prefix}/#{object_path}" : "#{path_prefix}/#{object_path}/#{CGI.escape(inner_id)}" | ||
end | ||
|
||
OBJECT_NAME = "campaign".freeze | ||
end | ||
end |