Class: Payabli::Invoice::Client
- Inherits:
-
Object
- Object
- Payabli::Invoice::Client
- Defined in:
- lib/payabli/invoice/client.rb
Instance Method Summary collapse
-
#add_invoice(request_options: {}, **params) ⇒ Payabli::Types::InvoiceResponseWithoutData
Creates an invoice in an entrypoint.
-
#delete_attached_from_invoice(request_options: {}, **params) ⇒ Payabli::Types::InvoiceResponseWithoutData
Deletes a file attached to an invoice.
-
#delete_invoice(request_options: {}, **params) ⇒ Payabli::Types::InvoiceResponseWithoutData
Deletes a single invoice from an entrypoint.
-
#edit_invoice(request_options: {}, **params) ⇒ Payabli::Types::InvoiceResponseWithoutData
Updates details for a single invoice in an entrypoint.
-
#get_attached_file_from_invoice(request_options: {}, **params) ⇒ Payabli::Types::FileContent
Retrieves a file attached to an invoice.
-
#get_invoice(request_options: {}, **params) ⇒ Payabli::Types::GetInvoiceRecord
Retrieves a single invoice by ID.
-
#get_invoice_number(request_options: {}, **params) ⇒ Payabli::Types::InvoiceNumberResponse
Retrieves the next available invoice number for a paypoint.
-
#get_invoice_pdf(request_options: {}, **params) ⇒ Hash[String, Object]
Export a single invoice in PDF format.
- #initialize(client:) ⇒ void constructor
-
#list_invoices(request_options: {}, **params) ⇒ Payabli::Types::QueryInvoiceResponse
Returns a list of invoices for an entrypoint.
-
#list_invoices_org(request_options: {}, **params) ⇒ Payabli::Types::QueryInvoiceResponse
Returns a list of invoices for an org.
-
#send_invoice(request_options: {}, **params) ⇒ Payabli::Types::SendInvoiceResponse
Sends an invoice from an entrypoint via email.
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/payabli/invoice/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#add_invoice(request_options: {}, **params) ⇒ Payabli::Types::InvoiceResponseWithoutData
Creates an invoice in an entrypoint.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/payabli/invoice/client.rb', line 61 def add_invoice(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) path_param_names = %i[entry] body_params = params.except(*path_param_names) query_param_names = %i[force_customer_creation] query_params = {} query_params["forceCustomerCreation"] = params[:force_customer_creation] if params.key?(:force_customer_creation) params = params.except(*query_param_names) headers = {} headers["idempotencyKey"] = params[:idempotency_key] if params[:idempotency_key] headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]).merge(headers) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "Invoice/#{URI.encode_uri_component(params[:entry].to_s)}", headers: headers, query: query_params, body: Payabli::Types::InvoiceDataRequest.new(body_params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::InvoiceResponseWithoutData.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#delete_attached_from_invoice(request_options: {}, **params) ⇒ Payabli::Types::InvoiceResponseWithoutData
Deletes a file attached to an invoice.
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/payabli/invoice/client.rb', line 165 def delete_attached_from_invoice(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "DELETE", path: "Invoice/attachedFileFromInvoice/#{URI.encode_uri_component(params[:id_invoice].to_s)}/#{URI.encode_uri_component(params[:filename].to_s)}", headers: headers, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::InvoiceResponseWithoutData.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#delete_invoice(request_options: {}, **params) ⇒ Payabli::Types::InvoiceResponseWithoutData
Deletes a single invoice from an entrypoint.
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
# File 'lib/payabli/invoice/client.rb', line 306 def delete_invoice(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "DELETE", path: "Invoice/#{URI.encode_uri_component(params[:id_invoice].to_s)}", headers: headers, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::InvoiceResponseWithoutData.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#edit_invoice(request_options: {}, **params) ⇒ Payabli::Types::InvoiceResponseWithoutData
Updates details for a single invoice in an entrypoint.
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
# File 'lib/payabli/invoice/client.rb', line 257 def edit_invoice(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) path_param_names = %i[id_invoice] body_params = params.except(*path_param_names) query_param_names = %i[force_customer_creation] query_params = {} query_params["forceCustomerCreation"] = params[:force_customer_creation] if params.key?(:force_customer_creation) params = params.except(*query_param_names) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "PUT", path: "Invoice/#{URI.encode_uri_component(params[:id_invoice].to_s)}", headers: headers, query: query_params, body: Payabli::Types::InvoiceDataRequest.new(body_params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::InvoiceResponseWithoutData.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_attached_file_from_invoice(request_options: {}, **params) ⇒ Payabli::Types::FileContent
Retrieves a file attached to an invoice.
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/payabli/invoice/client.rb', line 118 def get_attached_file_from_invoice(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["returnObject"] = params[:return_object] if params.key?(:return_object) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "Invoice/attachedFileFromInvoice/#{URI.encode_uri_component(params[:id_invoice].to_s)}/#{URI.encode_uri_component(params[:filename].to_s)}", headers: headers, query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::FileContent.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_invoice(request_options: {}, **params) ⇒ Payabli::Types::GetInvoiceRecord
Retrieves a single invoice by ID.
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/payabli/invoice/client.rb', line 204 def get_invoice(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "Invoice/#{URI.encode_uri_component(params[:id_invoice].to_s)}", headers: headers, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::GetInvoiceRecord.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_invoice_number(request_options: {}, **params) ⇒ Payabli::Types::InvoiceNumberResponse
Retrieves the next available invoice number for a paypoint.
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 |
# File 'lib/payabli/invoice/client.rb', line 345 def get_invoice_number(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "Invoice/getNumber/#{URI.encode_uri_component(params[:entry].to_s)}", headers: headers, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::InvoiceNumberResponse.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_invoice_pdf(request_options: {}, **params) ⇒ Hash[String, Object]
Export a single invoice in PDF format.
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 |
# File 'lib/payabli/invoice/client.rb', line 550 def get_invoice_pdf(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "Export/invoicePdf/#{URI.encode_uri_component(params[:id_invoice].to_s)}", headers: headers, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::File.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#list_invoices(request_options: {}, **params) ⇒ Payabli::Types::QueryInvoiceResponse
Returns a list of invoices for an entrypoint. Use filters to limit results. Include the exportFormat query
parameter to return the results as a file instead of a JSON response.
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 |
# File 'lib/payabli/invoice/client.rb', line 395 def list_invoices(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["exportFormat"] = params[:export_format] if params.key?(:export_format) query_params["fromRecord"] = params[:from_record] if params.key?(:from_record) query_params["limitRecord"] = params[:limit_record] if params.key?(:limit_record) query_params["parameters"] = params[:parameters] if params.key?(:parameters) query_params["sortBy"] = params[:sort_by] if params.key?(:sort_by) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "Query/invoices/#{URI.encode_uri_component(params[:entry].to_s)}", headers: headers, query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::QueryInvoiceResponse.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#list_invoices_org(request_options: {}, **params) ⇒ Payabli::Types::QueryInvoiceResponse
Returns a list of invoices for an org. Use filters to limit results. Include the exportFormat query parameter
to return the results as a file instead of a JSON response.
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 |
# File 'lib/payabli/invoice/client.rb', line 453 def list_invoices_org(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["exportFormat"] = params[:export_format] if params.key?(:export_format) query_params["fromRecord"] = params[:from_record] if params.key?(:from_record) query_params["limitRecord"] = params[:limit_record] if params.key?(:limit_record) query_params["parameters"] = params[:parameters] if params.key?(:parameters) query_params["sortBy"] = params[:sort_by] if params.key?(:sort_by) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "Query/invoices/org/#{URI.encode_uri_component(params[:org_id].to_s)}", headers: headers, query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::QueryInvoiceResponse.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#send_invoice(request_options: {}, **params) ⇒ Payabli::Types::SendInvoiceResponse
Sends an invoice from an entrypoint via email.
506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 |
# File 'lib/payabli/invoice/client.rb', line 506 def send_invoice(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["attachfile"] = params[:attachfile] if params.key?(:attachfile) query_params["mail2"] = params[:mail_2] if params.key?(:mail_2) headers = @client.auth_headers_for_endpoint(security: [{ "BearerAuth" => [] }, { "APIKeyAuth" => [] }]) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "Invoice/send/#{URI.encode_uri_component(params[:id_invoice].to_s)}", headers: headers, query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Payabli::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Payabli::Types::SendInvoiceResponse.load(response.body) else error_class = Payabli::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |