diff --git a/CHANGELOG.md b/CHANGELOG.md index 08815c2..e6326ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Notas das versões +## [v0.0.8 - 16/11/2020](https://github.com/vindi/vindi-ruby/releases/tag/v0.0.8) +- Adiciona endpoint para retentativa de envio de notas fiscais + ## [v0.0.7 - 14/10/2020](https://github.com/vindi/vindi-ruby/releases/tag/v0.0.7) - Adiciona endpoint para consulta de registros de utilização associados ao período diff --git a/lib/vindi/rest/invoice.rb b/lib/vindi/rest/invoice.rb index 9bbcac5..cff49f8 100644 --- a/lib/vindi/rest/invoice.rb +++ b/lib/vindi/rest/invoice.rb @@ -38,13 +38,23 @@ def create_invoice(options = {}) # # @params invoice_id [Integer] ID of the invoice # @option options [Hash] :options invoice attributes - # # @see https://vindi.github.io/api-docs/dist/#!/invoices/DELETE_version_invoices_id_format # @example Delete invoice #108 # client.delete_invoice(108) def delete_invoice(invoice_id, options = {}) delete("invoices/#{invoice_id}", options)[:invoice] end + + # Retry a invoice from merchant vindi + # + # @params invoice_id [Integer] ID of the invoice + # @option options [Hash] :options invoice attributes + # @see https://vindi.github.io/api-docs/dist/#/invoices/postV1InvoicesIdRetry + # @example Retry a invoice from merchant vindi + # client.retry_invoice(108) + def retry_invoice(invoice_id, options = {}) + post("invoices/#{invoice_id}/retry", options)[:invoice] + end end end end diff --git a/lib/vindi/version.rb b/lib/vindi/version.rb index dbd937e..647804d 100644 --- a/lib/vindi/version.rb +++ b/lib/vindi/version.rb @@ -1,3 +1,3 @@ module Vindi - VERSION = '0.0.7' + VERSION = '0.0.8' end diff --git a/spec/cassettes/vindi/rest/invoices/retry_invoice.yml b/spec/cassettes/vindi/rest/invoices/retry_invoice.yml new file mode 100644 index 0000000..24950dc --- /dev/null +++ b/spec/cassettes/vindi/rest/invoices/retry_invoice.yml @@ -0,0 +1,50 @@ +--- +http_interactions: +- request: + method: post + uri: https://sandbox-app.vindi.com.br/api/v1/invoices/108/retry + body: + encoding: UTF-8 + string: '' + headers: + User-Agent: + - Vindi-Ruby/0.0.7 + Authorization: + - Basic eER3M2VsUHdkZGx6cWdGekpxWlhraXktalpselZ2WTdMMWFWZGNEYk1IZzo= + Content-Type: + - application/x-www-form-urlencoded + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 201 + message: Created + headers: + Cache-Control: + - no-cache + Content-Type: + - application/json; charset=UTF-8 + Date: + - Mon, 26 Oct 2020 13:53:22 GMT + Server: + - nginx + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Vary: + - Origin + X-Request-Id: + - 94f8113e-e685-4b1c-ae64-96b7272d9c28 + X-Runtime: + - '0.004051' + Content-Length: + - '426' + Connection: + - keep-alive + body: + encoding: UTF-8 + string: '{"invoice":{"id":108,"amount":"1.0","status":"processing","integration_invoice_id":null,"integration_reference":null,"print_url":null,"description":null,"settings":null,"issued_at":null,"scheduled_at":null,"created_at":"2017-09-08T13:11:00.253-03:00","updated_at":"2017-09-08T13:11:00.253-03:00","bill":{"id":71,"code":null},"customer":{"id":20,"name":"Wagner + Narde","email":"wagner.narde@vindi.com.br","code":null}}}' + recorded_at: Mon, 26 Oct 2020 13:53:22 GMT +recorded_with: VCR 6.0.0 diff --git a/spec/vindi/rest/invoice_spec.rb b/spec/vindi/rest/invoice_spec.rb index b862dea..9129fee 100644 --- a/spec/vindi/rest/invoice_spec.rb +++ b/spec/vindi/rest/invoice_spec.rb @@ -44,4 +44,14 @@ end end end + + describe 'retry_invoice' do + it 'returns the retried invoice' do + VCR.use_cassette("rest/invoices/retry_invoice") do + invoice_response = client.retry_invoice(108) + assert_requested :post, vindi_url("invoices/108/retry") + expect(invoice_response[:status]).to eq('processing') + end + end + end end