Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new <see cref="FulfillmentServiceEntity"/>.
        /// </summary>
        /// <param name="fulfillmentServiceEntity">A new <see cref="FulfillmentServiceEntity"/>. Id should be set to null.</param>
        /// <param name="cancellationToken">Cancellation Token</param>
        /// has been created.</param>
        /// <returns>The new <see cref="FulfillmentServiceEntity"/>.</returns>
        public virtual async Task <FulfillmentServiceEntity> CreateAsync(FulfillmentServiceEntity fulfillmentServiceEntity, CancellationToken cancellationToken = default)
        {
            var req  = PrepareRequest($"fulfillment_services.json");
            var body = fulfillmentServiceEntity.ToDictionary();

            var content = new JsonContent(new
            {
                fulfillment_service = body
            });

            var response = await ExecuteRequestAsync <FulfillmentServiceEntity>(req, HttpMethod.Post, cancellationToken, content, "fulfillment_service");

            return(response.Result);
        }
        public async Task <FulfillmentServiceEntity> Create(bool skipAddToCreateList = false)
        {
            FulfillmentServiceEntity fulfillmentServiceEntity = await Service.CreateAsync(new FulfillmentServiceEntity()
            {
                Name                   = $"MarsFulfillment{DateTime.Now.Ticks}",
                CallbackUrl            = "http://google.com",
                InventoryManagement    = false,
                TrackingSupport        = false,
                RequiresShippingMethod = false,
                Format                 = "json",
            });

            if (!skipAddToCreateList)
            {
                Created.Add(fulfillmentServiceEntity);
            }

            return(fulfillmentServiceEntity);
        }