class VogogoRuby::VogogoDirectAPI
Constants
- ACCOUNT
- API_URL
- CREDIT_CARD_CHARGE
- CUSTOMER
- CUSTOMER_ACCOUNT
- DEPOSIT
- EFT_CREDIT
- INVOICE
- ITEM
- URL_BASE
- WITHDRAWAL
Public Class Methods
new(key, token, user)
click to toggle source
debug_output $stderr
# File lib/vogogo_ruby.rb, line 22 def initialize(key, token, user) @auth = {username: user, password: key + ':' + token} end
Public Instance Methods
create_customer(data)
click to toggle source
# File lib/vogogo_ruby.rb, line 87 def create_customer data raise DataHashError.new 'customer details hash cannot be empty' if data.nil? || data.empty? create CUSTOMER, data end
create_customer_account(data)
click to toggle source
# File lib/vogogo_ruby.rb, line 112 def create_customer_account data raise DataHashError.new 'customer account details hash cannot be empty' if data.nil? || data.empty? create CUSTOMER_ACCOUNT, data end
create_invoice(data)
click to toggle source
# File lib/vogogo_ruby.rb, line 42 def create_invoice data raise DataHashError.new 'invoice details hash cannot be empty' if data.nil? || data.empty? create INVOICE, data end
create_item(data)
click to toggle source
# File lib/vogogo_ruby.rb, line 62 def create_item data raise DataHashError.new 'item details hash cannot be empty' if data.nil? || data.empty? create ITEM, data end
delete_customer(customer_id)
click to toggle source
# File lib/vogogo_ruby.rb, line 92 def delete_customer customer_id raise IdentifierError.new 'customer_id cannot be empty' if customer_id.nil? || customer_id.empty? response = delete CUSTOMER, customer_id end
delete_customer_account(customer_account_id)
click to toggle source
# File lib/vogogo_ruby.rb, line 117 def delete_customer_account customer_account_id raise IdentifierError.new 'customer_account_id cannot be empty' if customer_account_id.nil? || customer_account_id.empty? response = delete CUSTOMER_ACCOUNT, customer_account_id end
delete_invoice(invoice_id)
click to toggle source
# File lib/vogogo_ruby.rb, line 57 def delete_invoice invoice_id raise IdentifierError.new 'invoice_id cannot be empty' if invoice_id.nil? || invoice_id.empty? response = delete INVOICE, invoice_id end
delete_item(item_id)
click to toggle source
# File lib/vogogo_ruby.rb, line 67 def delete_item item_id raise IdentifierError.new 'item_id cannot be empty' if item_id.nil? || item_id.empty? response = delete ITEM, item_id end
get_account(account_id)
click to toggle source
Retrieve an account details
# File lib/vogogo_ruby.rb, line 32 def get_account account_id raise IdentifierError.new 'account_id cannot be empty' if account_id.nil? || account_id.empty? get ACCOUNT, account_id end
get_accounts()
click to toggle source
Retrieve a list of financial accounts
# File lib/vogogo_ruby.rb, line 27 def get_accounts list ACCOUNT end
get_customer(customer_id)
click to toggle source
# File lib/vogogo_ruby.rb, line 97 def get_customer customer_id raise IdentifierError.new 'customer_id cannot be empty' if customer_id.nil? || customer_id.empty? get CUSTOMER, customer_id end
get_customer_account(customer_account_id)
click to toggle source
# File lib/vogogo_ruby.rb, line 122 def get_customer_account customer_account_id raise IdentifierError.new 'customer_account_id cannot be empty' if customer_account_id.nil? || customer_account_id.empty? get CUSTOMER_ACCOUNT, customer_account_id end
get_invoice(invoice_id)
click to toggle source
# File lib/vogogo_ruby.rb, line 37 def get_invoice invoice_id raise IdentifierError.new 'invoice_id cannot be empty' if invoice_id.nil? || invoice_id.empty? get INVOICE, invoice_id end
get_item(item_id)
click to toggle source
# File lib/vogogo_ruby.rb, line 72 def get_item item_id raise IdentifierError.new 'item_id cannot be empty' if item_id.nil? || item_id.empty? get ITEM, item_id end
list_customer_accounts()
click to toggle source
# File lib/vogogo_ruby.rb, line 127 def list_customer_accounts list CUSTOMER_ACCOUNT end
list_customers()
click to toggle source
# File lib/vogogo_ruby.rb, line 102 def list_customers list CUSTOMER end
list_invoices()
click to toggle source
# File lib/vogogo_ruby.rb, line 53 def list_invoices list INVOICE end
list_items()
click to toggle source
# File lib/vogogo_ruby.rb, line 77 def list_items list ITEM end
post_credit_card_charge(data)
click to toggle source
# File lib/vogogo_ruby.rb, line 131 def post_credit_card_charge data raise DataHashError.new 'credit card charge details hash cannot be empty' if data.nil? || data.empty? create CREDIT_CARD_CHARGE, data end
post_deposit(data)
click to toggle source
# File lib/vogogo_ruby.rb, line 141 def post_deposit data raise DataHashError.new 'deposit details hash cannot be empty' if data.nil? || data.empty? create DEPOSIT, data end
post_eft_credit(data)
click to toggle source
# File lib/vogogo_ruby.rb, line 136 def post_eft_credit data raise DataHashError.new 'eft credit details hash cannot be empty' if data.nil? || data.empty? create EFT_CREDIT, data end
post_withdrawal(data)
click to toggle source
# File lib/vogogo_ruby.rb, line 146 def post_withdrawal data raise DataHashError.new 'withdrawal details hash cannot be empty' if data.nil? || data.empty? create WITHDRAWAL, data end
update_customer(customer_id, data)
click to toggle source
# File lib/vogogo_ruby.rb, line 106 def update_customer customer_id, data raise DataHashError.new 'customer details hash cannot be empty' if data.nil? || data.empty? raise IdentifierError.new 'customer_id cannot be empty' if customer_id.nil? || customer_id.empty? response = update CUSTOMER, customer_id, data end
update_invoice(invoice_id, data)
click to toggle source
# File lib/vogogo_ruby.rb, line 47 def update_invoice invoice_id, data raise DataHashError.new 'invoice details hash cannot be empty' if data.nil? || data.empty? raise IdentifierError.new 'invoice_id cannot be empty' if invoice_id.nil? || invoice_id.empty? response = update INVOICE, invoice_id, data end
update_item(item_id, data)
click to toggle source
# File lib/vogogo_ruby.rb, line 81 def update_item item_id, data raise DataHashError.new 'item details hash cannot be empty' if data.nil? || data.empty? raise IdentifierError.new 'item_id cannot be empty' if item_id.nil? || item_id.empty? response = update ITEM, item_id, data end
Private Instance Methods
action(method, entity, id = '', data = {})
click to toggle source
# File lib/vogogo_ruby.rb, line 173 def action method, entity, id = '', data = {} options = {body: data.to_json, basic_auth: auth, headers: {'Content-Type' => 'application/json'}} id << '/' unless id.empty? self.class.send(method, path(entity.to_s + '/' + id.to_s), options) end
auth()
click to toggle source
# File lib/vogogo_ruby.rb, line 179 def auth @auth end
create(entity, data)
click to toggle source
# File lib/vogogo_ruby.rb, line 157 def create entity, data action('post', entity, '', data) end
delete(entity, id)
click to toggle source
# File lib/vogogo_ruby.rb, line 169 def delete entity, id action('delete', entity, id) end
get(entity, id)
click to toggle source
# File lib/vogogo_ruby.rb, line 161 def get entity, id action('get', entity, id) end
list(entity)
click to toggle source
# File lib/vogogo_ruby.rb, line 153 def list entity action('get', entity) end
path(method)
click to toggle source
# File lib/vogogo_ruby.rb, line 183 def path(method) API_URL + URL_BASE + method end
update(entity, id, data)
click to toggle source
# File lib/vogogo_ruby.rb, line 165 def update entity, id, data action('patch', entity, id, data) end