Class: Plivo::Resources::PhoneNumberCompliancesInterface
- Inherits:
-
Base::ResourceInterface
- Object
- Base::ResourceInterface
- Plivo::Resources::PhoneNumberCompliancesInterface
- Defined in:
- lib/plivo/resources/phone_number_compliance.rb
Constant Summary
Constants included from Utils
Instance Method Summary collapse
-
#create(data_hash, documents = nil) ⇒ Response
Create a phone number compliance application.
-
#delete(compliance_id) ⇒ Object
Delete a phone number compliance application.
-
#get(compliance_id, options = nil) ⇒ PhoneNumberCompliance
Get a phone number compliance application.
-
#initialize(client, resource_list_json = nil) ⇒ PhoneNumberCompliancesInterface
constructor
A new instance of PhoneNumberCompliancesInterface.
-
#list(options = nil) ⇒ Hash
List phone number compliance applications.
-
#update(compliance_id, data_hash, documents = nil) ⇒ PhoneNumberCompliance
Update a phone number compliance application.
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) ⇒ PhoneNumberCompliancesInterface
Returns a new instance of PhoneNumberCompliancesInterface.
92 93 94 95 96 97 |
# File 'lib/plivo/resources/phone_number_compliance.rb', line 92 def initialize(client, resource_list_json = nil) @_name = 'PhoneNumber/Compliance' @_resource_type = PhoneNumberCompliance @_identifier_string = 'compliance_id' super end |
Instance Method Details
#create(data_hash, documents = nil) ⇒ Response
Create a phone number compliance application
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/plivo/resources/phone_number_compliance.rb', line 104 def create(data_hash, documents = nil) params = { data: JSON.generate(data_hash) } if documents documents.each_with_index do |filepath, index| file_extension = filepath.split('.')[-1] content_type = case file_extension when 'jpeg', 'jpg' then 'image/jpeg' when 'png' then 'image/png' when 'pdf' then 'application/pdf' else raise_invalid_request("#{file_extension} is not supported") end params["documents[#{index}].file"] = Faraday::UploadIO.new(filepath, content_type) end end perform_create(params, true) end |
#delete(compliance_id) ⇒ Object
Delete a phone number compliance application
211 212 213 214 215 |
# File 'lib/plivo/resources/phone_number_compliance.rb', line 211 def delete(compliance_id) valid_param?(:compliance_id, compliance_id, [String, Symbol], true) PhoneNumberCompliance.new(@_client, resource_id: compliance_id).delete end |
#get(compliance_id, options = nil) ⇒ PhoneNumberCompliance
Get a phone number compliance application
127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/plivo/resources/phone_number_compliance.rb', line 127 def get(compliance_id, = nil) valid_param?(:compliance_id, compliance_id, [String, Symbol], true) params = {} if valid_param?(:options, , Hash, true) if .key?(:expand) && valid_param?(:expand, [:expand], [String, Symbol], false) params[:expand] = [:expand] end end perform_get(compliance_id, params) end |
#list(options = nil) ⇒ Hash
List phone number compliance applications
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/plivo/resources/phone_number_compliance.rb', line 152 def list( = nil) return perform_list if .nil? valid_param?(:options, , Hash, true) params = {} %i[status country_iso number_type user_type alias expand].each do |param| if .key?(param) && valid_param?(param, [param], [String, Symbol], false) params[param] = [param] end end %i[offset limit].each do |param| if .key?(param) && valid_param?(param, [param], [Integer], false) params[param] = [param] end end raise_invalid_request("Offset can't be negative") if .key?(:offset) && [:offset] < 0 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 perform_list(params) end |
#update(compliance_id, data_hash, documents = nil) ⇒ PhoneNumberCompliance
Update a phone number compliance application
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/plivo/resources/phone_number_compliance.rb', line 187 def update(compliance_id, data_hash, documents = nil) valid_param?(:compliance_id, compliance_id, [String, Symbol], true) params = { data: JSON.generate(data_hash) } if documents documents.each_with_index do |filepath, index| file_extension = filepath.split('.')[-1] content_type = case file_extension when 'jpeg', 'jpg' then 'image/jpeg' when 'png' then 'image/png' when 'pdf' then 'application/pdf' else raise_invalid_request("#{file_extension} is not supported") end params["documents[#{index}].file"] = Faraday::UploadIO.new(filepath, content_type) end end PhoneNumberCompliance.new(@_client, resource_id: compliance_id).update(params) end |