Пример #1
0
        public void testEnrollIdentity()
        {
            XooaClient xooaClient = new XooaClient();

            xooaClient.setApiToken(XooaConstants.API_TOKEN);

            try {
                var attrs = new List <attrs>();
                attrs.Add(new attrs("sample", "value", false));

                IdentityRequest request = new IdentityRequest("Kavi", "r", true, attrs);

                IdentityResponse identityResponse = xooaClient.enrollIdentity(request);

                identityResponse.display();

                Assert.IsNotEmpty(identityResponse.getId());

                Assert.IsNotEmpty(identityResponse.getIdentityName());

                Assert.IsNotNull(identityResponse.getCanManageIdentities());

                Assert.IsNotEmpty(identityResponse.getCreatedAt());

                Assert.IsNotEmpty(identityResponse.getAccess());

                Assert.IsNotEmpty(identityResponse.getAttrsList());
            } catch (XooaRequestTimeoutException xrte) {
                Assert.IsNotEmpty(xrte.getResultId());

                Assert.IsNotEmpty(xrte.getResultUrl());
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            //WebSocket socket = new WebSocket();
            //socket.subscribeAllEvents();

            XooaClient client = new XooaClient();

            client.setApiToken("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcGlLZXkiOiJIU0E0SkZRLUFHUjQ0NUstSkcwOUMzMi1CUDgyVDRZIiwiQXBpU2VjcmV0IjoiS2JZSzdDVHVaWThZSk9aIiwiUGFzc3BocmFzZSI6IjA1N2M2ODM3NjgyZDBjODBkMTllYTk0NjliYzI0MzczIiwiaWF0IjoxNTQzOTkzNjIzfQ.BkNZ6N5FfjCdYsAOYisFSelUDftDhnY3f8OYf4EgXYc");

            //client.subscribeAllEvents((data) => {
            //    Console.WriteLine("data - ", data.ToString());
            //});

            try {
                Console.WriteLine("----- Start -----");

                Console.WriteLine("----- Validate -----");

                client.validate().display();

                Console.WriteLine();

                Console.WriteLine("----- Current Block -----");

                client.getCurrentBlock().display();

                Console.WriteLine();

                Console.WriteLine("----- Current Block Async -----");

                PendingTransactionResponse currentBlockResponse = client.getCurrentBlockAsync();
                currentBlockResponse.display();

                Console.WriteLine();

                Console.WriteLine("----- Current Block From Result Id -----");

                client.getResultForCurrentBlock(currentBlockResponse.getResultId()).display();

                Console.WriteLine();

                Console.WriteLine("----- Block by Number -----");

                client.getBlockByNumber("10").display();

                Console.WriteLine();

                Console.WriteLine("----- Block by NUmber Async -----");

                PendingTransactionResponse blockByNumber = client.getBlockByNumberAsync("10");
                blockByNumber.display();

                Console.WriteLine();

                Console.WriteLine("----- Block Data from Result Id -----");

                client.getResultForBlockByNumber(blockByNumber.getResultId()).display();

                Console.WriteLine();

                Console.WriteLine("----- Invoke -----");

                string[] invokeargs = { "argsx", "200" };

                client.invoke("set", invokeargs).display();

                Console.WriteLine();

                Console.WriteLine("----- Query -----");

                string[] queryArgs = { "argsx" };

                client.query("get", queryArgs).display();

                Console.WriteLine();

                Console.WriteLine("----- Invoke Async -----");

                string[] invokeargs2 = { "argsx", "400" };

                PendingTransactionResponse invokeResponse = client.invokeAsync("set", invokeargs2);
                invokeResponse.display();
                Thread.Sleep(4000);

                Console.WriteLine();

                Console.WriteLine("----- Invoke from Result Id -----");

                client.getResultForInvoke(invokeResponse.getResultId()).display();

                Console.WriteLine();

                Console.WriteLine("----- Query Async -----");

                PendingTransactionResponse queryResponse = client.queryAsync("get", queryArgs);
                queryResponse.display();

                Console.WriteLine();

                Console.WriteLine("----- Query from Result ID -----");

                client.getResultForQuery(queryResponse.getResultId()).display();

                Console.WriteLine();

                Console.WriteLine("----- Current Identity -----");

                client.currentIdentity().display();

                Console.WriteLine();

                Console.WriteLine("----- Get All Identities -----");

                List <IdentityResponse> identities = client.getIdentities();
                foreach (IdentityResponse identity in identities)
                {
                    identity.display();
                    Console.WriteLine();
                }

                Console.WriteLine("----- Enroll Identity -----");

                attrs Attrib = new attrs("Name", "Value", false);

                List <attrs> attributes = new List <attrs>();
                attributes.Add(Attrib);

                IdentityRequest idReq = new IdentityRequest("Kavi", "r", false, attributes);

                IdentityResponse newIdentity1 = client.enrollIdentity(idReq);
                newIdentity1.display();

                Console.WriteLine();

                Console.WriteLine("----- Enroll Identity Async -----");

                PendingTransactionResponse pendingIdentity = client.enrollIdentityAsync(idReq);
                pendingIdentity.display();

                Console.WriteLine();

                Console.WriteLine("----- New Identity from Result Id -----");

                IdentityResponse newIdentity2 = client.getResultForIdentity(pendingIdentity.getResultId());
                newIdentity2.display();

                Console.WriteLine();

                Console.WriteLine("----- Regenerate New API Token -----");

                IdentityResponse newTokenId = client.regenerateIdentityApiToken(newIdentity1.getId());
                newTokenId.display();

                Console.WriteLine();

                Console.WriteLine("----- Get Identity -----");

                client.getIdentity(newTokenId.getId()).display();

                Console.WriteLine();

                Console.WriteLine("----- Delete Identity -----");

                string deleted1 = client.deleteIdentity(newIdentity2.getId());
                Console.WriteLine(deleted1);
                string deleted2 = client.deleteIdentity(newIdentity1.getId());
                Console.WriteLine(deleted2);

                Console.WriteLine();

                Console.WriteLine("----- End -----");
            } catch (XooaApiException xae) {
                xae.display();
            } catch (XooaRequestTimeoutException xrte) {
                xrte.display();
            }
            //Console.ReadLine();
        }