unit_ruby_sdk 0.1.0 → 0.1.1

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 (46) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +6 -0
  3. data/Gemfile.lock +4 -3
  4. data/lib/unit/api_resources/application_resource.rb +51 -57
  5. data/lib/unit/api_resources/base_resource.rb +31 -25
  6. data/lib/unit/api_resources/customer_resource.rb +52 -50
  7. data/lib/unit/errors/unit_error.rb +11 -9
  8. data/lib/unit/models/application/create_business_application_request.rb +82 -0
  9. data/lib/unit/models/application/create_individual_application_request.rb +92 -0
  10. data/lib/unit/models/application/list_application_params.rb +42 -0
  11. data/lib/unit/models/application/patch_application_request.rb +33 -0
  12. data/lib/unit/models/application/upload_document_request.rb +27 -0
  13. data/lib/unit/models/customer/add_authorized_users_request.rb +31 -0
  14. data/lib/unit/models/customer/archive_customer_request.rb +30 -0
  15. data/lib/unit/models/customer/list_customer_params.rb +42 -0
  16. data/lib/unit/models/customer/patch_business_customer_request.rb +48 -0
  17. data/lib/unit/models/customer/patch_individual_customer_request.rb +49 -0
  18. data/lib/unit/models/customer/remove_authorized_users_request.rb +31 -0
  19. data/lib/unit/models/unit_resource.rb +13 -11
  20. data/lib/unit/models/unit_response.rb +10 -8
  21. data/lib/unit/types/address.rb +29 -25
  22. data/lib/unit/types/authorized_user.rb +24 -20
  23. data/lib/unit/types/beneficial_owner.rb +46 -42
  24. data/lib/unit/types/business_contact.rb +20 -16
  25. data/lib/unit/types/device_fingerprint.rb +17 -13
  26. data/lib/unit/types/evaluation_params.rb +15 -11
  27. data/lib/unit/types/full_name.rb +17 -13
  28. data/lib/unit/types/officer.rb +46 -42
  29. data/lib/unit/types/phone.rb +17 -13
  30. data/lib/unit/types/power_of_attorney_agent.rb +42 -38
  31. data/lib/unit/types/relationship.rb +15 -11
  32. data/lib/unit/types/relationship_array.rb +21 -16
  33. data/lib/unit/version.rb +1 -1
  34. data/lib/unit_ruby_sdk.rb +48 -2
  35. metadata +13 -13
  36. data/lib/unit/models/applications/create_business_application_request.rb +0 -78
  37. data/lib/unit/models/applications/create_individual_application_request.rb +0 -88
  38. data/lib/unit/models/applications/list_application_params.rb +0 -38
  39. data/lib/unit/models/applications/patch_application_request.rb +0 -29
  40. data/lib/unit/models/applications/upload_document_request.rb +0 -24
  41. data/lib/unit/models/customers/add_authorized_users_request.rb +0 -27
  42. data/lib/unit/models/customers/archive_customer_request.rb +0 -26
  43. data/lib/unit/models/customers/list_customer_params.rb +0 -38
  44. data/lib/unit/models/customers/patch_business_customer_request.rb +0 -44
  45. data/lib/unit/models/customers/patch_individual_customer_request.rb +0 -45
  46. data/lib/unit/models/customers/remove_authorized_users_request.rb +0 -27
@@ -1,29 +0,0 @@
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
- class PatchApplicationRequest
7
- attr_reader :application_id, :type, :tags
8
-
9
- # @param application_id [String] The application id
10
- # @param type [String] The type
11
- # @param optional tags [String] The tags
12
- def initialize(application_id, type, tags = nil)
13
- @application_id = application_id
14
- @type = type
15
- @tags = tags
16
- end
17
-
18
- # @return [String] The JSON API payload
19
- def to_json_api
20
- payload = {
21
- data: {
22
- type: type,
23
- attributes: { tags: tags }
24
- }
25
- }
26
- payload[:data][:attributes].compact!
27
- payload.to_json
28
- end
29
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Creates request for uploading a document
4
- # See: https://docs.unit.co/application-documents/#upload-document
5
- class UploadDocumentRequest
6
- attr_reader :application_id, :document_id, :file, :file_type, :content_type, :is_back_side
7
-
8
- # @param application_id [String] The application ID
9
- # @param document_id [String] The document ID
10
- # @param file [String] The file path
11
- # @param file_type [String] The file type
12
- # @option file_type [String] :pdf
13
- # @option file_type [String] :jpg
14
- # @option file_type [String] :png
15
- # @param is_back_side [Boolean] The file is back side
16
- def initialize(application_id, document_id, file, file_type,
17
- is_back_side = nil)
18
- @application_id = application_id
19
- @document_id = document_id
20
- @file = file
21
- @file_type = file_type
22
- @is_back_side = is_back_side
23
- end
24
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Request to add authorized users to a project
4
- # See: https://docs.unit.co/customers#add-authorized-users
5
- class AddAuthorizedUsersRequest
6
- attr_reader :customer_id, :authorized_users
7
-
8
- # @param customer_id [String] The id of customer
9
- # @param authorized_users [Array<AuthorizedUser>] The authorized users
10
- def initialize(customer_id, authorized_users)
11
- @customer_id = customer_id
12
- @authorized_users = authorized_users
13
- end
14
-
15
- def to_json_api
16
- payload = {
17
- data: {
18
- type: "addAuthorizedUsers",
19
- attributes: {
20
- authorizedUsers: authorized_users.map(&:represent)
21
- }
22
- }
23
- }
24
- payload[:data][:attributes].compact!
25
- payload.to_json
26
- end
27
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Request to archive customer
4
- # See: https://docs.unit.co/customers#archive-customer
5
- class ArchiveCustomerRequest
6
- attr_reader :customer_id, :reason
7
-
8
- # @param customer_id [String] The id of customer
9
- # @param optional reason [String] The reason for archiving the customer
10
- # @option reason [String] Need to be one of the following: Inactive, FraudACHActivity, FraudCardActivity, FraudCheckActivity, FraudApplicationHistory, FraudAccountActivity, FraudClientIdentified, FraudLinkedToFraudulentCustomer.
11
- def initialize(customer_id, reason = nil)
12
- @customer_id = customer_id
13
- @reason = reason
14
- end
15
-
16
- def to_json_api
17
- payload = {
18
- data: {
19
- type: "archiveCustomer",
20
- attributes: { reason: reason }
21
- }
22
- }
23
- payload[:data][:attributes].compact!
24
- payload.to_json
25
- end
26
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # params for listing customers
4
- # See: https://docs.unit.co/customers#list-customers
5
- class ListCustomerParams
6
- attr_reader :limit, :offset, :query, :email, :tags, :status, :sort
7
-
8
- # @param optional limit [Integer] Maximum number of resources that will be returned. Maximum is 1000 resources.
9
- # @param optional offset [Integer] Number of resources to skip. See pagination: https://docs.unit.co/#intro-pagination
10
- # @param optional query [String] Search term according to the: https://docs.unit.co/#full-text-search
11
- # @param optional email [String] Filter customers by email address (case sensitive).
12
- # @param optional tags [Hash] Filter customers by tags. More information regarding tags: https://docs.unit.co/#tags
13
- # @param optional status [String] Filter customers by status. One of: Active, Archived
14
- # @param optional sort [String] Sorts the resources by the specified field.
15
- # @option sort=createdAt for ascending order
16
- # @option sort=-createdAt (leading minus sign) for descending order.
17
- def initialize(limit = 100, offset = 0, query = nil, email = nil, tags = nil, status = nil,
18
- sort = nil)
19
- @limit = limit
20
- @offset = offset
21
- @query = query
22
- @email = email
23
- @tags = tags
24
- @status = status
25
- @sort = sort
26
- end
27
-
28
- def to_hash
29
- params = { "page[limit]": limit,
30
- "page[offset]": offset,
31
- "filter[query]": query,
32
- "filter[email]": email,
33
- "filter[tags]": tags,
34
- "filter[status]": status,
35
- "sort": sort }
36
- params.compact!
37
- end
38
- end
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Update business customer information request
4
- # See: https://docs.unit.co/customers#update-business-customer
5
- class PatchBusinessCustomerRequest
6
- attr_reader :customer_id, :address, :phone, :contact, :authorized_users, :dba, :tags
7
-
8
- # @param customer_id [String] The id of business
9
- # @param optional address [Address] The address of business
10
- # @param optional phone [Phone] The phone of business
11
- # @param optional contact [BusinessContact] The primary contact of the business
12
- # @param optional authorized_users [Array<AuthorizedUser>] The authorized users of business
13
- # @param optional dba [String] The dba of business. To modify or add needed to specify the new dba name.
14
- # @param optional tags [Hash] Provides opportunity to add, update or delete tags from resources with the tags attribute on the corresponding Update operation
15
- # more information regarding tags: https://docs.unit.co/#updating-tags
16
- def initialize(customer_id, address = nil, phone = nil, contact = nil,
17
- authorized_users = nil, dba = nil, tags = nil)
18
- @customer_id = customer_id
19
- @address = address
20
- @phone = phone
21
- @contact = contact
22
- @authorized_users = authorized_users
23
- @dba = dba
24
- @tags = tags
25
- end
26
-
27
- def to_json_api
28
- payload = {
29
- data: {
30
- type: "businessCustomer",
31
- attributes: {
32
- address: address&.represent,
33
- phone: phone&.represent,
34
- contact: contact&.represent,
35
- authorized_users: authorized_users&.map(&:represent),
36
- dba: dba,
37
- tags: tags
38
- }
39
- }
40
- }
41
- payload[:data][:attributes].compact!
42
- payload.to_json
43
- end
44
- end
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Update individual customer information request
4
- # See: https://docs.unit.co/customers#update-individual-customer
5
- class PatchIndividualCustomerRequest
6
- attr_reader :customer_id, :address, :phone, :email, :dba, :authorized_users, :tags, :jwt_subject
7
-
8
- # @param customer_id [String] The id of individual customer
9
- # @param optional address [Address] The address of individual customer
10
- # @param optional phone [Phone] The phone of individual customer
11
- # @param optional email [String] The email of individual customer
12
- # @param optional dba [String] The dba of individual customer. If the individual is a sole proprietor who is doing business under a different name.
13
- # @param optional authorized_users [Array<AuthorizedUser>] The authorized users of individual customer
14
- # @param optional tags [Hash] Provides opportunity to add, update or delete tags from resources with the tags attribute on the corresponding Update operation
15
- # @param optional jwt_subject [String] The subject of the JWT
16
- # More information regarding JWTSubject: https://docs.unit.co/customer-api-tokens/#customers-create-customer-bearer-token-jwt
17
- def initialize(customer_id, address = nil, phone = nil, email = nil, dba = nil, authorized_users = nil, tags = nil, jwt_subject = nil)
18
- @customer_id = customer_id
19
- @address = address
20
- @phone = phone
21
- @email = email
22
- @dba = dba
23
- @authorized_users = authorized_users
24
- @tags = tags
25
- @jwt_subject = jwt_subject
26
- end
27
-
28
- def to_json_api
29
- payload = {
30
- data: {
31
- type: "individualCustomer",
32
- attributes: {
33
- address: address&.represent,
34
- phone: phone&.represent,
35
- email: email,
36
- dba: dba,
37
- authorized_users: authorized_users&.map(&:represent),
38
- tags: tags
39
- }
40
- }
41
- }
42
- payload[:data][:attributes].compact!
43
- payload.to_json
44
- end
45
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Request to remove authorized users from customer
4
- # See: https://docs.unit.co/customers#remove-authorized-users
5
- class RemoveAuthorizedUsersRequest
6
- attr_reader :customer_id, :authorized_users_emails
7
-
8
- # @param customer_id [String] The id of customer
9
- # @param authorized_users_emails [Array<String>] The list of authorized users emails to remove from the customer.
10
- def initialize(customer_id, authorized_users_emails)
11
- @customer_id = customer_id
12
- @authorized_users_emails = authorized_users_emails
13
- end
14
-
15
- def to_json_api
16
- payload = {
17
- data: {
18
- type: "removeAuthorizedUsers",
19
- attributes: {
20
- authorizedUsersEmails: authorized_users_emails
21
- }
22
- }
23
- }
24
- payload[:data][:attributes].compact!
25
- payload.to_json
26
- end
27
- end