class Mambu::Connection

Public Class Methods

new(username, password, tenant) click to toggle source
# File lib/mambu/connection.rb, line 3
def initialize(username, password, tenant)
  @username = username
  @password = password
  @tenant = tenant
  fail Mambu::Error, 'Insufficient credentials' unless valid?
end

Public Instance Methods

api_url() click to toggle source
# File lib/mambu/connection.rb, line 28
def api_url
  "https://#{@tenant}.mambu.com/api"
end
connection() click to toggle source
# File lib/mambu/connection.rb, line 22
def connection
  conn = Faraday.new
  conn.basic_auth(@username, @password)
  conn
end
get(url, options = {}) click to toggle source
# File lib/mambu/connection.rb, line 10
def get(url, options = {})
  request(:get, url, options)
end
loan_product(id) click to toggle source
# File lib/mambu/connection.rb, line 36
def loan_product(id)
  Mambu::LoanProduct.find(id, self)
end
loan_products() click to toggle source
# File lib/mambu/connection.rb, line 40
def loan_products
  Mambu::LoanProduct.find_all(self)
end
post(url, options = {}) click to toggle source
# File lib/mambu/connection.rb, line 14
def post(url, options = {})
  request(:post, url, options)
end
request(method, url, options) click to toggle source
# File lib/mambu/connection.rb, line 18
def request(method, url, options)
  Mambu::Response.new(connection.send(method, url, options))
end
valid?() click to toggle source
# File lib/mambu/connection.rb, line 32
def valid?
  @username.present? && @password.present? && @tenant.present?
end