Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions code-samples/messaging/global-business/cancel-message.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using com.Messente.Api.Api;
using com.Messente.Api.Client;

namespace Example
{
public class CancelMessage
{
public static void Main()
{
Configuration conf = new Configuration
{
Username = "YOUR_MESSENTE_API_USERNAME",
Password = "YOUR_MESSENTE_API_PASSWORD"
};

var apiInstance = new OmnimessageApi(conf);

try
{
apiInstance.CancelScheduledMessage("<omnimessage_id>");
Console.WriteLine("Scheduled omnimessage cancelled");
}
catch (Exception e)
{
Console.WriteLine("Exception when cancelling an omnimessage: " + e.Message);
}
}
}
}
23 changes: 23 additions & 0 deletions code-samples/messaging/global-business/cancel-message.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import com.messente.ApiClient;
import com.messente.ApiException;
import com.messente.api.*;
import com.messente.auth.HttpBasicAuth;

public class CancelMessage {
public static void main(String[] args) {
ApiClient apiClient = new ApiClient();
OmnimessageApi apiInstance = new OmnimessageApi(apiClient);

HttpBasicAuth basicAuth = (HttpBasicAuth) apiClient.getAuthentication("basicAuth");
basicAuth.setUsername("YOUR_MESSENTE_API_USERNAME");
basicAuth.setPassword("YOUR_MESSENTE_API_PASSWORD");

try {
apiInstance.cancelScheduledMessage("<omnimessage_id>");
System.out.println("Scheduled omnimessage cancelled");
} catch (ApiException e) {
System.err.println("Exception when cancelling an omnimessage");
System.err.println(e.getResponseBody());
}
}
}
16 changes: 16 additions & 0 deletions code-samples/messaging/global-business/cancel-message.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const MessenteApi = require('messente_api');

const defaultClient = MessenteApi.ApiClient.instance;
const basicAuth = defaultClient.authentications['basicAuth'];
basicAuth.username = 'YOUR_MESSENTE_API_USERNAME';
basicAuth.password = 'YOUR_MESSENTE_API_PASSWORD';

const api = new MessenteApi.OmnimessageApi();

api.cancelScheduledMessage('<omnimessage_id>', (error) => {
if (error) {
console.error(error);
} else {
console.log('Scheduled omnimessage cancelled');
}
});
18 changes: 18 additions & 0 deletions code-samples/messaging/global-business/cancel-message.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
require_once(__DIR__ . '/../vendor/autoload.php');

use Messente\Api\Api\OmnimessageApi;
use Messente\Api\Configuration;

$config = Configuration::getDefaultConfiguration()
->setUsername('YOUR_MESSENTE_API_USERNAME')
->setPassword('YOUR_MESSENTE_API_PASSWORD');

$apiInstance = new OmnimessageApi(new GuzzleHttp\Client(), $config);

try {
$apiInstance->cancelScheduledMessage('<omnimessage_id>');
echo 'Scheduled omnimessage cancelled', PHP_EOL;
} catch (Exception $e) {
echo 'Exception when cancelling an omnimessage: ', $e->getMessage(), PHP_EOL;
}
14 changes: 14 additions & 0 deletions code-samples/messaging/global-business/cancel-message.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from messente_api import ApiClient, Configuration, OmnimessageApi
from messente_api.rest import ApiException

configuration = Configuration()
configuration.username = "YOUR_MESSENTE_API_USERNAME"
configuration.password = "YOUR_MESSENTE_API_PASSWORD"

api_instance = OmnimessageApi(ApiClient(configuration))

try:
api_instance.cancel_scheduled_message("<omnimessage_id>")
print("Scheduled omnimessage cancelled")
except ApiException as exception:
print("Exception when cancelling an omnimessage: %s\n" % exception)
16 changes: 16 additions & 0 deletions code-samples/messaging/global-business/cancel-message.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require 'messente_api'

MessenteApi.configure do |config|
config.username = 'YOUR_MESSENTE_API_USERNAME'
config.password = 'YOUR_MESSENTE_API_PASSWORD'
end

api_instance = MessenteApi::OmnimessageApi.new

begin
api_instance.cancel_scheduled_message('<omnimessage_id>')
puts 'Scheduled omnimessage cancelled'
rescue MessenteApi::ApiError => e
puts "Exception when cancelling an omnimessage: #{e}"
puts e.response_body
end
4 changes: 4 additions & 0 deletions code-samples/messaging/global-business/cancel-message.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
curl -X DELETE \
'https://api.messente.com/v1/omnimessage/<omnimessage_id>' \
-u 'YOUR_MESSENTE_API_USERNAME:YOUR_MESSENTE_API_PASSWORD' \
-H 'Accept: application/json'
9 changes: 9 additions & 0 deletions code-samples/messaging/global-business/get-dlr.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// 1. Get a temporary WebHook URL from https://webhook.site.
// Leave the website open. This is where you'll see your incoming delivery reports.
// 2. Edit the previous code example by adding the delivery URL to the request.
var omnimessage = new Omnimessage(
to: "<recipient_phone_number>",
dlrUrl: "<webhook_url>",
messages: new System.Collections.Generic.List<OmnimessageMessagesInner> { smsInner }
);
// 3. Send an SMS with the script and monitor the incoming requests on the webhook's website.
5 changes: 5 additions & 0 deletions code-samples/messaging/global-business/get-dlr.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// 1. Get a temporary WebHook URL from https://webhook.site.
// Leave the website open. This is where you'll see your incoming delivery reports.
// 2. Edit the previous code example by adding the delivery URL to the request.
omnimessage.setDlrUrl("<webhook_url>");
// 3. Send an SMS with the script and monitor the incoming requests on the webhook's website.
9 changes: 9 additions & 0 deletions code-samples/messaging/global-business/get-dlr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// 1. Get a temporary WebHook URL from https://webhook.site.
// Leave the website open. This is where you'll see your incoming delivery reports.
// 2. Edit the previous code example by adding the delivery URL to the request.
const omnimessage = MessenteApi.Omnimessage.constructFromObject({
messages: [sms],
to: '<recipient_phone_number>',
dlrUrl: '<webhook_url>',
});
// 3. Send an SMS with the script and monitor the incoming requests on the webhook's website.
10 changes: 10 additions & 0 deletions code-samples/messaging/global-business/get-dlr.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
// 1. Get a temporary WebHook URL from https://webhook.site.
// Leave the website open. This is where you'll see your incoming delivery reports.
// 2. Edit the previous code example by adding the delivery URL to the request.
$omnimessage = new Omnimessage([
'to' => '<recipient_phone_number>',
'dlr_url' => '<webhook_url>',
'messages' => [$sms],
]);
// 3. Send an SMS with the script and monitor the incoming requests on the webhook's website.
9 changes: 9 additions & 0 deletions code-samples/messaging/global-business/get-dlr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# 1. Get a temporary WebHook URL from https://webhook.site.
# Leave the website open. This is where you'll see your incoming delivery reports.
# 2. Edit the previous code example by adding the delivery URL to the request.
omnimessage = Omnimessage(
messages=[sms_inner],
to="<recipient_phone_number>",
dlr_url="<webhook_url>",
)
# 3. Send an SMS with the script and monitor the incoming requests on the webhook's website.
5 changes: 5 additions & 0 deletions code-samples/messaging/global-business/get-dlr.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# 1. Get a temporary WebHook URL from https://webhook.site.
# Leave the website open. This is where you'll see your incoming delivery reports.
# 2. Edit the previous code example by adding the delivery URL to the request.
omnimessage.dlr_url = '<webhook_url>'
# 3. Send an SMS with the script and monitor the incoming requests on the webhook's website.
16 changes: 16 additions & 0 deletions code-samples/messaging/global-business/get-dlr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
curl -X POST \
'https://api.messente.com/v1/omnimessage' \
-u 'YOUR_MESSENTE_API_USERNAME:YOUR_MESSENTE_API_PASSWORD' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{
"to": "<recipient_phone_number>",
"dlr_url": "<webhook_url>",
"messages": [
{
"channel": "sms",
"sender": "<sender name (optional)>",
"text": "hello sms"
}
]
}'
30 changes: 30 additions & 0 deletions code-samples/messaging/global-business/get-sync-dlr.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using com.Messente.Api.Api;
using com.Messente.Api.Client;

namespace Example
{
public class GetSyncDlr
{
public static void Main()
{
Configuration conf = new Configuration
{
Username = "YOUR_MESSENTE_API_USERNAME",
Password = "YOUR_MESSENTE_API_PASSWORD"
};

var apiInstance = new DeliveryReportApi(conf);

try
{
var result = apiInstance.RetrieveDeliveryReport("<omnimessage_id>");
Console.WriteLine(result.ToJson());
}
catch (Exception e)
{
Console.WriteLine("Exception when retrieving delivery report: " + e.Message);
}
}
}
}
23 changes: 23 additions & 0 deletions code-samples/messaging/global-business/get-sync-dlr.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import com.messente.ApiClient;
import com.messente.ApiException;
import com.messente.api.*;
import com.messente.auth.HttpBasicAuth;

public class GetSyncDlr {
public static void main(String[] args) {
ApiClient apiClient = new ApiClient();
DeliveryReportApi apiInstance = new DeliveryReportApi(apiClient);

HttpBasicAuth basicAuth = (HttpBasicAuth) apiClient.getAuthentication("basicAuth");
basicAuth.setUsername("YOUR_MESSENTE_API_USERNAME");
basicAuth.setPassword("YOUR_MESSENTE_API_PASSWORD");

try {
Object result = apiInstance.retrieveDeliveryReport("<omnimessage_id>");
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when retrieving delivery report");
System.err.println(e.getResponseBody());
}
}
}
16 changes: 16 additions & 0 deletions code-samples/messaging/global-business/get-sync-dlr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const MessenteApi = require('messente_api');

const defaultClient = MessenteApi.ApiClient.instance;
const basicAuth = defaultClient.authentications['basicAuth'];
basicAuth.username = 'YOUR_MESSENTE_API_USERNAME';
basicAuth.password = 'YOUR_MESSENTE_API_PASSWORD';

const api = new MessenteApi.DeliveryReportApi();

api.retrieveDeliveryReport('<omnimessage_id>', (error, data) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ', data);
}
});
18 changes: 18 additions & 0 deletions code-samples/messaging/global-business/get-sync-dlr.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
require_once(__DIR__ . '/../vendor/autoload.php');

use Messente\Api\Api\DeliveryReportApi;
use Messente\Api\Configuration;

$config = Configuration::getDefaultConfiguration()
->setUsername('YOUR_MESSENTE_API_USERNAME')
->setPassword('YOUR_MESSENTE_API_PASSWORD');

$apiInstance = new DeliveryReportApi(new GuzzleHttp\Client(), $config);

try {
$result = $apiInstance->retrieveDeliveryReport('<omnimessage_id>');
print_r($result);
} catch (Exception $e) {
echo 'Exception when retrieving delivery report: ', $e->getMessage(), PHP_EOL;
}
15 changes: 15 additions & 0 deletions code-samples/messaging/global-business/get-sync-dlr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from pprint import pprint
from messente_api import ApiClient, Configuration, DeliveryReportApi
from messente_api.rest import ApiException

configuration = Configuration()
configuration.username = "YOUR_MESSENTE_API_USERNAME"
configuration.password = "YOUR_MESSENTE_API_PASSWORD"

api_instance = DeliveryReportApi(ApiClient(configuration))

try:
response = api_instance.retrieve_delivery_report("<omnimessage_id>")
pprint(response)
except ApiException as exception:
print("Exception when retrieving delivery report: %s\n" % exception)
16 changes: 16 additions & 0 deletions code-samples/messaging/global-business/get-sync-dlr.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require 'messente_api'

MessenteApi.configure do |config|
config.username = 'YOUR_MESSENTE_API_USERNAME'
config.password = 'YOUR_MESSENTE_API_PASSWORD'
end

api_instance = MessenteApi::DeliveryReportApi.new

begin
result = api_instance.retrieve_delivery_report('<omnimessage_id>')
puts result
rescue MessenteApi::ApiError => e
puts "Exception when retrieving delivery report: #{e}"
puts e.response_body
end
4 changes: 4 additions & 0 deletions code-samples/messaging/global-business/get-sync-dlr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
curl -X GET \
'https://api.messente.com/v1/omnimessage/<omnimessage_id>/status' \
-u 'YOUR_MESSENTE_API_USERNAME:YOUR_MESSENTE_API_PASSWORD' \
-H 'Accept: application/json'
42 changes: 42 additions & 0 deletions code-samples/messaging/global-business/schedule-message.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using com.Messente.Api.Api;
using com.Messente.Api.Client;
using com.Messente.Api.Model;

namespace Example
{
public class ScheduleMessage
{
public static void Main()
{
Configuration conf = new Configuration
{
Username = "YOUR_MESSENTE_API_USERNAME",
Password = "YOUR_MESSENTE_API_PASSWORD"
};

var apiInstance = new OmnimessageApi(conf);
var sms = new SMS(sender: "<sender name (optional)>", text: "hello sms");
OmnimessageMessagesInner smsInner = new OmnimessageMessagesInner(sms)
{
ActualInstance = sms
};

var omnimessage = new Omnimessage(
to: "<recipient_phone_number>",
timeToSend: "2019-06-22T09:05:07+04:00",
messages: new System.Collections.Generic.List<OmnimessageMessagesInner> { smsInner }
);

try
{
var result = apiInstance.SendOmnimessage(omnimessage);
Console.WriteLine(result.ToJson());
}
catch (Exception e)
{
Console.WriteLine("Exception when scheduling an omnimessage: " + e.Message);
}
}
}
}
Loading