README.md in api_client_base-1.10.0 vs README.md in api_client_base-1.11.0
- old
+ new
@@ -40,10 +40,12 @@
MyGem.configure do |c|
c.host = "https://test.api.com"
end
```
+Note: there is a default configuration setting called `after_response`. See the "Response hooks" section for more details.
+
- instantiate `MyGem::Client` by calling `MyGem.new(host: "https://api.com", username: "user", password: "password")`. If you do not specify an option, it will use the gem's default.
### Configuring the `Client`
#### Default Options
@@ -238,20 +240,49 @@
end
end
end
```
-You can an example gem at https://github.com/imacchiato/bridge_client-ruby.
+You can an example gem [here](https://github.com/bloom-solutions/binance_client-ruby).
+#### Response hooks
+
+If you want to give the applications access to the request and response objects after each response (useful when tracking rate limits that are reported in the response, for example), then:
+
+```ruby
+MyGem.configure do |c|
+ c.after_request = ->(request, response) do
+ if response.header("remaining-requets") < 20
+ Rails.logger.warn "mayday!"
+ end
+ end
+end
+```
+
+Note: the request and response objects are the request and response instances such as:
+- `GetUserResponse`
+- `GetUserRequest`
+
+You can assign any object that response to `call`:
+
+```ruby
+class AfterMyGemResponse
+ def self.call(request, response)
+ end
+end
+```
+
+Note: avoid putting long running/expensive requests here because this will block the Ruby process.
+
## 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.
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
## Contributing
-Bug reports and pull requests are welcome on GitHub at https://github.com/imacchiato/api_client-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
+Bug reports and pull requests are welcome on GitHub at https://github.com/bloom-solutions/api_client-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).