Class: Nfeiow::Client
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#company_id ⇒ Object
readonly
Returns the value of attribute company_id.
Instance Method Summary collapse
- #cancel_invoice(invoice_id) ⇒ Object
- #connection ⇒ Object
- #create_invoice(params) ⇒ Object
- #download_invoice_pdf(invoice_id) ⇒ Object
-
#initialize(company_id, api_key) ⇒ Client
constructor
A new instance of Client.
- #send_invoice_via_email(invoice_id) ⇒ Object
Methods included from Helpers
Constructor Details
#initialize(company_id, api_key) ⇒ Client
Returns a new instance of Client.
11 12 13 14 |
# File 'lib/nfeiow/client.rb', line 11 def initialize(company_id, api_key) @company_id = company_id @api_key = api_key end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
9 10 11 |
# File 'lib/nfeiow/client.rb', line 9 def api_key @api_key end |
#company_id ⇒ Object (readonly)
Returns the value of attribute company_id.
9 10 11 |
# File 'lib/nfeiow/client.rb', line 9 def company_id @company_id end |
Instance Method Details
#cancel_invoice(invoice_id) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/nfeiow/client.rb', line 32 def cancel_invoice(invoice_id) safe_http_call do connection.delete( path: "/v1/companies/#{company_id}/serviceinvoices/#{invoice_id}", headers: headers ) end end |
#connection ⇒ Object
16 17 18 19 20 |
# File 'lib/nfeiow/client.rb', line 16 def connection @connection ||= Excon.new( 'https://api.nfe.io/' ) end |
#create_invoice(params) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/nfeiow/client.rb', line 22 def create_invoice(params) safe_http_call do connection.post( path: "/v1/companies/#{company_id}/serviceinvoices", headers: headers, body: params.to_json ) end end |
#download_invoice_pdf(invoice_id) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/nfeiow/client.rb', line 41 def download_invoice_pdf(invoice_id) safe_http_call(true) do connection.get( path: "/v1/companies/#{company_id}/serviceinvoices/#{invoice_id}/pdf", headers: headers ) end end |
#send_invoice_via_email(invoice_id) ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/nfeiow/client.rb', line 50 def send_invoice_via_email(invoice_id) safe_http_call do connection.put( path: "/v1/companies/#{company_id}/serviceinvoices/#{invoice_id}/sendemail", headers: headers ) end end |