Sha256: 34b666319bb1f9da279dc99de04c4256985a6d540626063428214730f6680e45
Contents?: true
Size: 1.29 KB
Versions: 3
Compression:
Stored size: 1.29 KB
Contents
require "httparty" module EspnFflApi class ApiClient attr_reader :league_id, :year attr_writer :views, :params def initialize(year) @year = year @league_id = EspnFflApi.config.league_id end def views @views ||= [] end def params @params ||= [] end def get uri = build_uri(views: views, params: params) puts "HTTP GET: #{uri}" HTTParty.get(uri) end private def base_uri EspnFflApi.config.base_uri + year.to_s + "/segments/0/leagues/" + league_id end def build_uri(views: [], params: []) views_string = views.map do |view| next unless ApiClient.api_views.keys.include?(view) "view=#{ApiClient.api_views[view]}" end.join("&") params_string = params.join("&") views_string = "?" + views_string unless views_string.empty? params_string = "&" + params_string unless params_string.empty? base_uri + views_string + params_string end def self.api_views { draft: "mDraftDetail", live_scoring: "mLiveScoring", matchup_score: "mMatchupScore", matchup: "mMatchup", pending_transactions: "mPendingTransactions", positional_ratings: "mPositionalRatings", team: "mTeam", } end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
espn_ffl_api-0.1.4 | lib/espn_ffl_api/api_client.rb |
espn_ffl_api-0.1.3 | lib/espn_ffl_api/api_client.rb |
espn_ffl_api-0.1.2 | lib/espn_ffl_api/api_client.rb |