unit_ruby_sdk 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -0
- data/Gemfile.lock +4 -3
- data/lib/unit/api_resources/application_resource.rb +51 -57
- data/lib/unit/api_resources/base_resource.rb +31 -25
- data/lib/unit/api_resources/customer_resource.rb +52 -50
- data/lib/unit/errors/unit_error.rb +11 -9
- data/lib/unit/models/application/create_business_application_request.rb +82 -0
- data/lib/unit/models/application/create_individual_application_request.rb +92 -0
- data/lib/unit/models/application/list_application_params.rb +42 -0
- data/lib/unit/models/application/patch_application_request.rb +33 -0
- data/lib/unit/models/application/upload_document_request.rb +27 -0
- data/lib/unit/models/customer/add_authorized_users_request.rb +31 -0
- data/lib/unit/models/customer/archive_customer_request.rb +30 -0
- data/lib/unit/models/customer/list_customer_params.rb +42 -0
- data/lib/unit/models/customer/patch_business_customer_request.rb +48 -0
- data/lib/unit/models/customer/patch_individual_customer_request.rb +49 -0
- data/lib/unit/models/customer/remove_authorized_users_request.rb +31 -0
- data/lib/unit/models/unit_resource.rb +13 -11
- data/lib/unit/models/unit_response.rb +10 -8
- data/lib/unit/types/address.rb +29 -25
- data/lib/unit/types/authorized_user.rb +24 -20
- data/lib/unit/types/beneficial_owner.rb +46 -42
- data/lib/unit/types/business_contact.rb +20 -16
- data/lib/unit/types/device_fingerprint.rb +17 -13
- data/lib/unit/types/evaluation_params.rb +15 -11
- data/lib/unit/types/full_name.rb +17 -13
- data/lib/unit/types/officer.rb +46 -42
- data/lib/unit/types/phone.rb +17 -13
- data/lib/unit/types/power_of_attorney_agent.rb +42 -38
- data/lib/unit/types/relationship.rb +15 -11
- data/lib/unit/types/relationship_array.rb +21 -16
- data/lib/unit/version.rb +1 -1
- data/lib/unit_ruby_sdk.rb +48 -2
- metadata +13 -13
- data/lib/unit/models/applications/create_business_application_request.rb +0 -78
- data/lib/unit/models/applications/create_individual_application_request.rb +0 -88
- data/lib/unit/models/applications/list_application_params.rb +0 -38
- data/lib/unit/models/applications/patch_application_request.rb +0 -29
- data/lib/unit/models/applications/upload_document_request.rb +0 -24
- data/lib/unit/models/customers/add_authorized_users_request.rb +0 -27
- data/lib/unit/models/customers/archive_customer_request.rb +0 -26
- data/lib/unit/models/customers/list_customer_params.rb +0 -38
- data/lib/unit/models/customers/patch_business_customer_request.rb +0 -44
- data/lib/unit/models/customers/patch_individual_customer_request.rb +0 -45
- data/lib/unit/models/customers/remove_authorized_users_request.rb +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e5d766996e30818b915c5c1abae42e583abf6cf3e4c2bbc8035386edb06a83c
|
4
|
+
data.tar.gz: 23db92d5de9879ffd1361201432ae343b3f3beeac8abb8813a9c5a423bcd0dd1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0a323e41f06ada5acd1ea07261d15face211c8fa86dbb98cf7e3747c76318766b2a546a7a4de4cd4afbb6106aab90d1aa8dadda2e42436b63dff271be21807d
|
7
|
+
data.tar.gz: 5ac425d5e5e2d44e22b39a773aa2cdb2d15c642e4ff653cb98dbe64c91ca8ed301e3184891b2b0f2e53e7ffcfae4461eb40022bd48b0029dc13321439ed4205d
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
|
4
|
+
unit_ruby_sdk (0.1.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -115,6 +115,7 @@ GEM
|
|
115
115
|
|
116
116
|
PLATFORMS
|
117
117
|
arm64-darwin-21
|
118
|
+
universal-darwin-22
|
118
119
|
x86_64-darwin-21
|
119
120
|
x86_64-linux
|
120
121
|
|
@@ -125,7 +126,7 @@ DEPENDENCIES
|
|
125
126
|
rspec
|
126
127
|
rubocop (~> 1.21)
|
127
128
|
ruby-debug-ide
|
128
|
-
|
129
|
+
unit_ruby_sdk!
|
129
130
|
|
130
131
|
BUNDLED WITH
|
131
|
-
2.3.
|
132
|
+
2.3.25
|
@@ -1,75 +1,69 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "httparty"
|
4
|
-
|
5
|
-
require_relative "../api_resources/base_resource"
|
6
|
-
require_relative "../models/applications/create_business_application_request"
|
7
|
-
require_relative "../models/applications/create_individual_application_request"
|
8
|
-
require_relative "../models/applications/patch_application_request"
|
9
|
-
require_relative "../models/applications/list_application_params"
|
10
|
-
|
11
|
-
require_relative "../models/unit_response"
|
12
|
-
require_relative "../errors/unit_error"
|
4
|
+
require_relative "./base_resource"
|
13
5
|
require "json"
|
14
|
-
|
15
6
|
# class for creating requests for applications to Unit API and parsing responses
|
16
7
|
# See: https://docs.unit.co/applications
|
17
8
|
module Unit
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
9
|
+
module Resource
|
10
|
+
class ApplicationResource < Unit::Resource::BaseResource
|
11
|
+
class << self
|
12
|
+
# Create a new application by calling Unit's API
|
13
|
+
# @param [CreateIndividualApplicationRequest, CreateBusinessApplicationRequest] request
|
14
|
+
# @return [UnitResponse, UnitError]
|
15
|
+
def create_application(request)
|
16
|
+
payload = request.to_json_api
|
17
|
+
response = HTTParty.post("#{api_url}/applications", body: payload, headers: headers)
|
18
|
+
response_handler(response)
|
19
|
+
end
|
27
20
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
# Get an applications by calling Unit's API
|
37
|
-
# @param [ListApplicationParams] params
|
38
|
-
# @return [UnitResponse, UnitError]
|
39
|
-
def list_applications(params = nil)
|
40
|
-
response = HTTParty.get("#{api_url}/applications", body: params&.to_hash&.to_json, headers: headers)
|
21
|
+
# Get an application by calling Unit's API
|
22
|
+
# @param [Integer] application_id
|
23
|
+
# @return [UnitResponse, UnitError]
|
24
|
+
def get_application(application_id)
|
25
|
+
response = HTTParty.get("#{api_url}/applications/#{application_id}", headers: headers)
|
26
|
+
response_handler(response)
|
27
|
+
end
|
41
28
|
|
42
|
-
|
43
|
-
|
29
|
+
# Get an applications by calling Unit's API
|
30
|
+
# @param [ListApplicationParams] params
|
31
|
+
# @return [UnitResponse, UnitError]
|
32
|
+
def list_applications(params = nil)
|
33
|
+
response = HTTParty.get("#{api_url}/applications", body: params&.to_hash&.to_json, headers: headers)
|
34
|
+
response_handler(response)
|
35
|
+
end
|
44
36
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
37
|
+
# Upload a document to an application
|
38
|
+
# @param [UploadDocumentRequest] request
|
39
|
+
# @return [UnitResponse, UnitError]
|
40
|
+
def upload(request)
|
41
|
+
url = "#{api_url}/applications/#{request.application_id}/documents/#{request.document_id}"
|
42
|
+
url += "/back" if request.is_back_side
|
51
43
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
44
|
+
headers = {
|
45
|
+
"Authorization" => "Bearer #{token}",
|
46
|
+
"User-Agent" => "unit-ruby-sdk"
|
47
|
+
}
|
56
48
|
|
57
|
-
|
58
|
-
|
59
|
-
|
49
|
+
headers["Content-Type"] = "application/pdf" if request.file_type == "pdf"
|
50
|
+
headers["Content-Type"] = "image/jpeg" if request.file_type == "jpeg"
|
51
|
+
headers["Content-Type"] = "image/png" if request.file_type == "png"
|
60
52
|
|
61
|
-
|
53
|
+
response = HTTParty.put(url, body: request.file, headers: headers)
|
62
54
|
|
63
|
-
|
64
|
-
|
55
|
+
response_handler(response)
|
56
|
+
end
|
65
57
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
58
|
+
# Update an application by calling Unit's API
|
59
|
+
# @param [PatchApplicationRequest] request
|
60
|
+
# @return [UnitResponse, UnitError]
|
61
|
+
def update(request)
|
62
|
+
payload = request.to_json_api
|
63
|
+
response = HTTParty.patch("#{api_url}/applications/#{request.application_id}", body: payload, headers: headers)
|
64
|
+
response_handler(response)
|
65
|
+
end
|
66
|
+
end
|
73
67
|
end
|
74
68
|
end
|
75
69
|
end
|
@@ -3,33 +3,39 @@
|
|
3
3
|
require "httparty"
|
4
4
|
|
5
5
|
module Unit
|
6
|
-
|
7
|
-
|
6
|
+
module Resource
|
7
|
+
class BaseResource
|
8
|
+
class << self
|
9
|
+
# Check the response code and return a UnitResponse or UnitError
|
10
|
+
# @param [HTTParty::Response] response
|
11
|
+
def response_handler(response)
|
12
|
+
included = response["included"].nil? ? nil : response["included"]
|
13
|
+
meta = response["meta"].nil? ? nil : response["meta"]
|
14
|
+
case response.code
|
15
|
+
when 200...300
|
16
|
+
Unit::UnitResponse.new(response["data"], included, meta)
|
17
|
+
else
|
18
|
+
Unit::UnitError.from_json_api(response)
|
19
|
+
end
|
20
|
+
end
|
8
21
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
"Authorization" => "Bearer #{token}",
|
19
|
-
"User-Agent" => "unit-ruby-sdk"
|
20
|
-
}
|
21
|
-
end
|
22
|
+
protected
|
23
|
+
|
24
|
+
def api_url
|
25
|
+
Unit.config[:api_url]
|
26
|
+
end
|
27
|
+
|
28
|
+
def token
|
29
|
+
Unit.config[:token]
|
30
|
+
end
|
22
31
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
UnitResponse.new(response["data"], included, meta)
|
31
|
-
else
|
32
|
-
UnitError.from_json_api(response)
|
32
|
+
def headers
|
33
|
+
{
|
34
|
+
"Content-Type" => "application/vnd.api+json",
|
35
|
+
"Authorization" => "Bearer #{Unit.config[:token]}",
|
36
|
+
"User-Agent" => "unit-ruby-sdk"
|
37
|
+
}
|
38
|
+
end
|
33
39
|
end
|
34
40
|
end
|
35
41
|
end
|
@@ -5,65 +5,67 @@ require "httparty"
|
|
5
5
|
require_relative "../api_resources/base_resource"
|
6
6
|
require_relative "../models/unit_response"
|
7
7
|
require_relative "../errors/unit_error"
|
8
|
-
require_relative "../models/customers/patch_individual_customer_request"
|
9
|
-
require_relative "../models/customers/patch_business_customer_request"
|
10
8
|
|
11
9
|
# class for creating requests for customers to Unit API and parsing responses
|
12
10
|
# See: https://docs.unit.co/customers/
|
13
11
|
module Unit
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
12
|
+
module Resource
|
13
|
+
class CustomerResource < Unit::Resource::BaseResource
|
14
|
+
class << self
|
15
|
+
# Update a customer by calling Unit's API
|
16
|
+
# @param [PatchIndividualCustomerRequest, PatchBusinessCustomerRequest, PatchTrustCustomerRequest] request
|
17
|
+
# @return [UnitResponse, UnitError]
|
18
|
+
def update(request)
|
19
|
+
payload = request.to_json_api
|
20
|
+
response = HTTParty.patch("#{api_url}/customers/#{request.customer_id}", body: payload, headers: headers)
|
21
|
+
response_handler(response)
|
22
|
+
end
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
24
|
+
# Get a customer by calling Unit's API
|
25
|
+
# @param [String] customer_id
|
26
|
+
# @return [UnitResponse, UnitError]
|
27
|
+
def get(customer_id)
|
28
|
+
response = HTTParty.get("#{api_url}/customers/#{customer_id}", headers: headers)
|
29
|
+
response_handler(response)
|
30
|
+
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
32
|
+
# Get customers by calling Unit's API
|
33
|
+
# @param [ListCustomerParams] params
|
34
|
+
# @return [UnitResponse, UnitError]
|
35
|
+
def list(params = nil)
|
36
|
+
response = HTTParty.get("#{api_url}/customers", body: params&.to_hash&.to_json, headers: headers)
|
37
|
+
response_handler(response)
|
38
|
+
end
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
40
|
+
# Archive customers by calling Unit's API
|
41
|
+
# @param [ArchiveCustomerRequest] request
|
42
|
+
# @return [UnitResponse, UnitError]
|
43
|
+
def archive(request)
|
44
|
+
payload = request.to_json_api
|
45
|
+
response = HTTParty.post("#{api_url}/customers/#{request.customer_id}/archive", body: payload, headers: headers)
|
46
|
+
response_handler(response)
|
47
|
+
end
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
49
|
+
# Add authorized users to a customer by calling Unit's API
|
50
|
+
# @param [AddAuthorizedUsersRequest] request
|
51
|
+
# @return [UnitResponse, UnitError]
|
52
|
+
def add_authorized_users(request)
|
53
|
+
payload = request.to_json_api
|
54
|
+
response = HTTParty.post("#{api_url}/customers/#{request.customer_id}/authorized-users",
|
55
|
+
body: payload,
|
56
|
+
headers: headers)
|
57
|
+
response_handler(response)
|
58
|
+
end
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
60
|
+
# Remove authorized users from a customer by calling Unit's API
|
61
|
+
# @param [RemoveAuthorizedUsersRequest] request
|
62
|
+
# @return [UnitResponse, UnitError]
|
63
|
+
def remove_authorized_users(request)
|
64
|
+
payload = request.to_json_api
|
65
|
+
response = HTTParty.delete("#{api_url}/customers/#{request.customer_id}/authorized-users", body: payload, headers: headers)
|
66
|
+
response_handler(response)
|
67
|
+
end
|
68
|
+
end
|
67
69
|
end
|
68
70
|
end
|
69
71
|
end
|
@@ -11,17 +11,19 @@ module Unit
|
|
11
11
|
@errors = errors
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
class << self
|
15
|
+
# Creates a new UnitError from given response.
|
16
|
+
# @param [Hash] response The response returned from Unit's API
|
17
|
+
# @return [UnitError] a new UnitError populated with values taken from the response
|
18
|
+
def from_json_api(response)
|
19
|
+
errors = response["errors"]
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
errors&.map do |error|
|
22
|
+
UnitErrorPayload.new(error["title"], error["status"],
|
23
|
+
error["detail"], error["details"], error["source"], error["code"])
|
24
|
+
end
|
25
|
+
UnitError.new(errors)
|
23
26
|
end
|
24
|
-
UnitError.new(errors)
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "unit/types/full_name"
|
4
|
+
require "unit/types/address"
|
5
|
+
require "unit/types/phone"
|
6
|
+
require "unit/types/business_contact"
|
7
|
+
require "unit/types/beneficial_owner"
|
8
|
+
require "unit/types/officer"
|
9
|
+
|
10
|
+
# Request to create a business application
|
11
|
+
# See: https://docs.unit.co/applications/#create-business-application
|
12
|
+
module Unit
|
13
|
+
module Application
|
14
|
+
class CreateBusinessApplicationRequest
|
15
|
+
attr_reader :name, :address, :phone, :state_of_incorporation, :ein, :industry, :contact, :officer, :beneficial_owners,
|
16
|
+
:entity_type, :dba, :ip, :website, :tags, :idempotency_key, :device_fingerprints, :type
|
17
|
+
|
18
|
+
# @param name [String]
|
19
|
+
# @param address [Address]
|
20
|
+
# @param phone [Phone]
|
21
|
+
# @param state_of_incorporation [String]
|
22
|
+
# @param ein [String]
|
23
|
+
# @param industry [String]
|
24
|
+
# @param contact [BusinessContact]
|
25
|
+
# @param officer [Officer]
|
26
|
+
# @param beneficial_owners [Array]
|
27
|
+
# @param entity_type [String]
|
28
|
+
# @param optional dba [String]
|
29
|
+
# @param optional ip [String]
|
30
|
+
# @param optional website [String]
|
31
|
+
# @param optional tags [Hash]
|
32
|
+
# @param optional idempotency_key [String]
|
33
|
+
# @param optional device_fingerprints [DeviceFingerprint]
|
34
|
+
def initialize(name, address, phone, state_of_incorporation, ein, industry, contact, officer,
|
35
|
+
beneficial_owners, entity_type, dba = nil, ip = nil, website = nil, tags = nil, idempotency_key = nil,
|
36
|
+
device_fingerprints = nil)
|
37
|
+
@name = name
|
38
|
+
@address = address
|
39
|
+
@phone = phone
|
40
|
+
@state_of_incorporation = state_of_incorporation
|
41
|
+
@ein = ein
|
42
|
+
@industry = industry
|
43
|
+
@contact = contact
|
44
|
+
@officer = officer
|
45
|
+
@beneficial_owners = beneficial_owners.map(&:represent)
|
46
|
+
@entity_type = entity_type
|
47
|
+
@dba = dba
|
48
|
+
@ip = ip
|
49
|
+
@website = website
|
50
|
+
@tags = tags
|
51
|
+
@idempotency_key = idempotency_key
|
52
|
+
@device_fingerprints = device_fingerprints
|
53
|
+
@type = "businessApplication"
|
54
|
+
end
|
55
|
+
|
56
|
+
def to_json_api
|
57
|
+
payload = {
|
58
|
+
data: {
|
59
|
+
type: type,
|
60
|
+
attributes: {
|
61
|
+
name: name,
|
62
|
+
address: address.represent,
|
63
|
+
phone: phone.represent,
|
64
|
+
stateOfIncorporation: state_of_incorporation,
|
65
|
+
ein: ein,
|
66
|
+
industry: industry,
|
67
|
+
contact: contact.represent,
|
68
|
+
officer: officer.represent,
|
69
|
+
beneficialOwners: beneficial_owners,
|
70
|
+
entityType: entity_type,
|
71
|
+
dba: dba,
|
72
|
+
ip: ip,
|
73
|
+
website: website
|
74
|
+
}
|
75
|
+
}
|
76
|
+
}
|
77
|
+
payload[:data][:attributes].compact!
|
78
|
+
payload.to_json
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "unit/types/full_name"
|
4
|
+
require "unit/types/address"
|
5
|
+
require "unit/types/phone"
|
6
|
+
require "unit/types/device_fingerprint"
|
7
|
+
|
8
|
+
# Request to create an individual application
|
9
|
+
# See https://docs.unit.co/applications/#create-individual-application
|
10
|
+
module Unit
|
11
|
+
module Application
|
12
|
+
class CreateIndividualApplicationRequest
|
13
|
+
attr_reader :type, :ssn, :full_name, :date_of_birth, :address, :email, :phone, :ip, :ein, :industry, :dba, :sole_proprietorship,
|
14
|
+
:passport, :nationality, :device_fingerprints, :idempotency_key, :tags, :jwt_subject, :power_of_attorney_agent,
|
15
|
+
:evaluation_params
|
16
|
+
|
17
|
+
# @param ssn [String]
|
18
|
+
# @param full_name [FullName]
|
19
|
+
# @param date_of_birth [Date]
|
20
|
+
# @param address [Address]
|
21
|
+
# @param email [String]
|
22
|
+
# @param phone [Phone]
|
23
|
+
# @param optional ip [String]
|
24
|
+
# @param optional ein [String]
|
25
|
+
# @param optional industry [String]
|
26
|
+
# @param optional dba [String]
|
27
|
+
# @param optional sole_proprietorship [Boolean]
|
28
|
+
# @param optional passport [String]
|
29
|
+
# @param optional nationality [String]
|
30
|
+
# @param optional device_fingerprints [DeviceFingerprint]
|
31
|
+
# @param optional idempotency_key [String]
|
32
|
+
# @param optional tags [Hash]
|
33
|
+
# @param optional jwt_subject [String]
|
34
|
+
# @param optional power_of_attorney_agent [PowerOfAttorneyAgent]
|
35
|
+
# @param optional evaluation_params [EvaluationParams]
|
36
|
+
def initialize(ssn, full_name, date_of_birth, address, email, phone, ip = nil, ein = nil, industry = nil, dba = nil, sole_proprietorship = nil, passport = nil,
|
37
|
+
nationality = nil, device_fingerprints = nil, idempotency_key = nil, tags = nil, jwt_subject = nil, power_of_attorney_agent = nil,
|
38
|
+
evaluation_params = nil)
|
39
|
+
@ssn = ssn
|
40
|
+
@full_name = full_name
|
41
|
+
@date_of_birth = date_of_birth
|
42
|
+
@address = address
|
43
|
+
@phone = phone
|
44
|
+
@email = email
|
45
|
+
@ip = ip
|
46
|
+
@ein = ein
|
47
|
+
@industry = industry
|
48
|
+
@dba = dba
|
49
|
+
@sole_proprietorship = sole_proprietorship
|
50
|
+
@passport = passport
|
51
|
+
@nationality = nationality
|
52
|
+
@device_fingerprints = device_fingerprints
|
53
|
+
@idempotency_key = idempotency_key
|
54
|
+
@tags = tags
|
55
|
+
@jwt_object = jwt_subject
|
56
|
+
@power_of_attorney_agent = power_of_attorney_agent
|
57
|
+
@evaluation_params = evaluation_params
|
58
|
+
@type = "individualApplication"
|
59
|
+
end
|
60
|
+
|
61
|
+
def to_json_api
|
62
|
+
payload = {
|
63
|
+
data: {
|
64
|
+
type: type,
|
65
|
+
attributes: {
|
66
|
+
ssn: ssn,
|
67
|
+
fullName: full_name.represent,
|
68
|
+
dateOfBirth: date_of_birth,
|
69
|
+
address: address.represent,
|
70
|
+
email: email,
|
71
|
+
phone: phone.represent,
|
72
|
+
ip: ip,
|
73
|
+
ein: ein,
|
74
|
+
industry: industry,
|
75
|
+
dba: dba,
|
76
|
+
soleProprietorship: sole_proprietorship,
|
77
|
+
passport: passport,
|
78
|
+
nationality: nationality,
|
79
|
+
idempotencyKey: idempotency_key,
|
80
|
+
tags: tags,
|
81
|
+
jwtSubject: jwt_subject,
|
82
|
+
powerOfAttorneyAgent: power_of_attorney_agent&.represent,
|
83
|
+
evaluationParams: evaluation_params&.represent
|
84
|
+
}
|
85
|
+
}
|
86
|
+
}
|
87
|
+
payload[:data][:attributes].compact!
|
88
|
+
payload.to_json
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# params for list applications
|
4
|
+
# See: https://docs.unit.co/applications/#list-applications
|
5
|
+
module Unit
|
6
|
+
module Application
|
7
|
+
class ListApplicationParams
|
8
|
+
attr_reader :offset, :limit, :email, :tags, :query, :status, :sort
|
9
|
+
|
10
|
+
# @param offset [Integer] Number of resources to skip. See pagination: https://docs.unit.co/#intro-pagination
|
11
|
+
# @param limit [Integer] The limit Maximum number of resources that will be returned. Maximum is 1000 resources.
|
12
|
+
# @param email [String] Filter applications by email address (case sensitive).
|
13
|
+
# @param tags [String] Filter applications by tags. More information regarding tags: https://docs.unit.co/#tags
|
14
|
+
# @param query [String] Search term according to the: https://docs.unit.co/#full-text-search
|
15
|
+
# @param status [String] Filter applications by status: https://docs.unit.co/applications/#application-statuses
|
16
|
+
# @param sort [String] Sorts the resources by the specified field.
|
17
|
+
# @option sort=createdAt for ascending order
|
18
|
+
# @option sort=-createdAt (leading minus sign) for descending order.
|
19
|
+
def initialize(offset = 0, limit = 100, email = nil, tags = nil,
|
20
|
+
query = nil, status = nil, sort = nil)
|
21
|
+
@offset = offset
|
22
|
+
@limit = limit
|
23
|
+
@email = email
|
24
|
+
@tags = tags
|
25
|
+
@query = query
|
26
|
+
@status = status
|
27
|
+
@sort = sort
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_hash
|
31
|
+
params = { "page[limit]": limit,
|
32
|
+
"page[offset]": offset,
|
33
|
+
"filter[email]": email,
|
34
|
+
"filter[tags]": tags,
|
35
|
+
"filter[query]": query,
|
36
|
+
"filter[status]": status,
|
37
|
+
"sort": sort }
|
38
|
+
params.compact!
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Request to update application
|
4
|
+
# See for updating business application: https://docs.unit.co/applications/#update-business-application
|
5
|
+
# See for updating individual application: https://docs.unit.co/applications/#update-individual-application
|
6
|
+
module Unit
|
7
|
+
module Application
|
8
|
+
class PatchApplicationRequest
|
9
|
+
attr_reader :application_id, :type, :tags
|
10
|
+
|
11
|
+
# @param application_id [String] The application id
|
12
|
+
# @param type [String] The type
|
13
|
+
# @param optional tags [String] The tags
|
14
|
+
def initialize(application_id, type, tags = nil)
|
15
|
+
@application_id = application_id
|
16
|
+
@type = type
|
17
|
+
@tags = tags
|
18
|
+
end
|
19
|
+
|
20
|
+
# @return [String] The JSON API payload
|
21
|
+
def to_json_api
|
22
|
+
payload = {
|
23
|
+
data: {
|
24
|
+
type: type,
|
25
|
+
attributes: { tags: tags }
|
26
|
+
}
|
27
|
+
}
|
28
|
+
payload[:data][:attributes].compact!
|
29
|
+
payload.to_json
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|