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);
    }
    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);
    }
    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 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);
    }
    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);
    }
Example #6
0
    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);
    }
    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);
    }
Example #8
0
    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);
    }
Example #9
0
    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);
    }
        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);
        }
Example #11
0
    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}!"
                       ));
        }
    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 Token at twilio.com/console
        const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        const string authToken  = "your_auth_token";

        TwilioClient.Init(accountSid, authToken);

        var notification = NotificationResource.Create(
            body: "Hello Bob",
            toBinding: Promoter.ListOfOne("{\"binding_type\":\"sms\",\"address\":\"+15555555555\"}"),
            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
        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> {
            "Bob"
        },
                                                       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 notification = NotificationResource.Create(
            body: "Hello New Users",
            segment: Promoter.ListOfOne("new_user"),
            tag: Promoter.ListOfOne("preferred_device"),
            pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            );

        Console.WriteLine(notification.Sid);
    }
Example #17
0
    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,
            toBinding: new List <string> {
            "{\"binding_type\":\"sms\",\"address\":\"+1651000000000\"}"
        }
            body: "Knok-Knok! This is your first Notify SMS");

        Console.WriteLine(notification.Sid);
    }
    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,
            toBinding: new List <string> {
            "{\"binding_type\":\"sms\",\"address\":\"+15555555555\"}",
            "{\"binding_type\":\"facebook-messenger\",\"address\":\"123456789123\"}"
        },
            body: "Hello Bob");

        Console.WriteLine(notification.Sid);
    }
Example #19
0
    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"
        },
            body: "Hello Bob");

        Console.WriteLine(notification.Sid);
    }
Example #20
0
    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,
            body: "A new Rogue One trailer has been released!",
            tag: new List <string> {
            "rogue_one"
        },
            sms: "{\"from\":\"+16516667788\"}");

        Console.WriteLine(notification.Sid);
    }
Example #21
0
    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,
            toBinding: new List <string> {
            "{\"binding_type\":\"sms\",\"address\":\"+1651000000000\"}"
        }
            body: "Knok-Knok! This is your first Notify SMS");

        Console.WriteLine(notification.Sid);
    }
        public void TestCreateRequest()
        {
            var twilioRestClient = Substitute.For <ITwilioRestClient>();
            var request          = new Request(
                HttpMethod.Post,
                Twilio.Rest.Domain.Notify,
                "/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications",
                ""
                );

            twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content"));

            try
            {
                NotificationResource.Create("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", client: twilioRestClient);
                Assert.Fail("Expected TwilioException to be thrown for 500");
            }
            catch (ApiException) {}
            twilioRestClient.Received().Request(request);
        }
Example #23
0
    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 notification = NotificationResource.Create(
            body: "Knok-Knok! This is your first Notify SMS",
            identity: 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 notification = NotificationResource.Create(
            apn: "{\"aps\":{\"alert\":{\"title\":\"Short title for Watch.\"}}}",
            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!\"}}",
            identity: Promoter.ListOfOne("00000001"),
            title: "Generic loooooooong title for all Bindings",
            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,
            toBinding: new List <string> {
            "{\"binding_type\":\"sms\",\"address\":\"+15555555555\"}",
            "{\"binding_type\":\"facebook-messenger\",\"address\":\"123456789123\"}"
        },
            body: "Hello Bob");

        Console.WriteLine(notification.Sid);
    }
Example #26
0
    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,
            title: "Generic loooooooong title for all Bindings",
            body: "This is the body for all Bindings",
            identity: new List <string> {
            "Bob"
        },
            gcm: "{\"notification\":{\"tag\":\"MyTag\"}}",
            apn: "{\"aps\":{\"title\":\"Short title for Watch.\"}}");

        Console.WriteLine(notification.Sid);
    }
Example #27
0
        /// <summary>
        /// Notifies users via SMS about the latest stock price.
        /// </summary>
        /// <param name="stock">
        /// The particular stock whose target price was met.
        /// </param>
        /// <param name="latestPrice">
        /// The latest stock price.
        /// </param>
        /// <returns>
        /// Returns a NotificationResource with info on the request. Not interesting.
        /// </returns>
        public virtual NotificationResource NotifyUsers(Stock stock, double latestPrice)
        {
            var userIdentities = new List <string>();
            List <RequestRecord> matchingStocks = context.Requests
                                                  .Where(s => s.RequestId == stock.RequestId)
                                                  .ToList();

            foreach (var match in matchingStocks)
            {
                userIdentities.Add(match.TwilioBinding);
            }

            TwilioClient.Init(accountSid, authToken);
            NotificationResource notification = NotificationResource.Create(
                serviceSid,
                identity: userIdentities,
                body: $"${stock.Symbol.ToUpper()} has exceeded target price of {stock.Price} and has reached price ${latestPrice}"
                );

            return(notification);
        }
Example #28
0
    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 identity = new List <string> {
            "00000001"
        };

        var notification = NotificationResource.Create(
            body: "Hello Bob",
            identity: identity,
            pathServiceSid: "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            );

        Console.WriteLine(notification.Sid);
    }
    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,
            body: "Hello New Users",
            segment: new List <string> {
            "new_user"
        },
            tag: new List <string> {
            "preferred_device"
        });

        Console.WriteLine(notification.Sid);
    }
Example #30
0
    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"
        },
            apn: "{\"aps\" : " +
            "{ \"alert\": " +
            "{\"title\":\"Bob alert\"," +
            "\"body\" : \"Bob, you just received a badge\"}, " +
            "\"badge\" : 1 }}");

        Console.WriteLine(notification.Sid);
    }