Code Monkey home page Code Monkey logo

sleeper_rb's Introduction

SleeperRb

Gem Version Build Status

SleeperRb provides an object-oriented interface for the Sleeper Fantasy Football API. The Sleeper API is a read-only, no-authentication API for accessing information on Sleeper Fantasy Football leagues.

Installation

Add this line to your application's Gemfile:

gem 'sleeper_rb'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install sleeper_rb

Usage

Initialize a SleeperRb::Client and use that to start any queries.

client = SleeperRb::Client.new

Request resources from the client. The results will always be cached until you call refresh.

user = client.user(username: "foo")
=> #<SleeperRb::Resources::User:0x000056084a0c3d40 @username="foo">

From a given resource access its attributes or associated resources. No API requests will be made until one of the attributes is accessed.

user.user_id
=> 37440957478939283
user.display_name
=> "foobar"
# explicitly trigger a refresh to get, for example, an updated display_name
user.refresh.display_name
=> "newbar"

Some resources also have associations to other types of resources.

roster.players
=> [#<SleeperRb::Resources::Player:0x00005588808d2c60 @player_id="1479">,...]

Any resources returned as an array implement a ResourceArray variation that enables a light ActiveRecord-inspired syntax for filtering the collection.

roster.players.class
=> SleeperRb::Resources::PlayerArray
roster.players.where(position: "rb")
=> [#<SleeperRb::Resources::Player:0x00005588808d2828 @player_id="2431", @values=...]
roster.players.where(age: { lt: 25 })
=> [#<SleeperRb::Resources::Player:0x00005588808d2828 @player_id="2431", @values=...]

Check the complete documentation to see all possible resources that can be accessed.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/sjweil9/sleeper_rb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the SleeperRb project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

sleeper_rb's People

Contributors

sjweil9 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.