Class: Quickeebooks::Windows::Service::ServiceBase
- Inherits:
-
Object
- Object
- Quickeebooks::Windows::Service::ServiceBase
- Includes:
- Logging
- Defined in:
- lib/quickeebooks/windows/service/service_base.rb
Direct Known Subclasses
AccessToken, Account, Clazz, CompanyMetaData, Customer, CustomerMsg, Employee, Invoice, Item, Job, Payment, PaymentMethod, SalesReceipt, SalesRep, SalesTax, ShipMethod, SyncActivity, SyncStatus, TimeActivity
Constant Summary collapse
- XML_NS =
%{xmlns:ns2="http://www.intuit.com/sb/cdm/qbo" xmlns="http://www.intuit.com/sb/cdm/v2" xmlns:ns3="http://www.intuit.com/sb/cdm"}
Instance Attribute Summary collapse
-
#base_uri ⇒ Object
readonly
Returns the value of attribute base_uri.
-
#last_response_body ⇒ Object
readonly
Returns the value of attribute last_response_body.
-
#last_response_xml ⇒ Object
readonly
Returns the value of attribute last_response_xml.
-
#oauth ⇒ Object
Returns the value of attribute oauth.
-
#realm_id ⇒ Object
Returns the value of attribute realm_id.
Instance Method Summary collapse
- #access_token=(token) ⇒ Object
-
#enforce_filter_order(filters) ⇒ Object
Intuit API requires that filters obey a specific ordering Each Service implementation should have a
FILTER_ORDER
Array constant defined. -
#initialize(oauth_access_token = nil, realm_id = nil) ⇒ ServiceBase
constructor
A new instance of ServiceBase.
- #url_for_base(raw) ⇒ Object
- #url_for_resource(resource) ⇒ Object
Methods included from Logging
Constructor Details
#initialize(oauth_access_token = nil, realm_id = nil) ⇒ ServiceBase
Returns a new instance of ServiceBase.
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/quickeebooks/windows/service/service_base.rb', line 28 def initialize(oauth_access_token = nil, realm_id = nil) @base_uri = 'https://services.intuit.com/sb' if !oauth_access_token.nil? && !realm_id.nil? msg = "Quickeebooks::Windows::ServiceBase - " msg += "This version of the constructor is deprecated. " msg += "Use the no-arg constructor and set the AccessToken and the RealmID using the accessors." warn(msg) access_token = oauth_access_token realm_id = realm_id end end |
Instance Attribute Details
#base_uri ⇒ Object (readonly)
Returns the value of attribute base_uri.
22 23 24 |
# File 'lib/quickeebooks/windows/service/service_base.rb', line 22 def base_uri @base_uri end |
#last_response_body ⇒ Object (readonly)
Returns the value of attribute last_response_body.
23 24 25 |
# File 'lib/quickeebooks/windows/service/service_base.rb', line 23 def last_response_body @last_response_body end |
#last_response_xml ⇒ Object (readonly)
Returns the value of attribute last_response_xml.
24 25 26 |
# File 'lib/quickeebooks/windows/service/service_base.rb', line 24 def last_response_xml @last_response_xml end |
#oauth ⇒ Object
Returns the value of attribute oauth.
21 22 23 |
# File 'lib/quickeebooks/windows/service/service_base.rb', line 21 def oauth @oauth end |
#realm_id ⇒ Object
Returns the value of attribute realm_id.
20 21 22 |
# File 'lib/quickeebooks/windows/service/service_base.rb', line 20 def realm_id @realm_id end |
Instance Method Details
#access_token=(token) ⇒ Object
41 42 43 |
# File 'lib/quickeebooks/windows/service/service_base.rb', line 41 def access_token=(token) @oauth = token end |
#enforce_filter_order(filters) ⇒ Object
Intuit API requires that filters obey a specific ordering Each Service implementation should have a FILTER_ORDER
Array constant defined. If this is defined than any filters given will be re-ordered to match the required ordering
61 62 63 64 65 66 67 68 69 |
# File 'lib/quickeebooks/windows/service/service_base.rb', line 61 def enforce_filter_order(filters) if self.class.const_defined?(:FILTER_ORDER) self.class.const_get(:FILTER_ORDER).map do |field| filters.detect { |f| f.field.to_s == field } end.compact else filters end end |
#url_for_base(raw) ⇒ Object
53 54 55 |
# File 'lib/quickeebooks/windows/service/service_base.rb', line 53 def url_for_base(raw) "#{@base_uri}/#{raw}/v2/#{@realm_id}" end |
#url_for_resource(resource) ⇒ Object
49 50 51 |
# File 'lib/quickeebooks/windows/service/service_base.rb', line 49 def url_for_resource(resource) url_for_base(resource) end |