Class: Assistant::MicrosoftAdsChangeApproval
- Inherits:
-
Object
- Object
- Assistant::MicrosoftAdsChangeApproval
- Includes:
- Service
- Defined in:
- app/services/assistant/microsoft_ads_change_approval.rb
Overview
Issues and consumes one-time human approvals for Microsoft Ads mutations.
The approval is persisted on the conversation so a model cannot satisfy its
own confirmation prompt in the same turn. It is bound to the authenticated
sender, CRM account, tool, target IDs, and a canonicalized payload.
Defined Under Namespace
Classes: InvalidApproval, Result
Constant Summary collapse
- METADATA_KEY =
'microsoft_ads_change_approval'- APPROVAL_TTL =
30.minutes
- WRITE_TOOLS =
MicrosoftAdsChangePayload::WRITE_TOOLS
Class Method Summary collapse
-
.consume(**attributes) ⇒ Result
Approval outcome with operation 'consume'.
-
.request(**attributes) ⇒ Result
Approval outcome with operation 'request'.
Instance Method Summary collapse
Methods included from Service
#attributes_used, #build_result, call, #logger
Methods included from Service::Initializer
Class Method Details
.consume(**attributes) ⇒ Result
Returns approval outcome with operation 'consume'.
53 |
# File 'app/services/assistant/microsoft_ads_change_approval.rb', line 53 def consume(**attributes) = call(**attributes, operation: 'consume') |
.request(**attributes) ⇒ Result
Returns approval outcome with operation 'request'.
47 |
# File 'app/services/assistant/microsoft_ads_change_approval.rb', line 47 def request(**attributes) = call(**attributes, operation: 'request') |
Instance Method Details
#call ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/services/assistant/microsoft_ads_change_approval.rb', line 56 def call validate_context! @change_payload = MicrosoftAdsChangePayload.call(tool_name:, payload:) case operation when 'request' then request_approval when 'consume' then consume_approval else raise InvalidApproval, 'Unsupported approval operation.' end rescue InvalidApproval, MicrosoftAdsChangePayload::InvalidPayload => e failure(e.) end |