0.0
No commit activity in last 3 years
No release in over 3 years
Official Ruby client for the Emites API. Emites is a system for creating "notas fiscais eletrĂ´nicas" (NFe / NFSe) in Brazil.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 0.10
~> 0.2
~> 10.0
~> 4.0
~> 3.2
~> 0.9
~> 2.9

Runtime

~> 1.11
~> 0.8
~> 1.0
~> 1.6
 Project Readme

Emites Client

This is the official Ruby client for the Emites API.

Gem Version Build Status Test Coverage Code Climate Grade Inline docs

Installation

Add this line to your application's Gemfile:

gem 'emites-client', require: 'emites'

And then execute:

$ bundle

Or install it yourself as:

$ gem install emites-client

Configuration

Use Emites.configure to setup your environment:
require "emites"

Emites.configure do |config|
  config.url = "https://sandbox.emites.com.br/api/v1" # defaults to "https://app.emites.com.br/api/v1"
  config.user_agent = 'My App v1.0' # optional, but you should pass a custom user-agent identifying your app
end
Create a new token in your Emites account: https://app.emites.com.br/config/api

Usage

Given your token, create an instance of Emites::Client, as below:
client = Emites.client("YOUR_TOKEN_HERE")
Now you have access to every API endpoint:

Endpoints

HTTP method Endpoint Client method
POST /api/v1/emitters client.emitters.create
GET /api/v1/emitters client.emitters.list
GET /api/v1/emitters/:id client.emitters.info
GET /api/v1/emitters?cnpj=?:cnpj client.emitters.search
DELETE /api/v1/emitters/:id client.emitters.destroy
HTTP method Endpoint Client method
POST /api/v1/takers client.takers.create
GET /api/v1/takers client.takers.list
GET /api/v1/takers/:id client.takers.info
GET /api/v1/takers?cnpj=:cnpj client.takers.search
DELETE /api/v1/takers/:id client.takers.destroy
HTTP method Endpoint Client method
POST /api/v1/service-values client.services.create
GET /api/v1/service-values client.services.list
GET /api/v1/service-values/:id client.services.info
GET /api/v1/service-values?name=:name client.services.search
DELETE /api/v1/service-values/:id client.services.destroy
POST /api/v1/service-values/:id/calculation-liquid-amount client.services.calculate_liquid_amount
HTTP method Endpoint Client method
POST /api/v1/webhooks client.webhooks.create
GET /api/v1/webhooks client.webhooks.list
PUT /api/v1/webhooks/:id client.webhooks.update
DELETE /api/v1/webhooks/:id client.webhooks.destroy
HTTP method Endpoint Client method
POST /api/v1/nfse client.nfse.create
GET /api/v1/nfse client.nfse.list
GET /api/v1/nfse/:id client.nfse.info
GET /api/v1/nfse/:id/status client.nfse.status
GET /api/v1/nfse/:id/history client.nfse.history
GET /api/v1/nfse/:id/pdf client.nfse.pdf
GET /api/v1/nfse/:id/xml client.nfse.xml
POST /api/v1/nfse/:id/cancel client.nfse.cancel
DELETE /api/v1/nfse/:id client.nfse.destroy
PUT /api/v1/nfse/:id client.nfse.update

Callbacks

All actions that change data triggers an event that you can subscribe to. This event allow you to extend the logic executed when you call a client method.

Subscribing to an event

All you have to do is create a class that responds to a method #call with two arguments:

class MyListener
  def call(result, args)
  end
end

Where:

  • result is the return of a client method
  • args is an array of arguments passed to the client method you called

Now you have a listener, you can subscribe to an event:

Emites.subscribe("emites.emitters.destroy", MyListener.new)

Example:

When you call client.emitters.destroy(1), an event emites.emitters.destroy will be triggered. Your listener method #call will receive:

  • result would be true or false - depending on what client.emitters.destroy(1) returned
  • args would be [1] - an array with the arguments passed to the client method

Available hooks

Resource Events
emitters emites.emitters.create
emites.emitters.destroy
takers emites.takers.create
emites.takers.destroy
services emites.services.create
emites.services.destroy
webhooks emites.webhooks.create
emites.webhooks.update
emites.webhooks.destroy
nfse emites.nfse.create
emites.nfse.update
emites.nfse.destroy
emites.nfse.cancel

Contributing

  1. Fork it ( https://github.com/myfreecomm/emites-client-ruby/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request