From 162bfc749c21f0bd999403412ee7992e94839545 Mon Sep 17 00:00:00 2001 From: Richa Verma Date: Thu, 24 Jan 2019 21:22:44 +0530 Subject: [PATCH 1/4] address verification: address and idenity sdk methods --- lib/plivo/resources/addresses.rb | 123 +++++++--- lib/plivo/resources/identities.rb | 215 ++++++++++-------- spec/mocks/addressCreateErrorResponse.json | 8 + ...json => addressCreateSuccessResponse.json} | 0 spec/mocks/identityCreateErrorResponse.json | 8 + ...son => identityCreateSuccessResponse.json} | 0 spec/resource_addresses_spec.rb | 102 +++++++-- spec/resource_identities_spec.rb | 169 ++++++++++---- 8 files changed, 424 insertions(+), 201 deletions(-) create mode 100644 spec/mocks/addressCreateErrorResponse.json rename spec/mocks/{addressCreateResponse.json => addressCreateSuccessResponse.json} (100%) create mode 100644 spec/mocks/identityCreateErrorResponse.json rename spec/mocks/{identityCreateResponse.json => identityCreateSuccessResponse.json} (100%) diff --git a/lib/plivo/resources/addresses.rb b/lib/plivo/resources/addresses.rb index 43c35997..0e4fcd67 100644 --- a/lib/plivo/resources/addresses.rb +++ b/lib/plivo/resources/addresses.rb @@ -29,12 +29,21 @@ def delete # @option options [String] :alias - Alias name of the address # @option options [String] :auto_correct_address - If set to true, the address will be auto-corrected by the system if necessary. The param needs to be set to false explicitly so that it is not auto-corrected. # @option options [String] :callback_url - The callback URL that gets the result of address creation POSTed to. + # @option options [String] :phone_number_country + # @option options [String] :number_type + # @option options [String] :fiscal_identification_code + # @option options [String] :street_code + # @option options [String] :municipal_code + # @option options [String] :file + # @option options [String] :proof_type + # @option options [String] :id_number + # @return [Address] Address - def update(file_to_upload = nil, options = nil) + def update(options = nil) params = {} unless options.nil? - %i[salutation first_name last_name country_iso address_line1 address_line2 city region postal_code alias callback_url] + %i[first_name last_name country_iso address_line1 address_line2 city region postal_code alias callback_url phone_number_country fiscal_identification_code street_code municipal_code file id_number] .each do |param| if options.key?(param) && valid_param?(param, options[param], [String, Symbol], true) @@ -49,22 +58,47 @@ def update(file_to_upload = nil, options = nil) params[param] = options[param] end end - end - unless file_to_upload.nil? - file_extension = file_to_upload.split('.')[-1] + if options[:salutation] + valid_param?(:salutation, options[:salutation], [String, Symbol], true, ['Mr', 'Ms', :Ms, :Mr]) + params[:salutation] = options[:salutation] + end - 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 + if options[:number_type] + valid_param?(:number_type, options[:number_type], [String, Symbol], true, ['local', 'national', 'mobile', 'tollfree']) + params[:number_type] = options[:number_type] + end - params[:file] = Faraday::UploadIO.new(file_to_upload, content_type) - end + if options[:proof_type] + if options[:country_iso] + if options[:country_iso] == 'ES' + valid_param?(:proof_type, options[:proof_type], [String, Symbol], false, ['NIF', 'NIE', 'DNI']) + else + valid_param?(:proof_type, options[:proof_type], [String, Symbol], false, ['national_id', 'passport', 'business_id']) + end + else + valid_param?(:proof_type, options[:proof_type], [String, Symbol], false, ['NIF', 'NIE', 'DNI', 'national_id', 'passport', 'business_id']) + end + params[:proof_type] = options[:proof_type] + end + unless options[:file].nil? + file_extension = options[:file].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 + file_size = File.size("#{options[:file]}") + if file_size > 5000000 + raise_invalid_request("Maximum file size can be 5 MB") + end + params[:file] = Faraday::UploadIO.new(options[:file], content_type) + end + end return perform_update(params, true) end @@ -161,6 +195,8 @@ def list(options=nil) ## # Create a new address + # @param [String] phone_number_country + # @param [String] number_type # @param [String] country_iso # @param [String] salutation # @param [String] first_name @@ -170,8 +206,6 @@ def list(options=nil) # @param [String] city # @param [String] region # @param [String] postal_code - # @param [String] address_proof_type - # @param [String] file_to_upload # @param [Hash] options # @option options [String] :alias - Alias name of the address # @option options [String] :auto_correct_address - If set to true, the address will be auto-corrected by the system if necessary. The param needs to be set to false explicitly so that it is not auto-corrected. @@ -179,11 +213,16 @@ def list(options=nil) # @option options [String] :street_code - Street code of the address # @option options [String] :municipal_code - Municipal code of the address # @option options [String] :callback_url - The callback URL that gets the result of address creation POSTed to. + # @option options :file - A File to upload, which needs to be considered the proof of address. Max. file Size = 5 MB. File should be in jpg, pdf, or png format. + # @option options [String] :proof_type - The type of document that is provided as address proof + # @option options [String] :id_number - Unique Identifier for the address proof you have submitted + # @return [Address] Address - def create(country_iso, salutation, first_name, last_name, address_line1, address_line2, city, region, - postal_code, address_proof_type, file_to_upload=nil, options=nil) - valid_param?(:country_iso, country_iso, [String, Symbol], true) - valid_param?(:salutation, salutation, [String, Symbol], true, ['Mr', 'Ms', :Ms, :Mr]) + def create(phone_number_country, number_type, salutation, first_name, last_name, address_line1, address_line2, city, region, + postal_code, country_iso, options=nil) + valid_param?(:phone_number_country, phone_number_country, [String, Symbol], true) + valid_param?(:number_type, number_type, [String, Symbol], true, ['local', 'national', 'mobile', 'tollfree']) + valid_param?(:salutation, salutation, [String, Symbol], true, ['Mr', 'Ms']) valid_param?(:first_name, first_name, [String, Symbol], true) valid_param?(:last_name, last_name, [String, Symbol], true) valid_param?(:address_line1, address_line1, [String, Symbol], true) @@ -191,14 +230,12 @@ def create(country_iso, salutation, first_name, last_name, address_line1, addres valid_param?(:city, city, [String, Symbol], true) valid_param?(:region, region, [String, Symbol], true) valid_param?(:postal_code, postal_code, [String, Symbol], true) - valid_param?(:address_proof_type, - address_proof_type, - [String, Symbol], true, - ['national_id', 'passport', 'business_id', 'NIF', 'NIE', 'DNI', 'others', - :national_id, :passport, :business_id, :NIF, :NIE, :DNI, :others]) + valid_param?(:country_iso, country_iso, [String, Symbol], true) + params = { - country_iso: country_iso, + phone_number_country: phone_number_country, + number_type: number_type, salutation: salutation, first_name: first_name, last_name: last_name, @@ -207,7 +244,7 @@ def create(country_iso, salutation, first_name, last_name, address_line1, addres city: city, region: region, postal_code: postal_code, - address_proof_type: address_proof_type + country_iso: country_iso, } if country_iso == 'ES' @@ -223,8 +260,18 @@ def create(country_iso, salutation, first_name, last_name, address_line1, addres params[:municipal_code] = options[:municipal_code] end - unless file_to_upload.nil? - file_extension = file_to_upload.split('.')[-1] + if options[:proof_type] + if country_iso == 'ES' + valid_param?(:proof_type, options[:proof_type], [String, Symbol], false, ['NIF', 'NIE', 'DNI']) + else + valid_param?(:proof_type, options[:proof_type], [String, Symbol], false, ['national_id', 'passport', 'business_id']) + end + params[:proof_type] = options[:proof_type] + end + + + unless options[:file].nil? + file_extension = options[:file].split('.')[-1].downcase content_type = case file_extension when 'jpeg' then 'image/jpeg' @@ -233,11 +280,15 @@ def create(country_iso, salutation, first_name, last_name, address_line1, addres 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) + # add a check on file size + file_size = File.size("#{options[:file]}") + if file_size > 5000000 + raise_invalid_request("Maximum file size can be 5 MB") + end + params[:file] = Faraday::UploadIO.new(options[:file], content_type) end - %i[alias fiscal_identification_code street_code municipal_code callback_url] + %i[alias fiscal_identification_code street_code municipal_code callback_url id_number] .each do |param| if options.key?(param) && valid_param?(param, options[param], [String, Symbol], true) @@ -252,7 +303,6 @@ def create(country_iso, salutation, first_name, last_name, address_line1, addres params[param] = options[param] end end - perform_create(params, true) end @@ -274,9 +324,8 @@ def create(country_iso, salutation, first_name, last_name, address_line1, addres # @option options [String] :auto_correct_address - If set to true, the address will be auto-corrected by the system if necessary. The param needs to be set to false explicitly so that it is not auto-corrected. # @option options [String] :callback_url - The callback URL that gets the result of address creation POSTed to. # @return [Address] Address - def update(address_id, file_to_upload=nil, options=nil) - Address.new(@_client, - resource_id: address_id).update(file_to_upload, options) + def update(address_id, options=nil) + Address.new(@_client,resource_id: address_id).update(options) end ## @@ -299,4 +348,4 @@ def each end end end -end \ No newline at end of file +end diff --git a/lib/plivo/resources/identities.rb b/lib/plivo/resources/identities.rb index e4cf5c3d..ab987de6 100644 --- a/lib/plivo/resources/identities.rb +++ b/lib/plivo/resources/identities.rb @@ -15,41 +15,40 @@ def delete # Update an identity # @param [String] identity_id - # @param [String] file_to_upload # @param [Hash] options + # @option options [String] :phone_number_country - Country ISO 2 code for which you are submitted + # @option options [String] :number_type - This can only take values “local”, “national”, “mobile”, “tollfree” # @option options [String] :salutation - One of Mr or Ms # @option options [String] :first_name - First name of the user for whom the identity is created # @option options [String] :last_name - Last name of the user for whom the identity is created - # @option options [String] :country_iso - Country ISO 2 code - # @option options [String] :birth_place - Birthplace of the user for whom the identity is created - # @option options [String] :birth_date - Birth date in yyyy-mm-dd format of the user for whom the identity is created - # @option options [String] :nationality - Nationality of the user for whom the identity is created - # @option options [String] :id_nationality - Nationality mentioned in the identity proof - # @option options [String] :id_issue_date - Issue date in yyyy-mm-dd mentioned in the identity proof - # @option options [String] :id_type - - # @option options [String] :id_number - The unique number on the identifier # @option options [String] :address_line1 - Building name/number # @option options [String] :address_line2 - The street name/number of the address # @option options [String] :city - The city of the address for which the address proof is created # @option options [String] :region - The region of the address for which the address proof is created # @option options [String] :postal_code - The postal code of the address that is being created + # @option options [String] :country_iso - Country ISO 2 code + # @option options [String] :proof_type - The type of document that is provided as address proof + # @option options [String] :id_number - The unique number on the identifier + # @option options [String] :nationality - Nationality of the user for whom the identity is created + # @option options [String] :callback_url - The callback URL that gets the result of identity creation POSTed to. # @option options [String] :alias - Alias name of the identity + # @option options :file - A File to upload, which needs to be considered the proof of address. Max. file Size = 5 MB. File should be in jpg, pdf, or png format. + # @option options [String] :id_nationality - Nationality mentioned in the identity proof + # @option options [String] :birth_place - Birthplace of the user for whom the identity is created + # @option options [String] :birth_date - Birth date in yyyy-mm-dd format of the user for whom the identity is created + # @option options [String] :id_issue_date - Issue date in yyyy-mm-dd mentioned in the identity proof # @option options [String] :business_name - Business name of the user for whom the identity is created. - # @option options [String] :auto_correct_address - If set to true, the address will be auto-corrected by the system if necessary. The param needs to be set to false explicitly so that it is not auto-corrected. # @option options [String] :fiscal_identification_code - The code is valid for businesses alone # @option options [String] :street_code - Street code of the address # @option options [String] :municipal_code - Municipal code of the address - # @option options [String] :callback_url - The callback URL that gets the result of identity creation POSTed to. - # @option options [String] :subaccount - The link to the subaccount resource associated with the application. If the application belongs to the main account, this field will be null. # @return [Identity] Identity - def update(file_to_upload = nil, options = nil) + + def update(options = nil) params = {} unless options.nil? - %i[salutation first_name last_name country_iso birth_place birth_date nationality id_nationality id_issue_date - id_type id_number address_line1 address_line2 city region postal_code alias business_name - fiscal_identification_code street_code municipal_code callback_url subaccount - ] + %i[phone_number_country first_name last_name address_line1 address_line2 city region postal_code country_iso + id_number nationality callback_url alias id_nationality birth_place birth_date id_issue_date business_name fiscal_identification_code street_code municipal_code] .each do |param| if options.key?(param) && valid_param?(param, options[param], [String, Symbol], true) @@ -57,29 +56,45 @@ def update(file_to_upload = nil, options = nil) end end - %i[auto_correct_address] - .each do |param| - if options.key?(param) && - valid_param?(param, options[param], nil, true, [true, false]) - params[param] = options[param] - end + if options[:salutation] + valid_param?(:salutation, options[:salutation], [String, Symbol], true, ['Mr', 'Ms', :Ms, :Mr]) + params[:salutation] = options[:salutation] 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 + if options[:number_type] + valid_param?(:number_type, options[:number_type], [String, Symbol], true, ['local', 'national', 'mobile', 'tollfree']) + params[:number_type] = options[:number_type] + end - params[:file] = Faraday::UploadIO.new(file_to_upload, content_type) + if options[:proof_type] + if options[:country_iso] + if options[:country_iso] == 'ES' + valid_param?(:proof_type, options[:proof_type], [String, Symbol], false, ['NIF', 'NIE', 'DNI']) + else + valid_param?(:proof_type, options[:proof_type], [String, Symbol], false, ['national_id', 'passport', 'business_id']) + end + else + valid_param?(:proof_type, options[:proof_type], [String, Symbol], false, ['NIF', 'NIE', 'DNI', 'national_id', 'passport', 'business_id']) + end + params[:proof_type] = options[:proof_type] + end + unless options[:file].nil? + file_extension = options[:file].split('.')[-1].downcase + # add check on file size + 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 + file_size = File.size("#{options[:file]}") + if file_size > 5000000 + raise_invalid_request("Maximum file size can be 5 MB") + end + params[:file] = Faraday::UploadIO.new(options[:file], content_type) + end end - return perform_update(params, true) end @@ -173,74 +188,70 @@ def list(options=nil) ## # Create a new identity - # @param [String] country_iso + # @param [String] phone_number_country + # @param [String] number_type # @param [String] salutation # @param [String] first_name # @param [String] last_name - # @param [String] birth_place - # @param [String] birth_date - # @param [String] nationality - # @param [String] id_nationality - # @param [String] id_issue_date - # @param [String] id_type - # @param [String] id_number # @param [String] address_line1 # @param [String] address_line2 # @param [String] city # @param [String] region # @param [String] postal_code - # @param [String] file_to_upload + # @param [String] country_iso + # @param [String] proof_type + # @param [String] id_number + # @param [String] nationality # @param [Hash] options + # @option options [String] :callback_url - The callback URL that gets the result of identity creation POSTed to. # @option options [String] :alias - Alias name of the identity + # @option options :file - A File to upload, which needs to be considered the proof of address. Max. file Size = 5 MB. File should be in jpg, pdf, or png format. + # @option options [String] :id_nationality - Nationality of the user mentioned in the document + # @option options [String] :birth_place - Birth Place of the user mentioned in the document + # @option options [String] :birth_date - Birth Date of the user mentioned in the document + # @option options [String] :id_issue_date - Issued date of the proof being uploaded # @option options [String] :business_name - Business name of the user for whom the identity is created. - # @option options [String] :auto_correct_address - If set to true, the address will be auto-corrected by the system if necessary. The param needs to be set to false explicitly so that it is not auto-corrected. # @option options [String] :fiscal_identification_code - The code is valid for businesses alone # @option options [String] :street_code - Street code of the address # @option options [String] :municipal_code - Municipal code of the address - # @option options [String] :callback_url - The callback URL that gets the result of identity creation POSTed to. - # @option options [String] :subaccount - The link to the subaccount resource associated with the application. If the application belongs to the main account, this field will be null. # @return [Identity] Identity - 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, options=nil) - valid_param?(:country_iso, country_iso, [String, Symbol], true) + + def create(phone_number_country, number_type, salutation, first_name, last_name, address_line1, address_line2, + city, region, postal_code, country_iso, proof_type, id_number, nationality, options=nil) + valid_param?(:phone_number_country, phone_number_country, [String, Symbol], true) + valid_param?(:number_type, number_type, [String, Symbol], true, ['local', 'national', 'mobile', 'tollfree']) 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) + valid_param?(:country_iso, country_iso, [String, Symbol], true) + valid_param?(:proof_type, proof_type, [String, Symbol], true) + valid_param?(:id_number, id_number, [String, Symbol], true) + valid_param?(:nationality, nationality, [String, Symbol], true) params = { - country_iso: country_iso, + phone_number_country: phone_number_country, + number_type: number_type, 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 + postal_code: postal_code, + country_iso: country_iso, + proof_type: proof_type, + id_number: id_number, + nationality: nationality } - unless file_to_upload.nil? - file_extension = file_to_upload.split('.')[-1] + unless options[:file].nil? + file_extension = options[:file].split('.')[-1].downcase content_type = case file_extension when 'jpeg' then 'image/jpeg' @@ -249,61 +260,77 @@ def create(country_iso, salutation, first_name, last_name, birth_place, birth_da when 'pdf' then 'application/pdf' else raise_invalid_request("#{file_extension} is not yet supported for upload") end + file_size = File.size("#{options[:file]}") + if file_size > 5000000 + raise_invalid_request("Maximum file size can be 5 MB") + end + params[:file] = Faraday::UploadIO.new(options[:file], content_type) + end - params[:file] = Faraday::UploadIO.new(file_to_upload, content_type) + if country_iso == 'ES' + valid_param?(:fiscal_identification_code, options[:fiscal_identification_code], [String, Symbol], true) + params[:fiscal_identification_code] = options[:fiscal_identification_code] end - %i[alias business_name fiscal_identification_code street_code municipal_code callback_url subaccount] - .each do |param| - if options.key?(param) && - valid_param?(param, options[param], [String, Symbol], true) - params[param] = options[param] + if country_iso == 'DK' + valid_param?(:street_code, options[:street_code], [String, Symbol], true) + valid_param?(:municipal_code, options[:municipal_code], [String, Symbol], true) + + params[:street_code] = options[:street_code] + params[:municipal_code] = options[:municipal_code] + end + + if options[:proof_type] + if country_iso == 'ES' + valid_param?(:proof_type, options[:proof_type], [String, Symbol], false, ['NIF', 'NIE', 'DNI']) + else + valid_param?(:proof_type, options[:proof_type], [String, Symbol], false, ['national_id', 'passport', 'business_id']) end + params[:proof_type] = options[:proof_type] end - %i[auto_correct_address] + %i[callback_url alias id_nationality birth_place birth_date id_issue_date business_name fiscal_identification_code street_code municipal_code] .each do |param| if options.key?(param) && - valid_param?(param, options[param], nil, true, [true, false]) + valid_param?(param, options[param], [String, Symbol], true) params[param] = options[param] end end - perform_create(params, true) end # Update an identity # @param [String] identity_id - # @param [String] file_to_upload # @param [Hash] options + # @option options [String] :phone_number_country - Country ISO 2 code for which you are submitted + # @option options [String] :number_type - This can only take values “local”, “national”, “mobile”, “tollfree” # @option options [String] :salutation - One of Mr or Ms # @option options [String] :first_name - First name of the user for whom the identity is created # @option options [String] :last_name - Last name of the user for whom the identity is created - # @option options [String] :country_iso - Country ISO 2 code - # @option options [String] :birth_place - Birthplace of the user for whom the identity is created - # @option options [String] :birth_date - Birth date in yyyy-mm-dd format of the user for whom the identity is created - # @option options [String] :nationality - Nationality of the user for whom the identity is created - # @option options [String] :id_nationality - Nationality mentioned in the identity proof - # @option options [String] :id_issue_date - Issue date in yyyy-mm-dd mentioned in the identity proof - # @option options [String] :id_type - - # @option options [String] :id_number - The unique number on the identifier # @option options [String] :address_line1 - Building name/number # @option options [String] :address_line2 - The street name/number of the address # @option options [String] :city - The city of the address for which the address proof is created # @option options [String] :region - The region of the address for which the address proof is created # @option options [String] :postal_code - The postal code of the address that is being created + # @option options [String] :country_iso - Country ISO 2 code + # @option options [String] :proof_type - The type of document that is provided as address proof + # @option options [String] :id_number - The unique number on the identifier + # @option options [String] :nationality - Nationality of the user for whom the identity is created + # @option options [String] :callback_url - The callback URL that gets the result of identity creation POSTed to. # @option options [String] :alias - Alias name of the identity + # @option options :file - A File to upload, which needs to be considered the proof of address. Max. file Size = 5 MB. File should be in jpg, pdf, or png format. + # @option options [String] :id_nationality - Nationality mentioned in the identity proof + # @option options [String] :birth_place - Birthplace of the user for whom the identity is created + # @option options [String] :birth_date - Birth date in yyyy-mm-dd format of the user for whom the identity is created + # @option options [String] :id_issue_date - Issue date in yyyy-mm-dd mentioned in the identity proof # @option options [String] :business_name - Business name of the user for whom the identity is created. - # @option options [String] :auto_correct_address - If set to true, the address will be auto-corrected by the system if necessary. The param needs to be set to false explicitly so that it is not auto-corrected. # @option options [String] :fiscal_identification_code - The code is valid for businesses alone # @option options [String] :street_code - Street code of the address # @option options [String] :municipal_code - Municipal code of the address - # @option options [String] :callback_url - The callback URL that gets the result of identity creation POSTed to. - # @option options [String] :subaccount - The link to the subaccount resource associated with the application. If the application belongs to the main account, this field will be null. # @return [Identity] Identity - def update(identity_id, file_to_upload=nil, options=nil) + def update(identity_id, options=nil) Identity.new(@_client, - resource_id: identity_id).update(file_to_upload, options) + resource_id: identity_id).update(options) end ## @@ -316,4 +343,4 @@ def delete(identity_id) end end end -end \ No newline at end of file +end diff --git a/spec/mocks/addressCreateErrorResponse.json b/spec/mocks/addressCreateErrorResponse.json new file mode 100644 index 00000000..d020d313 --- /dev/null +++ b/spec/mocks/addressCreateErrorResponse.json @@ -0,0 +1,8 @@ +{ + "api_id": "396f3832-0a89-11e9-b0b4-066a42519598", + "error": { + "error": "user already exists", + "message": "Could not complete address verification.", + "status": "error" + } +} diff --git a/spec/mocks/addressCreateResponse.json b/spec/mocks/addressCreateSuccessResponse.json similarity index 100% rename from spec/mocks/addressCreateResponse.json rename to spec/mocks/addressCreateSuccessResponse.json diff --git a/spec/mocks/identityCreateErrorResponse.json b/spec/mocks/identityCreateErrorResponse.json new file mode 100644 index 00000000..a4f39225 --- /dev/null +++ b/spec/mocks/identityCreateErrorResponse.json @@ -0,0 +1,8 @@ +{ + "api_id": "396f3832-0a89-11e9-b0b4-066a42519598", + "error": { + "error": "user already exists", + "message": "Could not complete idenity verification.", + "status": "error" + } +} diff --git a/spec/mocks/identityCreateResponse.json b/spec/mocks/identityCreateSuccessResponse.json similarity index 100% rename from spec/mocks/identityCreateResponse.json rename to spec/mocks/identityCreateSuccessResponse.json diff --git a/spec/resource_addresses_spec.rb b/spec/resource_addresses_spec.rb index 275b4482..b04d902b 100644 --- a/spec/resource_addresses_spec.rb +++ b/spec/resource_addresses_spec.rb @@ -51,33 +51,91 @@ def to_json_list(list_object) }.to_json end - it 'creates an address' do - contents = File.read(Dir.pwd + '/spec/mocks/addressCreateResponse.json') +describe "create an address" do + it "creates an address sucessfully" do + contents = File.read(Dir.pwd + '/spec/mocks/addressCreateSuccessResponse.json') mock(200, JSON.parse(contents)) expect(JSON.parse(to_json_create(@api.addresses - .create( - 'US', - 'Mr', - 'Bruce', - 'Wayne', - '1234', - 'Wayne Towers', - 'New York', - 'NY', - '12345', - 'others', - nil, - { - callback_url: 'https://callback.url', - auto_correct_address: true - } + .create('US', + 'local', + 'Mr', + 'Bruce', + 'Wayne', + '1234', + 'Wayne Towers', + 'New York', + 'NY', + '12345', + 'US', + { + callback_url: 'https://callback.url', + proof_type: 'passport' + } )))) .to eql(JSON.parse(contents).reject { |_, v| v.nil? }) compare_requests(uri: '/v1/Account/MAXXXXXXXXXXXXXXXXXX/Verification/Address/', method: 'POST', data: { + phone_number_country: 'US', + number_type: 'local', + salutation: 'Mr', + first_name: 'Bruce', + last_name: 'Wayne', + address_line1: '1234', + address_line2: 'Wayne Towers', + city: 'New York', + region: 'NY', + postal_code: '12345', country_iso: 'US', + callback_url: 'https://callback.url', + proof_type: 'passport' + }) + end + + it "raises exception: in case of mandatory param - fiscal_identification_code is mandatory when country_iso is Spain" do + expect{@api.addresses.create('ES', + 'local', + 'Mr', + 'Bruce', + 'Wayne', + '1234', + 'Wayne Towers', + 'New York', + 'NY', + '12345', + 'ES', + { + callback_url: 'https://callback.url', + proof_type: 'passport' + } + )}.to raise_error(Plivo::Exceptions::InvalidRequestError) + end + + it "returns error: in case of invalid value for param" do + contents = File.read(Dir.pwd + '/spec/mocks/addressCreateErrorResponse.json') + mock(405, JSON.parse(contents)) + expect{@api.addresses.create('US', + 'local', + 'Mr', + 'Bruce', + 'Wayne', + '1234', + 'Wayne Towers', + 'New York', + 'NY', + '12345', + 'US', + { + callback_url: 'https://callback.url', + proof_type: 'passport' + } + )}.to raise_error(Plivo::Exceptions::InvalidRequestError) + compare_requests(uri: '/v1/Account/MAXXXXXXXXXXXXXXXXXX/Verification/Address/', + method: 'POST', + data: { + phone_number_country: 'US', + number_type: 'local', salutation: 'Mr', first_name: 'Bruce', last_name: 'Wayne', @@ -86,11 +144,13 @@ def to_json_list(list_object) city: 'New York', region: 'NY', postal_code: '12345', - address_proof_type: 'others', + country_iso: 'US', callback_url: 'https://callback.url', - auto_correct_address: true + proof_type: 'passport' }) end +end + it 'fetches details of an address' do contents = File.read(Dir.pwd + '/spec/mocks/addressGetResponse.json') @@ -127,7 +187,7 @@ def to_json_list(list_object) contents = File.read(Dir.pwd + '/spec/mocks/addressUpdateResponse.json') mock(200, JSON.parse(contents)) expect(JSON.parse(to_json_update(@api.addresses - .update(id, nil, { + .update(id, { salutation: 'Mr', first_name: 'Bruce' })))) diff --git a/spec/resource_identities_spec.rb b/spec/resource_identities_spec.rb index 2834ef21..318ea4fa 100644 --- a/spec/resource_identities_spec.rb +++ b/spec/resource_identities_spec.rb @@ -49,55 +49,126 @@ def to_json_list(list_object) }.to_json end - it 'creates an identity' do - contents = File.read(Dir.pwd + '/spec/mocks/identityCreateResponse.json') - mock(200, JSON.parse(contents)) + describe 'create an identity' do + it 'creates an idenity sucessfully' do + contents = File.read(Dir.pwd + '/spec/mocks/identityCreateSuccessResponse.json') + mock(200, JSON.parse(contents)) - expect(JSON.parse(to_json_create(@api.identities - .create( - 'US', - 'Mr', - 'Bruce', - 'Wayne', - 'Gotham City', - '1900-01-01', - 'US', - 'American', - '1900-01-01', - 'others', - 'BATMANRETURNS', - '1234', - 'Wayne Towers', - 'New York', - 'NY', - '12345', - nil, - { - callback_url: 'https://callback.url', - } - )))) - .to eql(JSON.parse(contents).reject { |_, v| v.nil? }) - compare_requests(uri: '/v1/Account/MAXXXXXXXXXXXXXXXXXX/Verification/Identity/', - method: 'POST', - data: { - country_iso: 'US', - salutation: 'Mr', - first_name: 'Bruce', - last_name: 'Wayne', - birth_place: 'Gotham City', - birth_date: '1900-01-01', - nationality: 'US', - id_nationality: 'American', - id_issue_date: '1900-01-01', - id_type: 'others', - id_number: 'BATMANRETURNS', - address_line1: '1234', - address_line2: 'Wayne Towers', - city: 'New York', - region: 'NY', - postal_code: '12345', - callback_url: 'https://callback.url' - }) + expect(JSON.parse(to_json_create(@api.identities + .create( + 'US', + 'local', + 'Mr', + 'Bruce', + 'Wayne', + '1234', + 'Wayne Towers', + 'New York', + 'NY', + '12345', + 'US', + 'passport', + '123456', + 'US', + { + callback_url: 'https://callback.url', + birth_date: '1900-01-01', + birth_place: 'Gotham City' + } + )))) + .to eql(JSON.parse(contents).reject { |_, v| v.nil? }) + compare_requests(uri: '/v1/Account/MAXXXXXXXXXXXXXXXXXX/Verification/Identity/', + method: 'POST', + data: { + phone_number_country: 'US', + number_type: 'local', + salutation: 'Mr', + first_name: 'Bruce', + last_name: 'Wayne', + address_line1: '1234', + address_line2: 'Wayne Towers', + city: 'New York', + region: 'NY', + postal_code: '12345', + country_iso: 'US', + proof_type: 'passport', + id_number: '123456', + nationality: 'US', + callback_url: 'https://callback.url', + birth_date: '1900-01-01', + birth_place: 'Gotham City' + }) + end + + it "raises exception: in case of mandatory param - fiscal_identification_code is mandatory when country_iso is Spain" do + expect{@api.identities.create('ES', + 'local', + 'Mr', + 'Bruce', + 'Wayne', + '1234', + 'Wayne Towers', + 'New York', + 'NY', + '12345', + 'ES', + 'passport', + '123456', + 'ES', + { + callback_url: 'https://callback.url', + birth_date: '1900-01-01', + birth_place: 'Gotham City' + } + )}.to raise_error(Plivo::Exceptions::InvalidRequestError) + end + + it "returns error: in case of invalid value for param" do + contents = File.read(Dir.pwd + '/spec/mocks/identityCreateErrorResponse.json') + mock(405, JSON.parse(contents)) + expect{@api.identities.create('US', + 'local', + 'Mr', + 'Bruce', + 'Wayne', + '1234', + 'Wayne Towers', + 'New York', + 'NY', + '12345', + 'US', + 'passport', + '123456', + 'US', + { + callback_url: 'https://callback.url', + birth_date: '1900-01-01', + birth_place: 'Gotham City' + } + )}.to raise_error(Plivo::Exceptions::InvalidRequestError) + compare_requests(uri: '/v1/Account/MAXXXXXXXXXXXXXXXXXX/Verification/Identity/', + method: 'POST', + data: { + phone_number_country: 'US', + number_type: 'local', + salutation: 'Mr', + first_name: 'Bruce', + last_name: 'Wayne', + address_line1: '1234', + address_line2: 'Wayne Towers', + city: 'New York', + region: 'NY', + postal_code: '12345', + country_iso: 'US', + proof_type: 'passport', + id_number: '123456', + nationality: 'US', + callback_url: 'https://callback.url', + birth_date: '1900-01-01', + birth_place: 'Gotham City' + }) + + end end it 'fetches details of an identity' do @@ -135,7 +206,7 @@ def to_json_list(list_object) contents = File.read(Dir.pwd + '/spec/mocks/identityUpdateResponse.json') mock(200, JSON.parse(contents)) expect(JSON.parse(to_json_update(@api.identities - .update(id, nil, + .update(id, { salutation: 'Mr', first_name: 'Bruce' From 1af3f65221ee135ee6d110e091c25f575a62e2c9 Mon Sep 17 00:00:00 2001 From: Richa Verma Date: Thu, 31 Jan 2019 01:59:09 +0530 Subject: [PATCH 2/4] test fixes --- lib/plivo/resources/addresses.rb | 1 + lib/plivo/resources/identities.rb | 30 ++++++++++++------------------ 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/lib/plivo/resources/addresses.rb b/lib/plivo/resources/addresses.rb index 0e4fcd67..b5debd8c 100644 --- a/lib/plivo/resources/addresses.rb +++ b/lib/plivo/resources/addresses.rb @@ -246,6 +246,7 @@ def create(phone_number_country, number_type, salutation, first_name, last_name, postal_code: postal_code, country_iso: country_iso, } + return perform_create(params, true) if options.nil? if country_iso == 'ES' valid_param?(:fiscal_identification_code, options[:fiscal_identification_code], [String, Symbol], true) diff --git a/lib/plivo/resources/identities.rb b/lib/plivo/resources/identities.rb index ab987de6..87819a57 100644 --- a/lib/plivo/resources/identities.rb +++ b/lib/plivo/resources/identities.rb @@ -101,16 +101,18 @@ def update(options = nil) 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, - id_number: @id_number, - id_type: @id_type, last_name: @last_name, - nationality: @nationality, + postal_code: @postal_code, + region: @region, salutation: @salutation, subaccount: @subaccount, url: @url, @@ -229,7 +231,6 @@ def create(phone_number_country, number_type, salutation, first_name, last_name, valid_param?(:region, region, [String, Symbol], true) valid_param?(:postal_code, postal_code, [String, Symbol], true) valid_param?(:country_iso, country_iso, [String, Symbol], true) - valid_param?(:proof_type, proof_type, [String, Symbol], true) valid_param?(:id_number, id_number, [String, Symbol], true) valid_param?(:nationality, nationality, [String, Symbol], true) @@ -245,11 +246,11 @@ def create(phone_number_country, number_type, salutation, first_name, last_name, region: region, postal_code: postal_code, country_iso: country_iso, - proof_type: proof_type, id_number: id_number, nationality: nationality } + return perform_create(params, true) if options.nil? unless options[:file].nil? file_extension = options[:file].split('.')[-1].downcase @@ -269,24 +270,17 @@ def create(phone_number_country, number_type, salutation, first_name, last_name, if country_iso == 'ES' valid_param?(:fiscal_identification_code, options[:fiscal_identification_code], [String, Symbol], true) + valid_param?(:proof_type, proof_type, [String, Symbol], true, ['NIF', 'NIE', 'DNI']) + params[:proof_type] = proof_type params[:fiscal_identification_code] = options[:fiscal_identification_code] - end - - if country_iso == 'DK' + elsif country_iso == 'DK' valid_param?(:street_code, options[:street_code], [String, Symbol], true) valid_param?(:municipal_code, options[:municipal_code], [String, Symbol], true) - params[:street_code] = options[:street_code] params[:municipal_code] = options[:municipal_code] - end - - if options[:proof_type] - if country_iso == 'ES' - valid_param?(:proof_type, options[:proof_type], [String, Symbol], false, ['NIF', 'NIE', 'DNI']) - else - valid_param?(:proof_type, options[:proof_type], [String, Symbol], false, ['national_id', 'passport', 'business_id']) - end - params[:proof_type] = options[:proof_type] + else + valid_param?(:proof_type, proof_type, [String, Symbol], true, ['national_id', 'passport', 'business_id']) + params[:proof_type] = proof_type end %i[callback_url alias id_nationality birth_place birth_date id_issue_date business_name fiscal_identification_code street_code municipal_code] From 3acb48f0bd2f96637bb2d9c7226286aaa885acf2 Mon Sep 17 00:00:00 2001 From: Richa Verma Date: Thu, 14 Feb 2019 17:26:39 +0530 Subject: [PATCH 3/4] updated default values for proof_type parameter --- lib/plivo/resources/addresses.rb | 6 +++--- lib/plivo/resources/identities.rb | 4 ++-- spec/resource_addresses_spec.rb | 10 +++++----- spec/resource_identities_spec.rb | 10 +++++----- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/plivo/resources/addresses.rb b/lib/plivo/resources/addresses.rb index b5debd8c..e8ea3a39 100644 --- a/lib/plivo/resources/addresses.rb +++ b/lib/plivo/resources/addresses.rb @@ -74,10 +74,10 @@ def update(options = nil) if options[:country_iso] == 'ES' valid_param?(:proof_type, options[:proof_type], [String, Symbol], false, ['NIF', 'NIE', 'DNI']) else - valid_param?(:proof_type, options[:proof_type], [String, Symbol], false, ['national_id', 'passport', 'business_id']) + valid_param?(:proof_type, options[:proof_type], [String, Symbol], false, ['NATIONAL_ID_CARD', 'PASSPORT', 'BUSINESS_REGISTRATION', 'any']) end else - valid_param?(:proof_type, options[:proof_type], [String, Symbol], false, ['NIF', 'NIE', 'DNI', 'national_id', 'passport', 'business_id']) + valid_param?(:proof_type, options[:proof_type], [String, Symbol], false, ['NIF', 'NIE', 'DNI', 'NATIONAL_ID_CARD', 'PASSPORT', 'BUSINESS_REGISTRATION', 'any']) end params[:proof_type] = options[:proof_type] end @@ -265,7 +265,7 @@ def create(phone_number_country, number_type, salutation, first_name, last_name, if country_iso == 'ES' valid_param?(:proof_type, options[:proof_type], [String, Symbol], false, ['NIF', 'NIE', 'DNI']) else - valid_param?(:proof_type, options[:proof_type], [String, Symbol], false, ['national_id', 'passport', 'business_id']) + valid_param?(:proof_type, options[:proof_type], [String, Symbol], false, ['NATIONAL_ID_CARD', 'PASSPORT', 'BUSINESS_REGISTRATION', 'any']) end params[:proof_type] = options[:proof_type] end diff --git a/lib/plivo/resources/identities.rb b/lib/plivo/resources/identities.rb index 87819a57..2f74ff89 100644 --- a/lib/plivo/resources/identities.rb +++ b/lib/plivo/resources/identities.rb @@ -71,7 +71,7 @@ def update(options = nil) if options[:country_iso] == 'ES' valid_param?(:proof_type, options[:proof_type], [String, Symbol], false, ['NIF', 'NIE', 'DNI']) else - valid_param?(:proof_type, options[:proof_type], [String, Symbol], false, ['national_id', 'passport', 'business_id']) + valid_param?(:proof_type, options[:proof_type], [String, Symbol], false, ['NATIONAL_ID_CARD', 'PASSPORT', 'BUSINESS_REGISTRATION', 'any']) end else valid_param?(:proof_type, options[:proof_type], [String, Symbol], false, ['NIF', 'NIE', 'DNI', 'national_id', 'passport', 'business_id']) @@ -279,7 +279,7 @@ def create(phone_number_country, number_type, salutation, first_name, last_name, params[:street_code] = options[:street_code] params[:municipal_code] = options[:municipal_code] else - valid_param?(:proof_type, proof_type, [String, Symbol], true, ['national_id', 'passport', 'business_id']) + valid_param?(:proof_type, proof_type, [String, Symbol], true, ['NATIONAL_ID_CARD', 'PASSPORT', 'BUSINESS_REGISTRATION', 'any']) params[:proof_type] = proof_type end diff --git a/spec/resource_addresses_spec.rb b/spec/resource_addresses_spec.rb index b04d902b..3a15ca06 100644 --- a/spec/resource_addresses_spec.rb +++ b/spec/resource_addresses_spec.rb @@ -70,7 +70,7 @@ def to_json_list(list_object) 'US', { callback_url: 'https://callback.url', - proof_type: 'passport' + proof_type: 'PASSPORT' } )))) .to eql(JSON.parse(contents).reject { |_, v| v.nil? }) @@ -89,7 +89,7 @@ def to_json_list(list_object) postal_code: '12345', country_iso: 'US', callback_url: 'https://callback.url', - proof_type: 'passport' + proof_type: 'PASSPORT' }) end @@ -107,7 +107,7 @@ def to_json_list(list_object) 'ES', { callback_url: 'https://callback.url', - proof_type: 'passport' + proof_type: 'PASSPORT' } )}.to raise_error(Plivo::Exceptions::InvalidRequestError) end @@ -128,7 +128,7 @@ def to_json_list(list_object) 'US', { callback_url: 'https://callback.url', - proof_type: 'passport' + proof_type: 'PASSPORT' } )}.to raise_error(Plivo::Exceptions::InvalidRequestError) compare_requests(uri: '/v1/Account/MAXXXXXXXXXXXXXXXXXX/Verification/Address/', @@ -146,7 +146,7 @@ def to_json_list(list_object) postal_code: '12345', country_iso: 'US', callback_url: 'https://callback.url', - proof_type: 'passport' + proof_type: 'PASSPORT' }) end end diff --git a/spec/resource_identities_spec.rb b/spec/resource_identities_spec.rb index 318ea4fa..8f2dc641 100644 --- a/spec/resource_identities_spec.rb +++ b/spec/resource_identities_spec.rb @@ -67,7 +67,7 @@ def to_json_list(list_object) 'NY', '12345', 'US', - 'passport', + 'PASSPORT', '123456', 'US', { @@ -91,7 +91,7 @@ def to_json_list(list_object) region: 'NY', postal_code: '12345', country_iso: 'US', - proof_type: 'passport', + proof_type: 'PASSPORT', id_number: '123456', nationality: 'US', callback_url: 'https://callback.url', @@ -112,7 +112,7 @@ def to_json_list(list_object) 'NY', '12345', 'ES', - 'passport', + 'PASSPORT', '123456', 'ES', { @@ -137,7 +137,7 @@ def to_json_list(list_object) 'NY', '12345', 'US', - 'passport', + 'PASSPORT', '123456', 'US', { @@ -160,7 +160,7 @@ def to_json_list(list_object) region: 'NY', postal_code: '12345', country_iso: 'US', - proof_type: 'passport', + proof_type: 'PASSPORT', id_number: '123456', nationality: 'US', callback_url: 'https://callback.url', From c75815410f261c67ad2adbed1ddde56e2c25cb2c Mon Sep 17 00:00:00 2001 From: Richa Verma Date: Fri, 29 Mar 2019 18:43:45 +0530 Subject: [PATCH 4/4] added parameter validations --- lib/plivo/resources/addresses.rb | 8 ++++++++ lib/plivo/resources/identities.rb | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/lib/plivo/resources/addresses.rb b/lib/plivo/resources/addresses.rb index e8ea3a39..d6b5ba04 100644 --- a/lib/plivo/resources/addresses.rb +++ b/lib/plivo/resources/addresses.rb @@ -43,6 +43,8 @@ def update(options = nil) params = {} unless options.nil? + valid_param?(:options, options, Hash, true) + %i[first_name last_name country_iso address_line1 address_line2 city region postal_code alias callback_url phone_number_country fiscal_identification_code street_code municipal_code file id_number] .each do |param| if options.key?(param) && @@ -83,6 +85,7 @@ def update(options = nil) end unless options[:file].nil? + valid_param?(:file, options[:file], [String, Symbol], true) file_extension = options[:file].split('.')[-1] content_type = case file_extension @@ -158,6 +161,7 @@ def list(options=nil) return perform_list if options.nil? params = {} + valid_param?(:options, options, Hash, true) %i[country_iso customer_name alias].each do |param| if options.key?(param) && valid_param?(param, options[param], @@ -248,6 +252,8 @@ def create(phone_number_country, number_type, salutation, first_name, last_name, } return perform_create(params, true) if options.nil? + valid_param?(:options, options, Hash, true) + if country_iso == 'ES' valid_param?(:fiscal_identification_code, options[:fiscal_identification_code], [String, Symbol], true) params[:fiscal_identification_code] = options[:fiscal_identification_code] @@ -272,6 +278,7 @@ def create(phone_number_country, number_type, salutation, first_name, last_name, unless options[:file].nil? + valid_param?(:file, options[:file], [String, Symbol], true) file_extension = options[:file].split('.')[-1].downcase content_type = case file_extension @@ -326,6 +333,7 @@ def create(phone_number_country, number_type, salutation, first_name, last_name, # @option options [String] :callback_url - The callback URL that gets the result of address creation POSTed to. # @return [Address] Address def update(address_id, options=nil) + valid_param?(:address_id, address_id, [String, Symbol], true) Address.new(@_client,resource_id: address_id).update(options) end diff --git a/lib/plivo/resources/identities.rb b/lib/plivo/resources/identities.rb index 2f74ff89..df56d8b2 100644 --- a/lib/plivo/resources/identities.rb +++ b/lib/plivo/resources/identities.rb @@ -47,6 +47,8 @@ def update(options = nil) params = {} unless options.nil? + valid_param?(:options, options, Hash, true) + %i[phone_number_country first_name last_name address_line1 address_line2 city region postal_code country_iso id_number nationality callback_url alias id_nationality birth_place birth_date id_issue_date business_name fiscal_identification_code street_code municipal_code] .each do |param| @@ -79,6 +81,7 @@ def update(options = nil) params[:proof_type] = options[:proof_type] end unless options[:file].nil? + valid_param?(:file, options[:file], [String, Symbol], true) file_extension = options[:file].split('.')[-1].downcase # add check on file size content_type = case file_extension @@ -152,6 +155,7 @@ def get(identity_id) def list(options=nil) return perform_list if options.nil? + valid_param?(:options, options, Hash, true) params = {} %i[country_iso customer_name alias].each do |param| @@ -251,7 +255,9 @@ def create(phone_number_country, number_type, salutation, first_name, last_name, } return perform_create(params, true) if options.nil? + valid_param?(:options, options, Hash, true) unless options[:file].nil? + valid_param?(:file, options[:file], [String, Symbol], true) file_extension = options[:file].split('.')[-1].downcase content_type = case file_extension @@ -323,6 +329,7 @@ def create(phone_number_country, number_type, salutation, first_name, last_name, # @option options [String] :municipal_code - Municipal code of the address # @return [Identity] Identity def update(identity_id, options=nil) + valid_param?(:identity_id, identity_id, [String, Symbol], true) Identity.new(@_client, resource_id: identity_id).update(options) end