Moonclerk
Moonclerk is a Ruby wrapper around Moonclerk's read-only REST API.
Installation
Add this line to your application's Gemfile:
gem 'moonclerk'
And then execute:
$ bundle
Or install it yourself as:
$ gem install moonclerk
Usage
Set your API key in an initializer (e.g. config/initializers/moonclerk.rb
):
Moonclerk.api_key = "<API-KEY>"
All
All objects have find
and list
, and some have where
which allows filtering on certain attributes. For any list
or where
call, next_page
and previous_page
can be used to traverse the results returned from the API:
Moonclerk::Customer.list.next_page
Customers (known as "Plans" in the MoonClerk UI)
To retrieve a customer:
Moonclerk::Customer.retrieve(id) # or Moonclerk::Customer.find(id)
To list customers:
Moonclerk::Customer.list # or Moonclerk::Customer.all
# Options include count and offset
# NOTE: Count defaults to 10 (max is 100), and offset defaults to 0
To filter customers:
Moonclerk::Customer.where(status: "active")
# Options include form_id, checkout_from, checkout_to, next_payment_from, next_payment_to, status, count, offset
# NOTE: Any parameter ending in _from or _to is expected to be a Date, Time or DateTime
# NOTE: Count defaults to 10 (max is 100), and offset defaults to 0
Forms
To retrieve a form:
Moonclerk::Form.retrieve(id) # or Moonclerk::Form.find(id)
To list forms:
Moonclerk::Form.list # or Moonclerk::Form.all
# Options include count and offset
# NOTE: Count defaults to 10 (max is 100), and offset defaults to 0
Payments
To retrieve a payment:
Moonclerk::Payment.retrieve(id) # or Moonclerk::Payment.find(id)
To list payments:
Moonclerk::Payment.list # or Moonclerk::Payment.all
# Options include count and offset
# NOTE: Count defaults to 10 (max is 100), and offset defaults to 0
To filter payments:
Moonclerk::Payment.where(status: "active")
# Options include form_id, customer_id, date_from, date_to, status, count, offset
# NOTE: Any parameter ending in _from or _to is expected to be a Date, Time or DateTime
# NOTE: Count defaults to 10 (max is 100), and offset defaults to 0
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run bin/console
for an interactive prompt that will allow you to experiment.
Contributing
- Fork it ( https://github.com/[my-github-username]/moonclerk/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request