Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
GetTransactionInformation.cs
1using System;
2using System.Collections.Generic;
3using System.Threading.Tasks;
4using System.Xml;
5using Waher.Content;
7using Waher.Script;
10
12{
17 {
22 : base("Wallet/GetTransactionInformation",
23 new KeyValuePair<Type, Expression>(typeof(Dictionary<string, object>), new Expression(jsonPattern)),
24 new KeyValuePair<Type, Expression>(typeof(XmlDocument), new Expression(xmlPattern)))
25 {
26 }
27
28 private static readonly string jsonPattern = Resources.LoadResourceAsText(typeof(GetTransactionInformation).Namespace + ".JSON.GetTransactionInformation.req");
29 private static readonly string xmlPattern = Resources.LoadResourceAsText(typeof(GetTransactionInformation).Namespace + ".XML.GetTransactionInformation.req");
30
39 public override async Task POST(HttpRequest Request, HttpResponse Response, Dictionary<string, IElement> Parameters)
40 {
42
43 string TransactionIdStr = (string)Parameters["PTransactionId"].AssociatedObjectValue;
44 string TabId = Parameters.TryGetValue("PTabId", out IElement E) ? (string)E?.AssociatedObjectValue : null;
45 string FunctionName = Parameters.TryGetValue("PFunctionName", out E) ? (string)E?.AssociatedObjectValue : null;
46
47 if (!Guid.TryParse(TransactionIdStr, out Guid TransactionId))
48 throw new BadRequestException("Invalid Transaction ID. Must be a GUID.");
49
50 if (!PaymentTransactions.TryGetTransaction(TransactionId, out PaymentTransaction Transaction))
51 throw new NotFoundException("Transaction not found.");
52
53 if (Transaction.UserName != User.UserName)
54 throw new ForbiddenException("Not your transaction.");
55
56 if (!string.IsNullOrEmpty(TabId) || !string.IsNullOrEmpty(FunctionName))
57 {
58 if (!string.IsNullOrEmpty(TabId))
59 Transaction.TabId = TabId;
60
61 if (!string.IsNullOrEmpty(FunctionName))
62 Transaction.FunctionName = FunctionName;
63
64 await Transaction.PushToClient();
65 }
66
67 await Response.Return(Transaction.GetInformation());
68 }
69 }
70}
Static class managing loading of resources stored as embedded resources or in content files.
Definition: Resources.cs:15
static string LoadResourceAsText(string ResourceName)
Loads a text resource from an embedded resource.
Definition: Resources.cs:96
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repe...
The server understood the request, but is refusing to fulfill it. Authorization will not help and the...
Represents an HTTP request.
Definition: HttpRequest.cs:18
Represets a response of an HTTP client request.
Definition: HttpResponse.cs:21
async Task Return(object Object)
Returns an object to the client. This method can only be called once per response,...
The server has not found anything matching the Request-URI. No indication is given of whether the con...
Class managing a script expression.
Definition: Expression.cs:39
Abstract base class for agent resources supporting the POST method.
static AccountUser AssertUserAuthenticated(HttpRequest Request)
Makes sure the request is made by an authenticated API user.
override async Task POST(HttpRequest Request, HttpResponse Response, Dictionary< string, IElement > Parameters)
Executes the POST method on the resource.
Basic interface for all types of elements.
Definition: IElement.cs:20