public static void Main(string[] args) { // Find your Account SID and Auth Token at twilio.com/console const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; const string serviceSid = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; TwilioClient.Init(accountSid, authToken); var notification = NotificationResource.Create( serviceSid, identity: new List <string> { "00000001" }, title: "Generic loooooooong title for all Bindings", body: "This is the body for all Bindings", data: "{\"custom_key1\":\"custom value 1\"," + "\"custom_key2\":\"custom value 2\"}", fcm: "{\"notification\":{\"title\":\"New alert\"," + "\"body\" : \"Hello Bob!\"}}", apn: "{\"aps\" : " + "{ \"alert\": " + "{\"title\":\"New alert\"," + "\"body\" : \"Hello Bob!\"}"); Console.WriteLine(notification.Sid); }
static void Main(string[] args) { // Find your Account Sid and Token at twilio.com/console const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; TwilioClient.Init(accountSid, authToken); var apn = new Dictionary <string, Object>() { { "aps", new Dictionary <string, Object>() { { "alert", new Dictionary <string, Object>() { { "title", "Bob alert" }, { "body", "Bob, you just received a badge" } } }, { "badge", 1 } } } }; var identity = new List <string> { "00000001" }; var notification = NotificationResource.Create( apn: apn, identity: identity, pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(notification.Sid); }
static void Main(string[] args) { const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; TwilioClient.Init(accountSid, authToken); var toBinding = new List <string> { JsonConvert.SerializeObject(new Dictionary <string, Object>() { { "binding_type", "sms" }, { "address", "+1651000000000" } }, Formatting.Indented), JsonConvert.SerializeObject(new Dictionary <string, Object>() { { "binding_type", "sms" }, { "address", "+1651000000001" } }, Formatting.Indented) }; var notification = NotificationResource.Create( body: "Knock-Knock! This is your first Notify SMS", toBinding: toBinding, pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(notification.Sid); }
static void Main(string[] args) { // Find your Account Sid and Token at twilio.com/console // DANGER! This is insecure. See http://twil.io/secure const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; TwilioClient.Init(accountSid, authToken); var toBinding = new List <string> { JsonConvert.SerializeObject(new Dictionary <string, Object>() { { "binding_type", "sms" }, { "address", "+1651000000000" } }, Formatting.Indented) }; var notification = NotificationResource.Create( body: "Knok-Knok! This is your first Notify SMS", toBinding: toBinding, identity: Promoter.ListOfOne("identity"), pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(notification.Sid); }
static void Main(string[] args) { // Find your Account Sid and Token at twilio.com/console const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; TwilioClient.Init(accountSid, authToken); var identity = new List <string> { "00000001" }; var tag = new List <string> { "preferred_device" }; var notification = NotificationResource.Create( body: "Hello Bob", identity: identity, tag: tag, pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(notification.Sid); }
static void Main(string[] args) { // Find your Account Sid and Token at twilio.com/console const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; TwilioClient.Init(accountSid, authToken); var toBinding = new List <string> { JsonConvert.SerializeObject(new Dictionary <string, Object>() { { "binding_type", "sms" }, { "address", "+15555555555" } }, Formatting.Indented) }; var notification = NotificationResource.Create( body: "Hello Bob", toBinding: toBinding, identity: Promoter.ListOfOne("Identity"), pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(notification.Sid); }
public static void Main(string[] args) { // Find your Account SID and Auth Token at twilio.com/console // To set up environmental variables, see http://twil.io/secure const string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID"); const string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN"); const string serviceSid = Environment.GetEnvironmentVariable("TWILIO_SERVICE_SID"); TwilioClient.Init(accountSid, authToken); var notification = NotificationResource.Create( serviceSid, identity: new List <string> { "00000001" }, title: "Generic loooooooong title for all Bindings", body: "This is the body for all Bindings", data: "{\"custom_key1\":\"custom value 1\"," + "\"custom_key2\":\"custom value 2\"}", fcm: "{\"notification\":{\"title\":\"New alert\"," + "\"body\" : \"Hello Bob!\"}}", apn: "{\"aps\" : " + "{ \"alert\": " + "{\"title\":\"New alert\"," + "\"body\" : \"Hello Bob!\"}}}"); Console.WriteLine(notification.Sid); }
/// <inheritdoc /> /// <summary> /// Send a notification /// </summary> /// <param name="notification">notification</param> public void SendNotification(NotificationResource notification) { mWebCallEvent.WebPath = "/notifications"; if (!string.IsNullOrEmpty(mWebCallEvent.WebPath)) { mWebCallEvent.WebPath = mWebCallEvent.WebPath.Replace("{format}", "json"); } mWebCallEvent.HeaderParams.Clear(); mWebCallEvent.QueryParams.Clear(); mWebCallEvent.AuthSettings.Clear(); mWebCallEvent.PostBody = null; mWebCallEvent.PostBody = KnetikClient.Serialize(notification); // http body (model) parameter // authentication settings mWebCallEvent.AuthSettings.Add("oauth2_client_credentials_grant"); // authentication settings mWebCallEvent.AuthSettings.Add("oauth2_password_grant"); // make the HTTP request mSendNotificationStartTime = DateTime.Now; mWebCallEvent.Context = mSendNotificationResponseContext; mWebCallEvent.RequestType = KnetikRequestType.POST; KnetikLogger.LogRequest(mSendNotificationStartTime, "SendNotification", "Sending server request..."); KnetikGlobalEventSystem.Publish(mWebCallEvent); }
private static async Task <List <NotificationResource> > GetAllNotifications(TwilioRestClient client) { var filename = @"C:\servicetitan\twilioNotifications.json"; if (File.Exists(filename)) { try { var json = await File.ReadAllTextAsync(filename); return(JsonConvert.DeserializeObject <List <NotificationResource> >(json)); } catch (Exception e) { Console.WriteLine(e); } } var all = (await NotificationResource.ReadAsync(new ReadNotificationOptions { PageSize = 1000 }, client)) .ToList(); await File.WriteAllTextAsync(filename, JsonConvert.SerializeObject(all)); return(all); }
/// <inheritdoc/> public async Task <ApiResponse <NotificationResource> > GetNotificationAsync( string tenantId, string notificationId, CancellationToken cancellationToken = default) { if (string.IsNullOrEmpty(tenantId)) { throw new ArgumentNullException(nameof(tenantId)); } if (string.IsNullOrEmpty(notificationId)) { throw new ArgumentNullException(nameof(notificationId)); } Uri requestUri = this.ConstructUri($"/{tenantId}/marain/usernotifications/{notificationId}"); HttpRequestMessage request = this.BuildRequest(HttpMethod.Get, requestUri); HttpResponseMessage response = await this.SendRequestAndThrowOnFailure(request, cancellationToken).ConfigureAwait(false); using Stream contentStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); NotificationResource result = await JsonSerializer.DeserializeAsync <NotificationResource>(contentStream, this.SerializerOptions).ConfigureAwait(false); return(new ApiResponse <NotificationResource>( response.StatusCode, result)); }
static void Main(string[] args) { // Find your Account Sid and Token at twilio.com/console // DANGER! This is insecure. See http://twil.io/secure const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; TwilioClient.Init(accountSid, authToken); var segment = new List <string> { "new_user" }; var tag = new List <string> { "preferred_device" }; var notification = NotificationResource.Create( body: "Hello New Users", segment: segment, tag: tag, pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(notification.Sid); }
static void Main(string[] args) { // Find your Account Sid and Token at twilio.com/console const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; TwilioClient.Init(accountSid, authToken); NotificationResource.Delete(pathSid: "NOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/console const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; TwilioClient.Init(accountSid, authToken); NotificationResource.Delete("NO5a7a84730f529f0a76b3e30c01315d1a"); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/console // To set up environmental variables, see http://twil.io/secure const string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID"); const string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN"); TwilioClient.Init(accountSid, authToken); NotificationResource.Delete("NO5a7a84730f529f0a76b3e30c01315d1a"); }
static void Main(string[] args) { // Find your Account Sid and Token at twilio.com/console // DANGER! This is insecure. See http://twil.io/secure const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; TwilioClient.Init(accountSid, authToken); NotificationResource.Delete(pathSid: "NO5a7a84730f529f0a76b3e30c01315d1a"); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/console const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; TwilioClient.Init(accountSid, authToken); var notification = NotificationResource.Fetch("NO5a7a84730f529f0a76b3e30c01315d1a"); Console.WriteLine(notification.MessageText); }
static void Main(string[] args) { // Find your Account Sid and Token at twilio.com/console // DANGER! This is insecure. See http://twil.io/secure const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; TwilioClient.Init(accountSid, authToken); var apn = new Dictionary <string, Object>() { { "aps", new Dictionary <string, Object>() { { "alert", new Dictionary <string, Object>() { { "title", "Short title for Watch." } } } } } }; var data = new Dictionary <string, Object>() { { "custom_key1", "custom value 1" }, { "custom_key2", "custom value 2" } }; var fcm = new Dictionary <string, Object>() { { "notification", new Dictionary <string, Object>() { { "title", "New alert" }, { "body", "Hello Bob!" } } } }; var identity = new List <string> { "00000001" }; var notification = NotificationResource.Create( apn: apn, body: "This is the body for all Bindings", data: data, fcm: fcm, identity: identity, title: "Generic loooooooong title for all Bindings", pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(notification.Sid); }
static void Main(string[] args) { // Find your Account Sid and Token at twilio.com/console const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; TwilioClient.Init(accountSid, authToken); var notification = NotificationResource.Fetch( pathSid: "NOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(notification.CallSid); }
public void TestReadFullResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.OK, "{\"end\": 0,\"first_page_uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json?PageSize=1&Page=0\",\"previous_page_uri\": null,\"next_page_uri\": null,\"notifications\": [{\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"api_version\": \"2008-08-01\",\"call_sid\": \"CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"date_created\": \"Thu, 30 Apr 2015 16:47:33 +0000\",\"date_updated\": \"Thu, 30 Apr 2015 16:47:35 +0000\",\"error_code\": \"21609\",\"log\": \"1\",\"message_date\": \"Thu, 30 Apr 2015 16:47:32 +0000\",\"message_text\": \"LogLevel=WARN&invalidStatusCallbackUrl=&Msg=Invalid+Url+for+callSid%3A+CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa+invalid+statusCallbackUrl%3A+&ErrorCode=21609\",\"more_info\": \"https://www.twilio.com/docs/errors/21609\",\"request_method\": null,\"request_url\": \"\",\"sid\": \"NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications/NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json\"}],\"page\": 0,\"page_size\": 1,\"start\": 0,\"uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json?PageSize=1&Page=0\"}" )); var response = NotificationResource.Read(client: twilioRestClient); Assert.NotNull(response); }
public void TestFetchResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.OK, "{\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"api_version\": \"2008-08-01\",\"call_sid\": \"CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"date_created\": \"Mon, 13 Sep 2010 20:02:01 +0000\",\"date_updated\": \"Mon, 13 Sep 2010 20:02:01 +0000\",\"error_code\": \"11200\",\"log\": \"0\",\"message_date\": \"Mon, 13 Sep 2010 20:02:00 +0000\",\"message_text\": \"EmailNotification=false&LogLevel=ERROR&sourceComponent=12000&Msg=&httpResponse=500&ErrorCode=11200&url=http%3A%2F%2Fvoiceforms4000.appspot.com%2Ftwiml\",\"more_info\": \"http://www.twilio.com/docs/errors/11200\",\"request_method\": \"get\",\"request_url\": \"https://voiceforms4000.appspot.com/twiml/9436/question/0\",\"request_variables\": \"AccountSid=ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&CallStatus=in-progress&ToZip=94937&ToCity=INVERNESS&ToState=CA&Called=%2B14156694923&To=%2B14156694923&ToCountry=US&CalledZip=94937&Direction=inbound&ApiVersion=2010-04-01&Caller=%2B17378742833&CalledCity=INVERNESS&CalledCountry=US&CallSid=CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa&CalledState=CA&From=%2B17378742833\",\"response_body\": \"blah blah\",\"response_headers\": \"Date=Mon%2C+13+Sep+2010+20%3A02%3A00+GMT&Content-Length=466&Connection=close&Content-Type=text%2Fhtml%3B+charset%3DUTF-8&Server=Google+Frontend\",\"sid\": \"NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications/NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json\"}" )); var response = NotificationResource.Fetch("NOXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", client: twilioRestClient); Assert.NotNull(response); }
public void TestFetchResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.OK, "{\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"chat_service_sid\": \"ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"log_enabled\": false,\"added_to_conversation\": {\"enabled\": true,\"template\": \"notifications.added_to_conversation.template\",\"sound\": \"ring\"},\"new_message\": {\"enabled\": true,\"template\": \"notifications.new_message.template\",\"badge_count_enabled\": false,\"sound\": \"ring\"},\"removed_from_conversation\": {\"enabled\": true,\"template\": \"notifications.removed_from_conversation.template\",\"sound\": \"ring\"},\"url\": \"https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Configuration/Notifications\"}" )); var response = NotificationResource.Fetch("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", client: twilioRestClient); Assert.NotNull(response); }
public void TestReadEmptyResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.OK, "{\"end\": 0,\"first_page_uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json?PageSize=1&Page=0\",\"next_page_uri\": null,\"notifications\": [],\"page\": 0,\"page_size\": 1,\"previous_page_uri\": null,\"start\": 0,\"uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json?PageSize=1&Page=0\"}" )); var response = NotificationResource.Read(client: twilioRestClient); Assert.NotNull(response); }
public void TestCreateDirectNotificationResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.Created, "{\"sid\": \"NOb8021351170b4e1286adaac3fdd6d082\",\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"service_sid\": \"IS699b53e02da45a1ba9d13b7d7d2766af\",\"date_created\": \"2016-03-24T23:42:28Z\",\"identities\": [],\"tags\": [],\"segments\": [],\"priority\": \"high\",\"ttl\": 2419200,\"title\": null,\"body\": \"body\",\"sound\": null,\"action\": null,\"data\": null,\"apn\": null,\"fcm\": null,\"gcm\": null,\"sms\": null,\"facebook_messenger\": null,\"alexa\": null}" )); var response = NotificationResource.Create("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", client: twilioRestClient); Assert.NotNull(response); }
static void Main(string[] args) { // Find your Account Sid and Token at twilio.com/console const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; TwilioClient.Init(accountSid, authToken); var notification = NotificationResource.Create( identity: Promoter.ListOfOne("Identity"), pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(notification.Sid); }
public virtual NotificationResource CreateNotification(string identity) { // there is only one identity/device this notification will be sent // to. However, this method requires a list. In case there is more than one. var identities = new List <string>() { identity }; return(NotificationResource.Create( _appSettings.TWILIO_NOTIFICATION_SERVICE_SID, identities, body: $"Hello, {identity}!" )); }
public void TestReadFullResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.OK, "{\"notifications\": [{\"account_sid\": \"ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"api_version\": \"2008-08-01\",\"call_sid\": \"CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"date_created\": \"Tue, 18 Aug 2015 08:46:56 +0000\",\"date_updated\": \"Tue, 18 Aug 2015 08:46:57 +0000\",\"error_code\": \"15003\",\"log\": \"1\",\"message_date\": \"Tue, 18 Aug 2015 08:46:56 +0000\",\"message_text\": \"statusCallback=http%3A%2F%2Fexample.com%2Ffoo.xml&ErrorCode=15003&LogLevel=WARN&Msg=Got+HTTP+404+response+to+http%3A%2F%2Fexample.com%2Ffoo.xml\",\"more_info\": \"https://www.twilio.com/docs/errors/15003\",\"request_method\": null,\"request_url\": \"\",\"sid\": \"NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications/NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json\"}],\"page\": 0,\"page_size\": 50,\"previous_page_uri\": null,\"end\": 0,\"first_page_uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json?PageSize=1&Page=0\",\"next_page_uri\": null,\"start\": 0,\"uri\": \"/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json\"}" )); var response = NotificationResource.Read("CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", client: twilioRestClient); Assert.NotNull(response); }
public void TestDeleteResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.NoContent, "null" )); var response = NotificationResource.Delete("NOaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", client: twilioRestClient); Assert.NotNull(response); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/console const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; TwilioClient.Init(accountSid, authToken); var notifications = NotificationResource.Read(); foreach (var notification in notifications) { Console.WriteLine(notification.MessageText); } }
static void Main(string[] args) { // Find your Account Sid and Token at twilio.com/console const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; TwilioClient.Init(accountSid, authToken); var notification = NotificationResource.Create( apn: "{\"aps\" : { \"alert\": {\"title\":\"Bob alert\",\"body\" :\"Bob, you just received a badge\"}, \"badge\" : 1 }}", identity: Promoter.ListOfOne("00000001"), pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ); Console.WriteLine(notification.Sid); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/console // To set up environmental variables, see http://twil.io/secure const string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID"); const string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN"); TwilioClient.Init(accountSid, authToken); var notifications = NotificationResource.Read(log: 1); foreach (var notification in notifications) { Console.WriteLine(notification.RequestUrl); } }
public static OutboundComm CreateNotification (Organization organization, NotificationResource notification) { return CreateNotification(organization, notification.ToString()); }
public static OutboundComm CreateNotificationFinancialValidationNeeded (Organization organization, double amountRequested, NotificationResource notification) { NotificationPayload payload = new NotificationPayload(notification.ToString()); payload.Strings[NotificationString.CurrencyCode] = organization.Currency.Code; payload.Strings[NotificationString.OrganizationName] = organization.Name; payload.Strings[NotificationString.BudgetAmountFloat] = amountRequested.ToString(CultureInfo.InvariantCulture); OutboundComm comm = OutboundComm.Create(null, null, organization, CommResolverClass.Unknown, null, CommTransmitterClass.CommsTransmitterMail, new PayloadEnvelope(payload).ToXml(), OutboundCommPriority.Low); People validators = organization.ValidatingPeople; foreach (Person validator in validators) { comm.AddRecipient(validator); } comm.Resolved = true; return comm; }
public static OutboundComm CreateNotificationOfFinancialValidation(FinancialAccount budget, Person concernedPerson, double amountRequested, string purpose, NotificationResource notification) { NotificationPayload payload = new NotificationPayload(notification.ToString()); payload.Strings[NotificationString.CurrencyCode] = budget.Organization.Currency.Code; payload.Strings[NotificationString.OrganizationName] = budget.Organization.Name; payload.Strings[NotificationString.BudgetAmountFloat] = amountRequested.ToString(CultureInfo.InvariantCulture); payload.Strings[NotificationString.RequestPurpose] = purpose; payload.Strings[NotificationString.BudgetName] = budget.Name; payload.Strings[NotificationString.ConcernedPersonName] = concernedPerson.Canonical; OutboundComm comm = OutboundComm.Create(null, null, budget.Organization, CommResolverClass.Unknown, null, CommTransmitterClass.CommsTransmitterMail, new PayloadEnvelope(payload).ToXml(), OutboundCommPriority.Low); comm.AddRecipient(concernedPerson); comm.Resolved = true; return comm; }
public static OutboundComm CreateNotificationAttestationNeeded(FinancialAccount budget, Person concernedPerson, string supplier, double amountRequested, string purpose, NotificationResource notification) { NotificationPayload payload = new NotificationPayload(notification.ToString()); payload.Strings[NotificationString.CurrencyCode] = budget.Organization.Currency.Code; payload.Strings[NotificationString.OrganizationName] = budget.Organization.Name; payload.Strings[NotificationString.BudgetAmountFloat] = amountRequested.ToString(CultureInfo.InvariantCulture); payload.Strings[NotificationString.RequestPurpose] = purpose; payload.Strings[NotificationString.Description] = purpose; payload.Strings[NotificationString.Supplier] = supplier; payload.Strings[NotificationString.BudgetName] = budget.Name; payload.Strings[NotificationString.ConcernedPersonName] = concernedPerson.Canonical; OutboundComm comm = OutboundComm.Create(null, null, budget.Organization, CommResolverClass.Unknown, null, CommTransmitterClass.CommsTransmitterMail, new PayloadEnvelope(payload).ToXml(), OutboundCommPriority.Low); if (budget.OwnerPersonId == 0) { comm.AddRecipient(Person.FromIdentity(1)); // Add admin - not good, should be org admins // HACK // TODO } else { comm.AddRecipient(budget.Owner); } comm.Resolved = true; return comm; }