Class: Timepad::Client
- Inherits:
-
Object
- Object
- Timepad::Client
- Defined in:
- lib/timepad/client.rb
Constant Summary collapse
- API_URI =
'https://api.timepad.ru'
- VERSION =
'1'
- FORMAT =
'json'
Instance Attribute Summary collapse
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #event ⇒ Object
-
#initialize(token = nil) ⇒ Client
constructor
A new instance of Client.
- #order ⇒ Object
- #request(action, params = {}) ⇒ Object
Constructor Details
#initialize(token = nil) ⇒ Client
Returns a new instance of Client.
8 9 10 |
# File 'lib/timepad/client.rb', line 8 def initialize(token = nil) @token = token unless token.nil? end |
Instance Attribute Details
#token ⇒ Object (readonly)
Returns the value of attribute token.
6 7 8 |
# File 'lib/timepad/client.rb', line 6 def token @token end |
Instance Method Details
#event ⇒ Object
18 19 20 |
# File 'lib/timepad/client.rb', line 18 def event @event ||= Timepad::Event.new(self) end |
#order ⇒ Object
22 23 24 |
# File 'lib/timepad/client.rb', line 22 def order @order ||= Timepad::Order.new(self) end |
#request(action, params = {}) ⇒ Object
12 13 14 15 16 |
# File 'lib/timepad/client.rb', line 12 def request(action, params = {}) uri = make_uri(action, params) response = Net::HTTP.get(uri) JSON.parse(response) end |