Skip to content

Commit

Permalink
Improves Notification Examples
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexCatarino committed Jun 26, 2024
1 parent 5b139ac commit c4563ce
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 17 deletions.
10 changes: 6 additions & 4 deletions Resources/notifications/email-setup.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<p>To send email notifications in your code files, run:</p>
<div class="section-example-container">
<pre class="csharp">Notify.Email(emailAddress, subject, body);</pre>
<pre class="python">self.notify.email(email_address, subject, body)</pre>
<pre class="csharp">var body = "2023-07-13T12:20:00.2033226Z,EURUSD,1.11853,89187,Market,Filled,99758.33511";
Notify.Email(emailAddress: "[email protected]", subject: "Last Trade", body: body);</pre>
<pre class="python">body = "2023-07-13T12:20:00.2033226Z,EURUSD,1.11853,89187,Market,Filled,99758.33511"
self.notify.email(email_address="[email protected]", subject="Last Trade", body=body)</pre>
</div>

<p>You can include an attachment and set its name.</p>
<div class="section-example-container">
<pre class="csharp">var attachment = "2023-07-13T12:20:00.2033226Z,EURUSD,1.11853,89187,Market,Filled,99758.33511";
var headers = new Dictionary&lt;string, string&gt; { { "filename", "trades.csv" } };
Notify.Email(emailAddress, subject, body, attachment, headers);</pre>
Notify.Email(emailAddress: "[email protected]", subject: "Last Trade", body: "See attachment", attachment: attachment, headers: headers);</pre>
<pre class="python">attachment = "2023-07-13T12:20:00.2033226Z,EURUSD,1.11853,89187,Market,Filled,99758.33511"
headers = { "filename": "trades.csv" }
self.notify.email(email_address, subject, body, attachment, headers)</pre>
self.notify.email(email_address="[email protected]", subject="Last Trade", body="See attachment", attachment=attachment, headers=headers)</pre>
</div>

<p>If you don't provide headers, the attachment name is <span class='public-file-name'>attachment.txt</span>.</p>
20 changes: 13 additions & 7 deletions Resources/notifications/ftp-setup.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
<p>To send a file to your FTP server in your code files, run:</p>
<div class="section-example-container">
<pre class="csharp">Notify.Ftp(hostname, username, password, filePath, fileContent, port);</pre>
<pre class="python">self.notify.ftp(hostname, username, password, file_path, file_content, port)</pre>
<pre class="csharp">var fileContent = "2023-07-13T12:20:00.2033226Z,EURUSD,1.11853,89187,Market,Filled,99758.33511";
Notify.Ftp(hostname: "myftpserver.com", username: "admin", password: "12345", filePath: "trades.csv", fileContent: fileContent, port: 21);</pre>
<pre class="python">file_content = "2023-07-13T12:20:00.2033226Z,EURUSD,1.11853,89187,Market,Filled,99758.33511"
self.notify.ftp(hostname: "myftpserver.com", username="admin", password="12345", file_path="trades.csv", file_content=file_content, port: 21)</pre>
</div>

<p>To send a file to your SFTP server in your code files, run:</p>
<div class="section-example-container">
<pre class="csharp">Notify.Sftp(hostname, username, password, filePath, fileContent, port);</pre>
<pre class="python">self.notify.Sftp(hostname, username, password, file_path, file_content, port)</pre>
<pre class="csharp">var fileContent = "2023-07-13T12:20:00.2033226Z,EURUSD,1.11853,89187,Market,Filled,99758.33511";
Notify.Sftp(hostname: "mysftpserver.com", username: "admin", password: "12345", filePath: "trades.csv", fileContent: fileContent, port: 21);</pre>
<pre class="python">file_content = "2023-07-13T12:20:00.2033226Z,EURUSD,1.11853,89187,Market,Filled,99758.33511"
self.notify.sftp(hostname: "mysftpserver.com", username="admin", password="12345", file_path="trades.csv", file_content=file_content, port: 21)</pre>
</div>

<p>You can use password authentication over SFTP using SSH keys.</p>
<div class="section-example-container">
<pre class="csharp">Notify.Sftp(hostname, username, privateKey, privateKeyPassphrase, filePath, fileContent, port);</pre>
<pre class="python">self.notify.Sftp(hostname, username, private_key, private_key_passphrase, file_path, file_content, port)</pre>
<pre class="csharp">var fileContent = "2023-07-13T12:20:00.2033226Z,EURUSD,1.11853,89187,Market,Filled,99758.33511";
Notify.Sftp(hostname: "mysftpserver.com", username: "admin", privateKey: "12345", privateKeyPassphrase: "67890", filePath: "trades.csv", fileContent: fileContent, port: 21);</pre>
<pre class="python">file_content = "2023-07-13T12:20:00.2033226Z,EURUSD,1.11853,89187,Market,Filled,99758.33511"
self.notify.sftp(hostname: "mysftpserver.com", username="admin", private_key= "12345", private_key_passphrase="67890", file_path="trades.csv", file_content=file_content, port: 21)</pre>
</div>

<p>The <code>port</code> parameter is optional.</p>
<p>The <code class="csharp">filePath</code><code class="python">file_path</code> parameter is path to file on the FTP server. The <code>port</code> parameter is optional.</p>
6 changes: 4 additions & 2 deletions Resources/notifications/sms-setup.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<p>To send SMS notifications in your code files, run:</p>
<div class="section-example-container">
<pre class="csharp">Notify.Sms(phoneNumber, message);</pre>
<pre class="python">self.notify.sms(phone_number, message)</pre>
<pre class="csharp">var message = "2023-07-13T12:20:00.2033226Z,EURUSD,1.11853,89187,Market,Filled,99758.33511";
Notify.Sms(phoneNumber: "+100503016366", message: message);</pre>
<pre class="python">message = "2023-07-13T12:20:00.2033226Z,EURUSD,1.11853,89187,Market,Filled,99758.33511"
self.notify.sms(phone_number: "+100503016366", message=message)</pre>
</div>
6 changes: 4 additions & 2 deletions Resources/notifications/telegram-setup.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<p>To send Telegram notifications in your code files, run:</p>
<div class="section-example-container">
<pre class="csharp">Notify.Telegram(id, message, token);</pre>
<pre class="python">self.notify.telegram(id, message, token)</pre>
<pre class="csharp">var message = "2023-07-13T12:20:00.2033226Z,EURUSD,1.11853,89187,Market,Filled,99758.33511";
Notify.Telegram(id: "503016366", message: message, token: "1234");</pre>
<pre class="python">message = "2023-07-13T12:20:00.2033226Z,EURUSD,1.11853,89187,Market,Filled,99758.33511"
self.notify.telegram(id="503016366", message=message, token="1234")</pre>
</div>

<p>The <code>id</code> argument is your Telegram group Id. <? include(DOCS_RESOURCES."/notifications/telegram-group-id.html"); ?></p>
Expand Down
8 changes: 6 additions & 2 deletions Resources/notifications/webhook-setup.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<p>To send webhook notifications in your code files, run:</p>
<div class="section-example-container">
<pre class="csharp">Notify.Web(url, data, headers);</pre>
<pre class="python">self.notify.web(url, data, headers)</pre>
<pre class="csharp">var data = "";
var headers = new Dictionary&lt;string, string&gt; { { "Authorization", "Basic XXXXXX" } };
Notify.Web(url: "http://api.myserver.com", data: data, headers: headers);</pre>
<pre class="python">data = ""
headers = { 'Authorization': 'Basic XXXXX' }
self.notify.web(url="http://api.myserver.com", data=data, headers=headers)</pre>
</div>

0 comments on commit c4563ce

Please sign in to comment.