unit_ruby_sdk 0.1.2 → 0.1.4

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 (56) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/Gemfile +0 -10
  4. data/README.md +97 -1
  5. data/lib/unit/api_resources/account_resource.rb +125 -0
  6. data/lib/unit/api_resources/api_token_resource.rb +59 -0
  7. data/lib/unit/api_resources/application_resource.rb +9 -9
  8. data/lib/unit/api_resources/base_resource.rb +3 -11
  9. data/lib/unit/api_resources/customer_resource.rb +12 -11
  10. data/lib/unit/api_resources/payment_resource.rb +32 -0
  11. data/lib/unit/api_resources/transaction_resource.rb +40 -0
  12. data/lib/unit/errors/unit_error.rb +7 -13
  13. data/lib/unit/errors/unit_error_payload.rb +15 -2
  14. data/lib/unit/models/account/account.rb +157 -0
  15. data/lib/unit/models/account/deposit/account_owners_request.rb +29 -0
  16. data/lib/unit/models/account/deposit/balance_history_request.rb +39 -0
  17. data/lib/unit/models/account/deposit/close_deposit_account_request.rb +36 -0
  18. data/lib/unit/models/account/deposit/create_deposit_account_request.rb +39 -0
  19. data/lib/unit/models/account/deposit/freeze_account_request.rb +36 -0
  20. data/lib/unit/models/account/deposit/list_account_params.rb +48 -0
  21. data/lib/unit/models/account/deposit/patch_deposit_account_request.rb +36 -0
  22. data/lib/unit/models/api_token/api_token.rb +89 -0
  23. data/lib/unit/models/api_token/customer/create_customer_token_request.rb +41 -0
  24. data/lib/unit/models/api_token/customer/create_customer_token_verification.rb +37 -0
  25. data/lib/unit/models/api_token/customer/create_token_using_jwt_request.rb +30 -0
  26. data/lib/unit/models/api_token/org/create_api_token_request.rb +40 -0
  27. data/lib/unit/models/application/application.rb +127 -0
  28. data/lib/unit/models/application/create_business_application_request.rb +7 -7
  29. data/lib/unit/models/application/create_individual_application_request.rb +14 -14
  30. data/lib/unit/models/application/list_application_params.rb +4 -4
  31. data/lib/unit/models/application/patch_application_request.rb +3 -3
  32. data/lib/unit/models/application/upload_document_request.rb +1 -1
  33. data/lib/unit/models/customer/add_authorized_users_request.rb +3 -3
  34. data/lib/unit/models/customer/archive_customer_request.rb +3 -4
  35. data/lib/unit/models/customer/customer.rb +96 -0
  36. data/lib/unit/models/customer/list_customer_params.rb +10 -12
  37. data/lib/unit/models/customer/patch_business_customer_request.rb +8 -8
  38. data/lib/unit/models/customer/patch_individual_customer_request.rb +9 -10
  39. data/lib/unit/models/customer/remove_authorized_users_request.rb +3 -3
  40. data/lib/unit/models/payment/create_book_payment_request.rb +49 -0
  41. data/lib/unit/models/payment/patch_book_payment_request.rb +31 -0
  42. data/lib/unit/models/payment/payment.rb +37 -0
  43. data/lib/unit/models/transaction/get_transaction_params.rb +28 -0
  44. data/lib/unit/models/transaction/list_transaction_params.rb +70 -0
  45. data/lib/unit/models/transaction/patch_tags_request.rb +33 -0
  46. data/lib/unit/models/transaction/transaction.rb +60 -0
  47. data/lib/unit/models/unit_response.rb +7 -1
  48. data/lib/unit/types/authorized_user.rb +1 -1
  49. data/lib/unit/types/relationship.rb +4 -5
  50. data/lib/unit/types/relationship_array.rb +14 -12
  51. data/lib/unit/types/restricted_resource.rb +23 -0
  52. data/lib/unit/utils/http_helper.rb +56 -0
  53. data/lib/unit/version.rb +1 -1
  54. data/lib/unit_ruby_sdk.rb +22 -21
  55. metadata +76 -7
  56. data/Gemfile.lock +0 -133
@@ -0,0 +1,127 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Unit
4
+ module Application
5
+ APPLICATION_LIST_OFFSET = 0
6
+ APPLICATION_LIST_LIMIT = 100
7
+ autoload :CreateBusinessApplicationRequest, "unit/models/application/create_business_application_request"
8
+ autoload :CreateIndividualApplicationRequest, "unit/models/application/create_individual_application_request"
9
+ autoload :ListApplicationParams, "unit/models/application/list_application_params"
10
+ autoload :PatchApplicationRequest, "unit/models/application/patch_application_request"
11
+ autoload :UploadDocumentRequest, "unit/models/application/upload_document_request"
12
+
13
+ class << self
14
+ # Create a new business application by calling Unit's API
15
+ # @param name [String]
16
+ # @param address [Address]
17
+ # @param phone [Phone]
18
+ # @param state_of_incorporation [String]
19
+ # @param ein [String]
20
+ # @param industry [String]
21
+ # @param contact [BusinessContact]
22
+ # @param officer [Officer]
23
+ # @param beneficial_owners [Array]
24
+ # @param entity_type [String]
25
+ # @param dba [String] - optional
26
+ # @param ip [String] - optional
27
+ # @param website [String] - optional
28
+ # @param tags [Hash] - optional
29
+ # @param idempotency_key [String] - optional
30
+ # @param device_fingerprints [DeviceFingerprint] - optional
31
+ # @return [UnitResponse, UnitError]
32
+ def create_business_application(name:, address:, phone:, state_of_incorporation:, ein:, industry:, contact:,
33
+ officer:, beneficial_owners:, entity_type:, dba: nil, ip: nil, website: nil,
34
+ tags: nil, idempotency_key: nil, device_fingerprints: nil)
35
+
36
+ request = CreateBusinessApplicationRequest.new(
37
+ name, address, phone, state_of_incorporation, ein, industry, contact, officer,
38
+ beneficial_owners, entity_type, dba, ip, website, tags, idempotency_key, device_fingerprints
39
+ )
40
+
41
+ Unit::Resource::ApplicationResource.create_application(request)
42
+ end
43
+
44
+ # Create a new individual application by calling Unit's API
45
+ # @param ssn [String]
46
+ # @param full_name [FullName]
47
+ # @param date_of_birth [Date]
48
+ # @param address [Address]
49
+ # @param email [String]
50
+ # @param phone [Phone]
51
+ # @param ip [String] - optional
52
+ # @param ein [String] - optional
53
+ # @param industry [String] - optional
54
+ # @param dba [String] - optional
55
+ # @param sole_proprietorship [Boolean] - optional
56
+ # @param passport [String] - optional
57
+ # @param nationality [String] - optional
58
+ # @param device_fingerprints [DeviceFingerprint] - optional
59
+ # @param idempotency_key [String] - optional
60
+ # @param tags [Hash] - optional
61
+ # @param jwt_subject [String] - optional
62
+ # @param power_of_attorney_agent [PowerOfAttorneyAgent] - optional
63
+ # @param evaluation_params [EvaluationParams] - optional
64
+ # @return [UnitResponse, UnitError]
65
+ def create_individual_application(ssn:, full_name:, date_of_birth:, address:, email:, phone:, ip: nil, ein: nil,
66
+ industry: nil, dba: nil, sole_proprietorship: nil, passport: nil, nationality: nil,
67
+ device_fingerprints: nil, idempotency_key: nil, tags: nil, jwt_subject: nil,
68
+ power_of_attorney_agent: nil, evaluation_params: nil)
69
+
70
+ request = CreateIndividualApplicationRequest.new(
71
+ ssn, full_name, date_of_birth, address, email, phone, ip, ein, industry, dba, sole_proprietorship, passport,
72
+ nationality, device_fingerprints, idempotency_key, tags, jwt_subject, power_of_attorney_agent, evaluation_params
73
+ )
74
+
75
+ Unit::Resource::ApplicationResource.create_application(request)
76
+ end
77
+
78
+ # Update an application by calling Unit's API
79
+ # @param application_id [String] The application id
80
+ # @param type [String] The type
81
+ # @param tags [Hash] The tags
82
+ # @return [UnitResponse, UnitError]
83
+ def update_application(application_id:, type:, tags: nil)
84
+ request = PatchApplicationRequest.new(application_id, type, tags)
85
+ Unit::Resource::ApplicationResource.update(request)
86
+ end
87
+
88
+ # List applications by calling Unit's API
89
+ # @param offset [Integer] Number of resources to skip.
90
+ # @param limit [Integer] The limit Maximum number of resources that will be returned.
91
+ # @param email [String] Filter applications by email address (case sensitive).
92
+ # @param tags [String] Filter applications by tags. More information regarding tags: https://docs.unit.co/#tags
93
+ # @param query [String] Search term according to the: https://docs.unit.co/#full-text-search
94
+ # @param status [String] Filter applications by status: https://docs.unit.co/applications/#application-statuses
95
+ # @param sort [String] Sorts the resources by the specified field.
96
+ # @option sort=createdAt for ascending order
97
+ # @option sort=-createdAt (leading minus sign) for descending order.
98
+ # @return [UnitResponse, UnitError]
99
+ def list_applications(offset: APPLICATION_LIST_OFFSET, limit: APPLICATION_LIST_LIMIT, email: nil, tags: nil, query: nil, status: nil, sort: nil)
100
+ request = Unit::Application::ListApplicationParams.new(offset, limit, email, tags, query, status, sort)
101
+ Unit::Resource::ApplicationResource.list_applications(request)
102
+ end
103
+
104
+ # Get an application by calling Unit's API
105
+ # @param [String] application_id
106
+ # @return [UnitResponse, UnitError]
107
+ def get_application(application_id)
108
+ Unit::Resource::ApplicationResource.get_application(application_id)
109
+ end
110
+
111
+ # Upload an application document by calling Unit's API
112
+ # @param application_id [String] The application ID
113
+ # @param document_id [String] The document ID
114
+ # @param file [String] The file path
115
+ # @param file_type [String] The file type
116
+ # @option file_type [String] :pdf
117
+ # @option file_type [String] :jpg
118
+ # @option file_type [String] :png
119
+ # @param is_back_side [Boolean] The file is back side
120
+ # @return [UnitResponse, UnitError]
121
+ def upload_document(application_id:, document_id:, file:, file_type:, is_back_side: false)
122
+ request = UploadDocumentRequest.new(application_id, document_id, file, file_type, is_back_side: is_back_side)
123
+ Unit::Resource::ApplicationResource.upload(request)
124
+ end
125
+ end
126
+ end
127
+ end
@@ -8,7 +8,7 @@ require "unit/types/beneficial_owner"
8
8
  require "unit/types/officer"
9
9
 
10
10
  # Request to create a business application
11
- # See: https://docs.unit.co/applications/#create-business-application
11
+ # @see https://docs.unit.co/applications/#create-business-application
12
12
  module Unit
13
13
  module Application
14
14
  class CreateBusinessApplicationRequest
@@ -25,12 +25,12 @@ module Unit
25
25
  # @param officer [Officer]
26
26
  # @param beneficial_owners [Array]
27
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]
28
+ # @param dba [String] - optional
29
+ # @param ip [String] - optional
30
+ # @param website [String] - optional
31
+ # @param tags [Hash] - optional
32
+ # @param idempotency_key [String] - optional
33
+ # @param device_fingerprints [DeviceFingerprint] - optional
34
34
  def initialize(name, address, phone, state_of_incorporation, ein, industry, contact, officer,
35
35
  beneficial_owners, entity_type, dba = nil, ip = nil, website = nil, tags = nil, idempotency_key = nil,
36
36
  device_fingerprints = nil)
@@ -6,7 +6,7 @@ require "unit/types/phone"
6
6
  require "unit/types/device_fingerprint"
7
7
 
8
8
  # Request to create an individual application
9
- # See https://docs.unit.co/applications/#create-individual-application
9
+ # @see https://docs.unit.co/applications/#create-individual-application
10
10
  module Unit
11
11
  module Application
12
12
  class CreateIndividualApplicationRequest
@@ -20,19 +20,19 @@ module Unit
20
20
  # @param address [Address]
21
21
  # @param email [String]
22
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]
23
+ # @param ip [String] - optional
24
+ # @param ein [String] - optional
25
+ # @param industry [String] - optional
26
+ # @param dba [String] - optional
27
+ # @param sole_proprietorship [Boolean] - optional
28
+ # @param passport [String] - optional
29
+ # @param nationality [String] - optional
30
+ # @param device_fingerprints [DeviceFingerprint] - optional
31
+ # @param idempotency_key [String] - optional
32
+ # @param tags [Hash] - optional
33
+ # @param jwt_subject [String] - optional
34
+ # @param power_of_attorney_agent [PowerOfAttorneyAgent] - optional
35
+ # @param evaluation_params [EvaluationParams] - optional
36
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
37
  nationality = nil, device_fingerprints = nil, idempotency_key = nil, tags = nil, jwt_subject = nil, power_of_attorney_agent = nil,
38
38
  evaluation_params = nil)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # params for list applications
4
- # See: https://docs.unit.co/applications/#list-applications
4
+ # @see https://docs.unit.co/applications/#list-applications
5
5
  module Unit
6
6
  module Application
7
7
  class ListApplicationParams
@@ -10,13 +10,13 @@ module Unit
10
10
  # @param offset [Integer] Number of resources to skip. See pagination: https://docs.unit.co/#intro-pagination
11
11
  # @param limit [Integer] The limit Maximum number of resources that will be returned. Maximum is 1000 resources.
12
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
13
+ # @param tags [Hash] Filter applications by tags. More information regarding tags: https://docs.unit.co/#tags
14
14
  # @param query [String] Search term according to the: https://docs.unit.co/#full-text-search
15
15
  # @param status [String] Filter applications by status: https://docs.unit.co/applications/#application-statuses
16
16
  # @param sort [String] Sorts the resources by the specified field.
17
17
  # @option sort=createdAt for ascending order
18
18
  # @option sort=-createdAt (leading minus sign) for descending order.
19
- def initialize(offset = 0, limit = 100, email = nil, tags = nil,
19
+ def initialize(offset = APPLICATION_LIST_OFFSET, limit = APPLICATION_LIST_LIMIT, email = nil, tags = nil,
20
20
  query = nil, status = nil, sort = nil)
21
21
  @offset = offset
22
22
  @limit = limit
@@ -35,7 +35,7 @@ module Unit
35
35
  "filter[query]": query,
36
36
  "filter[status]": status,
37
37
  "sort": sort }
38
- params.compact!
38
+ params.compact
39
39
  end
40
40
  end
41
41
  end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
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
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
6
  module Unit
7
7
  module Application
8
8
  class PatchApplicationRequest
@@ -10,7 +10,7 @@ module Unit
10
10
 
11
11
  # @param application_id [String] The application id
12
12
  # @param type [String] The type
13
- # @param optional tags [String] The tags
13
+ # @param tags [String] The tags
14
14
  def initialize(application_id, type, tags = nil)
15
15
  @application_id = application_id
16
16
  @type = type
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Creates request for uploading a document
4
- # See: https://docs.unit.co/application-documents/#upload-document
4
+ # @see https://docs.unit.co/application-documents/#upload-document
5
5
  module Unit
6
6
  module Application
7
7
  class UploadDocumentRequest
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Request to add authorized users to a project
4
- # See: https://docs.unit.co/customers#add-authorized-users
4
+ # @see https://docs.unit.co/customers#add-authorized-users
5
5
  module Unit
6
6
  module Customer
7
7
  class AddAuthorizedUsersRequest
8
8
  attr_reader :customer_id, :authorized_users
9
9
 
10
- # @param customer_id [String] The id of customer
11
- # @param authorized_users [Array<AuthorizedUser>] The authorized users
10
+ # @param customer_id [String]
11
+ # @param authorized_users [Array<AuthorizedUser>]
12
12
  def initialize(customer_id, authorized_users)
13
13
  @customer_id = customer_id
14
14
  @authorized_users = authorized_users
@@ -1,15 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Request to archive customer
4
- # See: https://docs.unit.co/customers#archive-customer
4
+ # @see https://docs.unit.co/customers#archive-customer
5
5
  module Unit
6
6
  module Customer
7
7
  class ArchiveCustomerRequest
8
8
  attr_reader :customer_id, :reason
9
9
 
10
- # @param customer_id [String] The id of customer
11
- # @param optional reason [String] The reason for archiving the customer
12
- # @option reason [String] Need to be one of the following: Inactive, FraudACHActivity, FraudCardActivity, FraudCheckActivity, FraudApplicationHistory, FraudAccountActivity, FraudClientIdentified, FraudLinkedToFraudulentCustomer.
10
+ # @param customer_id [String]
11
+ # @param reason [String] - optional
13
12
  def initialize(customer_id, reason = nil)
14
13
  @customer_id = customer_id
15
14
  @reason = reason
@@ -0,0 +1,96 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Unit
4
+ module Customer
5
+ CUSTOMER_LIST_LIMIT = 100
6
+ CUSTOMER_LIST_OFFSET = 0
7
+
8
+ autoload :AddAuthorizedUsersRequest, "unit/models/customer/add_authorized_users_request"
9
+ autoload :ArchiveCustomerRequest, "unit/models/customer/archive_customer_request"
10
+ autoload :ListCustomerParams, "unit/models/customer/list_customer_params"
11
+ autoload :PatchBusinessCustomerRequest, "unit/models/customer/patch_business_customer_request"
12
+ autoload :PatchIndividualCustomerRequest, "unit/models/customer/patch_individual_customer_request"
13
+ autoload :RemoveAuthorizedUsersRequest, "unit/models/customer/remove_authorized_users_request"
14
+
15
+ class << self
16
+ # Update individual customer by calling Unit's API
17
+ # @see https://docs.unit.co/customers#update-individual-customer
18
+ # @param customer_id [String]
19
+ # @param address [Address] - optional
20
+ # @param phone [Phone] - optional
21
+ # @param email [String] - optional
22
+ # @param dba [String] - optional
23
+ # @param authorized_users [Array<AuthorizedUser>] - optional
24
+ # @param tags [Hash] - optional
25
+ # @param jwt_subject [String] - optional
26
+ def update_individual_customer(customer_id:, address: nil, phone: nil, email: nil, dba: nil, authorized_users: nil, tags: nil, jwt_subject: nil)
27
+ request = PatchIndividualCustomerRequest.new(customer_id, address, phone, email, dba, authorized_users, tags, jwt_subject)
28
+ Unit::Resource::CustomerResource.update(request)
29
+ end
30
+
31
+ # Update business customer by calling Unit's API
32
+ # @see https://docs.unit.co/customers#update-business-customer
33
+ # @param customer_id [String]
34
+ # @param address [Address] - optional
35
+ # @param phone [Phone] - optional
36
+ # @param contact [BusinessContact] - optional
37
+ # @param authorized_users [Array<AuthorizedUser>] - optional
38
+ # @param dba [String] - optional
39
+ # @param tags [Hash] - optional
40
+ # @return [UnitResponse, UnitError]
41
+ def update_business_customer(customer_id:, address: nil, phone: nil, contact: nil, authorized_users: nil, dba: nil, tags: nil)
42
+ request = PatchBusinessCustomerRequest.new(customer_id, address, phone, contact, authorized_users, dba, tags)
43
+ Unit::Resource::CustomerResource.update(request)
44
+ end
45
+
46
+ # Get customer by calling Unit's API
47
+ # @see https://docs.unit.co/customers#get-specific-customer
48
+ # @param customer_id [String]
49
+ # @return [UnitResponse, UnitError]
50
+ def get_customer(customer_id)
51
+ Unit::Resource::CustomerResource.get(customer_id)
52
+ end
53
+
54
+ # List customers by calling Unit's API
55
+ # @see https://docs.unit.co/customers#list-customers
56
+ # @param limit [Integer] - optional
57
+ # @param offset [Integer] - optional
58
+ # @param query [String] - optional
59
+ # @param email [String] - optional
60
+ # @param tags [Hash] - optional
61
+ # @param status [String] - optional
62
+ # @param sort [String] - optional
63
+ def list_customers(offset: CUSTOMER_LIST_OFFSET, limit: CUSTOMER_LIST_LIMIT, email: nil, tags: nil, status: nil, query: nil, sort: nil)
64
+ request = ListCustomerParams.new(offset, limit, email, tags, status, query, sort)
65
+ Unit::Resource::CustomerResource.list(request)
66
+ end
67
+
68
+ # Archive customer by calling Unit's API
69
+ # @see https://docs.unit.co/customers#archive-customer
70
+ # @param customer_id [String]
71
+ # @param reason [String] - optional
72
+ def archive_customer(customer_id:, reason: nil)
73
+ request = ArchiveCustomerRequest.new(customer_id, reason)
74
+ Unit::Resource::CustomerResource.archive(request)
75
+ end
76
+
77
+ # Add authorized users by calling Unit's API
78
+ # @see https://docs.unit.co/customers#add-authorized-users
79
+ # @param customer_id [String]
80
+ # @param authorized_users [Array<AuthorizedUser>]
81
+ def add_authorized_users(customer_id:, authorized_users:)
82
+ request = AddAuthorizedUsersRequest.new(customer_id, authorized_users)
83
+ Unit::Resource::CustomerResource.add_authorized_users(request)
84
+ end
85
+
86
+ # Remove authorized users by calling Unit's API
87
+ # @see https://docs.unit.co/customers#remove-authorized-users
88
+ # @param customer_id [String]
89
+ # @param authorized_users [Array<AuthorizedUser>]
90
+ def remove_authorized_users(customer_id:, authorized_users:)
91
+ request = RemoveAuthorizedUsersRequest.new(customer_id, authorized_users)
92
+ Unit::Resource::CustomerResource.remove_authorized_users(request)
93
+ end
94
+ end
95
+ end
96
+ end
@@ -1,22 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # params for listing customers
4
- # See: https://docs.unit.co/customers#list-customers
4
+ # @see https://docs.unit.co/customers#list-customers
5
5
  module Unit
6
6
  module Customer
7
7
  class ListCustomerParams
8
8
  attr_reader :limit, :offset, :query, :email, :tags, :status, :sort
9
9
 
10
- # @param optional limit [Integer] Maximum number of resources that will be returned. Maximum is 1000 resources.
11
- # @param optional offset [Integer] Number of resources to skip. See pagination: https://docs.unit.co/#intro-pagination
12
- # @param optional query [String] Search term according to the: https://docs.unit.co/#full-text-search
13
- # @param optional email [String] Filter customers by email address (case sensitive).
14
- # @param optional tags [Hash] Filter customers by tags. More information regarding tags: https://docs.unit.co/#tags
15
- # @param optional status [String] Filter customers by status. One of: Active, Archived
16
- # @param optional 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(limit = 100, offset = 0, query = nil, email = nil, tags = nil, status = nil,
10
+ # @param limit [Integer] - optional
11
+ # @param offset [Integer] - optional
12
+ # @param query [String] - optional
13
+ # @param email [String] - optional
14
+ # @param tags [Hash] - optional
15
+ # @param status [String] - optional
16
+ # @param sort [String] - optional
17
+ def initialize(limit = CUSTOMER_LIST_LIMIT, offset = CUSTOMER_LIST_OFFSET, query = nil, email = nil, tags = nil, status = nil,
20
18
  sort = nil)
21
19
  @limit = limit
22
20
  @offset = offset
@@ -35,7 +33,7 @@ module Unit
35
33
  "filter[tags]": tags,
36
34
  "filter[status]": status,
37
35
  "sort": sort }
38
- params.compact!
36
+ params.compact
39
37
  end
40
38
  end
41
39
  end
@@ -1,19 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Update business customer information request
4
- # See: https://docs.unit.co/customers#update-business-customer
4
+ # @see https://docs.unit.co/customers#update-business-customer
5
5
  module Unit
6
6
  module Customer
7
7
  class PatchBusinessCustomerRequest
8
8
  attr_reader :customer_id, :address, :phone, :contact, :authorized_users, :dba, :tags
9
9
 
10
- # @param customer_id [String] The id of business
11
- # @param optional address [Address] The address of business
12
- # @param optional phone [Phone] The phone of business
13
- # @param optional contact [BusinessContact] The primary contact of the business
14
- # @param optional authorized_users [Array<AuthorizedUser>] The authorized users of business
15
- # @param optional dba [String] The dba of business. To modify or add needed to specify the new dba name.
16
- # @param optional tags [Hash] Provides opportunity to add, update or delete tags from resources with the tags attribute on the corresponding Update operation
10
+ # @param customer_id [String]
11
+ # @param address [Address] - optional
12
+ # @param phone [Phone] - optional
13
+ # @param contact [BusinessContact] - optional
14
+ # @param authorized_users [Array<AuthorizedUser>] - optional
15
+ # @param dba [String] - optional
16
+ # @param tags [Hash] - optional
17
17
  # more information regarding tags: https://docs.unit.co/#updating-tags
18
18
  def initialize(customer_id, address = nil, phone = nil, contact = nil,
19
19
  authorized_users = nil, dba = nil, tags = nil)
@@ -1,21 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Update individual customer information request
4
- # See: https://docs.unit.co/customers#update-individual-customer
4
+ # @see https://docs.unit.co/customers#update-individual-customer
5
5
  module Unit
6
6
  module Customer
7
7
  class PatchIndividualCustomerRequest
8
8
  attr_reader :customer_id, :address, :phone, :email, :dba, :authorized_users, :tags, :jwt_subject
9
9
 
10
- # @param customer_id [String] The id of individual customer
11
- # @param optional address [Address] The address of individual customer
12
- # @param optional phone [Phone] The phone of individual customer
13
- # @param optional email [String] The email of individual customer
14
- # @param optional dba [String] The dba of individual customer. If the individual is a sole proprietor who is doing business under a different name.
15
- # @param optional authorized_users [Array<AuthorizedUser>] The authorized users of individual customer
16
- # @param optional tags [Hash] Provides opportunity to add, update or delete tags from resources with the tags attribute on the corresponding Update operation
17
- # @param optional jwt_subject [String] The subject of the JWT
18
- # More information regarding JWTSubject: https://docs.unit.co/customer-api-tokens/#customers-create-customer-bearer-token-jwt
10
+ # @param customer_id [String]
11
+ # @param address [Address] - optional
12
+ # @param phone [Phone] - optional
13
+ # @param email [String] - optional
14
+ # @param dba [String] - optional
15
+ # @param authorized_users [Array<AuthorizedUser>] - optional
16
+ # @param tags [Hash] - optional
17
+ # @param jwt_subject [String] - optional
19
18
  def initialize(customer_id, address = nil, phone = nil, email = nil, dba = nil, authorized_users = nil, tags = nil, jwt_subject = nil)
20
19
  @customer_id = customer_id
21
20
  @address = address
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Request to remove authorized users from customer
4
- # See: https://docs.unit.co/customers#remove-authorized-users
4
+ # @see https://docs.unit.co/customers#remove-authorized-users
5
5
  module Unit
6
6
  module Customer
7
7
  class RemoveAuthorizedUsersRequest
8
8
  attr_reader :customer_id, :authorized_users_emails
9
9
 
10
- # @param customer_id [String] The id of customer
11
- # @param authorized_users_emails [Array<String>] The list of authorized users emails to remove from the customer.
10
+ # @param customer_id [String]
11
+ # @param authorized_users_emails [Array<String>]
12
12
  def initialize(customer_id, authorized_users_emails)
13
13
  @customer_id = customer_id
14
14
  @authorized_users_emails = authorized_users_emails
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Request to create a book payment
4
+ # @see https://docs.unit.co/book-payments#book-payments
5
+ module Unit
6
+ module Payment
7
+ class CreateBookPaymentRequest
8
+ attr_reader :amount, :description, :account_id, :counterparty_account_id, :transaction_summary_override, :idempotency_key, :tags, :relationships
9
+
10
+ # @param amount [Integer]
11
+ # @param description [String]
12
+ # @param account_id [String]
13
+ # @param counterparty_account_id [String]
14
+ # @param transaction_summary_override [String] - optional
15
+ # @param idempotency_key [String] - optional
16
+ # @param tags [Hash] - optional
17
+ def initialize(amount, description, account_id, counterparty_account_id, relationships, transaction_summary_override = nil,
18
+ idempotency_key = nil, tags = nil)
19
+ @amount = amount
20
+ @description = description
21
+ @account_id = account_id
22
+ @counterparty_account_id = counterparty_account_id
23
+ @relationships = relationships
24
+ @transaction_summary_override = transaction_summary_override
25
+ @idempotency_key = idempotency_key
26
+ @tags = tags
27
+ end
28
+
29
+ def to_json_api
30
+ payload = {
31
+ data: {
32
+ type: "bookPayment",
33
+ attributes: {
34
+ amount: amount,
35
+ description: description,
36
+ transactionSummaryOverride: transaction_summary_override,
37
+ idempotencyKey: idempotency_key,
38
+ tags: tags
39
+ },
40
+ relationships: { account: Unit::Types::Relationship.new("depositAccount", account_id).to_hash,
41
+ counterpartyAccount: Unit::Types::Relationship.new("depositAccount", counterparty_account_id).to_hash }
42
+ }
43
+ }
44
+ payload[:data][:attributes].compact!
45
+ payload.to_json
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Request to update a book payment
4
+ # @see https://docs.unit.co/book-payments#update-book-payment
5
+ module Unit
6
+ module Payment
7
+ class PatchBookPaymentRequest
8
+ attr_reader :payment_id, :tags
9
+
10
+ # @param payment_id [String]
11
+ # @param tags [Hash] - optional
12
+ def initialize(payment_id, tags = nil)
13
+ @payment_id = payment_id
14
+ @tags = tags
15
+ end
16
+
17
+ def to_json_api
18
+ payload = {
19
+ data: {
20
+ type: "bookPayment",
21
+ attributes: {
22
+ tags: tags
23
+ }
24
+ }
25
+ }
26
+ payload[:data][:attributes].compact!
27
+ payload.to_json
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Unit
4
+ module Payment
5
+ autoload :CreateBookPaymentRequest, "unit/models/payment/create_book_payment_request"
6
+ autoload :PatchBookPaymentRequest, "unit/models/payment/patch_book_payment_request"
7
+
8
+ class << self
9
+ # Create a new book payment by calling Unit's API
10
+ # @see https://docs.unit.co/book-payments#book-payments
11
+ # @param amount [Integer]
12
+ # @param description [String]
13
+ # @param account_id [String]
14
+ # @param counterparty_account_id [String]
15
+ # @param transaction_summary_override [String] - optional
16
+ # @param idempotency_key [String] - optional
17
+ # @param tags [Hash] - optional
18
+ # @return [UnitResponse, UnitError]
19
+ def create_book_payment(amount:, description:, account_id:, counterparty_account_id:, transaction_summary_override: nil,
20
+ idempotency_key: nil, tags: nil)
21
+ request = Unit::Payment::CreateBookPaymentRequest.new(amount, description, account_id, counterparty_account_id, transaction_summary_override,
22
+ idempotency_key, tags)
23
+ Unit::Resource::PaymentResource.create_payment(request)
24
+ end
25
+
26
+ # Update a book payment by calling Unit's API
27
+ # @see https://docs.unit.co/book-payments#update-book-payment
28
+ # @param payment_id [String]
29
+ # @param tags [Hash] - optional
30
+ # @return [UnitResponse, UnitError]
31
+ def update_book_payment(payment_id:, tags: nil)
32
+ request = Unit::Payment::PatchBookPaymentRequest.new(payment_id, tags)
33
+ Unit::Resource::PaymentResource.update_payment(request)
34
+ end
35
+ end
36
+ end
37
+ end