Class: Timepad::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/timepad/client.rb

Constant Summary collapse

API_URI =
'https://api.timepad.ru'
VERSION =
'1'
FORMAT =
'json'

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#tokenObject (readonly)

Returns the value of attribute token.



6
7
8
# File 'lib/timepad/client.rb', line 6

def token
  @token
end

Instance Method Details

#eventObject



18
19
20
# File 'lib/timepad/client.rb', line 18

def event
  @event ||= Timepad::Event.new(self)
end

#orderObject



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