Easybill
A wrapper for the Easybill online invoice service. Create invoices, manage customer information and their payments using the SOAP API.
Installation
Add this line to your application's Gemfile:
gem 'easybill'
And then execute:
$ bundle
Or install it yourself as:
$ gem install easybill
Usage
client = Easybill::Client.new(key: <your apikey>)
# => <Easybill::Client @key=<asdf>>
# Note: the 'key' argument can be left out if you store the key in a
# file name 'apikey' in the project root.
customer = client.get_customer_by_customer_number(700)
# => <Easybill::Customer ... > # a [OpenStruct](http://www.ruby-doc.org/stdlib-2.0/libdoc/ostruct/rdoc/OpenStruct.html)
client.search_customers("Foo")
# => [<Easybill::Customer>...] # Array[OpenStruct]
customer.company_name
# => "ACME Inc."
See lib/easybill/client.rb for currently supported operations.
If you need access to unmapped SOAP operations you can always use the underlying savonrb client:
client.client.class
# => Savon::Client
client.client.operations
# => [:get_customer, :get_customer_by_customer_number, :set_customer ... ]
client.client.call(<operation>, message: <hash>)
For exploration of the API and ease of development, there are some fixtures in place in fixtures.yaml:
require 'easybill/fixture'
include Easybill::Fixture
# provides "customer", "document" and "position" helper methods
invoice = document(:basic)
# => {...} # corresponding hash from the yaml fixtures
# the customer_id in the fixtures is probably not valid anymore:
customer_id = client.get_customer_by_customer_number(10001).customer_id
invoice["customerID"] = customer_id
client.client.call(:create_document, message: invoice)
# (lots of debug output)
Testing
If you need to update the vcr cassettes you can pass a valid api key to your test setting the EASYBILL_APIKEY environment variable.
EASYBILL_APIKEY='120931...' bundle exec rspec spec
Contributing
- Fork it
- 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 new Pull Request