unit_ruby_sdk 0.1.0 → 0.1.2

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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +6 -0
  3. data/Gemfile +1 -1
  4. data/Gemfile.lock +5 -3
  5. data/lib/unit/api_resources/application_resource.rb +51 -57
  6. data/lib/unit/api_resources/base_resource.rb +31 -25
  7. data/lib/unit/api_resources/customer_resource.rb +52 -50
  8. data/lib/unit/errors/unit_error.rb +11 -9
  9. data/lib/unit/models/application/create_business_application_request.rb +82 -0
  10. data/lib/unit/models/application/create_individual_application_request.rb +92 -0
  11. data/lib/unit/models/application/list_application_params.rb +42 -0
  12. data/lib/unit/models/application/patch_application_request.rb +33 -0
  13. data/lib/unit/models/application/upload_document_request.rb +27 -0
  14. data/lib/unit/models/customer/add_authorized_users_request.rb +31 -0
  15. data/lib/unit/models/customer/archive_customer_request.rb +30 -0
  16. data/lib/unit/models/customer/list_customer_params.rb +42 -0
  17. data/lib/unit/models/customer/patch_business_customer_request.rb +48 -0
  18. data/lib/unit/models/customer/patch_individual_customer_request.rb +49 -0
  19. data/lib/unit/models/customer/remove_authorized_users_request.rb +31 -0
  20. data/lib/unit/models/unit_resource.rb +13 -11
  21. data/lib/unit/models/unit_response.rb +10 -8
  22. data/lib/unit/types/address.rb +29 -25
  23. data/lib/unit/types/authorized_user.rb +24 -20
  24. data/lib/unit/types/beneficial_owner.rb +46 -42
  25. data/lib/unit/types/business_contact.rb +20 -16
  26. data/lib/unit/types/device_fingerprint.rb +17 -13
  27. data/lib/unit/types/evaluation_params.rb +15 -11
  28. data/lib/unit/types/full_name.rb +17 -13
  29. data/lib/unit/types/officer.rb +46 -42
  30. data/lib/unit/types/phone.rb +17 -13
  31. data/lib/unit/types/power_of_attorney_agent.rb +42 -38
  32. data/lib/unit/types/relationship.rb +15 -11
  33. data/lib/unit/types/relationship_array.rb +21 -16
  34. data/lib/unit/version.rb +1 -1
  35. data/lib/unit_ruby_sdk.rb +48 -2
  36. metadata +27 -13
  37. data/lib/unit/models/applications/create_business_application_request.rb +0 -78
  38. data/lib/unit/models/applications/create_individual_application_request.rb +0 -88
  39. data/lib/unit/models/applications/list_application_params.rb +0 -38
  40. data/lib/unit/models/applications/patch_application_request.rb +0 -29
  41. data/lib/unit/models/applications/upload_document_request.rb +0 -24
  42. data/lib/unit/models/customers/add_authorized_users_request.rb +0 -27
  43. data/lib/unit/models/customers/archive_customer_request.rb +0 -26
  44. data/lib/unit/models/customers/list_customer_params.rb +0 -38
  45. data/lib/unit/models/customers/patch_business_customer_request.rb +0 -44
  46. data/lib/unit/models/customers/patch_individual_customer_request.rb +0 -45
  47. 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: edd56d89aa8ed85ea598e976eb3b3ed6a51e977fa355653f00337e7acd2dbfc4
4
- data.tar.gz: 3f45bbad0250f27ddaf7f3dbbff18fdfa9ffcebf04b1c669aef786ca18b4897d
3
+ metadata.gz: 1c537218faa351239ef177faffa0c2b9de8d40eebf52eb3608b55e76dc89746a
4
+ data.tar.gz: aee02b9bca0da9370d687d5e374e1210198f7224e4834e585d32998fb3a74582
5
5
  SHA512:
6
- metadata.gz: 9a257ad6168f6d8955dd02fc8fe7257e3443f770f7427ea3f3c1852e8d37e7dd6210d7813dafef6bac6f0179595e2be9798bcfcdbd04334794a4bf899d12b04b
7
- data.tar.gz: 3ca7ed3b4580291c5574993dfef66387e9c82f4762ce883fb36c34699dcc1b08c73fe1515c74d4a4d45d85e36118e3390aae5260c1aeabca376cff003511ed70
6
+ metadata.gz: 30b0e0991cb6d0e291c0d6af7b4a8448ee293e06d06b1e7f2dac9b39b189807879eff0f048f788c41fc49045cd593dd319ee74e7c42fc7ec884c1495a3f45f8c
7
+ data.tar.gz: 0fbae70cf0069a97e19ab5bbf5284fe802f9355879e30f15484e63b13b67a56f5e141dfde7c2ed0f4b17298b4b618498e8f594239897c0e7ea3bc0b530981dbb
data/.rubocop.yml CHANGED
@@ -26,3 +26,9 @@ Metrics/AbcSize:
26
26
 
27
27
  Layout/LineLength:
28
28
  Max: 350
29
+
30
+ Style/ClassVars:
31
+ Enabled: false
32
+
33
+ Metrics/BlockLength:
34
+ Enabled: false
data/Gemfile CHANGED
@@ -9,7 +9,7 @@ gem "rake", "~> 13.0"
9
9
 
10
10
  gem "rubocop", "~> 1.21"
11
11
 
12
- gem "httparty"
12
+ gem "httparty", "~0.20.0"
13
13
 
14
14
  gem "ruby-debug-ide"
15
15
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- unit-ruby-sdk (0.1.0)
4
+ unit_ruby_sdk (0.1.1)
5
+ httparty
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
@@ -115,6 +116,7 @@ GEM
115
116
 
116
117
  PLATFORMS
117
118
  arm64-darwin-21
119
+ universal-darwin-22
118
120
  x86_64-darwin-21
119
121
  x86_64-linux
120
122
 
@@ -125,7 +127,7 @@ DEPENDENCIES
125
127
  rspec
126
128
  rubocop (~> 1.21)
127
129
  ruby-debug-ide
128
- unit-ruby-sdk!
130
+ unit_ruby_sdk!
129
131
 
130
132
  BUNDLED WITH
131
- 2.3.24
133
+ 2.3.26
@@ -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
- class ApplicationResource < Unit::BaseResource
19
- # Create a new application by calling Unit's API
20
- # @param [CreateIndividualApplicationRequest, CreateBusinessApplicationRequest] request
21
- # @return [UnitResponse, UnitError]
22
- def create_application(request)
23
- payload = request.to_json_api
24
- response = HTTParty.post("#{api_url}/applications", body: payload, headers: headers)
25
- response_handler(response)
26
- end
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
- # Get an application by calling Unit's API
29
- # @param [Integer] application_id
30
- # @return [UnitResponse, UnitError]
31
- def get_application(application_id)
32
- response = HTTParty.get("#{api_url}/applications/#{application_id}", headers: headers)
33
- response_handler(response)
34
- end
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
- response_handler(response)
43
- end
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
- # Upload a document to an application
46
- # @param [UploadDocumentRequest] request
47
- # @return [UnitResponse, UnitError]
48
- def upload(request)
49
- url = "#{api_url}/applications/#{request.application_id}/documents/#{request.document_id}"
50
- url += "/back" if request.is_back_side
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
- headers = {
53
- "Authorization" => "Bearer #{token}",
54
- "User-Agent" => "unit-ruby-sdk"
55
- }
44
+ headers = {
45
+ "Authorization" => "Bearer #{token}",
46
+ "User-Agent" => "unit-ruby-sdk"
47
+ }
56
48
 
57
- headers["Content-Type"] = "application/pdf" if request.file_type == "pdf"
58
- headers["Content-Type"] = "image/jpeg" if request.file_type == "jpeg"
59
- headers["Content-Type"] = "image/png" if request.file_type == "png"
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
- response = HTTParty.put(url, body: request.file, headers: headers)
53
+ response = HTTParty.put(url, body: request.file, headers: headers)
62
54
 
63
- response_handler(response)
64
- end
55
+ response_handler(response)
56
+ end
65
57
 
66
- # Update an application by calling Unit's API
67
- # @param [PatchApplicationRequest] request
68
- # @return [UnitResponse, UnitError]
69
- def update(request)
70
- payload = request.to_json_api
71
- response = HTTParty.patch("#{api_url}/applications/#{request.application_id}", body: payload, headers: headers)
72
- response_handler(response)
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
- class BaseResource
7
- attr_reader :api_url, :headers, :token
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
- # @param api_url [String] The API URL
10
- # @param token [String] The API token
11
- # @return [BaseResource]
12
- def initialize(api_url, token)
13
- @api_url = api_url
14
- @token = token
15
- @headers =
16
- {
17
- "Content-Type" => "application/vnd.api+json",
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
- # Check the response code and return a UnitResponse or UnitError
24
- # @param [HTTParty::Response] response
25
- def response_handler(response)
26
- included = response["included"].nil? ? nil : response["included"]
27
- meta = response["meta"].nil? ? nil : response["meta"]
28
- case response.code
29
- when 200...300
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
- class CustomerResource < Unit::BaseResource
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
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
- # Get a customer by calling Unit's API
25
- # @param [Integer] 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
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
- # 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
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
- # 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
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
- # 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
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
- # 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)
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
- # Creates a new UnitError from given response.
15
- # @param [Hash] response The response returned from Unit's API
16
- # @return [UnitError] a new UnitError populated with values taken from the response
17
- def self.from_json_api(response)
18
- errors = response["errors"]
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
- errors&.map do |error|
21
- UnitErrorPayload.new(error["title"], error["status"],
22
- error["detail"], error["details"], error["source"], error["code"])
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