Example #1
0
        public async Task GetPricesTest()
        {
            var request  = new PriceListRequest(this.connectionSettings.AccessToken, this.connectionSettings.ClientSecret);
            var response = await PriceService.GetPricesAsync(request, "A");

            Assert.IsTrue(response.Data.Count() > 0);
        }
Example #2
0
        public async Task POST_PriceList_Success()
        {
            string            externalIdentifier = "postPricelistCase01";
            PriceListTestData testData           = new PriceListTestData
            {
                ExternalIdentifier = externalIdentifier
            };

            PriceListRequest request = new PriceListRequest
            {
                Name       = "Pricelist name",
                Identifier = externalIdentifier,
                CreatedBy  = "post request"
            };

            HttpResponseExtended <PriceListResponse> response = await Client.PriceLists.Create(request);

            //validations
            Assert.IsNotNull(response);
            Assert.AreEqual(200, response.StatusCode);
            Assert.IsTrue(response.Success);
            Assert.IsNotNull(response.Result);

            //validate that all props are assigned in the response
            Assert.AreEqual(request.Name, response.Result.Name);
            Assert.AreEqual(request.CreatedBy, response.Result.CreatedBy);
            Assert.AreEqual(request.Identifier, response.Result.ExternalIdentifier);

            //scenario clean up
            await TestScenarioCleanUp(testData);
        }
Example #3
0
        public async Task PUT_PriceList_Success()
        {
            string externalIdentifier = "putCase01";
            //scenario setup
            PriceListTestData testData = new PriceListTestData
            {
                ExternalIdentifier = externalIdentifier
            };

            await TestScenarioSetUp(testData);

            PriceListRequest request = new PriceListRequest
            {
                Name       = "patched name ;)",
                UpdatedBy  = "put automated request",
                Identifier = "identifier_updated"
            };

            HttpResponseExtended <PriceListResponse> response = await Client.PriceLists.Update(externalIdentifier, request);

            //validations
            Assert.IsNotNull(response);
            Assert.AreEqual(200, response.StatusCode);
            Assert.IsTrue(response.Success);
            Assert.IsNotNull(response.Result);

            //validate that all properties has been updated
            Assert.AreEqual(request.Name, response.Result.Name);
            Assert.AreEqual(request.UpdatedBy, response.Result.UpdatedBy);
            Assert.AreEqual(externalIdentifier, response.Result.ExternalIdentifier);
            Assert.AreNotEqual(request.Identifier, response.Result.ExternalIdentifier);

            //test scenario clean up
            await TestScenarioSetUp(testData);
        }
Example #4
0
        public override async Task TestScenarioSetUp(PriceListTestData testData)
        {
            PriceListRequest request = new PriceListRequest
            {
                CreatedBy  = "temporal request",
                Identifier = testData.ExternalIdentifier,
                Name       = "Temporal name",
                UpdatedBy  = "temporal request"
            };

            await Client.PriceLists.Create(request);
        }
Example #5
0
        //TODO
        //pending
        //[TestMethod]
        public async Task POST_PriceList_Invalid()
        {
            string externalIdentifier = "postPricelistCase02";

            PriceListRequest request = new PriceListRequest
            {
                Identifier = externalIdentifier
            };

            HttpResponseExtended <PriceListResponse> response = await Client.PriceLists.Create(request);

            //validations
            Assert.IsNotNull(response);
            Assert.AreEqual(500, response.StatusCode);
            Assert.IsFalse(response.Success);
            Assert.IsNull(response.Result);
        }
Example #6
0
        public async Task PUT_PriceList_Not_Found()
        {
            string externalIdentifier = "putNotFoundPriceList01";

            PriceListRequest request = new PriceListRequest
            {
                Name       = "patched name ;)",
                UpdatedBy  = "put automated request",
                Identifier = externalIdentifier
            };

            HttpResponseExtended <PriceListResponse> response = await Client.PriceLists.Update(externalIdentifier, request);

            //validations
            Assert.IsNotNull(response);
            Assert.AreEqual(404, response.StatusCode);
            Assert.IsFalse(response.Success);
            Assert.IsNull(response.Result);
        }
Example #7
0
        public async Task <IActionResult> Get([FromQuery] PriceListRequest request)
        {
            var client = new BinanceClient();

            client.SetApiCredentials("7ICQp7LXtOdaFOTYyQV4GqjA2nwOzkwgOW3KgHCQTj5fyZHXNHD4XmRVW3BukcXZ", "MFr1NGf1rLwSaNZ5pOfndWG4GX4vIRVUBpiCXqckKhj44rBAjracQb44M1n0Ra7g");

            var requestHours = await client.Get24HPriceAsync(request.Pair);

            var requestKlines = await client.GetKlinesAsync(request.Pair, request.Interval, null, null, 1);

            decimal volume    = requestKlines.Data[0].Volume;
            decimal volumeBTC = requestKlines.Data[0].QuoteAssetVolume;

            decimal percent = RequestHelper.CalculatePercent(requestKlines.Data);

            decimal priceChangePercent = requestHours.Data.PriceChangePercent;
            decimal quoteVolume        = requestHours.Data.QuoteVolume;

            if (requestHours.Success && requestKlines.Success)
            {
                return(Json(new Binance24HPricesListResponse
                {
                    Success = true,
                    Volume = volume,
                    VolumeBTC = volumeBTC,
                    Percent = percent,
                    PriceChangePercent = priceChangePercent,
                    QuoteVolume = quoteVolume
                }));
            }



            return(Json(new ResponseModel {
                Success = false, Message = "dsf"
            }));
        }
Example #8
0
        public static async Task <ListedResourceResponse <PriceSubset> > GetPricesAsync(PriceListRequest listRequest, string priceList, string articleNumber = "")
        {
            var apiRequest = new FortnoxApiClientRequest <ListedResourceResponse <PriceSubset> >(HttpMethod.Get, listRequest.AccessToken, listRequest.ClientSecret,
                                                                                                 $"{ApiEndpoints.Prices}/sublist/{priceList}/{articleNumber}");

            apiRequest.SetSortOrder(listRequest.SortBy?.ToString(), listRequest.SortOrder.ToString());
            apiRequest.SetPageAndLimit(listRequest.Page, listRequest.Limit);

            if (listRequest.SearchParameters == null)
            {
                return(await FortnoxAPIClient.CallAsync(apiRequest));
            }

            foreach (var param in listRequest.SearchParameters)
            {
                apiRequest.AddSearchParam(param.Key.ToString().ToLower(), param.Value);
            }

            return(await FortnoxAPIClient.CallAsync(apiRequest));
        }