Sha256: a1f7b71c45fd96e45746259b4ca2c18101c69b8826ae69c970a46df13342a727

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

module SynapsePay
  class BankEndpoint < APIEndpoint
    
    def add(params={}, headers={})
      method = APIMethod.new(:post, "/bank/add", params, headers, self)
      json = @client.execute(method)
      Bank.new(json[:bank], method, @client)
    end

    def all(params={}, headers={})
      method = APIMethod.new(:post, "/bank/show", params, headers, self)
      json = @client.execute(method)
      APIList.new(:Bank, json[:banks], method, @client)
    end

    def link(params={}, headers={})
      method = APIMethod.new(:post, "/bank/login", params, headers, self)
      json = @client.execute(method)
      if(json[:is_mfa] && json[:response][:type] == "questions")
        BankMfaQuestions.new(json[:response], method, @client)
      elsif(json[:is_mfa] && json[:response][:type] == "device")
        BankMfaDevice.new(json[:response], method, @client)
      else
        APIList.new(:Bank, json[:banks], method, @client)
      end
    end

    def remove(bank_id, params={}, headers={})
      params = ParamsBuilder.merge({
        :bank_id => bank_id,
      }, params)
      method = APIMethod.new(:post, "/bank/delete", params, headers, self)
      json = @client.execute(method)
      json
    end

    def retrieve(id, params={}, headers={})
      params = ParamsBuilder.merge({
        :id => id,
      }, params)
      method = APIMethod.new(:post, "/bank/refresh", params, headers, self)
      json = @client.execute(method)
      APIList.new(:Bank, json[:banks], method, @client)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
synapse_pay-0.0.1 lib/synapse_pay/endpoints/bank_endpoint.rb