Project

billplz

0.01
No commit activity in last 3 years
No release in over 3 years
Abstraction library to interface with the Billplz API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1
>= 0
 Project Readme

Billplz

Gem Version Circle CI Code Climate

An abstraction library to interface with the Billplz API

Installation

Add this line to your application's Gemfile:

gem 'billplz'

And then execute:

$ bundle

Or install it yourself as:

$ gem install billplz

Usage

Configuration

You may store your Billplz configuration during initialization:

# config/initializers/billplz.rb
Billplz.configure do |config|
  config.api_key = ENV['BILLPLZ_API_KEY']
end

All the options above can be overridden during runtime:

Billplz.configuration.api_key = 'your-api-key'

Or, as a hash:

Billplz.configuration = { api_key: 'your-api-key' }

Collection

Create a new collection:

collection = Billplz::Collection.new({ title: 'My awesome collection' })
collection.create

Bill

Create a new bill:

bill = Billplz::Bill.new({ collection_id: VALID_COLLECTION_ID, ... })
bill.create

Get a bill:

bill = Billplz::Bill.new({ bill_id: 'abc123'})
bill = bill.get

# state (due, overdue and paid)
bill['state']

# paid (return false for due and overdue bill; true for paid bill)
bill['paid']

Delete a bill:

bill = Billplz::Bill.new({ bill_id: 'abc123'})
bill.delete

Response

Standard Net::HTTP response will be returned by all of the above methods. However, the gem packed a few helper methods to make your life easier:

  1. #success?

You can check for a successfull request using success?, example:

bill.success?
  1. #parsed_json

A convenient helper to parse the JSON response from the API, example:

bill_id = bill.parsed_json['id']

Development

Run rake test to run the unit tests.

Running rake test:remote will run tests that perform actual communication with the API server. Proceed with caution.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/tideee/billplz. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

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