class Economic::Session

The Economic::Session contains details and behaviors for a current connection to the API endpoint.

Attributes

authentication_cookies[R]

Public Class Methods

new() { |endpoint| ... } click to toggle source
# File lib/economic/session.rb, line 15
def initialize
  yield endpoint if block_given?
end

Public Instance Methods

accounts() click to toggle source
# File lib/economic/session.rb, line 77
def accounts
  @accounts ||= AccountProxy.new(self)
end
cash_book_entries() click to toggle source
# File lib/economic/session.rb, line 73
def cash_book_entries
  @cash_book_entries ||= CashBookEntryProxy.new(self)
end
cash_books() click to toggle source
# File lib/economic/session.rb, line 69
def cash_books
  @cash_books ||= CashBookProxy.new(self)
end
company() click to toggle source
# File lib/economic/session.rb, line 98
def company
  @company ||= CompanyProxy.new(self)
end
connect_with_token(private_app_id, access_id) click to toggle source

Connect/authenticate with an API token and app id

Reference: techtalk.e-conomic.com/why-were-implementing-a-new-api-connection-model/

Attributes

  • private_app_id - The App ID created in your developer agreement

  • access_id - The Access ID or token for your App ID

# File lib/economic/session.rb, line 28
def connect_with_token(private_app_id, access_id)
  endpoint.call(
    :connect_with_token,
    :token => access_id,
    :appToken => private_app_id
  ) do |response|
    store_authentication_cookies(response)
  end
end
contacts() click to toggle source

Provides access to the DebtorContacts

# File lib/economic/session.rb, line 39
def contacts
  @contacts ||= DebtorContactProxy.new(self)
end
creditor_entries() click to toggle source
# File lib/economic/session.rb, line 85
def creditor_entries
  @creditor_entries ||= CreditorEntryProxy.new(self)
end
creditors() click to toggle source

Provides access to creditors

# File lib/economic/session.rb, line 65
def creditors
  @creditors ||= CreditorProxy.new(self)
end
current_invoices() click to toggle source

Provides access to the current invoices - ie invoices that haven't yet been booked

# File lib/economic/session.rb, line 45
def current_invoices
  @current_invoices ||= CurrentInvoiceProxy.new(self)
end
debtor_entries() click to toggle source
# File lib/economic/session.rb, line 81
def debtor_entries
  @debtor_entries ||= DebtorEntryProxy.new(self)
end
debtors() click to toggle source

Provides access to the debtors

# File lib/economic/session.rb, line 60
def debtors
  @debtors ||= DebtorProxy.new(self)
end
endpoint() click to toggle source

Returns the SOAP endpoint to connect to

# File lib/economic/session.rb, line 113
def endpoint
  @endpoint ||= Economic::Endpoint.new
end
entries() click to toggle source
# File lib/economic/session.rb, line 89
def entries
  @entries ||= EntryProxy.new(self)
end
invoices() click to toggle source

Provides access to the invoices

# File lib/economic/session.rb, line 50
def invoices
  @invoices ||= InvoiceProxy.new(self)
end
orders() click to toggle source

Provides access to the orders

# File lib/economic/session.rb, line 55
def orders
  @orders ||= OrderProxy.new(self)
end
products() click to toggle source

Provides access to products

# File lib/economic/session.rb, line 94
def products
  @products ||= ProductProxy.new(self)
end
request(soap_action, data = nil) click to toggle source

Requests an action from the API endpoint

# File lib/economic/session.rb, line 103
def request(soap_action, data = nil)
  endpoint.call(soap_action, data, authentication_cookies)
end
session() click to toggle source

Returns self - used by proxies to access the session of their owner

# File lib/economic/session.rb, line 108
def session
  self
end

Private Instance Methods

store_authentication_cookies(response) click to toggle source
# File lib/economic/session.rb, line 119
def store_authentication_cookies(response)
  cookies = response.http.cookies
  @authentication_cookies = cookies
end