Ejemplo n.º 1
0
        protected override async Task Run()
        {
            if (IsNullOrEmpty(catalogId))
            {
                throw new InvalidOperationException("The mint scenario requires a catalog identifier for minting.");
            }

            if (quantity < 1L)
            {
                throw new InvalidOperationException("The mint scenario requires at least one token to be minted.");
            }

            WriteLine($"Starting mint scenario (partner = {partnerId})");

            if (!IsNullOrEmpty(partnerId))
            {
                Api.AddHeader("from", partnerId);
            }

            var response = await Api.PostAsync("mintrequests", new { catalogId = catalogId, quantity = quantity });

            var id = Data.MintRequestId = response.EnsureSuccessStatusCode().IdFromLocationHeader <Guid>();

            await Saga <MintRequestData>().Where(s => s.Id == id).ToComplete();

            WriteLine($"Completed mint scenario (mint request id = {id})");
        }
Ejemplo n.º 2
0
        protected override async Task Run()
        {
            if (IsNullOrEmpty(catalogId))
            {
                throw new InvalidOperationException("The order scenario requires a catalog identifier.");
            }

            if (quantity < 1)
            {
                throw new InvalidOperationException("The order scenario requires at least one token.");
            }

            WriteLine($"Starting order scenario (partner = {partnerId}, reserve only = {reserveOnly.ToString().ToLower()})");

            if (!IsNullOrEmpty(partnerId))
            {
                Api.AddHeader("from", partnerId);
            }

            var requestUri = "orders";

            if (reserveOnly)
            {
                requestUri += "?reserveOnly=true";
            }

            var response = await Api.PostAsync(requestUri, new { catalogId = catalogId, quantity = quantity });

            var id = Data.OrderId = response.EnsureSuccessStatusCode().IdFromLocationHeader <Guid>();

            await Saga <OrderData>().Where(s => s.Id == id).ToComplete();

            WriteLine($"Completed order scenario (order id = {id})");
        }