class Transfer

Public Class Methods

apiKey() click to toggle source
# File lib/capital_one/transfer.rb, line 11
def self.apiKey
        return Config.apiKey
end
createTransfer(accId, transfer) click to toggle source
*** POST ***

createAccount

Creates a new transfer
Parameters: AccountID, TransferHash
Returns the http response code.
# File lib/capital_one/transfer.rb, line 52
def self.createTransfer(accId, transfer)
        transferToCreate = transfer.to_json
        url = "#{self.urlWithEntity}/#{accId}/transfers?key=#{self.apiKey}"
        uri = URI.parse(url)
        http = Net::HTTP.new(uri.host, uri.port)
        request = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' =>'application/json'})
        request.body = transferToCreate
        response = http.request(request)
        return JSON.parse(response.body)
end
deleteTransfer(id) click to toggle source
*** DELETE ***

deleteAccount

delete a given transfer by TransferId.
Parameters: TransferId.
Returns the http response code.
# File lib/capital_one/transfer.rb, line 85
def self.deleteTransfer(id)
        url = "#{self.url}/transfers/#{id}?key=#{self.apiKey}"
        uri = URI.parse(url)
        http = Net::HTTP.new(uri.host, uri.port)
        key="?key=#{self.apiKey}"
        request = Net::HTTP::Delete.new(uri.path+key)
        response = http.request(request)
end
getAll(accId) click to toggle source
*** GET ***

getAll

Returns an array of hashes getting all the transfers for an account.
Each index in the array is the hash of an individual transfer.
# File lib/capital_one/transfer.rb, line 19
def self.getAll(accId)
        url = "#{self.urlWithEntity}/#{accId}/transfers?&key=#{self.apiKey}"
        resp = Net::HTTP.get_response(URI.parse(url))
        data = JSON.parse(resp.body)
end
getAllByType(accId, type) click to toggle source

getAllByType

Gets all transfers of a given type and account.

Parameters:

Accepts a string of the transfer type. 2 possbilities: payer or payee
Returns an array of hashes with the transfers.
# File lib/capital_one/transfer.rb, line 30
def self.getAllByType(accId, type)
        url = "#{self.urlWithEntity}/#{accId}/transfers?type=#{type}&key=#{self.apiKey}"
        resp = Net::HTTP.get_response(URI.parse(url))
        data = JSON.parse(resp.body)
end
getOne(id) click to toggle source

getOne

Returns the transfer specified by its transfer ID.

Parameters:

Accepts a string of the transfer ID. 
Returns a hash with the transfer info.
# File lib/capital_one/transfer.rb, line 41
def self.getOne(id)
        url = "#{self.url}/transfers/#{id}?key=#{self.apiKey}"
        resp = Net::HTTP.get_response(URI.parse(url))
        data = JSON.parse(resp.body)
end
updateTransfer(id, transfer) click to toggle source
*** PUT ***

updateAccount

Updates a transfer's info.
Parameters: TransferId, TransferHash
Returns the http response code.
# File lib/capital_one/transfer.rb, line 68
def self.updateTransfer(id, transfer)
        transferToUpdate = transfer.to_json
        url = "#{self.url}/transfers/#{id}?key=#{self.apiKey}"
        uri = URI.parse(url)
        http = Net::HTTP.new(uri.host, uri.port)
        key = "?key=#{self.apiKey}"
        request = Net::HTTP::Put.new(uri.path+key, initheader = {'Content-Type' =>'application/json'})
        request.body = transferToUpdate
        response = http.request(request)
        return JSON.parse(response.body)
end
url() click to toggle source
# File lib/capital_one/transfer.rb, line 7
def self.url
        return Config.baseUrl
end
urlWithEntity() click to toggle source
# File lib/capital_one/transfer.rb, line 3
def self.urlWithEntity
        return Config.baseUrl + "/accounts"
end