Ejemplo n.º 1
0
        static public void Main()
        {
            // Configure API key authorization: api_key
            Configuration.Default.AddApiKey("x-api-key", ExampleConstants.AWS_API_KEY);

            var stockx = new StockXApi();

            stockx.Configuration.BasePath = ExampleConstants.STOCKX_ENDPOINT;

            var login = new LoginRequest(ExampleConstants.STOCKX_USERNAME, ExampleConstants.STOCKX_PASSWORD);

            try
            {
                // Login and fetch the jwt header for authentication use in the request
                ApiResponse <LoginResponse> result = stockx.LoginWithHttpInfo(login);
                var jwt = result.Headers[ExampleConstants.JWT_HEADER];

                stockx.Configuration.DefaultHeader["jwt-authorization"] = jwt;

                // Find a product with search
                var search = stockx.Search("Jordan Retro Black Cat");

                // Lookup the product's data by its search id
                var firstResultStyle = search.Hits[0].StyleId;

                var productInfo = stockx.LookupProduct(firstResultStyle, "11");

                // Get the market data (highest bids, lowest asks, etc) about the product
                var id          = productInfo.Data[0].Id;
                var productUuid = productInfo.Data[0].Attributes.ProductUuid;

                var marketData = stockx.GetProductMarketData(id, productUuid);

                // Get the lowest ask and increment it
                var lowestAsk = marketData.Market.LowestAsk;
                lowestAsk++;

                // Create a portfolio item request with a higher bid
                var item = new PortfolioRequestPortfolioItem();
                item.Amount          = lowestAsk.ToString();
                item.SkuUuid         = "bae25b67-a721-4f57-ad5a-79973c7d0a5c";
                item.MatchedWithDate = "2018-12-12T05:00:00+0000";
                item.ExpiresAt       = "2018-12-12T12:39:07+00:00";

                var request = new PortfolioRequest();
                request.PortfolioItem = item;
                request.Customer      = result.Data.Customer;
                request.Timezone      = "America/Detroit";

                // Submit the ask
                var askResp = stockx.NewPortfolioAsk(request);

                Console.WriteLine(askResp);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Console.WriteLine("Exception when creating new lowest ask: " + e.Message);
            }
        }
Ejemplo n.º 2
0
        static public void Main()
        {
            // Configure API key authorization: api_key
            Configuration.Default.AddApiKey("x-api-key", ExampleConstants.AWS_API_KEY);

            var stockx = new StockXApi();

            stockx.Configuration.BasePath = ExampleConstants.STOCKX_ENDPOINT;

            var login = new LoginRequest(ExampleConstants.STOCKX_USERNAME, ExampleConstants.STOCKX_PASSWORD);

            try
            {
                // Login and fetch the jwt header for authentication use in the request
                ApiResponse <LoginResponse> result = stockx.LoginWithHttpInfo(login);
                var jwt = result.Headers[ExampleConstants.JWT_HEADER];

                stockx.Configuration.DefaultHeader["jwt-authorization"] = jwt;

                var item = new PortfolioRequestPortfolioItem();
                item.Amount          = "25";
                item.SkuUuid         = "bae25b67-a721-4f57-ad5a-79973c7d0a5c";
                item.MatchedWithDate = "2018-12-12T05:00:00+0000";
                item.ExpiresAt       = "2018-12-12T12:39:07+00:00";

                var request = new PortfolioRequest();
                request.PortfolioItem = item;
                request.Customer      = result.Data.Customer;
                request.Timezone      = "America/Detroit";

                // Create a new portfolio ask
                var askResp = stockx.NewPortfolioAsk(request);

                // Print the result of the ask call
                Console.WriteLine(askResp);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Console.WriteLine("Exception when calling StockXApi.NewPortfolioAsk: " + e.Message);
            }
        }