Class: Plivo::Resources::Address
- Inherits:
-
Base::Resource
- Object
- Base::Resource
- Plivo::Resources::Address
- Defined in:
- lib/plivo/resources/addresses.rb
Constant Summary
Constants included from Utils
Instance Attribute Summary
Attributes inherited from Base::Resource
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(client, options = nil) ⇒ Address
constructor
A new instance of Address.
- #to_s ⇒ Object
-
#update(file_to_upload = nil, options = nil) ⇒ Address
Update an address.
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, options = nil) ⇒ Address
Returns a new instance of Address.
6 7 8 9 10 |
# File 'lib/plivo/resources/addresses.rb', line 6 def initialize(client, = nil) @_name = 'Verification/Address' @_identifier_string = 'id' super end |
Instance Method Details
#delete ⇒ Object
12 13 14 |
# File 'lib/plivo/resources/addresses.rb', line 12 def delete perform_delete end |
#to_s ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/plivo/resources/addresses.rb', line 71 def to_s { account: @account, address_line1: @address_line1, address_line2: @address_line2, alias: @alias, api_id: @api_id, city: @city, country_iso: @country_iso, document_details: @document_details, first_name: @first_name, id: @id, last_name: @last_name, postal_code: @postal_code, region: @region, salutation: @salutation, subaccount: @subaccount, url: @url, validation_status: @validation_status, verification_status: @verification_status }.to_s end |
#update(file_to_upload = nil, options = nil) ⇒ Address
Update an address
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/plivo/resources/addresses.rb', line 33 def update(file_to_upload = nil, = nil) params = {} unless .nil? %i[salutation first_name last_name country_iso address_line1 address_line2 city region postal_code alias callback_url] .each do |param| if .key?(param) && valid_param?(param, [param], [String, Symbol], true) params[param] = [param] end end %i[auto_correct_address] .each do |param| if .key?(param) && valid_param?(param, [param], nil, true, [true, false]) params[param] = [param] end end end unless file_to_upload.nil? file_extension = file_to_upload.split('.')[-1] content_type = case file_extension when 'jpeg' then 'image/jpeg' when 'jpg' then 'image/jpeg' when 'png' then 'image/png' when 'pdf' then 'application/pdf' else raise_invalid_request("#{file_extension} is not yet supported for upload") end params[:file] = Faraday::UploadIO.new(file_to_upload, content_type) end return perform_update(params, true) end |