Class: XboxApi::Client
- Inherits:
-
Object
- Object
- XboxApi::Client
- Defined in:
- lib/xbox-api/client.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
Instance Method Summary collapse
- #calls_remaining ⇒ Object
- #fetch_body_and_parse(endpoint) ⇒ Object
- #gamer(tag) ⇒ Object
-
#initialize(api_key) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(api_key) ⇒ Client
Returns a new instance of Client.
7 8 9 10 |
# File 'lib/xbox-api/client.rb', line 7 def initialize(api_key) @api_key = api_key @base_url = "https://xboxapi.com/v2" end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
5 6 7 |
# File 'lib/xbox-api/client.rb', line 5 def api_key @api_key end |
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
5 6 7 |
# File 'lib/xbox-api/client.rb', line 5 def base_url @base_url end |
Instance Method Details
#calls_remaining ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/xbox-api/client.rb', line 20 def calls_remaining headers = fetch_headers { limit: headers["x-ratelimit-limit"], remaining: headers["x-ratelimit-remaining"], resets_in: headers["x-ratelimit-reset"] } end |
#fetch_body_and_parse(endpoint) ⇒ Object
16 17 18 |
# File 'lib/xbox-api/client.rb', line 16 def fetch_body_and_parse(endpoint) parse(get_with_token(endpoint).read) end |