Class: Economic::Session
- Inherits:
-
Object
- Object
- Economic::Session
- Extended by:
- Forwardable
- Defined in:
- lib/economic/session.rb
Overview
The Economic::Session contains details and behaviors for a current connection to the API endpoint.
Instance Attribute Summary collapse
-
#agreement_number ⇒ Object
Returns the value of attribute agreement_number.
-
#app_identifier ⇒ Object
Returns the value of attribute app_identifier.
-
#authentication_cookies ⇒ Object
readonly
Returns the value of attribute authentication_cookies.
-
#password ⇒ Object
Returns the value of attribute password.
-
#user_name ⇒ Object
Returns the value of attribute user_name.
Instance Method Summary collapse
- #accounts ⇒ Object
- #cash_book_entries ⇒ Object
- #cash_books ⇒ Object
- #company ⇒ Object
-
#connect ⇒ Object
Authenticates with E-conomic using credentials Assumes ::new was called with credentials as arguments.
-
#connect_with_credentials(agreement_number, user_name, password, app_identifier = nil) ⇒ Object
Connect/authenticate with credentials.
-
#connect_with_token(private_app_id, access_id) ⇒ Object
Connect/authenticate with an API token and app id.
-
#contacts ⇒ Object
Provides access to the DebtorContacts.
- #creditor_entries ⇒ Object
-
#creditors ⇒ Object
Provides access to creditors.
-
#current_invoices ⇒ Object
Provides access to the current invoices - ie invoices that haven’t yet been booked.
- #debtor_entries ⇒ Object
-
#debtors ⇒ Object
Provides access to the debtors.
-
#endpoint ⇒ Object
Returns the SOAP endpoint to connect to.
- #entries ⇒ Object
-
#initialize(agreement_number = nil, user_name = nil, password = nil, app_identifier = nil) {|endpoint| ... } ⇒ Session
constructor
A new instance of Session.
-
#invoices ⇒ Object
Provides access to the invoices.
-
#orders ⇒ Object
Provides access to the orders.
-
#products ⇒ Object
Provides access to products.
-
#request(soap_action, data = nil) ⇒ Object
Requests an action from the API endpoint.
-
#session ⇒ Object
Returns self - used by proxies to access the session of their owner.
Constructor Details
#initialize(agreement_number = nil, user_name = nil, password = nil, app_identifier = nil) {|endpoint| ... } ⇒ Session
Returns a new instance of Session.
14 15 16 17 18 19 20 |
# File 'lib/economic/session.rb', line 14 def initialize(agreement_number = nil, user_name = nil, password = nil, app_identifier = nil) self.agreement_number = agreement_number self.user_name = user_name self.password = password self.app_identifier = app_identifier yield endpoint if block_given? end |
Instance Attribute Details
#agreement_number ⇒ Object
Returns the value of attribute agreement_number.
11 12 13 |
# File 'lib/economic/session.rb', line 11 def agreement_number @agreement_number end |
#app_identifier ⇒ Object
Returns the value of attribute app_identifier.
11 12 13 |
# File 'lib/economic/session.rb', line 11 def app_identifier @app_identifier end |
#authentication_cookies ⇒ Object (readonly)
Returns the value of attribute authentication_cookies.
12 13 14 |
# File 'lib/economic/session.rb', line 12 def @authentication_cookies end |
#password ⇒ Object
Returns the value of attribute password.
11 12 13 |
# File 'lib/economic/session.rb', line 11 def password @password end |
#user_name ⇒ Object
Returns the value of attribute user_name.
11 12 13 |
# File 'lib/economic/session.rb', line 11 def user_name @user_name end |
Instance Method Details
#accounts ⇒ Object
108 109 110 |
# File 'lib/economic/session.rb', line 108 def accounts @accounts ||= AccountProxy.new(self) end |
#cash_book_entries ⇒ Object
104 105 106 |
# File 'lib/economic/session.rb', line 104 def cash_book_entries @cash_book_entries ||= CashBookEntryProxy.new(self) end |
#cash_books ⇒ Object
100 101 102 |
# File 'lib/economic/session.rb', line 100 def cash_books @cash_books ||= CashBookProxy.new(self) end |
#company ⇒ Object
129 130 131 |
# File 'lib/economic/session.rb', line 129 def company @company ||= CompanyProxy.new(self) end |
#connect ⇒ Object
Authenticates with E-conomic using credentials Assumes ::new was called with credentials as arguments.
65 66 67 |
# File 'lib/economic/session.rb', line 65 def connect connect_with_credentials(agreement_number, user_name, password, app_identifier) end |
#connect_with_credentials(agreement_number, user_name, password, app_identifier = nil) ⇒ Object
Connect/authenticate with credentials
Attributes
-
agreement_number
- your economic agreement number -
user_name
- your username -
password
- your passsword -
app_identifier
- A string identifiying your application, as described in techtalk.e-conomic.com/e-conomic-soap-api-now-requires-you-to-specify-a-custom-x-economicappidentifier-header/
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/economic/session.rb', line 50 def connect_with_credentials(agreement_number, user_name, password, app_identifier = nil) self.app_identifier = app_identifier if app_identifier endpoint.call( :connect, :agreementNumber => agreement_number, :userName => user_name, :password => password ) do |response| (response) end end |
#connect_with_token(private_app_id, access_id) ⇒ Object
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
31 32 33 34 35 36 37 38 39 |
# File 'lib/economic/session.rb', line 31 def connect_with_token(private_app_id, access_id) endpoint.call( :connect_with_token, :token => access_id, :appToken => private_app_id ) do |response| (response) end end |
#contacts ⇒ Object
Provides access to the DebtorContacts
70 71 72 |
# File 'lib/economic/session.rb', line 70 def contacts @contacts ||= DebtorContactProxy.new(self) end |
#creditor_entries ⇒ Object
116 117 118 |
# File 'lib/economic/session.rb', line 116 def creditor_entries @creditor_entries ||= CreditorEntryProxy.new(self) end |
#creditors ⇒ Object
Provides access to creditors
96 97 98 |
# File 'lib/economic/session.rb', line 96 def creditors @creditors ||= CreditorProxy.new(self) end |
#current_invoices ⇒ Object
Provides access to the current invoices - ie invoices that haven’t yet been booked
76 77 78 |
# File 'lib/economic/session.rb', line 76 def current_invoices @current_invoices ||= CurrentInvoiceProxy.new(self) end |
#debtor_entries ⇒ Object
112 113 114 |
# File 'lib/economic/session.rb', line 112 def debtor_entries @debtor_entries ||= DebtorEntryProxy.new(self) end |
#debtors ⇒ Object
Provides access to the debtors
91 92 93 |
# File 'lib/economic/session.rb', line 91 def debtors @debtors ||= DebtorProxy.new(self) end |
#endpoint ⇒ Object
Returns the SOAP endpoint to connect to
144 145 146 |
# File 'lib/economic/session.rb', line 144 def endpoint @endpoint ||= Economic::Endpoint.new(app_identifier) end |
#entries ⇒ Object
120 121 122 |
# File 'lib/economic/session.rb', line 120 def entries @entries ||= EntryProxy.new(self) end |
#invoices ⇒ Object
Provides access to the invoices
81 82 83 |
# File 'lib/economic/session.rb', line 81 def invoices @invoices ||= InvoiceProxy.new(self) end |
#orders ⇒ Object
Provides access to the orders
86 87 88 |
# File 'lib/economic/session.rb', line 86 def orders @orders ||= OrderProxy.new(self) end |
#products ⇒ Object
Provides access to products
125 126 127 |
# File 'lib/economic/session.rb', line 125 def products @products ||= ProductProxy.new(self) end |
#request(soap_action, data = nil) ⇒ Object
Requests an action from the API endpoint
134 135 136 |
# File 'lib/economic/session.rb', line 134 def request(soap_action, data = nil) endpoint.call(soap_action, data, ) end |
#session ⇒ Object
Returns self - used by proxies to access the session of their owner
139 140 141 |
# File 'lib/economic/session.rb', line 139 def session self end |