Class: Plivo::Resources::IdentityInterface
- Inherits:
-
Base::ResourceInterface
- Object
- Base::ResourceInterface
- Plivo::Resources::IdentityInterface
- Defined in:
- lib/plivo/resources/identities.rb
Constant Summary
Constants included from Utils
Instance Method Summary collapse
-
#create(country_iso, salutation, first_name, last_name, birth_place, birth_date, nationality, id_nationality, id_issue_date, id_type, id_number, address_line1, address_line2, city, region, postal_code, file_to_upload = nil, options = nil) ⇒ Identity
Create a new identity.
-
#delete(identity_id) ⇒ Object
Delete an identity.
-
#get(identity_id) ⇒ Identity
Get an identity.
-
#initialize(client, resource_list_json = nil) ⇒ IdentityInterface
constructor
A new instance of IdentityInterface.
-
#list(options = nil) ⇒ Hash
List all identities.
-
#update(identity_id, file_to_upload = nil, options = nil) ⇒ Identity
Update an identity.
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) ⇒ IdentityInterface
Returns a new instance of IdentityInterface.
109 110 111 112 113 114 |
# File 'lib/plivo/resources/identities.rb', line 109 def initialize(client, resource_list_json = nil) @_name = 'Verification/Identity' @_resource_type = Identity @_identifier_string = 'id' super end |
Instance Method Details
#create(country_iso, salutation, first_name, last_name, birth_place, birth_date, nationality, id_nationality, id_issue_date, id_type, id_number, address_line1, address_line2, city, region, postal_code, file_to_upload = nil, options = nil) ⇒ Identity
Create a new identity
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
# File 'lib/plivo/resources/identities.rb', line 203 def create(country_iso, salutation, first_name, last_name, birth_place, birth_date, nationality, id_nationality, id_issue_date, id_type, id_number, address_line1, address_line2, city, region, postal_code, file_to_upload=nil, =nil) valid_param?(:country_iso, country_iso, [String, Symbol], true) valid_param?(:salutation, salutation, [String, Symbol], true, ['Mr', 'Ms', :Ms, :Mr]) valid_param?(:first_name, first_name, [String, Symbol], true) valid_param?(:last_name, last_name, [String, Symbol], true) valid_param?(:birth_place, birth_place, [String, Symbol], true) valid_param?(:birth_date, birth_date, [String, Symbol], true) valid_param?(:nationality, nationality, [String, Symbol], true) valid_param?(:id_nationality, id_nationality, [String, Symbol], true) valid_param?(:id_issue_date, id_issue_date, [String, Symbol], true) valid_param?(:id_type, id_type, [String, Symbol], true) valid_param?(:id_number, id_number, [String, Symbol], true) valid_param?(:address_line1, address_line1, [String, Symbol], true) valid_param?(:address_line2, address_line2, [String, Symbol], true) valid_param?(:city, city, [String, Symbol], true) valid_param?(:region, region, [String, Symbol], true) valid_param?(:postal_code, postal_code, [String, Symbol], true) params = { country_iso: country_iso, salutation: salutation, first_name: first_name, last_name: last_name, birth_place: birth_place, birth_date: birth_date, nationality: nationality, id_nationality: id_nationality, id_issue_date: id_issue_date, id_type: id_type, id_number: id_number, address_line1: address_line1, address_line2: address_line2, city: city, region: region, postal_code: postal_code } 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 %i[alias business_name fiscal_identification_code street_code municipal_code callback_url subaccount] .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 perform_create(params, true) end |
#delete(identity_id) ⇒ Object
Delete an identity
312 313 314 315 316 |
# File 'lib/plivo/resources/identities.rb', line 312 def delete(identity_id) valid_param?(:identity_id, identity_id, [String, Symbol], true) Identity.new(@_client, resource_id: identity_id).delete end |
#get(identity_id) ⇒ Identity
Get an identity
120 121 122 123 |
# File 'lib/plivo/resources/identities.rb', line 120 def get(identity_id) valid_param?(:identity_id, identity_id, [String, Symbol], true) perform_get(identity_id) end |
#list(options = nil) ⇒ Hash
List all identities
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/plivo/resources/identities.rb', line 135 def list(=nil) return perform_list if .nil? params = {} %i[country_iso customer_name alias].each do |param| if .key?(param) && valid_param?(param, [param], [String, Symbol], true) params[param] = [param] end end %i[verification_status].each do |param| if .key?(param) && valid_param?(param, [param], [String, Symbol], true, ['pending', 'accepted', 'rejected', :pending, :accepted, :rejected]) params[param] = [param] end end %i[offset limit].each do |param| if .key?(param) && valid_param?(param, [param], [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(params) end |