/// <summary> /// Adds return routing to message /// </summary> /// <param name="message">The message to add return routing</param> public static void AddReturnRouting(this AgentMessage message) { message.AddDecorator(new TransportDecorator { ReturnRoute = ReturnRouteTypes.all.ToString("G") }, DecoratorNames.TransportDecorator); }
private static void ThreadMessage(this AgentMessage messageToThread, AgentMessage messageToThreadFrom) { ThreadDecorator previousMessageThreadContext = null; try { previousMessageThreadContext = messageToThreadFrom.GetDecorator <ThreadDecorator>(DecoratorIdentifier); } catch (AriesFrameworkException) { } ThreadDecorator currentThreadContext; if (previousMessageThreadContext != null) { currentThreadContext = new ThreadDecorator { ParentThreadId = previousMessageThreadContext.ParentThreadId, ThreadId = previousMessageThreadContext.ThreadId }; } else { currentThreadContext = new ThreadDecorator { ThreadId = messageToThreadFrom.Id }; } messageToThread.AddDecorator(currentThreadContext, DecoratorIdentifier); }
/// <summary> /// Threads the current message. /// </summary> /// <param name="messageToThread">Message to thread.</param> /// <param name="threadId">Thread id to thread the message with.</param> public static void ThreadFrom(this AgentMessage messageToThread, string threadId) { var currentThreadContext = new ThreadDecorator { ThreadId = threadId }; messageToThread.AddDecorator(currentThreadContext, DecoratorIdentifier); }
public void AttachPaymentReceipt(IAgentContext context, AgentMessage agentMessage, PaymentRecord paymentRecord) { if (paymentRecord.State != PaymentState.Paid) { throw new AgentFrameworkException(ErrorCode.RecordInInvalidState, "Payment record must be in state Paid to attach receipts"); } agentMessage.AddDecorator(new PaymentReceiptDecorator { RequestId = paymentRecord.ReferenceId, Amount = paymentRecord.Amount, TransactionId = paymentRecord.ReceiptId, PayeeId = paymentRecord.Address, SelectedMethod = "sov" }, "payment_receipt"); }
/// <summary> /// Adds an attachment to the message using the ~attach attachment /// </summary> /// <param name="message">The message.</param> /// <param name="attachment">The attachment.</param> /// <param name="overrideExisting">if set to <c>true</c> [override existing].</param> public static void AddAttachment(this AgentMessage message, Attachment attachment, bool overrideExisting = true) { var decorator = message.FindDecorator <AttachDecorator>("attach") ?? new AttachDecorator(); var existing = decorator[attachment]; if (existing != null && !overrideExisting) { throw new ArgumentException($"Attachment {attachment.Nickname} already exists."); } if (existing != null) { decorator.Remove(existing); } decorator.Add(attachment); message.AddDecorator(decorator, "attach"); }
public async Task <PaymentRecord> AttachPaymentRequestAsync(IAgentContext context, AgentMessage agentMessage, PaymentDetails details, PaymentAddressRecord addressRecord = null) { // TODO: Add validation var paymentRecord = new PaymentRecord { Address = addressRecord.Address, Method = "sov", Amount = details.Total.Amount.Value, Details = details }; details.Id = details.Id ?? paymentRecord.Id; paymentRecord.ReferenceId = details.Id; await paymentRecord.TriggerAsync(PaymentTrigger.RequestSent); await recordService.AddAsync(context.Wallet, paymentRecord); agentMessage.AddDecorator(new PaymentRequestDecorator { Method = new PaymentMethod { SupportedMethods = "sov", Data = new PaymentMethodData { PayeeId = addressRecord.Address, SupportedNetworks = new[] { "Sovrin MainNet" } } }, Details = details }, "payment_request"); return(paymentRecord); }