Module: ComplyanceSDK
- Defined in:
- lib/complyance_sdk.rb,
lib/complyance_sdk/railtie.rb,
lib/complyance_sdk/version.rb,
lib/complyance_sdk/erp/client.rb,
lib/complyance_sdk/http/client.rb,
lib/complyance_sdk/models/mode.rb,
lib/complyance_sdk/jobs/base_job.rb,
lib/complyance_sdk/models/source.rb,
lib/complyance_sdk/models/country.rb,
lib/complyance_sdk/models/purpose.rb,
lib/complyance_sdk/jobs/sidekiq_job.rb,
lib/complyance_sdk/models/operation.rb,
lib/complyance_sdk/config/sdk_config.rb,
lib/complyance_sdk/models/source_ref.rb,
lib/complyance_sdk/models/environment.rb,
lib/complyance_sdk/config/retry_config.rb,
lib/complyance_sdk/retry/retry_manager.rb,
lib/complyance_sdk/models/document_type.rb,
lib/complyance_sdk/models/policy_result.rb,
lib/complyance_sdk/models/unify_request.rb,
lib/complyance_sdk/retry/retry_strategy.rb,
lib/complyance_sdk/models/unify_response.rb,
lib/complyance_sdk/retry/circuit_breaker.rb,
lib/complyance_sdk/http/logging_middleware.rb,
lib/complyance_sdk/models/logical_doc_type.rb,
lib/complyance_sdk/exceptions/sdk_exception.rb,
lib/complyance_sdk/jobs/process_document_job.rb,
lib/complyance_sdk/middleware/rack_middleware.rb,
lib/complyance_sdk/generators/config_generator.rb,
lib/complyance_sdk/generators/install_generator.rb,
lib/complyance_sdk/models/gets_document_type_v2.rb,
lib/complyance_sdk/http/authentication_middleware.rb,
lib/complyance_sdk/models/country_policy_registry.rb,
lib/complyance_sdk/models/logical_doc_type_mapper.rb,
lib/complyance_sdk/queue/persistent_queue_manager.rb,
lib/complyance_sdk/exceptions/circuit_breaker_open_error.rb
Overview
Main module for the Complyance SDK
Defined Under Namespace
Modules: Config, ERP, Exceptions, Generators, HTTP, Jobs, Middleware, Models, Queue, Retry Classes: Railtie
Constant Summary collapse
- VERSION =
"3.0.4"
Class Attribute Summary collapse
-
.configuration ⇒ Object
Returns the value of attribute configuration.
Class Method Summary collapse
-
.cleanup_duplicate_files ⇒ Object
Clean up duplicate files across queue directories.
-
.cleanup_old_success_files(days_to_keep) ⇒ Object
Clean up old success files.
-
.clear_all_queues ⇒ Object
Clear all files from the queue (emergency cleanup).
-
.configure(config = nil) {|config| ... } ⇒ ComplyanceSDK::Config::SDKConfig
Configure the SDK with the provided configuration.
-
.configure_from_env ⇒ ComplyanceSDK::Config::SDKConfig
Configure the SDK from environment variables.
-
.configure_from_rails(environment = nil) ⇒ ComplyanceSDK::Config::SDKConfig
Configure the SDK from Rails credentials.
-
.configured? ⇒ Boolean
Check if the SDK is configured.
-
.create_mapping(options = {}) ⇒ ComplyanceSDK::Models::UnifyResponse
Convenience method for creating field mappings.
-
.create_mapping_logical(source_name, source_version, country, logical_type, payload) ⇒ ComplyanceSDK::Models::UnifyResponse
Convenience method to create mappings with logical document types.
-
.detailed_queue_status ⇒ Hash
Get detailed queue status.
- .drain_queue(timeout_seconds = 30) ⇒ Object
- .get_purchase_invoice(id) ⇒ Object
-
.get_status(submission_id) ⇒ ComplyanceSDK::Models::UnifyResponse
Get the status of a submission.
- .list_purchase_invoices(filters = {}) ⇒ Object
- .pause_queue_processing ⇒ Object
-
.process_pending_submissions ⇒ Object
Process pending submissions now.
-
.process_queued_submissions_first ⇒ Object
Process queued submissions before handling new requests.
-
.push_to_unify(source_name, source_version, logical_doc_type, country, operation, mode, purpose, payload, destinations = nil) ⇒ ComplyanceSDK::Models::UnifyResponse
Main API method for document processing (Java-style signature).
-
.push_to_unify_async(request, options = {}) ⇒ String, Object
Process a document asynchronously using background jobs.
-
.push_to_unify_from_json(source_name, source_version, logical_doc_type, country, operation, mode, purpose, json_payload, destinations = nil) ⇒ ComplyanceSDK::Models::UnifyResponse
Push to Unify API with logical document types using JSON string payload.
-
.push_to_unify_from_object(source_name, source_version, logical_doc_type, country, operation, mode, purpose, payload_object, destinations = nil) ⇒ ComplyanceSDK::Models::UnifyResponse
Push to Unify API with logical document types using object payload.
-
.push_to_unify_logical(source_name, source_version, logical_type, country, operation, mode, purpose, payload, destinations = nil) ⇒ ComplyanceSDK::Models::UnifyResponse
Push to Unify API with logical document types but full control over operation, mode, and purpose This is the primary method for all workflows with logical document types.
-
.push_to_unify_request(request) ⇒ ComplyanceSDK::Models::UnifyResponse
Main API method for document processing (UnifyRequest object).
-
.push_to_unify_v2(source_name, source_version, document_type_v2, country, operation, mode, purpose, payload, destinations = nil) ⇒ ComplyanceSDK::Models::UnifyResponse
Push to Unify API with GETS V2 document type.
- .push_to_unify_with_document_type(source_name, source_version, document_type, country, operation, mode, purpose, payload, destinations = nil) ⇒ Object
-
.push_to_unify_with_source_ref(source_ref, logical_type, country, operation, mode, purpose, payload, destinations = nil) ⇒ ComplyanceSDK::Models::UnifyResponse
Push to Unify API with logical document types using SourceRef.
-
.queue_status ⇒ Hash
Get queue status and statistics.
- .queue_status_detailed ⇒ Object
- .resume_queue_processing ⇒ Object
- .retry_failed(queue_item_id) ⇒ Object
-
.retry_failed_submissions ⇒ Object
Retry failed submissions.
-
.retry_manager(redis_config = {}) ⇒ ComplyanceSDK::Retry::RetryManager
Get the retry manager instance.
-
.submit_invoice(options = {}) ⇒ ComplyanceSDK::Models::UnifyResponse
Convenience method for submitting invoices.
-
.submit_invoice_logical(source_name, source_version, country, logical_type, payload) ⇒ ComplyanceSDK::Models::UnifyResponse
Convenience method to submit invoices with logical document types.
- .verify_webhook_signature(payload, signature, secret, algorithm = "sha256") ⇒ Object
-
.with_retry(operation_name, context = {}) { ... } ⇒ Object
Execute an operation with retry logic.
Class Attribute Details
.configuration ⇒ Object
Returns the value of attribute configuration.
35 36 37 |
# File 'lib/complyance_sdk.rb', line 35 def configuration @configuration end |
Class Method Details
.cleanup_duplicate_files ⇒ Object
Clean up duplicate files across queue directories
619 620 621 622 623 624 625 |
# File 'lib/complyance_sdk.rb', line 619 def cleanup_duplicate_files if queue_manager queue_manager.cleanup_duplicate_files else raise ComplyanceSDK::Exceptions::ConfigurationError.new("Queue Manager is not initialized") end end |
.cleanup_old_success_files(days_to_keep) ⇒ Object
Clean up old success files
605 606 607 |
# File 'lib/complyance_sdk.rb', line 605 def cleanup_old_success_files(days_to_keep) queue_manager&.cleanup_old_success_files(days_to_keep) end |
.clear_all_queues ⇒ Object
Clear all files from the queue (emergency cleanup)
610 611 612 613 614 615 616 |
# File 'lib/complyance_sdk.rb', line 610 def clear_all_queues if queue_manager queue_manager.clear_all_queues else raise ComplyanceSDK::Exceptions::ConfigurationError.new("Queue Manager is not initialized") end end |
.configure(config = nil) {|config| ... } ⇒ ComplyanceSDK::Config::SDKConfig
Configure the SDK with the provided configuration
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/complyance_sdk.rb', line 42 def configure(config = nil) self.configuration = config if config.is_a?(ComplyanceSDK::Config::SDKConfig) if block_given? self.configuration ||= ComplyanceSDK::Config::SDKConfig.new yield(configuration) end configuration end |
.configure_from_env ⇒ ComplyanceSDK::Config::SDKConfig
Configure the SDK from environment variables
56 57 58 |
# File 'lib/complyance_sdk.rb', line 56 def configure_from_env self.configuration = ComplyanceSDK::Config::SDKConfig.from_env end |
.configure_from_rails(environment = nil) ⇒ ComplyanceSDK::Config::SDKConfig
Configure the SDK from Rails credentials
64 65 66 |
# File 'lib/complyance_sdk.rb', line 64 def configure_from_rails(environment = nil) self.configuration = ComplyanceSDK::Config::SDKConfig.from_rails(environment) end |
.configured? ⇒ Boolean
Check if the SDK is configured
71 72 73 |
# File 'lib/complyance_sdk.rb', line 71 def configured? !configuration.nil? && configuration.valid? end |
.create_mapping(options = {}) ⇒ ComplyanceSDK::Models::UnifyResponse
Convenience method for creating field mappings
308 309 310 311 312 313 314 315 316 317 318 319 320 |
# File 'lib/complyance_sdk.rb', line 308 def create_mapping( = {}) request = ComplyanceSDK::Models::UnifyRequest.new( source: [:source] || default_source, document_type: [:document_type] || :tax_invoice, country: [:country], operation: :single, mode: :documents, purpose: :mapping, payload: [:payload] ) push_to_unify(request) end |
.create_mapping_logical(source_name, source_version, country, logical_type, payload) ⇒ ComplyanceSDK::Models::UnifyResponse
Convenience method to create mappings with logical document types
558 559 560 561 562 563 564 565 566 567 568 569 |
# File 'lib/complyance_sdk.rb', line 558 def create_mapping_logical(source_name, source_version, country, logical_type, payload) push_to_unify_logical( source_name, source_version, logical_type, country, :single, :documents, :mapping, payload ) end |
.detailed_queue_status ⇒ Hash
Get detailed queue status
585 586 587 |
# File 'lib/complyance_sdk.rb', line 585 def detailed_queue_status queue_manager ? queue_manager.queue_status_detailed : { error: "Queue Manager is not initialized" } end |
.drain_queue(timeout_seconds = 30) ⇒ Object
640 641 642 |
# File 'lib/complyance_sdk.rb', line 640 def drain_queue(timeout_seconds = 30) queue_manager ? queue_manager.drain_queue(timeout_seconds) : true end |
.get_purchase_invoice(id) ⇒ Object
655 656 657 658 659 660 661 662 663 664 665 666 |
# File 'lib/complyance_sdk.rb', line 655 def get_purchase_invoice(id) ensure_configured_for_purchase_api! if id.nil? || id.to_s.strip.empty? raise ComplyanceSDK::Exceptions::ValidationError.new( "Purchase invoice id is required", context: { suggestion: "Provide a valid purchase invoice id." } ) end http_client.get("/documents/#{URI.encode_www_form_component(id.to_s)}", { type: "purchases" }) end |
.get_status(submission_id) ⇒ ComplyanceSDK::Models::UnifyResponse
Get the status of a submission
326 327 328 329 330 331 332 333 334 335 336 337 338 |
# File 'lib/complyance_sdk.rb', line 326 def get_status(submission_id) unless configured? raise ComplyanceSDK::Exceptions::ConfigurationError.new( "SDK must be configured before making API calls" ) end response_data = with_retry("get_status", { submission_id: submission_id }) do http_client.get("/api/v1/submissions/#{submission_id}") end ComplyanceSDK::Models::UnifyResponse.from_h(response_data) end |
.list_purchase_invoices(filters = {}) ⇒ Object
649 650 651 652 653 |
# File 'lib/complyance_sdk.rb', line 649 def list_purchase_invoices(filters = {}) ensure_configured_for_purchase_api! query = { type: "purchases" }.merge(filters.reject { |_key, value| value.nil? }) http_client.get("/documents", query) end |
.pause_queue_processing ⇒ Object
632 633 634 |
# File 'lib/complyance_sdk.rb', line 632 def pause_queue_processing queue_manager&.pause_processing end |
.process_pending_submissions ⇒ Object
Process pending submissions now
628 629 630 |
# File 'lib/complyance_sdk.rb', line 628 def process_pending_submissions queue_manager&.process_pending_submissions_now end |
.process_queued_submissions_first ⇒ Object
Process queued submissions before handling new requests
645 646 647 |
# File 'lib/complyance_sdk.rb', line 645 def process_queued_submissions_first queue_manager&.process_pending_submissions_now end |
.push_to_unify(source_name, source_version, logical_doc_type, country, operation, mode, purpose, payload, destinations = nil) ⇒ ComplyanceSDK::Models::UnifyResponse
Main API method for document processing (Java-style signature)
111 112 113 |
# File 'lib/complyance_sdk.rb', line 111 def push_to_unify(source_name, source_version, logical_doc_type, country, operation, mode, purpose, payload, destinations = nil) push_to_unify_logical(source_name, source_version, logical_doc_type, country, operation, mode, purpose, payload, destinations) end |
.push_to_unify_async(request, options = {}) ⇒ String, Object
Process a document asynchronously using background jobs
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
# File 'lib/complyance_sdk.rb', line 348 def push_to_unify_async(request, = {}) unless configured? raise ComplyanceSDK::Exceptions::ConfigurationError.new( "SDK must be configured before making API calls" ) end # Convert hash to UnifyRequest if needed if request.is_a?(Hash) request = ComplyanceSDK::Models::UnifyRequest.from_h(request) end # Validate the request unless request.valid? raise ComplyanceSDK::Exceptions::ValidationError.new( "Invalid request: #{request.errors.join(', ')}", context: { errors: request.errors } ) end retry_manager.execute_async( request.to_h, job_type: [:job_type] || :active_job, callback_url: [:callback_url], callback_headers: [:callback_headers] || {} ) end |
.push_to_unify_from_json(source_name, source_version, logical_doc_type, country, operation, mode, purpose, json_payload, destinations = nil) ⇒ ComplyanceSDK::Models::UnifyResponse
Push to Unify API with logical document types using JSON string payload
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 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 |
# File 'lib/complyance_sdk.rb', line 127 def push_to_unify_from_json(source_name, source_version, logical_doc_type, country, operation, mode, purpose, json_payload, destinations = nil) if json_payload.nil? || json_payload.to_s.strip.empty? raise ComplyanceSDK::Exceptions::ValidationError.new( "Payload is required but was null or empty", context: { suggestion: 'Provide a non-empty JSON payload string. Example: \'{"invoiceNumber":"INV-123","amount":1000}\'' } ) end begin require 'json' payload_hash = JSON.parse(json_payload) unless payload_hash.is_a?(Hash) raise ComplyanceSDK::Exceptions::ValidationError.new( "Failed to parse JSON payload: parsed result is not a hash", context: { suggestion: 'Ensure the payload is valid JSON and represents an object structure. Example: \'{"invoiceNumber":"INV-123"}\'' } ) end push_to_unify(source_name, source_version, logical_doc_type, country, operation, mode, purpose, payload_hash, destinations) rescue JSON::ParserError => parse_error payload_snippet = json_payload.length > 100 ? json_payload[0..99] + '...' : json_payload raise ComplyanceSDK::Exceptions::ValidationError.new( "Failed to parse JSON payload: #{parse_error.}", context: { suggestion: 'Ensure the payload is valid JSON. Example: \'{"invoiceNumber":"INV-123","amount":1000}\'', payload_snippet: payload_snippet, parse_error: parse_error. } ) rescue ComplyanceSDK::Exceptions::ValidationError raise rescue StandardError => conversion_error raise ComplyanceSDK::Exceptions::ValidationError.new( "Failed to parse JSON payload: #{conversion_error.}", context: { suggestion: 'Ensure the payload is valid JSON. Example: \'{"invoiceNumber":"INV-123","amount":1000}\'', conversion_error: conversion_error. } ) end end |
.push_to_unify_from_object(source_name, source_version, logical_doc_type, country, operation, mode, purpose, payload_object, destinations = nil) ⇒ ComplyanceSDK::Models::UnifyResponse
Push to Unify API with logical document types using object payload
186 187 188 189 190 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 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
# File 'lib/complyance_sdk.rb', line 186 def push_to_unify_from_object(source_name, source_version, logical_doc_type, country, operation, mode, purpose, payload_object, destinations = nil) if payload_object.nil? raise ComplyanceSDK::Exceptions::ValidationError.new( "Payload object is required but was nil", context: { suggestion: "Provide a valid payload object. Example: {invoice_number: 'INV-123', amount: 1000}" } ) end begin # Convert object to hash payload_hash = if payload_object.is_a?(Hash) payload_object elsif payload_object.respond_to?(:to_h) payload_object.to_h elsif payload_object.respond_to?(:instance_variables) # Convert object instance variables to hash hash = {} payload_object.instance_variables.each do |var| key = var.to_s.delete('@') hash[key] = payload_object.instance_variable_get(var) end hash else # Try JSON serialization for other objects require 'json' json_str = payload_object.to_json JSON.parse(json_str) end unless payload_hash.is_a?(Hash) raise ComplyanceSDK::Exceptions::ValidationError.new( "Failed to convert payload object to hash: conversion returned invalid result", context: { suggestion: "Ensure the object structure is compatible with the SDK payload format. " + "The object should be convertible to a hash structure." } ) end push_to_unify(source_name, source_version, logical_doc_type, country, operation, mode, purpose, payload_hash, destinations) rescue ComplyanceSDK::Exceptions::ValidationError raise rescue StandardError => conversion_error raise ComplyanceSDK::Exceptions::ValidationError.new( "Failed to convert payload object to hash: #{conversion_error.}", context: { suggestion: "Ensure the object structure is compatible with the SDK payload format. " + "The object should be convertible to a hash. " + "Example: {invoice_number: 'INV-123', amount: 1000} or a class with public attributes.", object_type: payload_object.class.name, conversion_error: conversion_error. } ) end end |
.push_to_unify_logical(source_name, source_version, logical_type, country, operation, mode, purpose, payload, destinations = nil) ⇒ ComplyanceSDK::Models::UnifyResponse
Push to Unify API with logical document types but full control over operation, mode, and purpose This is the primary method for all workflows with logical document types
389 390 391 392 393 394 395 396 |
# File 'lib/complyance_sdk.rb', line 389 def push_to_unify_logical(source_name, source_version, logical_type, country, operation, mode, purpose, payload, destinations = nil) validate_required_parameter(logical_type, :logical_type, "Logical document type is required") policy = ComplyanceSDK::Models::CountryPolicyRegistry.evaluate(country, logical_type) merged_payload = (payload, policy.) set_invoice_data_document_type(merged_payload, logical_type) document_type_v2 = ComplyanceSDK::Models::LogicalDocTypeMapper.to_gets_document_type_v2(logical_type) push_to_unify_v2(source_name, source_version, document_type_v2, country, operation, mode, purpose, merged_payload, destinations) end |
.push_to_unify_request(request) ⇒ ComplyanceSDK::Models::UnifyResponse
Main API method for document processing (UnifyRequest object)
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/complyance_sdk.rb', line 248 def push_to_unify_request(request) unless configured? raise ComplyanceSDK::Exceptions::ConfigurationError.new( "SDK must be configured before making API calls" ) end # Convert hash to UnifyRequest if needed if request.is_a?(Hash) request = ComplyanceSDK::Models::UnifyRequest.from_h(request) end # Validate the request unless request.valid? raise ComplyanceSDK::Exceptions::ValidationError.new( "Invalid request: #{request.errors.join(', ')}", context: { errors: request.errors } ) end # Make the API call with retry logic response_data = with_retry("push_to_unify", { request_id: request.[:request_id] }) do http_client.post("", request.to_h) end # Convert response to UnifyResponse object ComplyanceSDK::Models::UnifyResponse.from_h(response_data) end |
.push_to_unify_v2(source_name, source_version, document_type_v2, country, operation, mode, purpose, payload, destinations = nil) ⇒ ComplyanceSDK::Models::UnifyResponse
Push to Unify API with GETS V2 document type
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 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 484 485 486 487 488 |
# File 'lib/complyance_sdk.rb', line 410 def push_to_unify_v2(source_name, source_version, document_type_v2, country, operation, mode, purpose, payload, destinations = nil) unless configured? raise ComplyanceSDK::Exceptions::ConfigurationError.new( "SDK must be configured before making API calls" ) end # Process queued submissions first before handling new requests process_queued_submissions_first # Validate required parameters # Handle source_name and source_version based on purpose final_source_name = if purpose == :mapping # For MAPPING purpose, source_name and source_version are optional source_name || "" else # For all other purposes, source_name is mandatory if source_name.nil? || source_name.to_s.strip.empty? raise ComplyanceSDK::Exceptions::ValidationError.new( "Source name is required", context: { field: :source_name } ) end source_name end final_source_version = if purpose == :mapping # For MAPPING purpose, source_version is optional source_version || "" else # For all other purposes, source_version is mandatory if source_version.nil? || source_version.to_s.strip.empty? raise ComplyanceSDK::Exceptions::ValidationError.new( "Source version is required", context: { field: :source_version } ) end source_version end # Validate other required parameters validate_required_parameter(document_type_v2, :document_type_v2, "GETS V2 documentType is required") validate_required_parameter(country, :country, "Country is required") validate_required_parameter(operation, :operation, "Operation is required") validate_required_parameter(mode, :mode, "Mode is required") validate_required_parameter(purpose, :purpose, "Purpose is required") validate_required_parameter(payload, :payload, "Payload is required") normalized_document_type_v2 = normalize_and_validate_document_type_v2(document_type_v2) # Validate country restrictions for current environment validate_country_for_environment(country, configuration.environment) request_payload = payload.dup set_payload_document_type_v2(request_payload, normalized_document_type_v2) set_invoice_data_document_type_from_v2(request_payload, normalized_document_type_v2.base) # Create source reference with type from configuration source_type = find_source_type(final_source_name, final_source_version) source_ref = ComplyanceSDK::Models::SourceRef.new(final_source_name, final_source_version, source_type) # Auto-generate destinations if none provided and auto-generation is enabled final_destinations = destinations || (configuration.auto_generate_tax_destination? ? generate_default_destinations(country, normalized_document_type_v2.base) : []) # Build and send request using the resolved base document type push_to_unify_internal_with_document_type( source_ref, resolve_base_document_type_from_v2(normalized_document_type_v2.base), normalized_document_type_v2.base, country, operation, mode, purpose, request_payload, final_destinations, normalized_document_type_v2 ) end |
.push_to_unify_with_document_type(source_name, source_version, document_type, country, operation, mode, purpose, payload, destinations = nil) ⇒ Object
490 491 492 493 494 495 496 497 498 499 500 501 502 |
# File 'lib/complyance_sdk.rb', line 490 def push_to_unify_with_document_type(source_name, source_version, document_type, country, operation, mode, purpose, payload, destinations = nil) push_to_unify_v2( source_name, source_version, document_type, country, operation, mode, purpose, payload, destinations ) end |
.push_to_unify_with_source_ref(source_ref, logical_type, country, operation, mode, purpose, payload, destinations = nil) ⇒ ComplyanceSDK::Models::UnifyResponse
Push to Unify API with logical document types using SourceRef
515 516 517 518 519 520 521 522 523 524 525 526 527 |
# File 'lib/complyance_sdk.rb', line 515 def push_to_unify_with_source_ref(source_ref, logical_type, country, operation, mode, purpose, payload, destinations = nil) push_to_unify_logical( source_ref.name, source_ref.version, logical_type, country, operation, mode, purpose, payload, destinations ) end |
.queue_status ⇒ Hash
Get queue status and statistics
574 575 576 577 578 579 580 |
# File 'lib/complyance_sdk.rb', line 574 def queue_status if queue_manager queue_manager.queue_status else { error: "Queue Manager is not initialized" } end end |
.queue_status_detailed ⇒ Object
589 590 591 |
# File 'lib/complyance_sdk.rb', line 589 def queue_status_detailed detailed_queue_status end |
.resume_queue_processing ⇒ Object
636 637 638 |
# File 'lib/complyance_sdk.rb', line 636 def resume_queue_processing queue_manager&.resume_processing end |
.retry_failed(queue_item_id) ⇒ Object
598 599 600 |
# File 'lib/complyance_sdk.rb', line 598 def retry_failed(queue_item_id) queue_manager&.retry_failed(queue_item_id) || false end |
.retry_failed_submissions ⇒ Object
Retry failed submissions
594 595 596 |
# File 'lib/complyance_sdk.rb', line 594 def retry_failed_submissions queue_manager&.retry_failed_submissions end |
.retry_manager(redis_config = {}) ⇒ ComplyanceSDK::Retry::RetryManager
Get the retry manager instance
79 80 81 |
# File 'lib/complyance_sdk.rb', line 79 def retry_manager(redis_config = {}) @retry_manager ||= ComplyanceSDK::Retry::RetryManager.new(configuration, redis_config) end |
.submit_invoice(options = {}) ⇒ ComplyanceSDK::Models::UnifyResponse
Convenience method for submitting invoices
286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/complyance_sdk.rb', line 286 def submit_invoice( = {}) request = ComplyanceSDK::Models::UnifyRequest.new( source: [:source] || default_source, document_type: [:document_type] || :tax_invoice, country: [:country], operation: :single, mode: :documents, purpose: [:purpose] || :invoicing, payload: [:payload] ) push_to_unify(request) end |
.submit_invoice_logical(source_name, source_version, country, logical_type, payload) ⇒ ComplyanceSDK::Models::UnifyResponse
Convenience method to submit invoices with logical document types
537 538 539 540 541 542 543 544 545 546 547 548 |
# File 'lib/complyance_sdk.rb', line 537 def submit_invoice_logical(source_name, source_version, country, logical_type, payload) push_to_unify_logical( source_name, source_version, logical_type, country, :single, :documents, :invoicing, payload ) end |
.verify_webhook_signature(payload, signature, secret, algorithm = "sha256") ⇒ Object
668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 |
# File 'lib/complyance_sdk.rb', line 668 def verify_webhook_signature(payload, signature, secret, algorithm = "sha256") normalized_algorithm = algorithm.to_s.downcase unless %w[sha256 sha512].include?(normalized_algorithm) raise ComplyanceSDK::Exceptions::ValidationError.new( "Unsupported webhook HMAC algorithm: #{algorithm}", context: { suggestion: "Use sha256 or sha512." } ) end expected_signature = OpenSSL::HMAC.hexdigest(normalized_algorithm, secret.to_s, payload.to_s) unless secure_compare(expected_signature, signature.to_s.strip) raise ComplyanceSDK::Exceptions::ValidationError.new( "Webhook signature verification failed", context: { suggestion: "Ensure you use the raw request body and the correct webhook secret." } ) end true end |
.with_retry(operation_name, context = {}) { ... } ⇒ Object
Execute an operation with retry logic
89 90 91 92 93 94 95 96 97 |
# File 'lib/complyance_sdk.rb', line 89 def with_retry(operation_name, context = {}) unless configured? raise ComplyanceSDK::Exceptions::ConfigurationError.new( "SDK must be configured before using retry functionality" ) end retry_manager.execute(operation_name, context) { yield } end |