Class: Emites::Resources::Nfse
- Defined in:
- lib/emites/resources/nfse.rb
Overview
A wrapper to Emites NFSes API
- API
-
Documentation: myfreecomm.github.io/emites/v1/modules/nfse.html
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#cancel(id) ⇒ Emites::Entities::NfseStatus
Cancels a Nfse by it’s id.
-
#create(params) ⇒ Emites::Entities::Nfse
Creates an Nfse.
-
#destroy(id) ⇒ Boolean
Deletes a Nfse by it’s id.
-
#history(id) ⇒ Object
Retrieves the entire Nfse status history by it’s id.
-
#info(id) ⇒ Emites::Entities::Nfse
Retrieves a Nfse by it’s id.
-
#list ⇒ Object
Lists all NFSes.
-
#pdf(id) ⇒ String
Retrieves Nfse PDF url.
-
#search(params = {}) ⇒ Object
Lists all NFSes matching search parameters.
-
#status(id) ⇒ Emites::Entities::NfseStatus
Retrieves a Nfse status by it’s id.
-
#update(id, params) ⇒ Emites::Entities::Nfse
Updates an Nfse.
-
#xml(id) ⇒ String
Retrieves Nfse XML url.
Methods inherited from Base
Methods included from Hooks
Constructor Details
This class inherits a constructor from Emites::Resources::Base
Instance Method Details
#cancel(id) ⇒ Emites::Entities::NfseStatus
Cancels a Nfse by it’s id
- API
-
Method:
POST /api/v1/nfse/:id/cancel
Documentation: myfreecomm.github.io/emites/sandbox/v1/modules/nfse.html#cancelamento
133 134 135 136 137 |
# File 'lib/emites/resources/nfse.rb', line 133 def cancel(id) http.post("/nfse/#{id}/cancel") do |response| respond_with_entity(response, Entities::NfseStatus) end end |
#create(params) ⇒ Emites::Entities::Nfse
Creates an Nfse
- API
-
Method:
POST /api/v1/nfse
Documentation: myfreecomm.github.io/emites/sandbox/v1/modules/nfse.html#criacao
163 164 165 166 167 |
# File 'lib/emites/resources/nfse.rb', line 163 def create(params) http.post("/nfse", { body: params }) do |response| respond_with_entity(response) end end |
#destroy(id) ⇒ Boolean
Deletes a Nfse by it’s id
- API
-
Method:
DELETE /api/v1/nfse/:id
Documentation: myfreecomm.github.io/emites/sandbox/v1/modules/nfse.html#remocao
148 149 150 151 152 |
# File 'lib/emites/resources/nfse.rb', line 148 def destroy(id) http.delete("/nfse/#{id}") do |response| response.code == 204 end end |
#history(id) ⇒ Object
Retrieves the entire Nfse status history by it’s id
- API
-
Method:
GET /api/v1/nfse/:id/history
Documentation: myfreecomm.github.io/emites/sandbox/v1/modules/nfse.html#historico
88 89 90 91 92 |
# File 'lib/emites/resources/nfse.rb', line 88 def history(id) http.get("/nfse/#{id}/history") do |response| respond_with_collection(response, Entities::NfseStatusTransition) end end |
#info(id) ⇒ Emites::Entities::Nfse
Retrieves a Nfse by it’s id
- API
-
Method:
GET /api/v1/nfse/:id
Documentation: myfreecomm.github.io/emites/sandbox/v1/modules/nfse.html#detalhes
58 59 60 61 62 |
# File 'lib/emites/resources/nfse.rb', line 58 def info(id) http.get("/nfse/#{id}") do |response| respond_with_entity(response) end end |
#list ⇒ Object
Lists all NFSes
- API
-
Method:
GET /api/v1/nfse
Documentation: myfreecomm.github.io/emites/v1/modules/nfse.html#listagem
28 29 30 31 32 |
# File 'lib/emites/resources/nfse.rb', line 28 def list http.get("/nfse") do |response| respond_with_collection(response) end end |
#pdf(id) ⇒ String
Retrieves Nfse PDF url
- API
-
Method:
GET /api/v1/nfse/:id/pdf
Documentation: myfreecomm.github.io/emites/sandbox/v1/modules/nfse.html#pdf
103 104 105 106 107 |
# File 'lib/emites/resources/nfse.rb', line 103 def pdf(id) http.get("/nfse/#{id}/pdf") do |response| response.headers.fetch("Location") { "" } end end |
#search(params = {}) ⇒ Object
Lists all NFSes matching search parameters
- API
-
Method:
GET /api/v1/nfse?status=:status&page=:page
Documentation: myfreecomm.github.io/emites/v1/modules/nfse.html#filtros
43 44 45 46 47 |
# File 'lib/emites/resources/nfse.rb', line 43 def search(params = {}) http.get("/nfse", params: filter(params)) do |response| respond_with_collection(response) end end |
#status(id) ⇒ Emites::Entities::NfseStatus
Retrieves a Nfse status by it’s id
- API
-
Method:
GET /api/v1/nfse/:id/status
Documentation: myfreecomm.github.io/emites/sandbox/v1/modules/nfse.html#status
73 74 75 76 77 |
# File 'lib/emites/resources/nfse.rb', line 73 def status(id) http.get("/nfse/#{id}/status") do |response| respond_with_entity(response, Entities::NfseStatus) end end |
#update(id, params) ⇒ Emites::Entities::Nfse
Updates an Nfse
- API
-
Method:
PUT /api/v1/:id
Documentation: myfreecomm.github.io/emites/sandbox/v1/modules/nfse.html#atualizacao-parcial-e-completa
179 180 181 182 183 |
# File 'lib/emites/resources/nfse.rb', line 179 def update(id, params) http.put("/nfse/#{id}", { body: params }) do |response| respond_with_entity(response) end end |
#xml(id) ⇒ String
Retrieves Nfse XML url
- API
-
Method:
GET /api/v1/nfse/:id/xml
Documentation: myfreecomm.github.io/emites/sandbox/v1/modules/nfse.html#xml
118 119 120 121 122 |
# File 'lib/emites/resources/nfse.rb', line 118 def xml(id) http.get("/nfse/#{id}/xml") do |response| response.headers.fetch("Location") { "" } end end |