Module: Decathlon::Sports

Defined in:
lib/decathlon/sports.rb,
lib/decathlon/sports/sport.rb,
lib/decathlon/sports/version.rb,
lib/decathlon/sports/recommendation.rb

Defined Under Namespace

Modules: Recommendations

Constant Summary collapse

VERSION =
'0.2.0'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.all(url: "#{API_URL}/sports", params: {}, headers: {}) ⇒ Object



13
14
15
# File 'lib/decathlon/sports/sport.rb', line 13

def self.all(url: "#{API_URL}/sports", params: {}, headers: {})
  call(url: url, params: params, headers: headers)
end

.call(url: API_URL, params: {}, headers: {}) ⇒ Object



8
9
10
11
# File 'lib/decathlon/sports/sport.rb', line 8

def self.call(url: API_URL, params: {}, headers: {})
  response = Faraday.get(url, params, headers)
  JSON.parse(response.body)
end

.find(id, params: {}, headers: {}) ⇒ Object



17
18
19
# File 'lib/decathlon/sports/sport.rb', line 17

def self.find(id, params: {}, headers: {})
  call(url: "#{API_URL}/sports/#{id}", params: params, headers: headers)
end

.isearch(query, params: {}, headers: {}) ⇒ Object



25
26
27
# File 'lib/decathlon/sports/sport.rb', line 25

def self.isearch(query, params: {}, headers: {})
  call(url: "#{API_URL}/sports/search/#{query}", params: params, headers: headers)
end

.search(query, params: {}, headers: {}) ⇒ Object



21
22
23
# File 'lib/decathlon/sports/sport.rb', line 21

def self.search(query, params: {}, headers: {})
  call(url: "#{API_URL}/sports?q=#{query}", params: params, headers: headers)
end

Instance Method Details

#group(id) ⇒ Object



33
34
35
# File 'lib/decathlon/sports/sport.rb', line 33

def group(id)
  call(url: "#{API_URL}/groups/#{id}")
end

#groupsObject



29
30
31
# File 'lib/decathlon/sports/sport.rb', line 29

def groups
  call(url: "#{API_URL}/groups")
end