4using System.Threading.Tasks;
18 : base(
"/RequestApiKey")
22 public override bool HandlesSubPaths =>
false;
23 public override bool UserSessions =>
true;
35 if (Content.
HasError || !(Content.
Decoded is Dictionary<string, string> Form))
49 string RecaptchaResponse;
51 if (!Form.ContainsKey(
"Name") ||
string.IsNullOrEmpty(Name = Form[
"Name"]))
63 if (!Form.ContainsKey(
"LinkedIn") ||
string.IsNullOrEmpty(LinkedIn = Form[
"LinkedIn"]))
69 if (!Form.ContainsKey(
"Organization") ||
string.IsNullOrEmpty(Organization = Form[
"Organization"]))
75 if (!Form.ContainsKey(
"Product") ||
string.IsNullOrEmpty(Product = Form[
"Product"]))
81 if (!Form.ContainsKey(
"Number") ||
string.IsNullOrEmpty(Number = Form[
"Number"]))
87 if (!Form.ContainsKey(
"Where") ||
string.IsNullOrEmpty(Where = Form[
"Where"]))
93 if (!Form.ContainsKey(
"TimeLimit") ||
string.IsNullOrEmpty(TimeLimit = Form[
"TimeLimit"]))
94 TimeLimit =
string.Empty;
96 if (!Form.ContainsKey(
"g-recaptcha-response") ||
string.IsNullOrEmpty(RecaptchaResponse = Form[
"g-recaptcha-response"]))
105 new KeyValuePair<string, object>(
"Name", Name),
106 new KeyValuePair<string, object>(
"EMail", EMail.
Value),
107 new KeyValuePair<string, object>(
"LinkedIn", LinkedIn),
108 new KeyValuePair<string, object>(
"Organization", Organization),
109 new KeyValuePair<string, object>(
"Product", Product),
110 new KeyValuePair<string, object>(
"Number", Number),
111 new KeyValuePair<string, object>(
"Where", Where),
112 new KeyValuePair<string, object>(
"TimeLimit", TimeLimit),
113 new KeyValuePair<string, object>(
"RemoteEndPoint", Request.
RemoteEndPoint));
115 Dictionary<string, object>
Feedback =
new Dictionary<string, object>();
116 foreach (KeyValuePair<string, object> P
in Tags)
121 StringBuilder Markdown =
new StringBuilder();
122 DateTime Now = DateTime.Now;
124 Markdown.AppendLine(
"API key requested.");
125 Markdown.AppendLine();
127 Markdown.AppendLine(
"| API Key request ||");
128 Markdown.AppendLine(
"|:------|:-------|");
130 Markdown.Append(
"| Name: | ");
132 Markdown.AppendLine(
" |");
134 Markdown.Append(
"| e-Mail: | <a href=\"mailto:");
135 Markdown.Append(EMail.
Replace(
"\"",
"""));
136 Markdown.Append(
"\" target=\"_blank\">");
138 Markdown.AppendLine(
"</a> |");
140 Markdown.Append(
"| LinkedIn: | <a href=\"");
141 Markdown.Append(LinkedIn.Replace(
"\"",
"""));
142 Markdown.Append(
"\" target=\"_blank\">");
144 Markdown.AppendLine(
"</a> |");
146 Markdown.Append(
"| Organization: | ");
148 Markdown.AppendLine(
" |");
150 Markdown.Append(
"| Product: | ");
152 Markdown.AppendLine(
" |");
154 Markdown.Append(
"| Number: | ");
156 Markdown.AppendLine(
" |");
158 Markdown.Append(
"| Where: | ");
160 Markdown.AppendLine(
" |");
162 Markdown.Append(
"| Time Limit: | ");
164 Markdown.AppendLine(
" |");
168 Markdown.Append(
"| Date | ");
170 Markdown.AppendLine(
" |");
171 Markdown.Append(
"| Time | ");
173 Markdown.AppendLine(
" |");
178 await IoTGateway.Gateway.SendNotification(Markdown.ToString());
Contains information about a response to a content request.
bool HasError
If an error occurred.
object Decoded
Decoded object.
Contains a markdown document. This markdown document class supports original markdown,...
static string Encode(string s)
Encodes all special characters in a string so that it can be included in a markdown document without ...
Static class managing the application event log. Applications and services log events on this static ...
static void Notice(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs a notice event.
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.
string RemoteEndPoint
Remote end-point.
bool HasData
If the request has data.
SessionVariables Session
Contains session states, if the resource requires sessions, or null otherwise.
async Task< ContentResponse > DecodeDataAsync()
Decodes data sent in request.
Represets a response of an HTTP client request.
async Task SendResponse()
Sends the response back to the client. If the resource is synchronous, there's no need to call this m...
Base class for all synchronous HTTP resources. A synchronous resource responds within the method hand...
The response to the request can be found under a different URI and SHOULD be retrieved using a GET me...
Represents a case-insensitive string.
string Value
String-representation of the case-insensitive string. (Representation is case sensitive....
static bool IsNullOrEmpty(CaseInsensitiveString value)
Indicates whether the specified string is null or an CaseInsensitiveString.Empty string.
CaseInsensitiveString Replace(CaseInsensitiveString oldValue, CaseInsensitiveString newValue)
Returns a new string in which all occurrences of a specified string in the current instance are repla...
Class that monitors login events, and help applications determine malicious intent....
static async Task< string > AppendWhoIsInfo(StringBuilder Markdown, string RemoteEndPoint)
Appends WHOIS information to a Markdown document.
static async Task< KeyValuePair< string, object >[]> Annotate(string RemoteEndPoint, params KeyValuePair< string, object >[] Tags)
Annotates a remote endpoint.
Provides the user with options to control notifications from the Broker.
static BrokerNotificationConfiguration Instance
Current instance of configuration.
bool ApiKeyRequested
If a notification should be sent when an API key has been requested.
static async Task< bool > SiteVerify(string RecaptchaResponse, string RemoteEndPoint)
Allows web pages and web services to verify that Google reCaptcha responses are valid.
bool AllowsPOST
If the POST method is allowed.
async Task POST(HttpRequest Request, HttpResponse Response)
Executes the POST method on the resource.
Service Module hosting the XMPP broker and its components.
static async Task AppendRemoteEndPointToTable(StringBuilder Markdown, string RemoteEndPoint)
Appends annotated information about a remote endpoint to a Markdown table.
POST Interface for HTTP resources.