0.0
No commit activity in last 3 years
No release in over 3 years
A simple Ruby wrapper for PE Accounting's public API.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.14
~> 10.0

Runtime

~> 1.0
>= 1.3.0, ~> 1.3
>= 1.4.0
~> 2.0
 Project Readme

PE Accounting Ruby Client

Gem

A simple low-level wrapper for PE Accounting's public API. It's publicly available at https://my.accounting.pe/api/v1/doc

Installation

Add this line to your application's Gemfile:

gem 'pe_accounting'

And then execute:

$ bundle

Or install it yourself as:

$ gem install pe_accounting

Usage

require 'pe_accounting'

# Initialize the API, the 3rd parameter is one of (:json, :xml) and sets how the wrapper will interact with the API.
>> api = PeAccounting::Client.new('your-api-token', 123)
=> <PeAccounting::Client:0x007fd6b7ac74d0 @company_id=123, @format=:json, @token="your-api-token", @endpoint="https://my.accounting.pe/api/v1/">

# Fetch a list of all the given company's clients. Returns a ruby Array or Hash, depending on the ressource's specifications
>> clients = api.get('client')
=> [ {"id"=>12345, "foreign-id"=>"", "name"=>"fdsmfkls", "contact"=>"fslmdkfsdmlkf", "address"=>{"address1"=>"sdfmsdlmfksdm", "address2"=>"", "zip-code"=>"12345", "state"=>"msdlfkdsmlk", "country"=>"sdflkdslkfj"}, "email"=>"sdflkjsfs@fdsd.fr", "country-code"=>"FR", "accountnr"=>0, "payment-days"=>14, "orgno"=>"123456-1234", "phone"=>"+33123456789", "user"=>{"id"=>12345}, "delivery-type"=>"Email", "vat-nr"=>"", "template"=>{"id"=>1234}, "active"=>true}, {"id"=>9876, "foreign-id"=>"", "name"=>"fdsmfkls", "contact"=>"fslmdkfsdmlkf", "address"=>{"address1"=>"sdfmsdlmfksdm", "address2"=>"", "zip-code"=>"12345", "state"=>"msdlfkdsmlk", "country"=>"sdflkdslkfj"}, "email"=>"sdflkjsfs@fdsd.fr", "country-code"=>"FR", "accountnr"=>0, "payment-days"=>14, "orgno"=>"123456-1235", "phone"=>"+33123456789", "user"=>{"id"=>9875}, "delivery-type"=>"Email", "vat-nr"=>"", "template"=>{"id"=>1234}, "active"=>true} ]

john = clients.first
john["name"] = "John Doe"

## Updates a client with the new name
api.post("client/#{john['id']}", john)

Accepted methods: get, put, post, delete. Only put and post accept a payload.

Development

After checking out the repo, run bin/setup to install dependencies. 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.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/ridem/pe-accounting-ruby-client.

License

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