Exemple #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("======== Mixin C# SDK Test ========= \n");
            MixinApi mixinApi = new MixinApi();

            mixinApi.Init(USRCONFIG.ClientId, USRCONFIG.ClientSecret, USRCONFIG.SessionId, USRCONFIG.PinToken, USRCONFIG.PrivateKey);

            Console.WriteLine("======== Initiation Finished ========= \n");

            Console.WriteLine("======== Test Create PIN ===========\n");

            //Console.WriteLine(mixinApi.CreatePIN(USRCONFIG.PinCode, "123456").ToString());

            Console.WriteLine();

            //Console.WriteLine(mixinApi.CreatePIN("123456", USRCONFIG.PinCode).ToString());

            Console.WriteLine("\n\n======== Test Verify PIN ===========\n");

            //Console.WriteLine(mixinApi.VerifyPIN(USRCONFIG.PinCode).ToString());


            Console.WriteLine("\n\n======== Test Deposit ===========\n");
            Console.WriteLine(mixinApi.Deposit("3596ab64-a575-39ad-964e-43b37f44e8cb").ToString());


            Console.WriteLine("\n\n======== Test Read Assets ===========\n");

            var assets = mixinApi.ReadAssets();

            foreach (var asset in assets)
            {
                Console.WriteLine(asset.ToString());
                Console.WriteLine();
            }

            Console.WriteLine("\n\n======== Test Read Asset ===========\n");
            Console.WriteLine(mixinApi.ReadAsset("6cfe566e-4aad-470b-8c9a-2fd35b49c68d"));

            Console.WriteLine("\n\n======== Test Search Assest ===========\n");

            assets = mixinApi.SearchAssets("CNB");
            foreach (var asset in assets)
            {
                Console.WriteLine(asset.ToString());
                Console.WriteLine();
            }

            Console.WriteLine("\n\n======== Test Network Asset ===========\n");
            Console.WriteLine(mixinApi.NetworkAsset("965e5c6e-434c-3fa9-b780-c50f43cd955c"));

            Console.WriteLine("\n\n======== Test Top Assets ===========\n");
            var topasset = mixinApi.TopAssets();

            foreach (var asset in topasset)
            {
                Console.WriteLine(asset.ToString());
                Console.WriteLine();
            }

            Console.WriteLine("\n\n======== Test Network Snapshot don't auth ===========\n");
            Console.WriteLine(mixinApi.NetworkSnapshot("85b8c435-1ef6-4f2a-85f9-8def2a852473", false));


            Console.WriteLine("\n\n======== Test Network Snapshot auth ===========\n");
            Console.WriteLine(mixinApi.NetworkSnapshot("85b8c435-1ef6-4f2a-85f9-8def2a852473", true));

            Console.WriteLine("\n\n======== Test Network Snapshots ===========\n");

            var snaps = mixinApi.NetworkSnapshots(2, "2019-01-02T15:04:05.999999999-07:00", null, null, false);

            foreach (var sn in snaps)
            {
                Console.WriteLine(sn.ToString());
                Console.WriteLine();
            }

            snaps = mixinApi.NetworkSnapshots(2, "2019-01-02T15:04:05.999999999-07:00", null, null, true);
            foreach (var sn in snaps)
            {
                Console.WriteLine(sn.ToString());
                Console.WriteLine();
            }

            Console.WriteLine("\n\n======== External Transactions ===========\n");
            var ts = mixinApi.ExternalTransactions("6cfe566e-4aad-470b-8c9a-2fd35b49c68d", null, null, null, 10, null);

            foreach (var t in ts)
            {
                Console.WriteLine(t.ToString());
                Console.WriteLine();
            }

            Console.WriteLine("\n\n======== Test Create Address ===========\n");
            //var addr = mixinApi.CreateAddress("965e5c6e-434c-3fa9-b780-c50f43cd955c", "0xe6Bf2C2E8f3243dF46308ca472038eA9Fa1bc42C", "CNB withdraw", null, null, USRCONFIG.PinCode);
            //Console.WriteLine(addr);

            Console.WriteLine("\n\n======== Test Create Address ===========\n");
            //addr = mixinApi.CreateAddress("965e5c6e-434c-3fa9-b780-c50f43cd955c", "0x078C5AF6C8Ab533b8ef7FAb822B5B5f70A9d1c35", "CNB withdraw123", null, null, USRCONFIG.PinCode);
            //Console.WriteLine(addr);

            Console.WriteLine("\n\n======== Test Read Address ===========\n");
            //Console.WriteLine(mixinApi.ReadAddress(addr.address_id));

            Console.WriteLine("\n\n======== Test Delete Address ===========\n");
            //Console.WriteLine(mixinApi.DeleteAddress(USRCONFIG.PinCode, addr.address_id));

            Console.WriteLine("\n\n======== Test Withdrawal Addresses ===========\n");
            var addrlist = mixinApi.WithdrawalAddresses("965e5c6e-434c-3fa9-b780-c50f43cd955c");

            foreach (var a in addrlist)
            {
                Console.WriteLine(a.ToString());
                Console.WriteLine();
            }

            Console.WriteLine("\n\n======== Test Withdrawal  ===========\n");
            //Console.WriteLine(mixinApi.Withdrawal(addrlist[0].address_id, "100", USRCONFIG.PinCode, System.Guid.NewGuid().ToString(), "Test withdraw"));


            Console.WriteLine("\n\n======== Test Search User  ===========\n");
            var u = mixinApi.SearchUser("31243");

            Console.WriteLine(u);

            Console.WriteLine("\n\n======== Test Read User  ===========\n");
            Console.WriteLine(mixinApi.ReadUser("cf0b9c0e-a80a-4044-a6dc-797400c148d7"));

            Console.WriteLine("\n\n======== Test Transfer  ===========\n");
            //Console.WriteLine(mixinApi.Transfer("965e5c6e-434c-3fa9-b780-c50f43cd955c", "cf0b9c0e-a80a-4044-a6dc-797400c148d7", "100", USRCONFIG.PinCode, System.Guid.NewGuid().ToString(), "Test Transfer"));


            Console.WriteLine("\n\n======== Test Verify Payment ===========\n");
            Console.WriteLine(mixinApi.VerifyPayment("965e5c6e-434c-3fa9-b780-c50f43cd955c", "cf0b9c0e-a80a-4044-a6dc-797400c148d7", "100", "414c95cc-d695-48df-b23b-00815b21ed00"));

            Console.WriteLine("\n\n======== Test Read Transfer ===========\n");
            Console.WriteLine(mixinApi.ReadTransfer("414c95cc-d695-48df-b23b-00815b21ed00"));

            Console.WriteLine("\n\n======== Test APP User ===========\n");

            var kpgen = new RsaKeyPairGenerator();

            kpgen.Init(new KeyGenerationParameters(new SecureRandom(new CryptoApiRandomGenerator()), 1024));

            var keyPair = kpgen.GenerateKeyPair();
            AsymmetricKeyParameter privateKey = keyPair.Private;
            AsymmetricKeyParameter publicKey  = keyPair.Public;

            SubjectPublicKeyInfo info = SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(keyPair.Public);
            string pk = Convert.ToBase64String(info.GetDerEncoded());


            var user = mixinApi.APPUser("Csharp" + (new Random().Next() % 100) + "test", pk);

            Console.WriteLine(user);

            Console.WriteLine("\n\n======== Test Read Profile ===========\n");
            Console.WriteLine(mixinApi.ReadProfile());

            Console.WriteLine("\n\n======== Test Update Profile ===========\n");
            Console.WriteLine(mixinApi.UpdateProfile("mixin_csharp_sdk_demo", "iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAAK/INwWK6QAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QA/wD/AP+gvaeTAAAAB3RJTUUH4wEJAgwnFleLvwAAEWhJREFUaN61mXmMXVd9xz/nnLu8bfbNY4+dOCZ2bJOoIRskbKLQQJpUgbD8QdWyFpWyCRpQoSrQShVFLFUqBahUGkGRKEVBVgqEUoJLgCQkBBLHOI4dO9jO2GN7tjdvu/csv/5x74xnbIdCoEf6+ln33Tnn+z2/9ZyneJZj3+GnOVlbzwXMcdT3c7IHTSvsHNLRTE/qCjUoUAMiBQ4lbQ0LG+u68/NZ7/pixURFWO/nOK6HGOmd4OLNF/zGPNSzIX/P4SYpjhOhxiO9lJcP2eGWU8/NA1d54TLgQqMYU4qKAiPgRegGOIlwONY8kmge7Itk74OtePGiKGNSt8iJuPaCwf8/Ad974jSTeol9YZzXXPiQuuvo1dss6mYn6qaA2hlrNVCLoBYpYg1GgVIgAl4gD0LXQdcLLjCvFY/GyF2pDrte9YPKwW+9OONVU10ePpVyxWTtdyfggaNNZrqQ6MBB28/GqLMpw7zNinpj7rkoMYqRiqY/KYgvTyrnWUiAPEAzF2azgA9IxXAg0XJHPeKOp9r6+Na+gBXF1qjJBZNjv52Ag0emua89SEUHptI8Ppqlr85Ff7DruSL3wmhVM1nXxPr/3gs5a8HcC9OdwHwmVA1Si9R9VcMnLhky3zq44HzLKV5/ceXZC3jsiUP8V2eK9WlOI1aDTcuHup53tqz0O4EL+g3jNfNrmfoZRYkw0wkcbXlSrRhI9Vwt4jOjsb9t0aqlJae5OG1x9ebzW+IZBXzz8TmezlOqRmhEYWLJ6k+2nPxxMw/ai+KiQcPEb0l+9Tje9jzV9CRGMZRq15+ofxmJ3EdaXs9mQXORm+bKnc855++i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FRodW1iOjpJbWFnZTo6V2lkdGgAMTI40I0R3QAAABl0RVh0VGh1bWI6Ok1pbWV0eXBlAGltYWdlL3BuZz+yVk4AAAAXdEVYdFRodW1iOjpNVGltZQAxNTQ2OTcxMTU59OK0DQAAABJ0RVh0VGh1bWI6OlNpemUAMTYxODVCiLvlAQAAAGJ0RVh0VGh1bWI6OlVSSQBmaWxlOi8vL2hvbWUvd3d3cm9vdC9uZXdzaXRlL3d3dy5lYXN5aWNvbi5uZXQvY2RuLWltZy5lYXN5aWNvbi5jbi9maWxlcy8xMDgvMTA4NjU1NS5wbmcDuUg9AAAAAElFTkSuQmCC"));

            Console.WriteLine("\n\n======== Test Update Perference ===========\n");
            Console.WriteLine(mixinApi.UpdatePerference("CONTACTS", "CONTACTS"));
            Console.WriteLine(mixinApi.UpdatePerference("EVERYBODY", "EVERYBODY"));

            Console.WriteLine("\n\n======== Test Rotate User's QR ===========\n");
            Console.WriteLine(mixinApi.RotateUserQR());

            Console.WriteLine("\n\n======== Test Friends ===========\n");
            var friends = mixinApi.Friends();

            foreach (var f in friends)
            {
                Console.WriteLine(f);
                Console.WriteLine();
            }

            Console.WriteLine("\n\n======== Test Create Attachment ===========\n");
            Console.WriteLine(mixinApi.CreateAttachment());


            Console.WriteLine("\n\n======== Test Create Conversation ===========\n");

            var users = new List <ParticipantAction>();

            users.Add(new ParticipantAction {
                action = "ADD", role = "", user_id = u.user_id
            });
            Console.WriteLine(mixinApi.CreateConversation("GROUP", users));

            Console.WriteLine(mixinApi.CreateConversation("CONTACT", users));

            Console.WriteLine("\n\n======== Test Read Conversation ===========\n");
            Console.WriteLine(mixinApi.ReadConversation("fd72abcd-b080-3e0e-bfea-a0b1282b4bd0"));



            mixinApi.WebSocketConnect(HandleOnRecivedMessage).Wait();

            mixinApi.StartRecive();

            do
            {
                var msg = Console.ReadLine();
                mixinApi.SendTextMessage("fd72abcd-b080-3e0e-bfea-a0b1282b4bd0", msg).Wait();
            } while (true);
        }