Beispiel #1
0
 public void ThrowsForNullOAuthRefreshToken()
 {
     Assert.Throws <ArgumentNullException>(
         () => TransactClient.CreateOAuthOnly(
             1,
             "00000000-0000-0000-0000-000000000000",
             "00000000-0000-0000-0000-000000000000",
             null));
 }
Beispiel #2
0
 public void ThrowsForNullOAuthClientSecret()
 {
     Assert.Throws <ArgumentNullException>(
         () => TransactClient.CreateOAuthOnly(
             1,
             "00000000-0000-0000-0000-000000000000",
             null,
             "00000000-0000-0000-0000-000000000000"));
 }
Beispiel #3
0
            public void SetsPodNumber()
            {
                var client = TransactClient.CreateOAuthOnly(
                    1,
                    "00000000-0000-0000-0000-000000000001",
                    "00000000-0000-0000-0000-000000000002",
                    "00000000-0000-0000-0000-000000000003");

                Assert.Equal(1, client.Configuration.PodNumber);
            }
Beispiel #4
0
            public void SetsOAuthRefreshToken()
            {
                var client = TransactClient.CreateOAuthOnly(
                    1,
                    "00000000-0000-0000-0000-000000000001",
                    "00000000-0000-0000-0000-000000000002",
                    "00000000-0000-0000-0000-000000000003");

                Assert.Equal(
                    "00000000-0000-0000-0000-000000000003",
                    client.Configuration.OAuthRefreshToken);
            }
Beispiel #5
0
            public void SetsOAuthClientSecret()
            {
                var client = TransactClient.CreateOAuthOnly(
                    1,
                    "00000000-0000-0000-0000-000000000001",
                    "00000000-0000-0000-0000-000000000002",
                    "00000000-0000-0000-0000-000000000003");

                Assert.Equal(
                    "00000000-0000-0000-0000-000000000002",
                    client.Configuration.OAuthClientSecret);
            }
Beispiel #6
0
        private async static Task MainAsync(string[] args)
        {
            var client = TransactClient.Create(
                -1, // Change this to the correct pod number
                "username",
                "password");

            var oAuthClient = TransactClient.CreateOAuthOnly(
                -1, // Change this to the correct pod number
                oAuthClientId: "00000000-0000-0000-0000-000000000000",
                oAuthClientSecret: "00000000-0000-0000-0000-000000000000",
                oAuthRefreshToken: "00000000-0000-0000-0000-000000000000");

            var sendMessageResponse = client.SendMessage(GetTestMessage("SendMessage"));

            Console.WriteLine("sendMessageResponse:");
            Console.WriteLine(sendMessageResponse.RawResponse);
            Console.WriteLine();

            var sendMessageAsyncResponse = await client.SendMessageAsync(GetTestMessage("SendMessageAsync"));

            Console.WriteLine("sendMessageAsyncResponse:");
            Console.WriteLine(sendMessageAsyncResponse.RawResponse);
            Console.WriteLine();

            var sendMessageOAuthResponse = oAuthClient.SendMessage(GetTestMessage("SendMessage-UsingOAuth"));

            Console.WriteLine("sendMessageOAuthResponse:");
            Console.WriteLine(sendMessageOAuthResponse.RawResponse);
            Console.WriteLine();

            var sendMessageAsyncOAuthResponse = await oAuthClient.SendMessageAsync(GetTestMessage("SendMessageAsync-UsingOAuth"));

            Console.WriteLine("sendMessageAsyncOAuthResponse:");
            Console.WriteLine(sendMessageAsyncOAuthResponse.RawResponse);
            Console.WriteLine();

            var sendMessageBatchResponse = client.SendMessageBatch(GetTestMessage("SendMessageBatch"));

            Console.WriteLine("sendMessageBatchResponse:");
            Console.WriteLine(sendMessageBatchResponse.Single());
            Console.WriteLine();

            var getStatusOfMessageBatchStart = DateTime.Now;

            while (true)
            {
                try
                {
                    var getStatusOfMessageBatchResponse =
                        client.GetStatusOfMessageBatch(sendMessageBatchResponse.Single());

                    Console.WriteLine("getStatusOfMessageBatchResponse:");
                    Console.WriteLine(getStatusOfMessageBatchResponse.RawResponse);
                    Console.WriteLine();

                    break;
                }
                catch (TransactClientException ex)
                {
                    if (ex.Message != string.Format(
                            "Requested file transact/status/{0} does not currently exist.",
                            sendMessageBatchResponse.Single()))
                    {
                        throw;
                    }

                    Console.WriteLine("getStatusOfMessageBatchResponse:");
                    Console.WriteLine(ex.Message);
                    Console.WriteLine();

                    Console.WriteLine(string.Format("Sleeping for {0}...", SleepDuration.ToString()));
                    Thread.Sleep(SleepDuration);
                    Console.WriteLine();
                }

                if (getStatusOfMessageBatchStart.Add(Timeout) < DateTime.Now)
                {
                    Console.WriteLine(string.Format(
                                          "getStatusOfMessageBatchResponse: Response timed out after {0}.",
                                          Timeout.ToString()));
                    break;
                }
            }

            var sendMessageBatchAsyncResponse = await client.SendMessageBatchAsync(GetTestMessage("SendMessageBatchAsync"));

            Console.WriteLine("sendMessageBatchAsyncResponse:");
            Console.WriteLine(sendMessageBatchAsyncResponse.Single());
            Console.WriteLine();

            var getStatusOfMessageBatchAsyncStart = DateTime.Now;

            while (true)
            {
                try
                {
                    var getStatusOfMessageBatchAsyncResponse =
                        await client.GetStatusOfMessageBatchAsync(sendMessageBatchAsyncResponse.Single());

                    Console.WriteLine("getStatusOfMessageBatchAsyncResponse:");
                    Console.WriteLine(getStatusOfMessageBatchAsyncResponse.RawResponse);
                    Console.WriteLine();

                    break;
                }
                catch (TransactClientException ex)
                {
                    if (ex.Message != string.Format(
                            "Requested file transact/status/{0} does not currently exist.",
                            sendMessageBatchAsyncResponse.Single()))
                    {
                        throw;
                    }

                    Console.WriteLine("getStatusOfMessageBatchAsyncResponse:");
                    Console.WriteLine(ex.Message);
                    Console.WriteLine();

                    Console.WriteLine(string.Format("Sleeping for {0}...", SleepDuration.ToString()));
                    Thread.Sleep(SleepDuration);
                    Console.WriteLine();
                }

                if (getStatusOfMessageBatchAsyncStart.Add(Timeout) < DateTime.Now)
                {
                    Console.WriteLine(string.Format(
                                          "getStatusOfMessageBatchAsyncResponse: Response timed out after {0}.",
                                          Timeout.ToString()));
                    break;
                }
            }

            Console.WriteLine();
            Console.WriteLine("Operation completed.");
            Console.ReadLine();
        }