Sha256: 5c498548d18c61e1045336617846b2179d314948388eca07324af21ec28c24c8

Contents?: true

Size: 1.67 KB

Versions: 55

Compression:

Stored size: 1.67 KB

Contents

module Sportradar
  module Api
    module Soccer
      class Group < Data
        attr_reader :league_group

        def initialize(data = {}, league_group: nil, **opts)
          @id = data['id']

          @league_group = league_group || data['league_group']

          @tournaments_hash = {}
          # @daily_schedule   = {}

          update(data, **opts)
        end

        def update(data, **opts)
          create_data(@tournaments_hash, data['tournaments'], klass: Tournament, api: api, league_group: @league_group) if data['tournaments']
        end

        def tournaments
          @tournaments_hash.values
        end

        def tournament(id)
          @tournaments_hash[id]
        end

        def api
          @api ||= Sportradar::Api::Soccer::Api.new(league_group: @league_group)
        end

        def get_tournaments
          data = api.get_data(path_tournaments).to_h
          ingest_tournaments(data)
        end

        def ingest_tournaments(data)
          update(data, source: :tournaments)
          data
        end

        def queue_tournaments
          url, headers, options, timeout = api.get_request_info(path_tournaments)
          {url: url, headers: headers, params: options, timeout: timeout, callback: method(:ingest_tournaments)}
        end

        def path_tournaments
          'tournaments'
        end

        def self.europe
          self.new(league_group: 'eu')
        end
        def self.americas
          self.new(league_group: 'am')
        end
        def self.north_america
          self.new(league_group: 'na')
        end

        def self.international
          self.new(league_group: 'intl')
        end

      end
    end
  end
end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
sportradar-api-0.20.2 lib/sportradar/api/soccer/group.rb
sportradar-api-0.20.1 lib/sportradar/api/soccer/group.rb
sportradar-api-0.20.0 lib/sportradar/api/soccer/group.rb
sportradar-api-0.20.0.pre2 lib/sportradar/api/soccer/group.rb
sportradar-api-0.20.0.pre lib/sportradar/api/soccer/group.rb
sportradar-api-0.19.6 lib/sportradar/api/soccer/group.rb
sportradar-api-0.19.5 lib/sportradar/api/soccer/group.rb
sportradar-api-0.19.4 lib/sportradar/api/soccer/group.rb
sportradar-api-0.19.3 lib/sportradar/api/soccer/group.rb
sportradar-api-0.19.2 lib/sportradar/api/soccer/group.rb
sportradar-api-0.19.1 lib/sportradar/api/soccer/group.rb
sportradar-api-0.19.0 lib/sportradar/api/soccer/group.rb
sportradar-api-0.18.1 lib/sportradar/api/soccer/group.rb
sportradar-api-0.18.0 lib/sportradar/api/soccer/group.rb
sportradar-api-0.17.6 lib/sportradar/api/soccer/group.rb
sportradar-api-0.17.5 lib/sportradar/api/soccer/group.rb
sportradar-api-0.17.5.pre lib/sportradar/api/soccer/group.rb
sportradar-api-0.17.4 lib/sportradar/api/soccer/group.rb
sportradar-api-0.17.3 lib/sportradar/api/soccer/group.rb
sportradar-api-0.17.2 lib/sportradar/api/soccer/group.rb