Giter Club home page Giter Club logo

baremetrics_api's Introduction

This gem is no longer being updated or maintained by Rewind. Drop us a note if you'd like to take over maintenance

Baremetrics API

This is a Ruby Gem for the Baremetrics API developed by Rewind.

Installation

Add this line to your application's Gemfile:

gem 'baremetrics_api'

And then execute:

$ bundle

Or install it yourself as:

$ gem install baremetrics_api

Usage

Initializing the Client

This gem uses a client model for communication with the API. You initialize a client first with the desired configuration and then use it for making requests:

client = BaremetricsAPI::Client.new(api_key: '1234')

client.list_sources

The only required configuration parameter to initialize the client is the API key using this constructor. Unprovided parameters will have their default value set.

You can also initialize the client using a configuration block to have it globally configured:

BaremetricsAPI.client.configure do |config|
  config.api_key = '123'
  config.sandbox = false
  config.response_limit = 30
  config.log_traffic = false
end

BaremetricsAPI.client.list_source

Note that you must specify all the configuration parameters when using this method as they will not have a default value.

Configuration Parameters

api_key: String - The Baremetrics API key. Can be sandbox or production.

sandbox: Boolean - Whether to use the sandbox or production API endpoint. (Default: false)

response_limit: Integer - The amount of items to return per page for GET requests (Default: 30)

log_traffic: Boolean - Output a log of requests and responses from the Baremetrics API (Default: false)

Making Requests

The gem tries to best match its method names to the name of the corresponding API call in the Baremetrics documentation. All API calls are available as methods on the client object. To list which calls are available run: client.methods

The arguments required for each endpoint are named keywords. We tried to best match the names of the parameters as described in the Baremetrics API documentation.

An example call would be:

client.list_customers(source_id: '123')

The response to all calls is raw JSON that is returned from the Baremetrics API.

Rate Limiting

The Baremetrics API has a rate limit which refreshes per-hour. When the rate limit is exceeded, this gem will throw the following exception Error::RateLimitExeeded.

You should rescue this exception and retry after an hour when the rate limit is refreshed.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/rewindit/baremetrics.

License

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

baremetrics_api's People

Contributors

dnorth98 avatar olepalm avatar ress avatar seashellski avatar smandegar avatar

Stargazers

 avatar

Watchers

 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.