# SleeperRb [![Gem Version](https://badge.fury.io/rb/sleeper_rb.svg)](https://badge.fury.io/rb/sleeper_rb) [![Build Status](https://app.travis-ci.com/sjweil9/sleeper_rb.svg?branch=main)](https://app.travis-ci.com/sjweil9/sleeper_rb) `SleeperRb` provides an object-oriented interface for the [Sleeper Fantasy Football API](https://docs.sleeper.app/#introduction). 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: ```ruby 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. ```ruby client = SleeperRb::Client.new ``` Request resources from the client. The results will always be cached until you call `refresh`. ```ruby user = client.user(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. ```ruby 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. ```ruby roster.players => [#,...] ``` Any resources returned as an array implement a ResourceArray variation that enables a light ActiveRecord-inspired syntax for filtering the collection. ```ruby roster.players.class => SleeperRb::Resources::PlayerArray roster.players.where(position: "rb") => [# [#