Class: Cryptopay::Invoices
- Inherits:
-
Object
- Object
- Cryptopay::Invoices
- Defined in:
- lib/cryptopay/api/invoices.rb
Instance Method Summary collapse
-
#commit_recalculation(invoice_id, recalculation_id, _opts = {}) ⇒ InvoiceRecalculationResult
Commit invoice recalculation This endpoint allows you to commit invoice recalculation.
-
#create(invoice_params, _opts = {}) ⇒ InvoiceResult
Create an invoice This endpoint allows you to create invoices.
-
#create_recalculation(invoice_id, invoice_recalculation_params, _opts = {}) ⇒ InvoiceRecalculationResult
Create invoice recalculation This endpoint allows you to recalculate invoices.
-
#create_refund(invoice_id, invoice_refund_params, _opts = {}) ⇒ InvoiceRefundResult
Create invoice refund This endpoint allows you to create invoice refunds.
-
#initialize(connection) ⇒ Invoices
constructor
A new instance of Invoices.
-
#list(opts = {}) ⇒ InvoiceListResult
List invoices This endpoint allows you to retrieve a list of all invoices.
-
#list_refunds(invoice_id, _opts = {}) ⇒ InvoiceRefundListResult
List invoice refunds This endpoint allows you to retrieve a list of a particular invoice refunds.
-
#retrieve(invoice_id, _opts = {}) ⇒ InvoiceResult
Retrieve an invoice This endpoint allows you to retrieve the invoice details.
-
#retrieve_by_custom_id(custom_id, _opts = {}) ⇒ InvoiceResult
Retrieve an invoice by custom_id This endpoint allows you to retrieve invoice details by its custom_id.
Constructor Details
#initialize(connection) ⇒ Invoices
Returns a new instance of Invoices.
8 9 10 |
# File 'lib/cryptopay/api/invoices.rb', line 8 def initialize(connection) @connection = connection end |
Instance Method Details
#commit_recalculation(invoice_id, recalculation_id, _opts = {}) ⇒ InvoiceRecalculationResult
Commit invoice recalculation This endpoint allows you to commit invoice recalculation.
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cryptopay/api/invoices.rb', line 18 def commit_recalculation(invoice_id, recalculation_id, _opts = {}) path = '/api/invoices/{invoice_id}/recalculations/{recalculation_id}/commit' path = path.sub('{invoice_id}', CGI.escape(invoice_id.to_s)) path = path.sub('{recalculation_id}', CGI.escape(recalculation_id.to_s)) req = Request.new( method: :post, path: path ) connection.call(req, return_type: InvoiceRecalculationResult) end |
#create(invoice_params, _opts = {}) ⇒ InvoiceResult
Create an invoice This endpoint allows you to create invoices.
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/cryptopay/api/invoices.rb', line 36 def create(invoice_params, _opts = {}) path = '/api/invoices' req = Request.new( method: :post, path: path, body_params: invoice_params ) connection.call(req, return_type: InvoiceResult) end |
#create_recalculation(invoice_id, invoice_recalculation_params, _opts = {}) ⇒ InvoiceRecalculationResult
Create invoice recalculation This endpoint allows you to recalculate invoices.
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/cryptopay/api/invoices.rb', line 54 def create_recalculation(invoice_id, invoice_recalculation_params, _opts = {}) path = '/api/invoices/{invoice_id}/recalculations' path = path.sub('{invoice_id}', CGI.escape(invoice_id.to_s)) req = Request.new( method: :post, path: path, body_params: invoice_recalculation_params ) connection.call(req, return_type: InvoiceRecalculationResult) end |
#create_refund(invoice_id, invoice_refund_params, _opts = {}) ⇒ InvoiceRefundResult
Create invoice refund This endpoint allows you to create invoice refunds.
73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/cryptopay/api/invoices.rb', line 73 def create_refund(invoice_id, invoice_refund_params, _opts = {}) path = '/api/invoices/{invoice_id}/refunds' path = path.sub('{invoice_id}', CGI.escape(invoice_id.to_s)) req = Request.new( method: :post, path: path, body_params: invoice_refund_params ) connection.call(req, return_type: InvoiceRefundResult) end |
#list(opts = {}) ⇒ InvoiceListResult
List invoices This endpoint allows you to retrieve a list of all invoices.
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/cryptopay/api/invoices.rb', line 93 def list(opts = {}) path = '/api/invoices' query_params = {} query_params[:customer_id] = opts[:customer_id] unless opts[:customer_id].nil? query_params[:starting_after] = opts[:starting_after] unless opts[:starting_after].nil? query_params[:subscription_id] = opts[:subscription_id] unless opts[:subscription_id].nil? req = Request.new( method: :get, path: path, query_params: query_params ) connection.call(req, return_type: InvoiceListResult) end |
#list_refunds(invoice_id, _opts = {}) ⇒ InvoiceRefundListResult
List invoice refunds This endpoint allows you to retrieve a list of a particular invoice refunds.
115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/cryptopay/api/invoices.rb', line 115 def list_refunds(invoice_id, _opts = {}) path = '/api/invoices/{invoice_id}/refunds' path = path.sub('{invoice_id}', CGI.escape(invoice_id.to_s)) req = Request.new( method: :get, path: path ) connection.call(req, return_type: InvoiceRefundListResult) end |
#retrieve(invoice_id, _opts = {}) ⇒ InvoiceResult
Retrieve an invoice This endpoint allows you to retrieve the invoice details.
132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/cryptopay/api/invoices.rb', line 132 def retrieve(invoice_id, _opts = {}) path = '/api/invoices/{invoice_id}' path = path.sub('{invoice_id}', CGI.escape(invoice_id.to_s)) req = Request.new( method: :get, path: path ) connection.call(req, return_type: InvoiceResult) end |
#retrieve_by_custom_id(custom_id, _opts = {}) ⇒ InvoiceResult
Retrieve an invoice by custom_id This endpoint allows you to retrieve invoice details by its custom_id.
149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/cryptopay/api/invoices.rb', line 149 def retrieve_by_custom_id(custom_id, _opts = {}) path = '/api/invoices/custom_id/{custom_id}' path = path.sub('{custom_id}', CGI.escape(custom_id.to_s)) req = Request.new( method: :get, path: path ) connection.call(req, return_type: InvoiceResult) end |