Class: Sportradar::Api::Content

Inherits:
Request
  • Object
show all
Defined in:
lib/sportradar/api/content.rb

Defined Under Namespace

Classes: Article, ArticleList, Reference

Instance Attribute Summary collapse

Attributes inherited from Request

#qps_allotted, #qps_current, #quota_allotted, #quota_current

Instance Method Summary collapse

Methods inherited from Request

#get, #get_data, #get_request_info, #parse_usage, #sim!, #usage

Constructor Details

#initialize(sport, access_level = default_access_level) ⇒ Content

Returns a new instance of Content.



6
7
8
9
10
11
# File 'lib/sportradar/api/content.rb', line 6

def initialize( sport, access_level = default_access_level)
  raise Sportradar::Api::Error::InvalidSport unless allowed_sports.include? sport
  @sport = sport
  raise Sportradar::Api::Error::InvalidAccessLevel unless allowed_access_levels.include? access_level
  @access_level = access_level
end

Instance Attribute Details

#access_levelObject

Returns the value of attribute access_level.



4
5
6
# File 'lib/sportradar/api/content.rb', line 4

def access_level
  @access_level
end

#sportObject

Returns the value of attribute sport.



4
5
6
# File 'lib/sportradar/api/content.rb', line 4

def sport
  @sport
end

Instance Method Details

#analysis(date = Date.today, content_type: 'all') ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/sportradar/api/content.rb', line 23

def analysis( date = Date.today, content_type: 'all' )
  raise Sportradar::Api::Error::InvalidType unless allowed_analysis_types.include? content_type
  response = get request_url("#{provider }/analysis/#{date_path(date)}/#{content_type}")
  if response.success? && response["items"]
    Sportradar::Api::Content::ArticleList.new response.to_h
  else
    response
  end
end

#news(date = Date.today, content_type: 'all') ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/sportradar/api/content.rb', line 13

def news( date = Date.today, content_type: 'all' )
  raise Sportradar::Api::Error::InvalidType unless allowed_news_types.include? content_type
  response = get request_url("#{provider }/news/#{date_path(date)}/#{content_type}")
  if response.success? && response["items"]
    Sportradar::Api::Content::ArticleList.new response.to_h
  else
    response
  end
end