Class: NflData::MySportsFeeds::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_host: ENV.fetch("MYSPORTSFEEDS_API_HOST"), api_key: ENV.fetch("MYSPORTSFEEDS_API_KEY"), api_version: ENV.fetch("MYSPORTSFEEDS_API_VERSION")) ⇒ Client

Returns a new instance of Client.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/nfl_data/my_sports_feeds/client.rb', line 8

def initialize(
  api_host: ENV.fetch("MYSPORTSFEEDS_API_HOST"),
  api_key: ENV.fetch("MYSPORTSFEEDS_API_KEY"),
  api_version: ENV.fetch("MYSPORTSFEEDS_API_VERSION")
)
  @api_host = api_host
  @api_key = api_key
  @api_version = api_version
  @format = "json"
  @base_url = "#{@api_host}/#{@api_version}/pull/nfl/"
end

Instance Attribute Details

#api_hostObject (readonly)

Returns the value of attribute api_host.



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

def api_host
  @api_host
end

#api_keyObject (readonly)

Returns the value of attribute api_key.



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

def api_key
  @api_key
end

#api_versionObject (readonly)

Returns the value of attribute api_version.



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

def api_version
  @api_version
end

#base_urlObject (readonly)

Returns the value of attribute base_url.



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

def base_url
  @base_url
end

#formatObject (readonly)

Returns the value of attribute format.



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

def format
  @format
end

Instance Method Details

#get(endpoint:, params: {}) ⇒ Object



20
21
22
# File 'lib/nfl_data/my_sports_feeds/client.rb', line 20

def get(endpoint:, params: {})
  request(method: :get, endpoint: endpoint, params: params)
end