Class: CommandTower::Messaging::Execution::AdapterResult
- Inherits:
-
Data
- Object
- Data
- CommandTower::Messaging::Execution::AdapterResult
- Defined in:
- app/services/command_tower/messaging/execution/adapter_result.rb
Constant Summary collapse
- OUTCOMES =
%i[success retryable_failure terminal_failure].freeze
Instance Attribute Summary collapse
-
#error_code ⇒ Object
readonly
Returns the value of attribute error_code.
-
#normalized_provider_status ⇒ Object
readonly
Returns the value of attribute normalized_provider_status.
-
#outcome ⇒ Object
readonly
Returns the value of attribute outcome.
-
#provider_message_id ⇒ Object
readonly
Returns the value of attribute provider_message_id.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#error_code ⇒ Object (readonly)
Returns the value of attribute error_code
6 7 8 |
# File 'app/services/command_tower/messaging/execution/adapter_result.rb', line 6 def error_code @error_code end |
#normalized_provider_status ⇒ Object (readonly)
Returns the value of attribute normalized_provider_status
6 7 8 |
# File 'app/services/command_tower/messaging/execution/adapter_result.rb', line 6 def normalized_provider_status @normalized_provider_status end |
#outcome ⇒ Object (readonly)
Returns the value of attribute outcome
6 7 8 |
# File 'app/services/command_tower/messaging/execution/adapter_result.rb', line 6 def outcome @outcome end |
#provider_message_id ⇒ Object (readonly)
Returns the value of attribute provider_message_id
6 7 8 |
# File 'app/services/command_tower/messaging/execution/adapter_result.rb', line 6 def @provider_message_id end |
Class Method Details
.build(outcome:, normalized_provider_status: nil, provider_message_id: nil, error_code: nil) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/services/command_tower/messaging/execution/adapter_result.rb', line 14 def self.build( outcome:, normalized_provider_status: nil, provider_message_id: nil, error_code: nil ) raise InvalidAdapterContractError, "arbitrary hashes are not accepted as outcome" if outcome.is_a?(Hash) raise InvalidAdapterContractError, "raw exception objects are not accepted" if exception_like?(outcome) || exception_like?(normalized_provider_status) || exception_like?() || exception_like?(error_code) raise InvalidAdapterContractError, "raw exception messages are not accepted" if (error_code) normalized_outcome = normalize_outcome!(outcome) validate_optional_string!(normalized_provider_status, "normalized_provider_status") validate_optional_string!(, "provider_message_id") validate_optional_string!(error_code, "error_code") new( outcome: normalized_outcome, normalized_provider_status:, provider_message_id:, error_code:, ).freeze end |
Instance Method Details
#retryable_failure? ⇒ Boolean
71 72 73 |
# File 'app/services/command_tower/messaging/execution/adapter_result.rb', line 71 def retryable_failure? outcome == :retryable_failure end |
#success? ⇒ Boolean
67 68 69 |
# File 'app/services/command_tower/messaging/execution/adapter_result.rb', line 67 def success? outcome == :success end |
#terminal_failure? ⇒ Boolean
75 76 77 |
# File 'app/services/command_tower/messaging/execution/adapter_result.rb', line 75 def terminal_failure? outcome == :terminal_failure end |