class Deposit

Public Class Methods

apiKey() click to toggle source
# File lib/capital_one/deposit.rb, line 11
def self.apiKey
  return Config.apiKey
end
createDeposit(toAcc, deposit) click to toggle source

createDeposit

Creates a new deposit.
Parameters: toAccountId, DepositHash
DepositHash is formatted as follows: 
{
  "medium": "balance",
  "transaction_date": "string",
  "status": "pending",
  "amount": 0,
  "description": "string"
}
Returns http response code.
# File lib/capital_one/deposit.rb, line 56
def self.createDeposit(toAcc, deposit)
  depositToCreate = deposit.to_json
  url = "#{self.urlWithEntity}/#{toAcc}/deposits?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 = depositToCreate
  resp = http.request(request)
  data = JSON.parse(resp.body)
end
deleteDeposit(id) click to toggle source

deleteDeposit

Deletes an existing deposit

Parameters: DepositId

Returns http response code
# File lib/capital_one/deposit.rb, line 102
def self.deleteDeposit(id)
  url = "#{self.url}/deposits/#{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)
  resp = http.request(request)
end
getAllByAccountId(accID) click to toggle source
*** GET ***

getAllByAccountId

Get all deposits for a specific account

Parameters: AccountID

Returns an array of hashes containing the deposits for that account.
# File lib/capital_one/deposit.rb, line 22
def self.getAllByAccountId(accID)
  url = "#{self.urlWithEntity}/#{accID}/deposits?key=#{self.apiKey}"
  resp = Net::HTTP.get_response(URI.parse(url))
  data = JSON.parse(resp.body)
  return data
end
getOne(id) click to toggle source

getOne

Returns a deposit for a given ID

Parameters: DepositId

Returns a hash with the deposit data
# File lib/capital_one/deposit.rb, line 34
def self.getOne(id)
  url = "#{self.url}/deposits/#{id}?key=#{self.apiKey}"
  resp = Net::HTTP.get_response(URI.parse(url))
  data = JSON.parse(resp.body)
end
updateDeposit(id, deposit) click to toggle source

updateDeposit

Updates an existing deposit

Parameters: DepositId, DepositHash

DepositHash is formatted as follows: 
{
  "medium": "balance",
  "transaction_date": "string",
  "status": "pending",
  "amount": 0,
  "description": "string"
}
Returns http response code
# File lib/capital_one/deposit.rb, line 83
def self.updateDeposit(id, deposit)
  depositToUpdate = deposit.to_json
  url = "#{self.url}/deposits/#{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 = depositToUpdate
  response = http.request(request)
  return JSON.parse(response.body)
end
url() click to toggle source
# File lib/capital_one/deposit.rb, line 7
def self.url
  return Config.baseUrl
end
urlWithEntity() click to toggle source
# File lib/capital_one/deposit.rb, line 3
def self.urlWithEntity
  return Config.baseUrl + "/accounts"
end