Beispiel #1
0
        public void Execute()
        {
            var v1 = new AssetClient(instanceUrl, accessToken);

            dynamic result = v1.Create(
                Asset(
                    ("AssetType", "Story"),
                    ("Scope", "Scope:0"),
                    ("Name", "Story 1 from Tuple")
                    ),
                Asset(
                    ("AssetType", "Story"),
                    ("Scope", "Scope:0"),
                    ("Name", "Story 2 from Tuple")
                    ),
                Asset(
                    ("AssetType", "Story"),
                    ("Scope", "Scope:0"),
                    ("Name", "Story 3 from Tuple")
                    ),
                Asset(
                    ("AssetType", "Story"),
                    ("Scope", "Scope:0"),
                    ("Name", "Story 4 from Tuple")
                    )
                );

            WriteLine("Result returned from .Create with multiple assets:");
            WriteLine(result);
        }
        public void Execute()
        {
            var v1 = new AssetClient(instanceUrl, accessToken);

            var story = v1.Create(new
            {
                AssetType = "Story",
                Scope     = "Scope:0",
                Name      = "My Story",
                Children  = new []
                {
                    new
                    {
                        AssetType = "Test",
                        Name      = "Test"
                    },
                    new
                    {
                        AssetType = "Task",
                        Name      = "Task"
                    }
                }
            });

            dynamic queriedStory = v1
                                   .Query(story.Oid)
                                   .Select("Name", "Scope")
                                   .RetrieveFirst();

            WriteLine(queriedStory.Oid);
            WriteLine(queriedStory.Name);
            WriteLine(queriedStory["Scope"].Oid);
            WriteLine(queriedStory.Scope.Oid);
        }
        public List <Story> GetAll()
        {
            List <Story> storyList = new List <Story>();

            string instanceUrl = "https://www16.v1host.com/api-examples/api/asset";
            string accessToken = "1.bndNO51GiliELZu1bbQdq3omgRI=";

            var v1 = new AssetClient(instanceUrl, accessToken);


            var assets = v1
                         .Query("Story")
                         .Select("Name", "Scope", "Estimate", "Description", "Number", "IsClosed")
                         .Retrieve();

            foreach (dynamic story in assets)
            {
                storyList.Add(new Story
                {
                    Href        = story.Oid,
                    Scope       = story.Scope.Oid,
                    Name        = story.Name,
                    Description = story.Description,
                    Number      = story.Number,
                    IsClosed    = Convert.ToBoolean(story.IsClosed)
                                  //Attachments
                                  //Owners
                });
            }

            return(storyList);
        }
Beispiel #4
0
        public void Execute()
        {
            var v1 = new AssetClient(instanceUrl, accessToken);

            dynamic newStory = v1.Create(new {
                AssetType   = "Story",
                Scope       = "Scope:1015",
                Name        = $"Test Story Scope:1015 Update scalar attribute",
                Description = "I am not going to change this description after it is set"
            });

            dynamic retrievedStory = v1.Query(newStory.Oid).Select("Name", "Description").RetrieveFirst();

            retrievedStory.Name = $"{newStory.Name} - Name updated";

            v1.Update(retrievedStory);

            dynamic updatedRetrievedStory = v1.Query(retrievedStory.Oid).Select("Name", "Description").RetrieveFirst();

            WriteLine($"{newStory.Oid} original name: {newStory.Name}");
            WriteLine($"{retrievedStory.Oid} updated name: {updatedRetrievedStory.Name}");
            WriteLine($"{newStory.Oid} original description: {newStory.Description}");
            WriteLine($"{updatedRetrievedStory.Oid} non-updated description: {updatedRetrievedStory.Description}");

            WriteLine("Now we are going to try updating the original newStory object...");

            newStory.Name = "Test Story Scope:1015 updated on original newStory object!";
            v1.Update(newStory);

            dynamic newStoryFetchedAfterUpdate = v1.Query(newStory.Oid).Select("Name").RetrieveFirst();

            WriteLine($"{newStoryFetchedAfterUpdate.Oid} updated name is: {newStoryFetchedAfterUpdate.Name}");
        }
        public void Execute()
        {
            var v1 = new AssetClient(instanceUrl, accessToken);

            dynamic results = v1
                              .Query("Epic")
                              .Where("Scope.Name", "Josh API Test")
                              .Select(
                "Name",
                From("Subs")
                .Select(
                    "Name",
                    From("Children")
                    .Select(
                        "Name", "AssetType"
                        )
                    )
                )
                              .Retrieve();

            foreach (var result in results)
            {
                WriteLine(result);
            }
        }
Beispiel #6
0
        public void Execute()
        {
            var v1 = new AssetClient(instanceUrl, accessToken);

            var assets = v1
                         .Query("Scope")
                         .Select("Name", "Description", "Status", "Members", "Workitems:Defect")
                         .Retrieve();

            foreach (dynamic scope in assets)
            {
                WriteLine(scope.Oid);
                WriteLine(scope.Description);
                WriteLine(scope.Status);
                WriteLine($"Members count: {scope.Members.Count}");
                foreach (dynamic member in scope.Members)
                {
                    WriteLine(member);
                }
                WriteLine($"Defects count: {scope["Workitems:Defect"].Count}");
                foreach (dynamic defect in scope["Workitems:Defect"])
                {
                    WriteLine(defect);
                }
                WriteLine("---");
            }

            /* Expect to produce:
             *
             * If 3 Scopes available, then:
             *
             * Scope:00001
             * First scope
             * null // when there is no Status
             * Members count: 2
             * Member:20
             * Member:90
             * Defects count: 2
             * Defect:00010
             * Defect:00011
             * ---
             * Scope:00002
             * Second scope
             * ScopeStatus:1012
             * Members count: 2
             * Member:20
             * Member:400
             * Defects count: 1
             * Defect:00012
             * ----
             * Scope:00003
             * Third scope
             * null // when there is no Status
             * Members count: 1
             * Member:20 // Always one member in this particular Multi-Value relation
             * Defects count: 0
             */
        }
Beispiel #7
0
        public WalletService(Client miyabiClient, TransactionService transactionService)
        {
            _cryptographicService = new Secp256k1EccService();
            _transactionService   = transactionService;
            var privateKey = _cryptographicService.CreatePrivateKey();

            _keyPair     = new KeyPair(privateKey);
            _assetClient = new AssetClient(miyabiClient);
        }
        /// <summary>
        /// show Asset of designated publickeyAddress
        /// </summary>
        /// <param name="client"></param>
        /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
        public static async Task <decimal> ShowAsset()
        {
            var client      = SetClient();
            var assetClient = new AssetClient(client);

            //var myaddress = new PublicKeyAddress(Utils.GetUser0KeyPair());だめ
            var myaddress = new PublicKeyAddress(PublicKey.Parse("0338f9e2e7ad512fe039adaa509f7b555fb88719144945bd94f58887d8d54fed78"));
            var result    = await assetClient.GetAssetAsync(TableName, myaddress);

            return(result.Value);
        }
        public void Execute()
        {
            var v1 = new AssetClient(instanceUrl, accessToken);

            dynamic newStory = v1.Create(new {
                AssetType = "Story",
                Scope     = "Scope:1015",
                Name      = $"Test Story Scope:1015 Create new Story with scalar attribute"
            });

            WriteLine("Created: " + newStory.Oid);
        }
Beispiel #10
0
        public void Execute()
        {
            var v1 = new AssetClient(instanceUrl, accessToken);

            dynamic epic = v1.Create(Attributes(
                                         ("AssetType", "Epic"),
                                         ("Scope", "Scope:0"),
                                         ("Name", "Epic made from a Tuple"),
                                         ("Subs", Assets(
                                              Asset(
                                                  "Story",
                                                  ("Name", "Story 1 from a Tuple"),
                                                  ("Children", Assets(
                                                       Asset("Test", ("Name", "Test 1 from a Tuple")),
                                                       Asset("Task", ("Name", "Task 1 from a Tuple"))
                                                       ))
                                                  ),
                                              Asset(
                                                  "Story",
                                                  ("Name", "Story 2 from a Tuple"),
                                                  ("Children", Assets(
                                                       Asset("Test", ("Name", "Test 2 from a Tuple")),
                                                       Asset("Task", ("Name", "Task 2 from a Tuple"))
                                                       ))
                                                  )
                                              ))
                                         ));

            WriteLine("Epic returned from .Create (which does not requery the system, but fills in Oids linearly from server response):");
            PrintEpic(epic);

            epic = v1
                   .Query(epic.Oid)
                   .Select(
                "Name",
                "Scope",
                From("Subs")
                .Select(
                    "AssetType",
                    "Name",
                    From("Children")
                    .Select(
                        "AssetType",
                        "Name"
                        )
                    )
                )
                   .RetrieveFirst();

            WriteLine();
            WriteLine("Epic returned from .Query, requerying the system with subselect syntax to pull in nested relationships:");
            PrintEpic(epic);
        }
Beispiel #11
0
        /// <summary>
        /// show Asset of designated publickeyAddress
        /// </summary>
        /// <param name="client"></param>
        /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
        public async Task <decimal> ShowAsset()
        {
            var client      = this.SetClient();
            var assetClient = new AssetClient(client);

            AssetTypesRegisterer.RegisterTypes();

            var myaddress = new PublicKeyAddress(Utils.GetUser0KeyPair());
            var result    = await assetClient.GetAssetAsync(TableName, myaddress);

            return(result.Value);
        }
        public void Execute()
        {
            var v1 = new AssetClient(instanceUrl, accessToken);

            dynamic story = new VersionOne.SDK.API.Asset.Asset("Story");

            story.Scope = "Scope:1015";
            story.Name  = "Story created from newed up Asset instance";

            dynamic createdStory = v1.Create(story);

            WriteLine("Created: " + createdStory.Oid);
        }
        public void Execute()
        {
            var v1 = new AssetClient(instanceUrl, accessToken);

            var assets = v1
                         .Query("Story")
                         .Where("Number", "S-01001")
                         .Select("Name", "Number")
                         .Retrieve();

            foreach (dynamic story in assets)
            {
                WriteLine(story.Oid);
                WriteLine(story.Name);
                WriteLine(story.Number);
            }
        }
Beispiel #14
0
        /// <summary>
        /// show Asset of  designated publickeyAddress
        /// </summary>
        /// <param name="client"></param>
        private static async Task ShowAsset(IClient client)
        {
            // AssetClient has access to asset endpoints
            var assetClient = new AssetClient(client);

            var addresses = new Address[] {
                new PublicKeyAddress(Utils.GetUser0KeyPair()),
                new PublicKeyAddress(Utils.GetUser1KeyPair()),
            };

            foreach (var address in addresses)
            {
                var result = await assetClient.GetAssetAsync(TableName, address);

                Console.WriteLine($"address={address}, amount={result.Value}");
            }
        }
        public void Execute()
        {
            const string scopeOid = "Scope:1015";

            var v1 = new AssetClient(instanceUrl, accessToken);

            dynamic scope = v1
                            .Query(scopeOid)
                            .Select("Workitems:Story")
                            .RetrieveFirst();

            WriteLine($"Story count: {scope["Workitems:Story"].Count}");
            foreach (var story in scope["Workitems:Story"])
            {
                WriteLine(story);
            }
        }
        static async Task TestSomeCalls()
        {
            AssetClient  assetClient = new AssetClient(serviceOptions, authToken);
            List <Asset> assets      = await assetClient.GetAll(null, null, null);

            foreach (Asset asset in assets)
            {
                Console.WriteLine(string.Format("Got asset {0}", asset.Name));
            }
            assets = await assetClient.GetChangedAssets(DateTimeOffset.Now.AddDays(-10));

            Console.WriteLine("***************CHANGED ASSETS**************");
            foreach (Asset asset in assets)
            {
                Console.WriteLine(string.Format("Got changed asset {0}", asset.Name));
            }
        }
Beispiel #17
0
        private AssetClient CreateAssetClient()
        {
            AssetClient client;

            if (!string.IsNullOrWhiteSpace(_v1Connector.Username))
            {
                client = new AssetClient(_v1Connector.AssetApiUrl, _v1Connector.Username, _v1Connector.Password);
            }
            else if (!string.IsNullOrWhiteSpace(_v1Connector.AccessToken))
            {
                client = new AssetClient(_v1Connector.AssetApiUrl, _v1Connector.AccessToken);
            }
            else
            {
                throw new InvalidOperationException("Could not find any credentials to use. Please call either WithUsernameAndPassword or WithAccessToken before attempting to call Query.");
            }
            client.UserAgent = _v1Connector.UserAgent;
            return(client);
        }
        public void Execute()
        {
            var v1 = new AssetClient(instanceUrl, accessToken);

            dynamic epic = v1.Create(
                ("AssetType", "Epic"),
                ("Scope", "Scope:0"),
                ("Name", "Epic with four Stories"),
                ("Subs", Assets(
                     Asset(
                         ("AssetType", "Story"),
                         ("Name", "Story in Epic")
                         ),
                     Asset(
                         ("AssetType", "Story"),
                         ("Name", "Another Story in Epic")
                         ),
                     Asset(
                         ("AssetType", "Story"),
                         ("Name", "Story in Epic")
                         ),
                     Asset(
                         ("AssetType", "Story"),
                         ("Name", "Another Story in Epic")
                         )
                     ))
                );

            IEnumerable <string> updated = v1.Update(
                From("Story")
                .Where(
                    Equal("Name", "Story in Epic", "Another Story in Epic"),
                    Equal("Scope", "Scope:0"),
                    Equal("Super", epic.Oid)
                    ), new
            {
                Description = "Updated via bulk API"
            });

            WriteLine("Updated the following Assets: " + string.Join(", ", updated));
        }
Beispiel #19
0
        /// <summary>
        /// show Asset of designated publickeyAddress
        /// </summary>
        /// <param name="client"></param>
        /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
        public async Task <decimal> ShowAsset(string publickey)
        {
            PublicKeyAddress myaddress = null;
            var client      = this.SetClient();
            var assetClient = new AssetClient(client);

            AssetTypesRegisterer.RegisterTypes();

            try
            {
                var value = PublicKey.Parse(publickey);
                myaddress = new PublicKeyAddress(value);
            }
            catch (Exception)
            {
                return(0m);
            }

            var result = await assetClient.GetAssetAsync(TableName, myaddress);

            return(result.Value);
        }
        public void Execute()
        {
            var v1 = new AssetClient(instanceUrl, accessToken);

            dynamic epic = v1.Create(
                ("AssetType", "Epic"),
                ("Scope", "Scope:0"),
                ("Name", "Epic with four Stories"),
                ("Subs", Assets(
                     Asset(
                         ("AssetType", "Story"),
                         ("Name", "Story in Epic")
                         ),
                     Asset(
                         ("AssetType", "Story"),
                         ("Name", "Story in Epic")
                         ),
                     Asset(
                         ("AssetType", "Story"),
                         ("Name", "Story in Epic")
                         ),
                     Asset(
                         ("AssetType", "Story"),
                         ("Name", "Story in Epic")
                         )
                     ))
                );

            IEnumerable <string> assetsOperatedOn = v1.ExecuteOperation(
                From("Story")
                .Where(
                    Equal("Name", "Story in Epic"),
                    Equal("Scope", "Scope:0"),
                    Equal("Super", epic.Oid)
                    ), "QuickClose");

            WriteLine("Operated on the following Assets: " + string.Join(", ", assetsOperatedOn));
        }
Beispiel #21
0
        public void Execute()
        {
            var v1 = new AssetClient(instanceUrl, accessToken);

            var epicDict = new Dictionary <string, object>()
            {
                { "AssetType", "Epic" },
                { "Scope", "Scope:0" },
                { "Name", "My Epic" },
                { "Subs", new []
                  {
                      new Dictionary <string, object>()
                      {
                          { "AssetType", "Story" },
                          { "Name", "My Epic : My Story 1" },
                          { "Children", new []
                                            {
                                                new Dictionary <string, object>()
                                                {
                                                    { "AssetType", "Test" },
                                                    { "Name", "My Story 1: Test" }
                                                },
                                                new  Dictionary <string, object>()
                                                {
                                                    { "AssetType", "Task" },
                                                    { "Name", "My Story 1: Task" }
                                                }
                                            } }
                      },
                      new Dictionary <string, object>()
                      {
                          { "AssetType", "Story" },
                          { "Name", "My Epic : My Story 2" },
                          { "Children", new []
                                            {
                                                new Dictionary <string, object>()
                                                {
                                                    { "AssetType", "Test" },
                                                    { "Name", "My Story 2: Test" }
                                                },
                                                new  Dictionary <string, object>()
                                                {
                                                    { "AssetType", "Task" },
                                                    { "Name", "My Story 2: Task" }
                                                }
                                            } }
                      }
                  } }
            };

            dynamic epic = v1.Create(epicDict);

            WriteLine("Epic returned from .Create (which does not requery the system, but fills in Oids linearly from server response):");
            PrintEpic(epic);

            epic = v1
                   .Query(epic.Oid)
                   .Select(
                "Name",
                "Scope",
                From("Subs")
                .Select(
                    "AssetType",
                    "Name",
                    From("Children")
                    .Select(
                        "AssetType",
                        "Name"
                        )
                    )
                )
                   .RetrieveFirst();

            WriteLine();
            WriteLine("Epic returned from .Query, requerying the system with subselect syntax to pull in nested relationships:");
            PrintEpic(epic);
        }
Beispiel #22
0
        public void Execute()
        {
            var v1 = new AssetClient(instanceUrl, accessToken);

            var epic = Asset("Epic", new
            {
                Scope = "Scope:0",
                Name  = "My Epic",
                Subs  = Assets(
                    Asset("Story", new
                {
                    Name     = "My Epic : My Story 1",
                    Children = Assets(
                        Asset("Test", new
                    {
                        Name = "My Story 1: Test"
                    }),
                        Asset("Task", new
                    {
                        Name = "My Story 1: Task"
                    })
                        )
                }),
                    Asset("Story", new
                {
                    Name     = "My Epic : My Story 2",
                    Children = Assets(
                        Asset("Test", new
                    {
                        Name = "My Story 2: Test"
                    }),
                        Asset("Task", new
                    {
                        Name = "My Story 2: Task"
                    })
                        )
                })
                    )
            });

            // TODO: probably should be void in this case
            epic = v1.Create(epic);

            WriteLine("Epic returned from .Create (which does not requery the system, but fills in Oids linearly from server response):");
            PrintEpic(epic);

            epic = v1
                   .Query(epic.Oid)
                   .Select(
                "Name",
                "Scope",
                From("Subs")
                .Select(
                    "AssetType",
                    "Name",
                    From("Children")
                    .Select(
                        "AssetType",
                        "Name"
                        )
                    )
                )
                   .RetrieveFirst();

            WriteLine();
            WriteLine("Epic returned from .Query, requerying the system with subselect syntax to pull in nested relationships:");
            PrintEpic(epic);
        }