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::Invoice::Types::InvoiceResponseWithoutData
Creates an invoice in an entrypoint.
-
#delete_attached_from_invoice(request_options: {}, **params) ⇒ Payabli::Invoice::Types::InvoiceResponseWithoutData
Deletes an invoice that’s attached to a file.
-
#delete_invoice(request_options: {}, **params) ⇒ Payabli::Invoice::Types::InvoiceResponseWithoutData
Deletes a single invoice from an entrypoint.
-
#edit_invoice(request_options: {}, **params) ⇒ Payabli::Invoice::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::Invoice::Types::GetInvoiceRecord
Retrieves a single invoice by ID.
-
#get_invoice_number(request_options: {}, **params) ⇒ Payabli::Invoice::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::Invoice::Types::QueryInvoiceResponse
Returns a list of invoices for an entrypoint.
-
#list_invoices_org(request_options: {}, **params) ⇒ Payabli::Invoice::Types::QueryInvoiceResponse
Returns a list of invoices for an org.
-
#send_invoice(request_options: {}, **params) ⇒ Payabli::Invoice::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::Invoice::Types::InvoiceResponseWithoutData
Creates an invoice in an entrypoint.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/payabli/invoice/client.rb', line 27 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] 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::Invoice::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::Invoice::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::Invoice::Types::InvoiceResponseWithoutData
Deletes an invoice that’s attached to a file.
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 76 def delete_attached_from_invoice(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) 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)}", 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::Invoice::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::Invoice::Types::InvoiceResponseWithoutData
Deletes a single invoice from an entrypoint.
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/payabli/invoice/client.rb', line 110 def delete_invoice(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "DELETE", path: "Invoice/#{URI.encode_uri_component(params[:id_invoice].to_s)}", 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::Invoice::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::Invoice::Types::InvoiceResponseWithoutData
Updates details for a single invoice in an entrypoint.
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/payabli/invoice/client.rb', line 145 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) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "PUT", path: "Invoice/#{URI.encode_uri_component(params[:id_invoice].to_s)}", query: query_params, body: Payabli::Invoice::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::Invoice::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.
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/payabli/invoice/client.rb', line 191 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) 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)}", 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::Invoice::Types::GetInvoiceRecord
Retrieves a single invoice by ID.
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
# File 'lib/payabli/invoice/client.rb', line 229 def get_invoice(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "Invoice/#{URI.encode_uri_component(params[:id_invoice].to_s)}", 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::Invoice::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::Invoice::Types::InvoiceNumberResponse
Retrieves the next available invoice number for a paypoint.
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
# File 'lib/payabli/invoice/client.rb', line 263 def get_invoice_number(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "Invoice/getNumber/#{URI.encode_uri_component(params[:entry].to_s)}", 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::Invoice::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.
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 |
# File 'lib/payabli/invoice/client.rb', line 434 def get_invoice_pdf(request_options: {}, **params) params = Payabli::Internal::Types::Utils.normalize_keys(params) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "Export/invoicePdf/#{URI.encode_uri_component(params[:id_invoice].to_s)}", 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::Invoice::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.
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
# File 'lib/payabli/invoice/client.rb', line 303 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) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "Query/invoices/#{URI.encode_uri_component(params[:entry].to_s)}", 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::Invoice::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::Invoice::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.
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 |
# File 'lib/payabli/invoice/client.rb', line 351 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) 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)}", 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::Invoice::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::Invoice::Types::SendInvoiceResponse
Sends an invoice from an entrypoint via email.
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 |
# File 'lib/payabli/invoice/client.rb', line 395 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) request = Payabli::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "Invoice/send/#{URI.encode_uri_component(params[:id_invoice].to_s)}", 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::Invoice::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 |