Class: Quickbooks::Service::AccessToken
- Inherits:
-
BaseService
- Object
- BaseService
- Quickbooks::Service::AccessToken
- Defined in:
- lib/quickbooks/service/access_token.rb
Constant Summary collapse
- RENEW_URL =
"https://appcenter.intuit.com/api/v1/connection/reconnect"
- DISCONNECT_URL_OAUTH1 =
"https://appcenter.intuit.com/api/v1/connection/disconnect"
- DISCONNECT_URL_OAUTH2 =
"https://developer.api.intuit.com/v2/oauth2/tokens/revoke"
Constants inherited from BaseService
BaseService::BASE_DOMAIN, BaseService::HTTP_ACCEPT, BaseService::HTTP_ACCEPT_ENCODING, BaseService::HTTP_CONTENT_TYPE, BaseService::SANDBOX_DOMAIN, BaseService::XML_NS
Instance Attribute Summary
Attributes inherited from BaseService
#base_uri, #company_id, #last_response_intuit_tid, #last_response_xml, #oauth
Instance Method Summary collapse
Methods inherited from BaseService
#access_token=, #default_model_query, #initialize, #is_json?, #is_pdf?, #realm_id=, #rebuild_connection!, #url_for_base, #url_for_query, #url_for_resource
Methods included from ServiceCrud
#all, #create, #delete, #delete_by_query_string, #exists?, #fetch_by_id, #find_by, #query, #query_in_batches
Methods included from Util::Logging
Constructor Details
This class inherits a constructor from Quickbooks::Service::BaseService
Instance Method Details
#disconnect ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/quickbooks/service/access_token.rb', line 24 def disconnect if oauth_v1? response = do_http_get(DISCONNECT_URL_OAUTH1) if response && response.code.to_i == 200 Quickbooks::Model::AccessTokenResponse.from_xml(response.plain_body) end elsif oauth_v2? conn = Faraday.new conn.basic_auth oauth.client.id, oauth.client.secret response = conn.post(DISCONNECT_URL_OAUTH2, token: oauth.refresh_token || oauth.token) if response.success? Quickbooks::Model::AccessTokenResponse.new(error_code: "0") else Quickbooks::Model::AccessTokenResponse.new( error_code: response.status.to_s, error_message: response.reason_phrase ) end end end |
#renew ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/quickbooks/service/access_token.rb', line 10 def renew result = nil response = do_http_get(RENEW_URL) if response code = response.code.to_i if code == 200 result = Quickbooks::Model::AccessTokenResponse.from_xml(response.plain_body) end end result end |