Class: Xero::Connection
- Inherits:
-
Object
- Object
- Xero::Connection
- Defined in:
- lib/xero/connection.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#consumer_options ⇒ Object
Returns the value of attribute consumer_options.
Instance Method Summary collapse
- #access_token ⇒ Object
- #consumer ⇒ Object
- #get(path, params = {}) ⇒ Object
- #get_by_id(path, id) ⇒ Object
-
#initialize(options = {}) ⇒ Connection
constructor
A new instance of Connection.
- #post(path, payload, params = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Connection
Returns a new instance of Connection.
6 7 8 9 10 11 12 13 |
# File 'lib/xero/connection.rb', line 6 def initialize( = {}) self. = { site: 'https://api.xero.com', request_token_path: '/oauth/RequestToken', access_token_path: '/oauth/AccessToken', authorize_path: '/oauth/Authorize' }.reverse_merge() end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
4 5 6 |
# File 'lib/xero/connection.rb', line 4 def client @client end |
#consumer_options ⇒ Object
Returns the value of attribute consumer_options.
4 5 6 |
# File 'lib/xero/connection.rb', line 4 def @consumer_options end |
Instance Method Details
#access_token ⇒ Object
22 23 24 25 26 27 |
# File 'lib/xero/connection.rb', line 22 def access_token @access_token ||= ::OAuth::AccessToken.new( consumer, Xero.configuration.consumer_key, Xero.configuration.consumer_secret ) end |
#consumer ⇒ Object
15 16 17 18 19 20 |
# File 'lib/xero/connection.rb', line 15 def consumer @consumer ||= ::OAuth::Consumer.new( Xero.configuration.consumer_key, Xero.configuration.consumer_secret, self. ) end |
#get(path, params = {}) ⇒ Object
33 34 35 36 |
# File 'lib/xero/connection.rb', line 33 def get(path, params = {}) path = "#{path}?#{params.to_query}" unless params.blank? make_request(:get, path) end |
#get_by_id(path, id) ⇒ Object
29 30 31 |
# File 'lib/xero/connection.rb', line 29 def get_by_id(path, id) make_request(:get, "#{path}/#{id}") end |
#post(path, payload, params = {}) ⇒ Object
38 39 40 |
# File 'lib/xero/connection.rb', line 38 def post(path, payload, params = {}) make_request(:post, path, { xml: payload }) end |