Class: Spoll::Client

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

Constant Summary collapse

HEADERS =
{ 'Content-Type' => 'application/json; charset=utf-8' }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client_id, client_secret, host, version) ⇒ Client

Returns a new instance of Client.



7
8
9
10
11
# File 'lib/spoll/client.rb', line 7

def initialize(client_id, client_secret, host, version)
  @client = ::OAuth2::Client.new(client_id, client_secret, site: host)
  @version = version
  get_token
end

Instance Attribute Details

#tokenObject (readonly)

Returns the value of attribute token.



3
4
5
# File 'lib/spoll/client.rb', line 3

def token
  @token
end

#versionObject (readonly)

Returns the value of attribute version.



3
4
5
# File 'lib/spoll/client.rb', line 3

def version
  @version
end

Instance Method Details

#get_event(id, params = {}) ⇒ Object



29
30
31
# File 'lib/spoll/client.rb', line 29

def get_event(id, params = {})
  get("/events/#{id}", params)
end

#get_events(params) ⇒ Object



25
26
27
# File 'lib/spoll/client.rb', line 25

def get_events(params)
  get('/events', params)
end

#get_match(id, params = {}) ⇒ Object



21
22
23
# File 'lib/spoll/client.rb', line 21

def get_match(id, params = {})
  get("/matches/#{id}", params)
end

#post_match(params) ⇒ Object



13
14
15
# File 'lib/spoll/client.rb', line 13

def post_match(params)
  post('/matches', { match: params })
end

#put_match(id, params) ⇒ Object



17
18
19
# File 'lib/spoll/client.rb', line 17

def put_match(id, params)
  put("/matches/#{id}", { match: params })
end