Class: Vault::InvoiceBuilder::Client
- Inherits:
-
Object
- Object
- Vault::InvoiceBuilder::Client
- Defined in:
- lib/vault-invoice-builder-client.rb,
lib/vault-invoice-builder-client/client.rb,
lib/vault-invoice-builder-client/version.rb
Overview
Client for the Vault::InvoiceBuilder HTTP API.
Constant Summary collapse
- VERSION =
The
Vault::InvoiceBuilder::Clientgem version. '0.0.7'
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
The
Vault::InvoiceBuilderHTTP API URL.
Instance Method Summary collapse
-
#initialize(url = nil) ⇒ Client
constructor
Instantiate a client.
-
#post(statement) ⇒ Excon::Response
deprecated
Deprecated.
Please use #post_url instead
-
#post_url(statement_url, json_size = nil, options = {}) ⇒ Excon::Response
POST an encrypted statement URL to to the proxy-able /statement/:id endpoint.
-
#render_html(statement) ⇒ String
Render a statement into an HTML invoice.
- #store(statement) ⇒ Excon::Response deprecated Deprecated.
Constructor Details
#initialize(url = nil) ⇒ Client
Instantiate a client.
13 14 15 |
# File 'lib/vault-invoice-builder-client/client.rb', line 13 def initialize(url = nil) @url = url || ENV['VAULT_INVOICE_BUILDER_URL'] end |
Instance Attribute Details
#url ⇒ Object (readonly)
The Vault::InvoiceBuilder HTTP API URL.
5 6 7 |
# File 'lib/vault-invoice-builder-client/client.rb', line 5 def url @url end |
Instance Method Details
#post(statement) ⇒ Excon::Response
Deprecated.
Please use #post_url instead
POST a statement to to the proxy-able /statement/:id endpoint
62 63 64 65 66 67 68 69 70 |
# File 'lib/vault-invoice-builder-client/client.rb', line 62 def post(statement) connection = Excon.new(@url) id = statement[:id] || statement['id'] response = connection.post( path: "/statement/#{id}", headers: {'Content-Type' => 'application/json'}, body: JSON.generate(statement), expects: [200]) end |
#post_url(statement_url, json_size = nil, options = {}) ⇒ Excon::Response
POST an encrypted statement URL to to the proxy-able /statement/:id endpoint
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/vault-invoice-builder-client/client.rb', line 43 def post_url(statement_url, json_size=nil, ={}) connection = Excon.new(@url) params = { url: statement_url, json_size: json_size }.merge() connection.post( path: "/statements", headers: {'Content-Type' => 'application/json'}, body: JSON.generate(params), expects: [202] ) end |
#render_html(statement) ⇒ String
Render a statement into an HTML invoice.
24 25 26 27 28 29 30 31 32 |
# File 'lib/vault-invoice-builder-client/client.rb', line 24 def render_html(statement) connection = Excon.new(@url) response = connection.post( path: "/invoice.html", headers: {'Content-Type' => 'application/json'}, body: JSON.generate(statement), expects: [200]) response.body end |
#store(statement) ⇒ Excon::Response
Deprecated.
Returns The response object.
79 80 81 82 83 84 85 86 |
# File 'lib/vault-invoice-builder-client/client.rb', line 79 def store(statement) connection = Excon.new(@url) response = connection.post( path: '/store', headers: {'Content-Type' => 'application/json'}, body: JSON.generate(statement), expects: [200]) end |