Class: Quickeebooks::Online::Service::ServiceBase
- Inherits:
-
Object
- Object
- Quickeebooks::Online::Service::ServiceBase
- Defined in:
- lib/quickeebooks/online/service/service_base.rb
Direct Known Subclasses
AccessToken, Account, Bill, CompanyMetaData, Customer, Entitlement, Invoice, Item, Payment
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
Constructor Details
#initialize(oauth_access_token = nil, realm_id = nil) ⇒ ServiceBase
Returns a new instance of ServiceBase.
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/quickeebooks/online/service/service_base.rb', line 25 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) access_token = oauth_access_token realm_id = realm_id end end |
Instance Attribute Details
#base_uri ⇒ Object
Returns the value of attribute base_uri.
20 21 22 |
# File 'lib/quickeebooks/online/service/service_base.rb', line 20 def base_uri @base_uri end |
#oauth ⇒ Object
Returns the value of attribute oauth.
19 20 21 |
# File 'lib/quickeebooks/online/service/service_base.rb', line 19 def oauth @oauth end |
#realm_id ⇒ Object
Returns the value of attribute realm_id.
18 19 20 |
# File 'lib/quickeebooks/online/service/service_base.rb', line 18 def realm_id @realm_id end |
Instance Method Details
#access_token=(token) ⇒ Object
36 37 38 |
# File 'lib/quickeebooks/online/service/service_base.rb', line 36 def access_token=(token) @oauth = token end |
#base_url=(uri) ⇒ Object
uri is of the form ‘qbo.intuit.com/qbo36`
45 46 47 |
# File 'lib/quickeebooks/online/service/service_base.rb', line 45 def base_url=(uri) @base_uri = uri end |
#login_name ⇒ Object
gives us the qbo user’s LoginName useful for verifying email address against
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/quickeebooks/online/service/service_base.rb', line 59 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
53 54 55 |
# File 'lib/quickeebooks/online/service/service_base.rb', line 53 def url_for_base(raw) "#{QB_BASE_URI}/#{raw}/v2/#{@realm_id}" end |
#url_for_resource(resource) ⇒ Object
49 50 51 |
# File 'lib/quickeebooks/online/service/service_base.rb', line 49 def url_for_resource(resource) url_for_base("resource/#{resource}") end |