unit_ruby_sdk 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +12 -0
- data/lib/unit/api_resources/counterparty_resource.rb +65 -0
- data/lib/unit/models/account/account.rb +2 -2
- data/lib/unit/models/counterparty/counterparty.rb +93 -0
- data/lib/unit/models/counterparty/create_counterparty_request.rb +56 -0
- data/lib/unit/models/counterparty/create_with_plaid_token_request.rb +53 -0
- data/lib/unit/models/counterparty/list_counterparty_params.rb +45 -0
- data/lib/unit/models/counterparty/update_counterparty_request.rb +40 -0
- data/lib/unit/version.rb +1 -1
- data/lib/unit_ruby_sdk.rb +3 -0
- metadata +8 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: bf85eb968fc7cac1337e5093a9c5998a98997ad7f37956e79c45498785b08ffb
         | 
| 4 | 
            +
              data.tar.gz: e60405762229150510a2e82b76d25aecc547c009c287ca694ef95611e2319c28
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 91ea490c2a75df07cf37281fc32aef9965767fbbcbe12b035a8caf500e3fd08bd23dc2b8eb5c522eef2491885a13c4053ad9c3b0c906925ea077c42ab27c4452
         | 
| 7 | 
            +
              data.tar.gz: 4c687d3bd7a49d5c0bf4c113b20aabf42e1fcfec5381165ced6fb5f45825565bd5ab058529c97224d6d3680df936663589f02011de0b2b636429af8174b37d29
         | 
    
        data/README.md
    CHANGED
    
    | @@ -121,6 +121,18 @@ deposit = response.data | |
| 121 121 | 
             
            puts deposit.id
         | 
| 122 122 | 
             
            ```
         | 
| 123 123 |  | 
| 124 | 
            +
            ### Creating a counterparty with a plaid token
         | 
| 125 | 
            +
            ```ruby
         | 
| 126 | 
            +
            response = Unit::Counterparty.create_with_plaid_token(
         | 
| 127 | 
            +
              customer_id: "823139", 
         | 
| 128 | 
            +
              type: "Business", 
         | 
| 129 | 
            +
              name: "Jo Joel", 
         | 
| 130 | 
            +
              plaid_processor_token: "processor-sandbox-plaid-token")
         | 
| 131 | 
            +
             | 
| 132 | 
            +
            counterparty = response.data
         | 
| 133 | 
            +
            puts counterparty.id
         | 
| 134 | 
            +
            ```
         | 
| 135 | 
            +
             | 
| 124 136 | 
             
            ### Logging Errors
         | 
| 125 137 |  | 
| 126 138 | 
             
            ```ruby
         | 
| @@ -0,0 +1,65 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require_relative "./base_resource"
         | 
| 4 | 
            +
            require_relative "../utils/http_helper"
         | 
| 5 | 
            +
            require "json"
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            # class for creating requests for counterparties to Unit API and parsing responses
         | 
| 8 | 
            +
            # @see https://docs.unit.co/payments-counterparties
         | 
| 9 | 
            +
            module Unit
         | 
| 10 | 
            +
              module Resource
         | 
| 11 | 
            +
                class CounterpartyResource < Unit::Resource::BaseResource
         | 
| 12 | 
            +
                  class << self
         | 
| 13 | 
            +
                    # Create a counterparty by calling Unit's API
         | 
| 14 | 
            +
                    # @param request [CreateCounterpartyRequest, CreateWithPlaidTokenRequest]
         | 
| 15 | 
            +
                    # @return [UnitResponse, UnitError]
         | 
| 16 | 
            +
                    def create_counterparty(request)
         | 
| 17 | 
            +
                      payload = request.to_json_api
         | 
| 18 | 
            +
                      response = HttpHelper.post("#{api_url}/counterparties", body: payload, headers: headers)
         | 
| 19 | 
            +
                      response_handler(response)
         | 
| 20 | 
            +
                    end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                    # Update counterparty by calling Unit's API
         | 
| 23 | 
            +
                    # @param request [UpdateCounterpartyRequest]
         | 
| 24 | 
            +
                    # @return [UnitResponse, UnitError]
         | 
| 25 | 
            +
                    def update_counterparty(request)
         | 
| 26 | 
            +
                      payload = request.to_json_api
         | 
| 27 | 
            +
                      response = HttpHelper.patch("#{api_url}/counterparties/#{request.counterparty_id}", body: payload, headers: headers)
         | 
| 28 | 
            +
                      response_handler(response)
         | 
| 29 | 
            +
                    end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                    # Delete counterparty by calling Unit's API
         | 
| 32 | 
            +
                    # @param counterparty_id String
         | 
| 33 | 
            +
                    # @return [UnitResponse, UnitError]
         | 
| 34 | 
            +
                    def delete(counterparty_id)
         | 
| 35 | 
            +
                      response = HttpHelper.delete("#{api_url}/counterparties/#{counterparty_id}", headers: headers, response_type: "delete")
         | 
| 36 | 
            +
                      file_response_handler(response)
         | 
| 37 | 
            +
                    end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                    # Get counterparty by id by calling Unit's API
         | 
| 40 | 
            +
                    # @param counterparty_id String
         | 
| 41 | 
            +
                    # @return [UnitResponse, UnitError]
         | 
| 42 | 
            +
                    def get_counterparty(counterparty_id)
         | 
| 43 | 
            +
                      response = HttpHelper.get("#{api_url}/counterparties/#{counterparty_id}", headers: headers)
         | 
| 44 | 
            +
                      response_handler(response)
         | 
| 45 | 
            +
                    end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                    # Get counterparty balance
         | 
| 48 | 
            +
                    # @param counterparty_id String
         | 
| 49 | 
            +
                    # @return [UnitResponse, UnitError]
         | 
| 50 | 
            +
                    def get_counterparty_balance(counterparty_id)
         | 
| 51 | 
            +
                      response = HttpHelper.get("#{api_url}/counterparties/#{counterparty_id}/balance", headers: headers)
         | 
| 52 | 
            +
                      response_handler(response)
         | 
| 53 | 
            +
                    end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                    # List counterparties
         | 
| 56 | 
            +
                    # @param params [ListCounterpartyParams]
         | 
| 57 | 
            +
                    # @return [UnitResponse, UnitError]
         | 
| 58 | 
            +
                    def list(params = nil)
         | 
| 59 | 
            +
                      response = HttpHelper.get("#{api_url}/counterparties", params: params.to_hash, headers: headers)
         | 
| 60 | 
            +
                      response_handler(response)
         | 
| 61 | 
            +
                    end
         | 
| 62 | 
            +
                  end
         | 
| 63 | 
            +
                end
         | 
| 64 | 
            +
              end
         | 
| 65 | 
            +
            end
         | 
| @@ -34,8 +34,8 @@ module Unit | |
| 34 34 | 
             
                    # @param reason [String]
         | 
| 35 35 | 
             
                    # @param fraud_reason [String] - optional
         | 
| 36 36 | 
             
                    # @return [UnitResponse, UnitError]
         | 
| 37 | 
            -
                    def close_deposit_account(account_id:, reason:)
         | 
| 38 | 
            -
                      request = CloseDepositAccountRequest.new(account_id, reason)
         | 
| 37 | 
            +
                    def close_deposit_account(account_id:, reason:, fraud_reason: nil)
         | 
| 38 | 
            +
                      request = CloseDepositAccountRequest.new(account_id, reason, fraud_reason)
         | 
| 39 39 | 
             
                      Unit::Resource::AccountResource.close_account(request)
         | 
| 40 40 | 
             
                    end
         | 
| 41 41 |  | 
| @@ -0,0 +1,93 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Unit
         | 
| 4 | 
            +
              module Counterparty
         | 
| 5 | 
            +
                COUNTER_PARTY_LIMIT = 100
         | 
| 6 | 
            +
                COUNTER_PARTY_OFFSET = 0
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                autoload :CreateCounterpartyRequest, "unit/models/counterparty/create_counterparty_request"
         | 
| 9 | 
            +
                autoload :CreateWithPlaidTokenRequest, "unit/models/counterparty/create_with_plaid_token_request"
         | 
| 10 | 
            +
                autoload :ListCounterpartyParams, "unit/models/counterparty/list_counterparty_params"
         | 
| 11 | 
            +
                autoload :UpdateCounterpartyRequest, "unit/models/counterparty/update_counterparty_request"
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                class << self
         | 
| 14 | 
            +
                  # Create counterparty by calling Unit's API
         | 
| 15 | 
            +
                  # @see https://docs.unit.co/payments-counterparties/#create-counterparty
         | 
| 16 | 
            +
                  # @param customer_id [String]
         | 
| 17 | 
            +
                  # @param name [String]
         | 
| 18 | 
            +
                  # @param routing_number [String]
         | 
| 19 | 
            +
                  # @param account_number [String]
         | 
| 20 | 
            +
                  # @param account_type [String]
         | 
| 21 | 
            +
                  # @param type [String]
         | 
| 22 | 
            +
                  # @param tags [Hash] - optional
         | 
| 23 | 
            +
                  # @param permissions [String] - optional
         | 
| 24 | 
            +
                  # @param idempotency_key [String] - optional
         | 
| 25 | 
            +
                  def create_counterparty(customer_id:, name:, routing_number:, account_number:, account_type:, type:, tags: nil, permissions: nil, idempotency_key: nil)
         | 
| 26 | 
            +
                    request = CreateCounterpartyRequest.new(customer_id, name, routing_number, account_number, account_type, type, tags, permissions, idempotency_key)
         | 
| 27 | 
            +
                    Unit::Resource::CounterpartyResource.create_counterparty(request)
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  # Create counterparty with plaid token
         | 
| 31 | 
            +
                  # @see https://docs.unit.co/payments-counterparties/#create-counterparty-with-plaid-token
         | 
| 32 | 
            +
                  # @param customer_id [String]
         | 
| 33 | 
            +
                  # @param type [String]
         | 
| 34 | 
            +
                  # @param name [String]
         | 
| 35 | 
            +
                  # @param plaid_processor_token [String]
         | 
| 36 | 
            +
                  # @param verify_name [Boolean] - optional
         | 
| 37 | 
            +
                  # @param permissions [String] - optional
         | 
| 38 | 
            +
                  # @param tags [Hash] - optional
         | 
| 39 | 
            +
                  # @param idempotency_key [String] - optional
         | 
| 40 | 
            +
                  def create_with_plaid_token(customer_id:, type:, name:, plaid_processor_token:, verify_name: nil, permissions: nil, tags: nil, idempotency_key: nil)
         | 
| 41 | 
            +
                    request = CreateWithPlaidTokenRequest.new(customer_id, type, name, plaid_processor_token, verify_name, permissions, tags, idempotency_key)
         | 
| 42 | 
            +
                    Unit::Resource::CounterpartyResource.create_counterparty(request)
         | 
| 43 | 
            +
                  end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                  # List counterparties
         | 
| 46 | 
            +
                  # @see https://docs.unit.co/payments-counterparties/#list-counterparties
         | 
| 47 | 
            +
                  # @param limit [Integer] - optional
         | 
| 48 | 
            +
                  # @param offset [Integer] - optional
         | 
| 49 | 
            +
                  # @param customer_id [String] - optional
         | 
| 50 | 
            +
                  # @param account_number [String] - optional
         | 
| 51 | 
            +
                  # @param routing_number [String] - optional
         | 
| 52 | 
            +
                  # @param tags [Hash] - optional
         | 
| 53 | 
            +
                  # @param permissions [Array<String>] - optional
         | 
| 54 | 
            +
                  def list_counterparty(limit: COUNTER_PARTY_LIMIT, offset: COUNTER_PARTY_OFFSET, customer_id: nil, account_number: nil, routing_number: nil, tags: nil, permissions: nil)
         | 
| 55 | 
            +
                    params = ListCounterpartyParams.new(limit, offset, customer_id, account_number, routing_number, tags, permissions)
         | 
| 56 | 
            +
                    Unit::Resource::CounterpartyResource.list(params)
         | 
| 57 | 
            +
                  end
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                  # Get counterparty by id
         | 
| 60 | 
            +
                  # @param counterparty_id [String]
         | 
| 61 | 
            +
                  # @see https://docs.unit.co/payments-counterparties/#get-one-counterparty
         | 
| 62 | 
            +
                  def get_counterparty(counterparty_id:)
         | 
| 63 | 
            +
                    Unit::Resource::CounterpartyResource.get_counterparty(counterparty_id)
         | 
| 64 | 
            +
                  end
         | 
| 65 | 
            +
             | 
| 66 | 
            +
                  # Get counterparty balance
         | 
| 67 | 
            +
                  # @param counterparty_id [String]
         | 
| 68 | 
            +
                  # @see https://docs.unit.co/payments-counterparties/#get-counterparty-balance
         | 
| 69 | 
            +
                  def get_counterparty_balance(counterparty_id:)
         | 
| 70 | 
            +
                    Unit::Resource::CounterpartyResource.get_counterparty_balance(counterparty_id)
         | 
| 71 | 
            +
                  end
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                  # Update counterparty
         | 
| 74 | 
            +
                  # @see https://docs.unit.co/payments-counterparties/#list-counterparties
         | 
| 75 | 
            +
                  # @param counterparty_id [String]
         | 
| 76 | 
            +
                  # @param plaid_processor_token [String]
         | 
| 77 | 
            +
                  # @param verify_name [Boolean] - optional
         | 
| 78 | 
            +
                  # @param permissions [String] - optional
         | 
| 79 | 
            +
                  # @param tags [Hash] - optional
         | 
| 80 | 
            +
                  def update_counterparty(counterparty_id:, plaid_processor_token: nil, verify_name: nil, permissions: nil, tags: nil)
         | 
| 81 | 
            +
                    request = UpdateCounterpartyRequest.new(counterparty_id, plaid_processor_token, verify_name, permissions, tags)
         | 
| 82 | 
            +
                    Unit::Resource::CounterpartyResource.update_counterparty(request)
         | 
| 83 | 
            +
                  end
         | 
| 84 | 
            +
             | 
| 85 | 
            +
                  # Delete counterparty
         | 
| 86 | 
            +
                  # @param counterparty_id [String]
         | 
| 87 | 
            +
                  # @see https://docs.unit.co/payments-counterparties/#get-one-counterparty
         | 
| 88 | 
            +
                  def delete_counterparty(counterparty_id:)
         | 
| 89 | 
            +
                    Unit::Resource::CounterpartyResource.delete(counterparty_id)
         | 
| 90 | 
            +
                  end
         | 
| 91 | 
            +
                end
         | 
| 92 | 
            +
              end
         | 
| 93 | 
            +
            end
         | 
| @@ -0,0 +1,56 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            # Request to create a counterparty
         | 
| 4 | 
            +
            # @see https://docs.unit.co/payments-counterparties/#create-counterparty
         | 
| 5 | 
            +
            module Unit
         | 
| 6 | 
            +
              module Counterparty
         | 
| 7 | 
            +
                class CreateCounterpartyRequest
         | 
| 8 | 
            +
                  attr_reader :customer_id, :name, :routing_number, :account_number, :account_type,
         | 
| 9 | 
            +
                              :type, :tags, :permissions, :idempotency_key
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  # @param customer_id [String]
         | 
| 12 | 
            +
                  # @param name [String]
         | 
| 13 | 
            +
                  # @param routing_number [String]
         | 
| 14 | 
            +
                  # @param account_number [String]
         | 
| 15 | 
            +
                  # @param account_type [String]
         | 
| 16 | 
            +
                  # @param type [String]
         | 
| 17 | 
            +
                  # @param tags [Hash] - optional
         | 
| 18 | 
            +
                  # @param permissions [String] - optional
         | 
| 19 | 
            +
                  # @param idempotency_key [String] - optional
         | 
| 20 | 
            +
                  def initialize(customer_id, name, routing_number, account_number, account_type, type, tags = nil, permissions = nil, idempotency_key = nil)
         | 
| 21 | 
            +
                    @customer_id = customer_id
         | 
| 22 | 
            +
                    @name = name
         | 
| 23 | 
            +
                    @routing_number = routing_number
         | 
| 24 | 
            +
                    @account_number = account_number
         | 
| 25 | 
            +
                    @account_type = account_type
         | 
| 26 | 
            +
                    @type = type
         | 
| 27 | 
            +
                    @tags = tags
         | 
| 28 | 
            +
                    @permissions = permissions
         | 
| 29 | 
            +
                    @idempotency_key = idempotency_key
         | 
| 30 | 
            +
                  end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                  def to_json_api
         | 
| 33 | 
            +
                    payload = {
         | 
| 34 | 
            +
                      "data": {
         | 
| 35 | 
            +
                        "type": "achCounterparty",
         | 
| 36 | 
            +
                        "attributes": {
         | 
| 37 | 
            +
                          name: name,
         | 
| 38 | 
            +
                          routingNumber: routing_number,
         | 
| 39 | 
            +
                          accountNumber: account_number,
         | 
| 40 | 
            +
                          accountType: account_type,
         | 
| 41 | 
            +
                          type: type,
         | 
| 42 | 
            +
                          tags: tags,
         | 
| 43 | 
            +
                          permissions: permissions,
         | 
| 44 | 
            +
                          idempotencyKey: idempotency_key
         | 
| 45 | 
            +
                        },
         | 
| 46 | 
            +
                        "relationships": {
         | 
| 47 | 
            +
                          customer: Unit::Types::Relationship.new("customer", customer_id).to_hash
         | 
| 48 | 
            +
                        }
         | 
| 49 | 
            +
                      }
         | 
| 50 | 
            +
                    }
         | 
| 51 | 
            +
                    payload[:data][:attributes].compact!
         | 
| 52 | 
            +
                    payload.to_json
         | 
| 53 | 
            +
                  end
         | 
| 54 | 
            +
                end
         | 
| 55 | 
            +
              end
         | 
| 56 | 
            +
            end
         | 
| @@ -0,0 +1,53 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            # Request to create a counterparty with plaid token
         | 
| 4 | 
            +
            # @see https://docs.unit.co/payments-counterparties/#create-counterparty-with-plaid-token
         | 
| 5 | 
            +
            module Unit
         | 
| 6 | 
            +
              module Counterparty
         | 
| 7 | 
            +
                class CreateWithPlaidTokenRequest
         | 
| 8 | 
            +
                  attr_reader :customer_id, :type, :name, :plaid_processor_token,
         | 
| 9 | 
            +
                              :verify_name, :permissions, :tags, :idempotency_key
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  # @param customer_id [String]
         | 
| 12 | 
            +
                  # @param type [String]
         | 
| 13 | 
            +
                  # @param name [String]
         | 
| 14 | 
            +
                  # @param plaid_processor_token [String]
         | 
| 15 | 
            +
                  # @param verify_name [Boolean] - optional
         | 
| 16 | 
            +
                  # @param permissions [String] - optional
         | 
| 17 | 
            +
                  # @param tags [Hash] - optional
         | 
| 18 | 
            +
                  # @param idempotency_key [String] - optional
         | 
| 19 | 
            +
                  def initialize(customer_id, type, name, plaid_processor_token, verify_name = nil, permissions = nil, tags = nil, idempotency_key = nil)
         | 
| 20 | 
            +
                    @customer_id = customer_id
         | 
| 21 | 
            +
                    @type = type
         | 
| 22 | 
            +
                    @name = name
         | 
| 23 | 
            +
                    @plaid_processor_token = plaid_processor_token
         | 
| 24 | 
            +
                    @verify_name = verify_name
         | 
| 25 | 
            +
                    @permissions = permissions
         | 
| 26 | 
            +
                    @tags = tags
         | 
| 27 | 
            +
                    @idempotency_key = idempotency_key
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  def to_json_api
         | 
| 31 | 
            +
                    payload = {
         | 
| 32 | 
            +
                      "data": {
         | 
| 33 | 
            +
                        "type": "achCounterparty",
         | 
| 34 | 
            +
                        "attributes": {
         | 
| 35 | 
            +
                          type: type,
         | 
| 36 | 
            +
                          name: name,
         | 
| 37 | 
            +
                          plaidProcessorToken: plaid_processor_token,
         | 
| 38 | 
            +
                          verifyName: verify_name,
         | 
| 39 | 
            +
                          permissions: permissions,
         | 
| 40 | 
            +
                          tags: tags,
         | 
| 41 | 
            +
                          idempotencyKey: idempotency_key
         | 
| 42 | 
            +
                        },
         | 
| 43 | 
            +
                        "relationships": {
         | 
| 44 | 
            +
                          customer: Unit::Types::Relationship.new("customer", customer_id).to_hash
         | 
| 45 | 
            +
                        }
         | 
| 46 | 
            +
                      }
         | 
| 47 | 
            +
                    }
         | 
| 48 | 
            +
                    payload[:data][:attributes].compact!
         | 
| 49 | 
            +
                    payload.to_json
         | 
| 50 | 
            +
                  end
         | 
| 51 | 
            +
                end
         | 
| 52 | 
            +
              end
         | 
| 53 | 
            +
            end
         | 
| @@ -0,0 +1,45 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            # Request to list counterparties
         | 
| 4 | 
            +
            # @see https://docs.unit.co/payments-counterparties/#list-counterparties
         | 
| 5 | 
            +
            module Unit
         | 
| 6 | 
            +
              module Counterparty
         | 
| 7 | 
            +
                class ListCounterpartyParams
         | 
| 8 | 
            +
                  attr_reader :limit, :offset, :customer_id, :account_number, :routing_number, :tags, :permissions
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  # @param limit [Integer] - optional
         | 
| 11 | 
            +
                  # @param offset [Integer] - optional
         | 
| 12 | 
            +
                  # @param customer_id [String] - optional
         | 
| 13 | 
            +
                  # @param account_number [String] - optional
         | 
| 14 | 
            +
                  # @param routing_number [String] - optional
         | 
| 15 | 
            +
                  # @param tags [Hash] - optional
         | 
| 16 | 
            +
                  # @param permissions [Array<String>] - optional
         | 
| 17 | 
            +
                  def initialize(limit = COUNTER_PARTY_LIMIT, offset = COUNTER_PARTY_OFFSET, customer_id = nil,
         | 
| 18 | 
            +
                                 account_number = nil, routing_number = nil, tags = nil, permissions = nil)
         | 
| 19 | 
            +
                    @limit = limit
         | 
| 20 | 
            +
                    @offset = offset
         | 
| 21 | 
            +
                    @customer_id = customer_id
         | 
| 22 | 
            +
                    @account_number = account_number
         | 
| 23 | 
            +
                    @routing_number = routing_number
         | 
| 24 | 
            +
                    @tags = tags
         | 
| 25 | 
            +
                    @permissions = permissions
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  def to_hash
         | 
| 29 | 
            +
                    params =
         | 
| 30 | 
            +
                      {
         | 
| 31 | 
            +
                        "page[limit]": limit,
         | 
| 32 | 
            +
                        "page[offset]": offset,
         | 
| 33 | 
            +
                        "filter[customerId]": customer_id,
         | 
| 34 | 
            +
                        "filter[accountNumber]": account_number,
         | 
| 35 | 
            +
                        "filter[routingNumber]": routing_number,
         | 
| 36 | 
            +
                        "filter[tags]": tags
         | 
| 37 | 
            +
                      }
         | 
| 38 | 
            +
                    permissions&.each_with_index&.map do |val, index|
         | 
| 39 | 
            +
                      params.merge!({ "filter[permissions][#{index}]": val })
         | 
| 40 | 
            +
                    end
         | 
| 41 | 
            +
                    params.compact
         | 
| 42 | 
            +
                  end
         | 
| 43 | 
            +
                end
         | 
| 44 | 
            +
              end
         | 
| 45 | 
            +
            end
         | 
| @@ -0,0 +1,40 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            # Request to update a counterparty
         | 
| 4 | 
            +
            # @see https://docs.unit.co/payments-counterparties/#list-counterparties
         | 
| 5 | 
            +
            module Unit
         | 
| 6 | 
            +
              module Counterparty
         | 
| 7 | 
            +
                class UpdateCounterpartyRequest
         | 
| 8 | 
            +
                  attr_reader :counterparty_id, :plaid_processor_token, :verify_name, :permissions, :tags
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  # @param counterparty_id [String]
         | 
| 11 | 
            +
                  # @param plaid_processor_token [String]
         | 
| 12 | 
            +
                  # @param verify_name [Boolean] - optional
         | 
| 13 | 
            +
                  # @param permissions [String] - optional
         | 
| 14 | 
            +
                  # @param tags [Hash] - optional
         | 
| 15 | 
            +
                  def initialize(counterparty_id, plaid_processor_token, verify_name = nil, permissions = nil, tags = nil)
         | 
| 16 | 
            +
                    @counterparty_id = counterparty_id
         | 
| 17 | 
            +
                    @plaid_processor_token = plaid_processor_token
         | 
| 18 | 
            +
                    @verify_name = verify_name
         | 
| 19 | 
            +
                    @permissions = permissions
         | 
| 20 | 
            +
                    @tags = tags
         | 
| 21 | 
            +
                  end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                  def to_json_api
         | 
| 24 | 
            +
                    payload = {
         | 
| 25 | 
            +
                      "data": {
         | 
| 26 | 
            +
                        "type": "counterparty",
         | 
| 27 | 
            +
                        attributes: {
         | 
| 28 | 
            +
                          plaidProcessorToken: plaid_processor_token,
         | 
| 29 | 
            +
                          verifyName: verify_name,
         | 
| 30 | 
            +
                          permissions: permissions,
         | 
| 31 | 
            +
                          tags: tags
         | 
| 32 | 
            +
                        }
         | 
| 33 | 
            +
                      }
         | 
| 34 | 
            +
                    }
         | 
| 35 | 
            +
                    payload[:data][:attributes].compact!
         | 
| 36 | 
            +
                    payload.to_json
         | 
| 37 | 
            +
                  end
         | 
| 38 | 
            +
                end
         | 
| 39 | 
            +
              end
         | 
| 40 | 
            +
            end
         | 
    
        data/lib/unit/version.rb
    CHANGED
    
    
    
        data/lib/unit_ruby_sdk.rb
    CHANGED
    
    | @@ -13,6 +13,8 @@ module Unit | |
| 13 13 | 
             
              autoload :Statement, "unit/models/statement/statement"
         | 
| 14 14 | 
             
              autoload :AtmLocation, "unit/models/atm_location/atm_location"
         | 
| 15 15 | 
             
              autoload :CheckDeposit, "unit/models/check_deposit/check_deposit"
         | 
| 16 | 
            +
              autoload :Counterparty, "unit/models/counterparty/counterparty"
         | 
| 17 | 
            +
             | 
| 16 18 | 
             
              module Resource
         | 
| 17 19 | 
             
                autoload :ApplicationResource, "unit/api_resources/application_resource"
         | 
| 18 20 | 
             
                autoload :CustomerResource, "unit/api_resources/customer_resource"
         | 
| @@ -24,6 +26,7 @@ module Unit | |
| 24 26 | 
             
                autoload :StatementResource, "unit/api_resources/statement_resource"
         | 
| 25 27 | 
             
                autoload :AtmLocationResource, "unit/api_resources/atm_location_resource"
         | 
| 26 28 | 
             
                autoload :CheckDepositResource, "unit/api_resources/check_deposit_resource"
         | 
| 29 | 
            +
                autoload :CounterpartyResource, "unit/api_resources/counterparty_resource"
         | 
| 27 30 | 
             
              end
         | 
| 28 31 |  | 
| 29 32 | 
             
              module Types
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: unit_ruby_sdk
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.0. | 
| 4 | 
            +
              version: 1.0.3
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Unit
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2023-02- | 
| 11 | 
            +
            date: 2023-02-12 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: factory_bot_rails
         | 
| @@ -101,6 +101,7 @@ files: | |
| 101 101 | 
             
            - lib/unit/api_resources/base_resource.rb
         | 
| 102 102 | 
             
            - lib/unit/api_resources/card_resource.rb
         | 
| 103 103 | 
             
            - lib/unit/api_resources/check_deposit_resource.rb
         | 
| 104 | 
            +
            - lib/unit/api_resources/counterparty_resource.rb
         | 
| 104 105 | 
             
            - lib/unit/api_resources/customer_resource.rb
         | 
| 105 106 | 
             
            - lib/unit/api_resources/payment_resource.rb
         | 
| 106 107 | 
             
            - lib/unit/api_resources/statement_resource.rb
         | 
| @@ -144,6 +145,11 @@ files: | |
| 144 145 | 
             
            - lib/unit/models/check_deposit/list_deposit_params.rb
         | 
| 145 146 | 
             
            - lib/unit/models/check_deposit/patch_deposit_request.rb
         | 
| 146 147 | 
             
            - lib/unit/models/check_deposit/upload_image_request.rb
         | 
| 148 | 
            +
            - lib/unit/models/counterparty/counterparty.rb
         | 
| 149 | 
            +
            - lib/unit/models/counterparty/create_counterparty_request.rb
         | 
| 150 | 
            +
            - lib/unit/models/counterparty/create_with_plaid_token_request.rb
         | 
| 151 | 
            +
            - lib/unit/models/counterparty/list_counterparty_params.rb
         | 
| 152 | 
            +
            - lib/unit/models/counterparty/update_counterparty_request.rb
         | 
| 147 153 | 
             
            - lib/unit/models/customer/add_authorized_users_request.rb
         | 
| 148 154 | 
             
            - lib/unit/models/customer/archive_customer_request.rb
         | 
| 149 155 | 
             
            - lib/unit/models/customer/customer.rb
         |