Sha256: 11bc8b0ed5a0dde6a48e5a31b86ff5bbe9523027171918fceeddd332264bfc3e

Contents?: true

Size: 824 Bytes

Versions: 1

Compression:

Stored size: 824 Bytes

Contents

# frozen_string_literal: true

require "espn_ffl_api/version"
require "espn_ffl_api/api_client"
require "espn_ffl_api/owner"
require "espn_ffl_api/team"
require "espn_ffl_api"
require "dotenv"

EspnAPI = EspnFflApi

module EspnFflApi

  Dotenv.load

  class Error < StandardError; end

  @config = {
    league_id: ENV["ESPN_LEAGUE_ID"],
    base_uri: "http://fantasy.espn.com/apis/v3/games/ffl/seasons/",
  }

  def self.config
    OpenStruct.new(@config)
  end

  def self.client
    @@client ||= ApiClient.new(2019)
  end

  def self.owners
    client.views = [:team]

    @@owners ||= client.get["members"].map do |member_hash|
      Owner.build(member_hash)
    end
  end

  def self.teams
    client.views = [:team]

    @@teams ||= client.get["teams"].map do |team_hash|
      Team.build(team_hash)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
espn_ffl_api-0.1.4 lib/espn_ffl_api.rb