active_call-doc_fox 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +70 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +355 -0
- data/Rakefile +12 -0
- data/lib/active_call-doc_fox.rb +3 -0
- data/lib/doc_fox/access_token/facade.rb +12 -0
- data/lib/doc_fox/access_token/get_service.rb +62 -0
- data/lib/doc_fox/authentication/facade.rb +12 -0
- data/lib/doc_fox/authentication/get_service.rb +41 -0
- data/lib/doc_fox/base_service.rb +79 -0
- data/lib/doc_fox/concerns/enumerable.rb +65 -0
- data/lib/doc_fox/error.rb +67 -0
- data/lib/doc_fox/kyc_application/approve_service.rb +53 -0
- data/lib/doc_fox/kyc_application/archive_service.rb +43 -0
- data/lib/doc_fox/kyc_application/create_service.rb +61 -0
- data/lib/doc_fox/kyc_application/delete_service.rb +29 -0
- data/lib/doc_fox/kyc_application/facade.rb +22 -0
- data/lib/doc_fox/kyc_application/get_service.rb +52 -0
- data/lib/doc_fox/kyc_application/list_service.rb +46 -0
- data/lib/doc_fox/kyc_application/transfer_service.rb +56 -0
- data/lib/doc_fox/kyc_application/unapprove_service.rb +56 -0
- data/lib/doc_fox/kyc_application/unarchive_service.rb +43 -0
- data/lib/doc_fox/kyc_entity_template/facade.rb +17 -0
- data/lib/doc_fox/kyc_entity_template/get_service.rb +43 -0
- data/lib/doc_fox/kyc_entity_template/list_service.rb +28 -0
- data/lib/doc_fox/user/facade.rb +16 -0
- data/lib/doc_fox/user/get_service.rb +43 -0
- data/lib/doc_fox/user/list_service.rb +28 -0
- data/lib/doc_fox/version.rb +5 -0
- data/lib/doc_fox.rb +16 -0
- data/sig/doc_fox.rbs +4 -0
- metadata +109 -0
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DocFox::Enumerable
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
include Enumerable
|
8
|
+
|
9
|
+
attr_reader :path, :facade_klass, :page, :per_page
|
10
|
+
|
11
|
+
validates :path, :facade_klass, presence: true
|
12
|
+
validates :page, :per_page, presence: true, numericality: { greater_than_or_equal_to: 1 }
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(path:, facade_klass:, page: 1, per_page: Float::INFINITY)
|
16
|
+
@path = path
|
17
|
+
@facade_klass = facade_klass
|
18
|
+
@page = page
|
19
|
+
@per_page = per_page
|
20
|
+
end
|
21
|
+
|
22
|
+
def call
|
23
|
+
self
|
24
|
+
end
|
25
|
+
|
26
|
+
def each
|
27
|
+
return to_enum(:each) unless block_given?
|
28
|
+
return if invalid?
|
29
|
+
|
30
|
+
total = 0
|
31
|
+
|
32
|
+
catch :list_end do
|
33
|
+
loop do
|
34
|
+
@response = connection.get(path, params)
|
35
|
+
validate(:response)
|
36
|
+
|
37
|
+
unless success?
|
38
|
+
raise exception_for(response, errors) if bang?
|
39
|
+
|
40
|
+
throw :list_end
|
41
|
+
end
|
42
|
+
|
43
|
+
response.body['data'].each do |hash|
|
44
|
+
yield facade_klass.new(hash)
|
45
|
+
total += 1
|
46
|
+
throw :list_end if total >= per_page
|
47
|
+
end
|
48
|
+
|
49
|
+
break if total >= response.body.dig('meta', 'total')
|
50
|
+
|
51
|
+
@_params[:page] = response.body.dig('meta', 'page') + 1
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def params
|
59
|
+
@_params ||= { page: page, per_page: max_per_page_per_request }
|
60
|
+
end
|
61
|
+
|
62
|
+
def max_per_page_per_request
|
63
|
+
@_max_per_page_per_request ||= per_page.infinite? ? 100 : [per_page, 100].min
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DocFox
|
4
|
+
class Error < StandardError; end
|
5
|
+
|
6
|
+
class ValidationError < Error
|
7
|
+
include ActiveCall::ValidationErrorable
|
8
|
+
end
|
9
|
+
|
10
|
+
class RequestError < Error
|
11
|
+
include ActiveCall::RequestErrorable
|
12
|
+
end
|
13
|
+
|
14
|
+
# 400..499
|
15
|
+
class ClientError < RequestError; end
|
16
|
+
|
17
|
+
# 400
|
18
|
+
class BadRequestError < ClientError; end
|
19
|
+
|
20
|
+
# 401
|
21
|
+
class UnauthorizedError < ClientError; end
|
22
|
+
|
23
|
+
# 403
|
24
|
+
class ForbiddenError < ClientError; end
|
25
|
+
|
26
|
+
# 404
|
27
|
+
class NotFoundError < ClientError; end
|
28
|
+
|
29
|
+
# 406
|
30
|
+
class NotAcceptableError < ClientError; end
|
31
|
+
|
32
|
+
# 407
|
33
|
+
class ProxyAuthenticationRequiredError < ClientError; end
|
34
|
+
|
35
|
+
# 408
|
36
|
+
class RequestTimeoutError < ClientError; end
|
37
|
+
|
38
|
+
# 409
|
39
|
+
class ConflictError < ClientError; end
|
40
|
+
|
41
|
+
# 410
|
42
|
+
class GoneError < ClientError; end
|
43
|
+
|
44
|
+
# 422
|
45
|
+
class UnprocessableEntityError < ClientError; end
|
46
|
+
|
47
|
+
# 429
|
48
|
+
class TooManyRequestsError < ClientError; end
|
49
|
+
|
50
|
+
# 500..599
|
51
|
+
class ServerError < RequestError; end
|
52
|
+
|
53
|
+
# 500
|
54
|
+
class InternalServerError < ServerError; end
|
55
|
+
|
56
|
+
# 501
|
57
|
+
class NotImplementedError < ServerError; end
|
58
|
+
|
59
|
+
# 502
|
60
|
+
class BadGatewayError < ServerError; end
|
61
|
+
|
62
|
+
# 503
|
63
|
+
class ServiceUnavailableError < ServerError; end
|
64
|
+
|
65
|
+
# 504
|
66
|
+
class GatewayTimeoutError < ServerError; end
|
67
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class DocFox::KycApplication::ApproveService < DocFox::BaseService
|
4
|
+
attr_reader :id
|
5
|
+
|
6
|
+
validates :id, presence: true
|
7
|
+
|
8
|
+
after_call :set_facade
|
9
|
+
|
10
|
+
delegate_missing_to :@facade
|
11
|
+
|
12
|
+
def initialize(id:)
|
13
|
+
@id = id
|
14
|
+
end
|
15
|
+
|
16
|
+
# Approve a KYC application.
|
17
|
+
#
|
18
|
+
# ==== Examples
|
19
|
+
#
|
20
|
+
# service = DocFox::KycApplication::ApproveService.call(id: '')
|
21
|
+
#
|
22
|
+
# service.success? # => true
|
23
|
+
# service.errors # => #<ActiveModel::Errors []>
|
24
|
+
#
|
25
|
+
# service.response # => #<Faraday::Response ...>
|
26
|
+
# service.response.status # => 200
|
27
|
+
# service.response.body # => {}
|
28
|
+
#
|
29
|
+
# service.facade # => #<DocFox::KycApplication::Facade ...>
|
30
|
+
# service.facade.id
|
31
|
+
# service.id
|
32
|
+
#
|
33
|
+
# PATCH /api/v2/kyc_applications/:id/approve
|
34
|
+
def call
|
35
|
+
connection.patch("kyc_applications/#{id}/approve", **params)
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def params
|
41
|
+
{
|
42
|
+
data: {
|
43
|
+
type: 'kyc_application',
|
44
|
+
id: id,
|
45
|
+
attributes: {}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
def set_facade
|
51
|
+
@facade = DocFox::KycApplication::Facade.new(response.body)
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class DocFox::KycApplication::ArchiveService < DocFox::BaseService
|
4
|
+
attr_reader :id, :reason
|
5
|
+
|
6
|
+
validates :id, :reason, presence: true
|
7
|
+
|
8
|
+
def initialize(id:, reason:)
|
9
|
+
@id = id
|
10
|
+
@reason = reason
|
11
|
+
end
|
12
|
+
|
13
|
+
# Archive a KYC application.
|
14
|
+
#
|
15
|
+
# ==== Examples
|
16
|
+
#
|
17
|
+
# service = DocFox::KycApplication::ArchiveService.call(id: '', reason: '')
|
18
|
+
#
|
19
|
+
# service.success? # => true
|
20
|
+
# service.errors # => #<ActiveModel::Errors []>
|
21
|
+
#
|
22
|
+
# service.response # => #<Faraday::Response ...>
|
23
|
+
# service.response.status # => 204
|
24
|
+
# service.response.body # => ""
|
25
|
+
#
|
26
|
+
# POST /api/v2/kyc_applications/:id/archive
|
27
|
+
def call
|
28
|
+
connection.post("kyc_applications/#{id}/archive", **params)
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def params
|
34
|
+
{
|
35
|
+
data: {
|
36
|
+
type: 'application_archiving',
|
37
|
+
attributes: {
|
38
|
+
reason: reason
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class DocFox::KycApplication::CreateService < DocFox::BaseService
|
4
|
+
attr_reader :data
|
5
|
+
|
6
|
+
validates :data, presence: true
|
7
|
+
|
8
|
+
after_call :set_facade
|
9
|
+
|
10
|
+
delegate_missing_to :@facade
|
11
|
+
|
12
|
+
def initialize(data:)
|
13
|
+
@data = data
|
14
|
+
end
|
15
|
+
|
16
|
+
# Create a KYC application.
|
17
|
+
#
|
18
|
+
# ==== Examples
|
19
|
+
#
|
20
|
+
# service = DocFox::KycApplication::CreateService.call(
|
21
|
+
# data: {
|
22
|
+
# type: 'kyc_application',
|
23
|
+
# attributes: {
|
24
|
+
# kyc_entity_template_id: 'aaaaaaaa-1111-2222-3333-bbbbbbbbbbbb',
|
25
|
+
# names: {
|
26
|
+
# first_names: 'Eric Theodore',
|
27
|
+
# last_names: 'Cartman'
|
28
|
+
# },
|
29
|
+
# # ...more fields following the schema definitions.
|
30
|
+
# }
|
31
|
+
# }
|
32
|
+
# )
|
33
|
+
#
|
34
|
+
# service.success? # => true
|
35
|
+
# service.errors # => #<ActiveModel::Errors []>
|
36
|
+
#
|
37
|
+
# service.response # => #<Faraday::Response ...>
|
38
|
+
# service.response.status # => 201
|
39
|
+
# service.response.body # => {}
|
40
|
+
#
|
41
|
+
# service.facade # => #<DocFox::KycApplication::Facade ...>
|
42
|
+
# service.facade.id
|
43
|
+
# service.id
|
44
|
+
#
|
45
|
+
# POST /api/v2/kyc_applications
|
46
|
+
def call
|
47
|
+
connection.post('kyc_applications', **params)
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def params
|
53
|
+
{
|
54
|
+
data: data
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
def set_facade
|
59
|
+
@facade = DocFox::KycApplication::Facade.new(response.body)
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class DocFox::KycApplication::DeleteService < DocFox::BaseService
|
4
|
+
attr_reader :id
|
5
|
+
|
6
|
+
validates :id, presence: true
|
7
|
+
|
8
|
+
def initialize(id:)
|
9
|
+
@id = id
|
10
|
+
end
|
11
|
+
|
12
|
+
# Delete a KYC application.
|
13
|
+
#
|
14
|
+
# ==== Examples
|
15
|
+
#
|
16
|
+
# service = DocFox::KycApplication::DeleteService.call(id: '')
|
17
|
+
#
|
18
|
+
# service.success? # => true
|
19
|
+
# service.errors # => #<ActiveModel::Errors []>
|
20
|
+
#
|
21
|
+
# service.response # => #<Faraday::Response ...>
|
22
|
+
# service.response.status # => 204
|
23
|
+
# service.response.body # => ""
|
24
|
+
#
|
25
|
+
# DELETE /api/v2/kyc_applications/:id
|
26
|
+
def call
|
27
|
+
connection.delete("kyc_applications/#{id}")
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class DocFox::KycApplication::Facade
|
4
|
+
attr_reader :id, :attributes, :relationships, :included, :approved_at, :archived, :archived_reason, :created_at,
|
5
|
+
:kyc_entity_type_name, :renew_at, :status, :updated_at
|
6
|
+
|
7
|
+
def initialize(hash)
|
8
|
+
@id = hash.dig('data', 'id') || hash['id']
|
9
|
+
@attributes = hash.dig('data', 'attributes') || hash['attributes']
|
10
|
+
@relationships = hash.dig('data', 'relationships') || hash['relationships']
|
11
|
+
@included = hash['included']
|
12
|
+
|
13
|
+
@approved_at = attributes['approved_at']
|
14
|
+
@archived = attributes['archived']
|
15
|
+
@archived_reason = attributes['archived_reason']
|
16
|
+
@created_at = attributes['created_at']
|
17
|
+
@kyc_entity_type_name = attributes['kyc_entity_type_name']
|
18
|
+
@renew_at = attributes['renew_at']
|
19
|
+
@status = attributes['status']
|
20
|
+
@updated_at = attributes['updated_at']
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class DocFox::KycApplication::GetService < DocFox::BaseService
|
4
|
+
attr_reader :id, :params
|
5
|
+
|
6
|
+
after_call :set_facade
|
7
|
+
|
8
|
+
delegate_missing_to :@facade
|
9
|
+
|
10
|
+
validates :id, presence: true
|
11
|
+
|
12
|
+
def initialize(id:, params: {})
|
13
|
+
@id = id
|
14
|
+
@params = params
|
15
|
+
end
|
16
|
+
|
17
|
+
# Get a KYC application.
|
18
|
+
#
|
19
|
+
# ==== Examples
|
20
|
+
#
|
21
|
+
# service = DocFox::KycApplication::GetService.call(id: '')
|
22
|
+
#
|
23
|
+
# service.success? # => true
|
24
|
+
# service.errors # => #<ActiveModel::Errors []>
|
25
|
+
#
|
26
|
+
# service.response # => #<Faraday::Response ...>
|
27
|
+
# service.response.status # => 200
|
28
|
+
# service.response.body # => {}
|
29
|
+
#
|
30
|
+
# service.facade # => #<DocFox::KycApplication::Facade ...>
|
31
|
+
# service.facade.id
|
32
|
+
# service.id
|
33
|
+
#
|
34
|
+
# service.relationships.dig('profile', 'data', 'id')
|
35
|
+
# service.relationships.dig('data_requirements', 'links', 'related')
|
36
|
+
#
|
37
|
+
# Include related resources.
|
38
|
+
#
|
39
|
+
# service = DocFox::KycApplication::GetService.call(id: '', params: { include: 'managed_by,profile.names' })
|
40
|
+
# service.included
|
41
|
+
#
|
42
|
+
# GET /api/v2/kyc_applications/:id
|
43
|
+
def call
|
44
|
+
connection.get("kyc_applications/#{id}", params)
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def set_facade
|
50
|
+
@facade = DocFox::KycApplication::Facade.new(response.body)
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class DocFox::KycApplication::ListService < DocFox::BaseService
|
4
|
+
include DocFox::Enumerable
|
5
|
+
|
6
|
+
attr_reader :search_term
|
7
|
+
|
8
|
+
# List KYC applications.
|
9
|
+
#
|
10
|
+
# ==== Examples
|
11
|
+
#
|
12
|
+
# service = DocFox::KycApplication::ListService.call.first
|
13
|
+
# service.id
|
14
|
+
# service.status
|
15
|
+
#
|
16
|
+
# If you don't provide the `per_page` argument, multiple API requests will be made untill all records have been
|
17
|
+
# returned. You could be rate limited, so use wisely.
|
18
|
+
#
|
19
|
+
# DocFox::KycApplication::ListService.call(page: 1, per_page: 10).map { _1 }
|
20
|
+
#
|
21
|
+
# Filter by names, numbers contact information or external refs.
|
22
|
+
#
|
23
|
+
# DocFox::KycApplication::ListService.call(search_term: 'eric.cartman@example.com').map { _1 }
|
24
|
+
#
|
25
|
+
# GET /api/v2/kyc_applications
|
26
|
+
def initialize(page: 1, per_page: Float::INFINITY, search_term: nil)
|
27
|
+
@search_term = search_term
|
28
|
+
|
29
|
+
super(
|
30
|
+
path: 'kyc_applications',
|
31
|
+
facade_klass: DocFox::KycApplication::Facade,
|
32
|
+
page: page,
|
33
|
+
per_page: per_page
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def params
|
40
|
+
@_params ||= begin
|
41
|
+
params = { page: page, per_page: max_per_page_per_request }
|
42
|
+
params[:filter] = { search_term: search_term } if search_term.present?
|
43
|
+
params
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class DocFox::KycApplication::TransferService < DocFox::BaseService
|
4
|
+
attr_reader :id, :transfer_to_user_id
|
5
|
+
|
6
|
+
validates :id, :transfer_to_user_id, presence: true
|
7
|
+
|
8
|
+
after_call :set_facade
|
9
|
+
|
10
|
+
delegate_missing_to :@facade
|
11
|
+
|
12
|
+
def initialize(id:, transfer_to_user_id:)
|
13
|
+
@id = id
|
14
|
+
@transfer_to_user_id = transfer_to_user_id
|
15
|
+
end
|
16
|
+
|
17
|
+
# Transfer a KYC application.
|
18
|
+
#
|
19
|
+
# ==== Examples
|
20
|
+
#
|
21
|
+
# service = DocFox::KycApplication::TransferService.call(id: '', transfer_to_user_id: '')
|
22
|
+
#
|
23
|
+
# service.success? # => true
|
24
|
+
# service.errors # => #<ActiveModel::Errors []>
|
25
|
+
#
|
26
|
+
# service.response # => #<Faraday::Response ...>
|
27
|
+
# service.response.status # => 200
|
28
|
+
# service.response.body # => {}
|
29
|
+
#
|
30
|
+
# service.facade # => #<DocFox::KycApplication::Facade ...>
|
31
|
+
# service.facade.id
|
32
|
+
# service.id
|
33
|
+
#
|
34
|
+
# PATCH /api/v2/kyc_applications/:id/transfer
|
35
|
+
def call
|
36
|
+
connection.patch("kyc_applications/#{id}/transfer", **params)
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def params
|
42
|
+
{
|
43
|
+
data: {
|
44
|
+
type: 'kyc_application',
|
45
|
+
id: id,
|
46
|
+
attributes: {
|
47
|
+
transfer_to_user_id: transfer_to_user_id
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
def set_facade
|
54
|
+
@facade = DocFox::KycApplication::Facade.new(response.body)
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class DocFox::KycApplication::UnapproveService < DocFox::BaseService
|
4
|
+
attr_reader :id, :reason
|
5
|
+
|
6
|
+
validates :id, :reason, presence: true
|
7
|
+
|
8
|
+
after_call :set_facade
|
9
|
+
|
10
|
+
delegate_missing_to :@facade
|
11
|
+
|
12
|
+
def initialize(id:, reason:)
|
13
|
+
@id = id
|
14
|
+
@reason = reason
|
15
|
+
end
|
16
|
+
|
17
|
+
# Unapprove a KYC application.
|
18
|
+
#
|
19
|
+
# ==== Examples
|
20
|
+
#
|
21
|
+
# service = DocFox::KycApplication::UnapproveService.call(id: '', reason: '')
|
22
|
+
#
|
23
|
+
# service.success? # => true
|
24
|
+
# service.errors # => #<ActiveModel::Errors []>
|
25
|
+
#
|
26
|
+
# service.response # => #<Faraday::Response ...>
|
27
|
+
# service.response.status # => 200
|
28
|
+
# service.response.body # => {}
|
29
|
+
#
|
30
|
+
# service.facade # => #<DocFox::KycApplication::Facade ...>
|
31
|
+
# service.facade.id
|
32
|
+
# service.id
|
33
|
+
#
|
34
|
+
# PATCH /api/v2/kyc_applications/:id/unapprove
|
35
|
+
def call
|
36
|
+
connection.patch("kyc_applications/#{id}/unapprove", **params)
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def params
|
42
|
+
{
|
43
|
+
data: {
|
44
|
+
type: 'kyc_application',
|
45
|
+
id: id,
|
46
|
+
attributes: {
|
47
|
+
reason: reason
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
def set_facade
|
54
|
+
@facade = DocFox::KycApplication::Facade.new(response.body)
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class DocFox::KycApplication::UnarchiveService < DocFox::BaseService
|
4
|
+
attr_reader :id, :reason
|
5
|
+
|
6
|
+
validates :id, :reason, presence: true
|
7
|
+
|
8
|
+
def initialize(id:, reason:)
|
9
|
+
@id = id
|
10
|
+
@reason = reason
|
11
|
+
end
|
12
|
+
|
13
|
+
# Unarchive a KYC application.
|
14
|
+
#
|
15
|
+
# ==== Examples
|
16
|
+
#
|
17
|
+
# service = DocFox::KycApplication::UnarchiveService.call(id: '', reason: '')
|
18
|
+
#
|
19
|
+
# service.success? # => true
|
20
|
+
# service.errors # => #<ActiveModel::Errors []>
|
21
|
+
#
|
22
|
+
# service.response # => #<Faraday::Response ...>
|
23
|
+
# service.response.status # => 204
|
24
|
+
# service.response.body # => ""
|
25
|
+
#
|
26
|
+
# POST /api/v2/kyc_applications/:id/unarchive
|
27
|
+
def call
|
28
|
+
connection.post("kyc_applications/#{id}/unarchive", **params)
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def params
|
34
|
+
{
|
35
|
+
data: {
|
36
|
+
type: 'application_archiving',
|
37
|
+
attributes: {
|
38
|
+
reason: reason
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class DocFox::KycEntityTemplate::Facade
|
4
|
+
attr_reader :id, :attributes, :created_at, :kyc_entity_type_name, :kyc_entity_type_category, :profile_schema,
|
5
|
+
:updated_at
|
6
|
+
|
7
|
+
def initialize(hash)
|
8
|
+
@id = hash.dig('data', 'id') || hash['id']
|
9
|
+
@attributes = hash.dig('data', 'attributes') || hash['attributes']
|
10
|
+
|
11
|
+
@created_at = attributes['created_at']
|
12
|
+
@kyc_entity_type_name = attributes['kyc_entity_type_name']
|
13
|
+
@kyc_entity_type_category = attributes['kyc_entity_type_category']
|
14
|
+
@profile_schema = attributes['profile_schema']
|
15
|
+
@updated_at = attributes['updated_at']
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class DocFox::KycEntityTemplate::GetService < DocFox::BaseService
|
4
|
+
attr_reader :id
|
5
|
+
|
6
|
+
after_call :set_facade
|
7
|
+
|
8
|
+
delegate_missing_to :@facade
|
9
|
+
|
10
|
+
validates :id, presence: true
|
11
|
+
|
12
|
+
def initialize(id:)
|
13
|
+
@id = id
|
14
|
+
end
|
15
|
+
|
16
|
+
# Get a KYC application.
|
17
|
+
#
|
18
|
+
# ==== Examples
|
19
|
+
#
|
20
|
+
# service = DocFox::KycEntityTemplate::GetService.call(id: '')
|
21
|
+
#
|
22
|
+
# service.success? # => true
|
23
|
+
# service.errors # => #<ActiveModel::Errors []>
|
24
|
+
#
|
25
|
+
# service.response # => #<Faraday::Response ...>
|
26
|
+
# service.response.status # => 200
|
27
|
+
# service.response.body # => {}
|
28
|
+
#
|
29
|
+
# service.facade # => #<DocFox::KycEntityTemplate::Facade ...>
|
30
|
+
# service.facade.id
|
31
|
+
# service.id
|
32
|
+
#
|
33
|
+
# GET /api/v2/kyc_entity_templates/:id
|
34
|
+
def call
|
35
|
+
connection.get("kyc_entity_templates/#{id}")
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def set_facade
|
41
|
+
@facade = DocFox::KycEntityTemplate::Facade.new(response.body)
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class DocFox::KycEntityTemplate::ListService < DocFox::BaseService
|
4
|
+
include DocFox::Enumerable
|
5
|
+
|
6
|
+
# List KYC entity templates.
|
7
|
+
#
|
8
|
+
# ==== Examples
|
9
|
+
#
|
10
|
+
# service = DocFox::KycEntityTemplate::ListService.call.first
|
11
|
+
# service.id
|
12
|
+
# service.kyc_entity_type_name
|
13
|
+
#
|
14
|
+
# If you don't provide the `per_page` argument, multiple API requests will be made untill all records have been
|
15
|
+
# returned. You could be rate limited, so use wisely.
|
16
|
+
#
|
17
|
+
# DocFox::KycEntityTemplate::ListService.call(page: 1, per_page: 10).map { _1 }
|
18
|
+
#
|
19
|
+
# GET /api/v2/kyc_entity_templates
|
20
|
+
def initialize(page: 1, per_page: Float::INFINITY)
|
21
|
+
super(
|
22
|
+
path: 'kyc_entity_templates',
|
23
|
+
facade_klass: DocFox::KycEntityTemplate::Facade,
|
24
|
+
page: page,
|
25
|
+
per_page: per_page
|
26
|
+
)
|
27
|
+
end
|
28
|
+
end
|