Class: Wavix::Numbers::Papers::Client
- Inherits:
-
Object
- Object
- Wavix::Numbers::Papers::Client
- Defined in:
- lib/wavix/numbers/papers/client.rb
Instance Method Summary collapse
- #initialize(client:) ⇒ void constructor
-
#upload(request_options: {}, **params) ⇒ Array[Wavix::Types::NumberDocument]
Uploads a verification document for one or more phone numbers.
Constructor Details
#initialize(client:) ⇒ void
10 11 12 |
# File 'lib/wavix/numbers/papers/client.rb', line 10 def initialize(client:) @client = client end |
Instance Method Details
#upload(request_options: {}, **params) ⇒ Array[Wavix::Types::NumberDocument]
Uploads a verification document for one or more phone numbers. Uploaded files must meet the following requirements:
- Allowed formats: PNG, JPG, JPEG, TIFF, BMP, or PDF
- Maximum file size: 10 MB
- Files can't be password protected
- PDF files must not contain digital signatures
30 31 32 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 |
# File 'lib/wavix/numbers/papers/client.rb', line 30 def upload(request_options: {}, **params) params = Wavix::Internal::Types::Utils.normalize_keys(params) body = Internal::Multipart::FormData.new if params[:did_ids] body.add( name: "did_ids", value: params[:did_ids] ) end body.add_part(params[:doc_attachment].to_form_data_part(name: "doc_attachment")) if params[:doc_attachment] if params[:doc_id] body.add( name: "doc_id", value: params[:doc_id] ) end request = Wavix::Internal::Multipart::Request.new( base_url: [:base_url], method: "POST", path: "v1/numbers/papers", body: body, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Wavix::Errors::TimeoutError end code = response.code.to_i return if code.between?(200, 299) error_class = Wavix::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end |