Class: Sportradar::Api::Content
- Defined in:
- lib/sportradar/api/content.rb
Defined Under Namespace
Classes: Article, ArticleList, Reference
Instance Attribute Summary collapse
-
#access_level ⇒ Object
Returns the value of attribute access_level.
-
#sport ⇒ Object
Returns the value of attribute sport.
Attributes inherited from Request
#qps_allotted, #qps_current, #quota_allotted, #quota_current
Instance Method Summary collapse
- #analysis(date = Date.today, content_type: 'all') ⇒ Object
-
#initialize(sport, access_level = default_access_level) ⇒ Content
constructor
A new instance of Content.
- #news(date = Date.today, content_type: 'all') ⇒ Object
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_level ⇒ Object
Returns the value of attribute access_level.
4 5 6 |
# File 'lib/sportradar/api/content.rb', line 4 def access_level @access_level end |
#sport ⇒ Object
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 |