Class: Spoll::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/spoll.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) ⇒ Api

Returns a new instance of Api.



10
11
12
13
14
# File 'lib/spoll.rb', line 10

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.



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

def token
  @token
end

#versionObject (readonly)

Returns the value of attribute version.



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

def version
  @version
end

Instance Method Details

#get_event(event_id) ⇒ Object



32
33
34
# File 'lib/spoll.rb', line 32

def get_event(event_id)
  get("/events/#{event_id}", include: 'match.team,event_type,match.season.league')
end

#get_events(match_id) ⇒ Object



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

def get_events(match_id)
  get("/events?match_id=#{match_id}", {})
end

#get_match(id) ⇒ Object



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

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

#post_match(params) ⇒ Object



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

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

#put_match(id, params) ⇒ Object



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

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