Class: Quickeebooks::Online::Service::ServiceBase
- Inherits:
-
Object
- Object
- Quickeebooks::Online::Service::ServiceBase
- Includes:
- Logging
- Defined in:
- lib/quickeebooks/online/service/service_base.rb
Direct Known Subclasses
AccessToken, Account, Bill, BillPayment, Clazz, CompanyMetaData, Customer, Employee, Entitlement, Invoice, Item, Job, JournalEntry, Payment, PaymentMethod, SalesReceipt, SalesTerm, TimeActivity, TrackingClass, Vendor
Constant Summary collapse
- QB_BASE_URI =
"https://qbo.sbfinance.intuit.com"
- 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
Returns the value of attribute base_uri.
-
#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
-
#base_url=(uri) ⇒ Object
uri is of the form ‘qbo.intuit.com/qbo36`.
-
#initialize(oauth_access_token = nil, realm_id = nil) ⇒ ServiceBase
constructor
A new instance of ServiceBase.
-
#login_name ⇒ Object
gives us the qbo user’s LoginName useful for verifying email address against.
- #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.
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/quickeebooks/online/service/service_base.rb', line 27 def initialize(oauth_access_token = nil, realm_id = nil) if !oauth_access_token.nil? && !realm_id.nil? msg = "Quickeebooks::Online::ServiceBase - " msg += "This version of the constructor is deprecated. " msg += "Use the no-arg constructor and set the AccessToken (access_token=) and the RealmID (realm_id=) using the setters." warn(msg) self.access_token = oauth_access_token self.realm_id = realm_id end end |
Instance Attribute Details
#base_uri ⇒ Object
Returns the value of attribute base_uri.
22 23 24 |
# File 'lib/quickeebooks/online/service/service_base.rb', line 22 def base_uri @base_uri end |
#oauth ⇒ Object
Returns the value of attribute oauth.
21 22 23 |
# File 'lib/quickeebooks/online/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/online/service/service_base.rb', line 20 def realm_id @realm_id end |
Instance Method Details
#access_token=(token) ⇒ Object
38 39 40 |
# File 'lib/quickeebooks/online/service/service_base.rb', line 38 def access_token=(token) @oauth = token end |
#base_url=(uri) ⇒ Object
uri is of the form ‘qbo.intuit.com/qbo36`
47 48 49 |
# File 'lib/quickeebooks/online/service/service_base.rb', line 47 def base_url=(uri) @base_uri = uri end |
#login_name ⇒ Object
gives us the qbo user’s LoginName useful for verifying email address against
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/quickeebooks/online/service/service_base.rb', line 61 def login_name @login_name ||= begin url = "https://qbo.intuit.com/qbo1/rest/user/v2/#{@realm_id}" response = @oauth.request(:get, url) if response && response.code.to_i == 200 xml = parse_xml(response.body) xml.xpath("//qbo:QboUser/qbo:LoginName")[0].text end end end |
#url_for_base(raw) ⇒ Object
55 56 57 |
# File 'lib/quickeebooks/online/service/service_base.rb', line 55 def url_for_base(raw) "#{QB_BASE_URI}/#{raw}/v2/#{@realm_id}" end |
#url_for_resource(resource) ⇒ Object
51 52 53 |
# File 'lib/quickeebooks/online/service/service_base.rb', line 51 def url_for_resource(resource) url_for_base("resource/#{resource}") end |