Class: MangoApi::KycDocuments

Inherits:
Object
  • Object
show all
Extended by:
UriProvider
Defined in:
lib/mangopay/api/service/kyc_documents.rb

Overview

Provides API method delegates concerning the KycDocument entity

Class Method Summary collapse

Methods included from UriProvider

provide_uri

Class Method Details

.all {|filter_request = FilterRequest.new| ... } ⇒ Array

Retrieves pages of KYC document entities belonging to current environment’s client. Allows configuration of paging and sorting parameters by yielding a filtering object to a provided block. When no filters are specified, will retrieve the first page of 10 newest results.

Allowed FilterRequest params:

  • page

  • per_page

  • sort_field and sort_direction

  • before_date

  • after_date

  • status

Yields:

Returns:

  • (Array)

    the requested entities



77
78
79
80
81
82
83
# File 'lib/mangopay/api/service/kyc_documents.rb', line 77

def all
  uri = provide_uri(:get_kyc_documents)
  filter_request = nil
  yield filter_request = FilterRequest.new if block_given?
  results = HttpClient.get(uri, filter_request)
  parse_docs results
end

.consult(id) ⇒ Array

Creates temporary URLs where each page of a KYC document can be viewed.

Parameters:

  • +id+ (String)

    ID of the KYC documents which to consult

Returns:

  • (Array)

    DocumentPageConsults for the document’s pages



113
114
115
116
117
# File 'lib/mangopay/api/service/kyc_documents.rb', line 113

def consult(id)
  uri = provide_uri(:consult_kyc_document, id)
  results = HttpClient.post(uri, nil)
  parse_consults results
end

.create(kyc_document, user_id, id_key = nil) ⇒ KycDocument

Creates a new KYC document entity.

KycDocument properties:

  • Required

    • type

  • Optional

    • tag

to be created created for

Parameters:

  • +kyc_document+ (KycDocument)

    model object of the KYC document

  • +user_id+ (String)

    ID of the user who the document is being

  • +id_key+ (String)

    idempotency key for future response replication

Returns:

  • (KycDocument)

    the newly-created KycDocument entity object



27
28
29
30
31
# File 'lib/mangopay/api/service/kyc_documents.rb', line 27

def create(kyc_document, user_id, id_key = nil)
  uri = provide_uri(:create_kyc_document, user_id)
  response = HttpClient.post(uri, kyc_document, id_key)
  parse response
end

.of_user(id) {|filter_request = FilterRequest.new| ... } ⇒ Array

Retrieves pages of KYC document entities belonging to a certain user entity. Allows configuration of paging and sorting parameters by yielding a filtering object to a provided block. When no filters are specified, will retrieve the first page of 10 newest results.

Allowed FilterRequest params:

  • page

  • per_page

  • sort_field and sort_direction

  • before_date

  • after_date

  • status

Parameters:

  • +id+ (String)

    ID of the user whose KYC documents to retrieve

Yields:

Returns:

  • (Array)

    the requested entities



100
101
102
103
104
105
106
# File 'lib/mangopay/api/service/kyc_documents.rb', line 100

def of_user(id)
  uri = provide_uri(:get_users_kyc_documents, id)
  filter_request = nil
  yield filter_request = FilterRequest.new if block_given?
  results = HttpClient.get(uri, filter_request)
  parse_docs results
end

.submit(id, user_id, tag = nil) ⇒ KycDocument

Submits a KYC document entity for approval.

submitted for

Parameters:

  • +id+ (String)

    ID of the KYC document to submit

  • +user_id+ (String)

    ID of the user who the document is being

  • +tag+ (String)

    custom data to add with the request

Returns:

  • (KycDocument)

    the submitted KycDocument entity object



55
56
57
58
59
60
# File 'lib/mangopay/api/service/kyc_documents.rb', line 55

def submit(id, user_id, tag = nil)
  uri = provide_uri(:submit_kyc_document, user_id, id)
  request = SubmitDocumentRequest.new(tag)
  response = HttpClient.put(uri, request)
  parse response
end

.upload_page(id, user_id, path) ⇒ Object

Uploads a KYC document page. Allowed file extensions: .pdf .jpeg .jpg .gif .png

is being uploaded for updated for

Parameters:

  • +id+ (String)

    ID of the KYC document entity that the page

  • +user_id+ (String)

    ID of the user who the document is being

  • +path+ (String)

    path of the KYC document page image



41
42
43
44
45
46
# File 'lib/mangopay/api/service/kyc_documents.rb', line 41

def upload_page(id, user_id, path)
  uri = provide_uri(:upload_kyc_document_page, user_id, id)
  body = UploadFileRequest.new
  body.file = FileEncoder.encode_base64 path
  HttpClient.post(uri, body)
end