Class: Plivo::Resources::CampaignInterface
- Inherits:
-
Base::ResourceInterface
- Object
- Base::ResourceInterface
- Plivo::Resources::CampaignInterface
- Defined in:
- lib/plivo/resources/campaign.rb
Constant Summary
Constants included from Utils
Instance Method Summary collapse
-
#create(options = nil) ⇒ Object
Create a new Camapign.
-
#delete(campaign_id) ⇒ Object
Delete Campaign.
-
#get(campaign_id) ⇒ Campaign
Get an Campaign.
-
#get_number(campaign_id, number) ⇒ Object
get campaign number.
-
#get_numbers(campaign_id, options = nil) ⇒ Object
get campaign numbers.
-
#initialize(client, resource_list_json = nil) ⇒ CampaignInterface
constructor
A new instance of CampaignInterface.
-
#list(options = nil) ⇒ Hash
List all Campaign.
-
#number_link(options = nil) ⇒ Object
campaign number link.
-
#number_unlink(campaign_id, number, options = nil) ⇒ Object
unlink campaign number.
-
#update(campaign_id, options = nil) ⇒ Object
Update Camapign.
Methods included from Utils
GetSortedQueryParamString?, compute_signatureV3?, expected_type?, expected_value?, generate_url?, getMapFromQueryString?, is_one_among_string_url?, multi_valid_param?, raise_invalid_request, valid_account?, valid_date_format?, valid_mainaccount?, valid_multiple_destination_integers?, valid_multiple_destination_nos?, valid_param?, valid_range?, valid_signature?, valid_signatureV3?, valid_subaccount?, valid_url?
Constructor Details
#initialize(client, resource_list_json = nil) ⇒ CampaignInterface
Returns a new instance of CampaignInterface.
20 21 22 23 24 25 |
# File 'lib/plivo/resources/campaign.rb', line 20 def initialize(client, resource_list_json = nil) @_name = '10dlc/Campaign' @_resource_type = Campaign @_identifier_string = 'campaign_id' super end |
Instance Method Details
#create(options = nil) ⇒ Object
Create a new Camapign
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/plivo/resources/campaign.rb', line 66 def create(=nil) valid_param?(:options, , Hash, true) if not [:brand_id] raise_invalid_request("brand_id must be provided") end if not [:vertical] raise_invalid_request("vertical must be provided") end if not [:usecase] raise_invalid_request("usecase must be provided") end if not [:message_flow] raise_invalid_request("message_flow must be provided") end if not [:help_message] raise_invalid_request("help_message must be provided") end if not [:optout_message] raise_invalid_request("optout_message must be provided") end perform_create() end |
#delete(campaign_id) ⇒ Object
Delete Campaign
147 148 149 150 |
# File 'lib/plivo/resources/campaign.rb', line 147 def delete(campaign_id) valid_param?(:campaign_id, campaign_id, [String, Symbol], true) perform_delete(campaign_id) end |
#get(campaign_id) ⇒ Campaign
Get an Campaign
31 32 33 34 |
# File 'lib/plivo/resources/campaign.rb', line 31 def get(campaign_id) valid_param?(:campaign_id, campaign_id, [String, Symbol], true) perform_get(campaign_id) end |
#get_number(campaign_id, number) ⇒ Object
get campaign number
133 134 135 136 |
# File 'lib/plivo/resources/campaign.rb', line 133 def get_number(campaign_id, number) action = campaign_id + '/Number/' + number perform_action_with_identifier(action, 'GET', nil) end |
#get_numbers(campaign_id, options = nil) ⇒ Object
get campaign numbers
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/plivo/resources/campaign.rb', line 112 def get_numbers(campaign_id, = nil) params = {} %i[offset limit].each do |param| if .key?(param) && valid_param?(param, [param], [Integer, Integer], true) params[param] = [param] end end if .key?(:limit) && ([:limit] > 20 || [:limit] <= 0) raise_invalid_request('The maximum number of results that can be '\ "fetched is 20. limit can't be more than 20 or less than 1") end if .key?(:offset) && [:offset] < 0 raise_invalid_request("Offset can't be negative") end action = campaign_id + '/Number' perform_action_with_identifier(action, 'GET', params) end |
#list(options = nil) ⇒ Hash
List all Campaign
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/plivo/resources/campaign.rb', line 44 def list(=nil) return perform_list_without_object if .nil? params = {} %i[usecase brand limit offset].each do |param| if .key?(param) && valid_param?(param, [param], [String, Integer], true) params[param] = [param] end end if .key?(:limit) && ([:limit] > 20 || [:limit] <= 0) raise_invalid_request('The maximum number of results that can be '\ "fetched is 20. limit can't be more than 20 or less than 1") end if .key?(:offset) && [:offset] < 0 raise_invalid_request("Offset can't be negative") end perform_list_without_object(params) end |
#number_link(options = nil) ⇒ Object
campaign number link
101 102 103 104 105 106 107 108 |
# File 'lib/plivo/resources/campaign.rb', line 101 def number_link(=nil) valid_param?(:options, , Hash, true) if not [:campaign_id] raise_invalid_request("campaign_id must be provided") end action = [:campaign_id] + '/Number' perform_action_with_identifier(action, 'POST', ) end |
#number_unlink(campaign_id, number, options = nil) ⇒ Object
unlink campaign number
140 141 142 143 |
# File 'lib/plivo/resources/campaign.rb', line 140 def number_unlink(campaign_id, number, = nil) action = campaign_id + '/Number/' + number perform_action_with_identifier(action, 'DELETE', nil) end |
#update(campaign_id, options = nil) ⇒ Object
Update Camapign
90 91 92 93 94 95 96 97 |
# File 'lib/plivo/resources/campaign.rb', line 90 def update(campaign_id, =nil) valid_param?(:options, , Hash, true) if not campaign_id raise_invalid_request("campaign_id must be provided") end action = campaign_id perform_action_with_identifier(action, 'POST', ) end |