Class: SportsApi::Football::CountryResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/sports_api/football/resources/country.rb

Instance Attribute Summary

Attributes inherited from Resource

#client

Instance Method Summary collapse

Methods inherited from Resource

#get_request, #initialize

Constructor Details

This class inherits a constructor from SportsApi::Resource

Instance Method Details

#find_by_code(code:) ⇒ Object



15
16
17
18
# File 'lib/sports_api/football/resources/country.rb', line 15

def find_by_code(code:)
  response = get_request('countries', params: { code: code.to_s })
  SportsApi::Football::Country.new(response.body['response'][0])
end

#find_by_name(name:) ⇒ Object



20
21
22
23
# File 'lib/sports_api/football/resources/country.rb', line 20

def find_by_name(name:)
  response = get_request('countries', params: { name: name.to_s })
  SportsApi::Football::Country.new(response.body['response'][0])
end

#list(**params) ⇒ Object

Arguments: name: [String](optional) - The name of the country. code: [String] (optional) - The country code (= XXX). search: [String] (optional) - The country name, can be some letters (>= XXX).



10
11
12
13
# File 'lib/sports_api/football/resources/country.rb', line 10

def list(**params)
  response = get_request('countries', params:)
  Collection.from_response(response, type: SportsApi::Football::Country)
end