Sha256: 6172512355d7e9b18d7eabf10805988b370c5ce0909d477e7fc7c3a443a9e1ec

Contents?: true

Size: 1.11 KB

Versions: 4

Compression:

Stored size: 1.11 KB

Contents

module Moip2
  class BankAccountsApi
    attr_reader :client

    def initialize(client)
      @client = client
    end

    def create(account_id, bank_account)
      Resource::BankAccount.new client, client.post(
        base_account_path(account_id),
         bank_account,
      )
    end

    def show(bank_account_id)
      Resource::BankAccount.new client, client.get(
        base_bank_account_path(bank_account_id),
      )
    end

    def delete(bank_account_id)
      Resource::BankAccount.new client, client.delete(
        base_bank_account_path(bank_account_id),
      )
    end

    def update(bank_account_id, bank_account)
      Resource::BankAccount.new client, client.put(
        base_bank_account_path(bank_account_id),
        bank_account,
      )
    end

    def find_all(account_id)
      Resource::BankAccount.new client, client.get(
        base_account_path(account_id),
      )
    end

    private

    def base_bank_account_path(bank_account_id)
      "/v2/bankaccounts/#{bank_account_id}"
    end

    def base_account_path(account_id)
      "/v2/accounts/#{account_id}/bankaccounts"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
moip2-1.3.1 lib/moip2/bank_accounts_api.rb
moip2-1.2.1 lib/moip2/bank_accounts_api.rb
moip2-1.2.0 lib/moip2/bank_accounts_api.rb
moip2-1.1.0 lib/moip2/bank_accounts_api.rb