class Plaidio::Call

Constants

BASE_URL

Public Class Methods

new() click to toggle source

This initializes our instance variables, and sets up a new Customer class.

# File lib/plaidio/call.rb, line 7
def initialize
  Plaidio::Configure::KEYS.each do |key|
    instance_variable_set(:"@#{key}", Plaidio.instance_variable_get(:"@#{key}"))
  end
end

Public Instance Methods

add_account(type,username,password,email) click to toggle source
# File lib/plaidio/call.rb, line 13
def add_account(type,username,password,email)
  post('/connect',type,username,password,email)
  return parse_response(@response)
end
get_place(id) click to toggle source
# File lib/plaidio/call.rb, line 18
def get_place(id)
  get('/entity',id)
  return parse_place(@response)
end

Protected Instance Methods

parse_place(response) click to toggle source
# File lib/plaidio/call.rb, line 51
def parse_place(response)
  @parsed_response = Hash.new
  @parsed_response[:code] = response.code
  response = JSON.parse(response)["entity"]
  @parsed_response[:category] = response["category"]
  @parsed_response[:name] = response["name"]
  @parsed_response[:id] = response["_id"]
  @parsed_response[:phone] = response["meta"]["contact"]["telephone"]
  @parsed_response[:location] = response["meta"]["location"]
  return @parsed_response
end
parse_response(response) click to toggle source
# File lib/plaidio/call.rb, line 24
def parse_response(response)
  case response.code
  when 200
    @parsed_response = Hash.new
    @parsed_response[:code] = response.code
    response = JSON.parse(response)
    @parsed_response[:access_token] = response["access_token"]
    @parsed_response[:accounts] = response["accounts"]
    @parsed_response[:transactions] = response["transactions"]
    return @parsed_response
  when 201  
    @parsed_response = Hash.new
    @parsed_response[:code] = response.code
    response = JSON.parse(response)
    @parsed_response = Hash.new
    @parsed_response[:type] = response["type"]
    @parsed_response[:access_token] = response["access_token"]
    @parsed_response[:mfa_info] = response["mfa_info"]
    return @parsed_response
  else
    @parsed_response = Hash.new
    @parsed_response[:code] = response.code
    @parsed_response[:message] = response
    return @parsed_response
  end
end

Private Instance Methods

get(path,id) click to toggle source
# File lib/plaidio/call.rb, line 71
def get(path,id)
  url = BASE_URL + path
  @response = RestClient.get(url, params: {entity_id: id})
  return @response
end
post(path,type,username,password,email) click to toggle source
# File lib/plaidio/call.rb, line 65
def post(path,type,username,password,email)
  url = BASE_URL + path
  @response = RestClient.post url, client_id: self.instance_variable_get(:'@customer_id') ,secret: self.instance_variable_get(:'@secret'), type: type , credentials: {username:  username, password: password} , email: email
  return @response
end