dblock / strava-ruby-client

A complete Ruby client for the Strava API v3.
https://code.dblock.org/2018/11/27/writing-a-new-strava-api-ruby-client.html
MIT License
97 stars 22 forks source link

Draft: adds rate limit class #40

Closed simonneutert closed 2 years ago

simonneutert commented 3 years ago

this may not be exactly what you had in mind, but maybe we can make this work in a way you feel good merging it. let me know what you think and I will add tests and finish the job.

simonneutert commented 3 years ago

errors go down with every endpoint I fix, but I still do have some busy work to finish.

but I'd like to get your feedback first. I do like that models do not get instantiated directly anymore, to be honest. it feels a bit cleaner having methods be in charge, just like paginate always did the magic.

dblock commented 3 years ago

errors go down with every endpoint I fix, but I still do have some busy work to finish.

but I'd like to get your feedback first. I do like that models do not get instantiated directly anymore, to be honest. it feels a bit cleaner having methods be in charge, just like paginate always did the magic.

So you already see the problem, it's getting messy, so that's probably not the right solution. Try this:

simonneutert commented 3 years ago

errors go down with every endpoint I fix, but I still do have some busy work to finish. but I'd like to get your feedback first. I do like that models do not get instantiated directly anymore, to be honest. it feels a bit cleaner having methods be in charge, just like paginate always did the magic.

So you already see the problem, it's getting messy, so that's probably not the right solution. Try this:

  • The response is now an object.
  • Add a different constructor to the Model base class that takes a response. Now models will inherit from a class that is constructed from a response and not a hash, and it should keep a reference to the response object.
  • Because all models inherit from Model, you can get access to the response object and hence the headers.
  • Lazy instantiation everywhere so we only parse/construct when needed.

this was my first implementation I tried, but I failed getting it to work with the Hashie::Trash Model class inherits from

I will let this sink in a bit and see what my sub conscience comes up with 😞

dblock commented 3 years ago

I will let this sink in a bit and see what my sub conscience comes up with 😞

Let me know if you need help!

dblock commented 2 years ago

Want to try finish this up @simonneutert?

simonneutert commented 2 years ago

i will give this another try and get back to you with what I come up with ✌️

dangerpr-bot commented 2 years ago
1 Error
:no_entry_sign: The TOC found in README.md doesn't match the sections of the file.
1 Warning
:warning: Unless you're refactoring existing code or improving documentation, please update CHANGELOG.md.

Here's the expected TOC for README.md:

# Table of Contents

- [Installation](#installation)
- [Usage](#usage)
  - [Activities](#activities)
    - [Create an Activity](#create-an-activity)
    - [Get Activity](#get-activity)
    - [List Activity Photos](#list-activity-photos)
    - [List Activity Comments](#list-activity-comments)
    - [List Activity Kudoers](#list-activity-kudoers)
    - [List Activity Laps](#list-activity-laps)
    - [List Athlete Activities](#list-athlete-activities)
    - [Get Activity Zones](#get-activity-zones)
    - [Update Activity](#update-activity)
  - [Athletes](#athletes)
    - [Get Authenticated Athlete](#get-authenticated-athlete)
    - [Get Zones](#get-zones)
    - [Get Athlete Stats](#get-athlete-stats)
    - [Update Athlete](#update-athlete)
  - [Clubs](#clubs)
    - [List Club Activities](#list-club-activities)
    - [List Club Events](#list-club-events)
    - [List Club Administrators](#list-club-administrators)
    - [Get Club](#get-club)
    - [List Club Members](#list-club-members)
    - [List Athlete Clubs](#list-athlete-clubs)
  - [Gears](#gears)
    - [Get Equipment](#get-equipment)
  - [Routes](#routes)
    - [Export Route GPX](#export-route-gpx)
    - [Export Route TCX](#export-route-tcx)
    - [Get Route](#get-route)
    - [List Athlete Routes](#list-athlete-routes)
  - [Running Races](#running-races)
    - [Get Running Race](#get-running-race)
    - [List Running Races](#list-running-races)
  - [Segment Efforts](#segment-efforts)
    - [List Segment Efforts](#list-segment-efforts)
    - [Get Segment Effort](#get-segment-effort)
  - [Segments](#segments)
    - [Explore Segments](#explore-segments)
    - [Get Segment Leaderboard](#get-segment-leaderboard)
    - [List Starred Segments](#list-starred-segments)
    - [Get Segment](#get-segment)
    - [Star Segment](#star-segment)
  - [Streams](#streams)
    - [Get Activity Streams](#get-activity-streams)
    - [Get Segment Effort Streams](#get-segment-effort-streams)
    - [Get Segment Streams](#get-segment-streams)
  - [Uploads](#uploads)
    - [Upload Activity](#upload-activity)
    - [Get Upload](#get-upload)
  - [Pagination](#pagination)
  - [OAuth](#oauth)
    - [OAuth Workflow](#oauth-workflow)
    - [Deauthorize](#deauthorize)
    - [Command Line OAuth Workflow](#command-line-oauth-workflow)
  - [Webhooks](#webhooks)
- [Configuration](#configuration)
  - [Web Client Options](#web-client-options)
  - [API Client Options](#api-client-options)
  - [OAuth Client Options](#oauth-client-options)
  - [OAuth Client Ratelimits](#oauth-client-ratelimits)
  - [Webhooks Client Options](#webhooks-client-options)
- [Errors](#errors)
- [Tools](#tools)
  - [Strava OAuth Token](#strava-oauth-token)
- [Users](#users)
- [Resources](#resources)
- [Upgrading](#upgrading)
- [Contributing](#contributing)
- [Copyright and License](#copyright-and-license)

Here's an example of a CHANGELOG.md entry:

* [#40](https://github.com/dblock/strava-ruby-client/pull/40): Draft: adds rate limit class - [@simonneutert](https://github.com/simonneutert).

Generated by :no_entry_sign: Danger

simonneutert commented 2 years ago

new attempt in PR https://github.com/dblock/strava-ruby-client/pull/50