public CreateInboundShipmentPlanResponse InvokeCreateInboundShipmentPlan()
        {
            // Create a request.
            CreateInboundShipmentPlanRequest request = new CreateInboundShipmentPlanRequest();
            string sellerId = "example";

            request.SellerId = sellerId;
            string mwsAuthToken = "example";

            request.MWSAuthToken = mwsAuthToken;
            string marketplace = "example";

            request.Marketplace = marketplace;
            Address shipFromAddress = new Address();

            request.ShipFromAddress = shipFromAddress;
            string labelPrepPreference = "example";

            request.LabelPrepPreference = labelPrepPreference;
            string shipToCountryCode = "example";

            request.ShipToCountryCode = shipToCountryCode;
            string shipToCountrySubdivisionCode = "example";

            request.ShipToCountrySubdivisionCode = shipToCountrySubdivisionCode;
            InboundShipmentPlanRequestItemList inboundShipmentPlanRequestItems =
                new InboundShipmentPlanRequestItemList();

            request.InboundShipmentPlanRequestItems = inboundShipmentPlanRequestItems;
            return(this.client.CreateInboundShipmentPlan(request));
        }
        public CreateShipmentResponse CreateInboundShipment(CreateShipmentRequest createShipmentRequest)
        {
            Address shipsFromAddress = AddressUtility.GetShipFromAddress();

            CreateShipmentResponse createShipmentResponse = null;

            List <InboundShipmentPlanRequestItem> shipmentPlanRequestItems = createShipmentRequest
                                                                             .ShipmentItems
                                                                             .Select(s =>
                                                                                     new InboundShipmentPlanRequestItem
            {
                ASIN           = s.Asin,
                SellerSKU      = s.Sku,
                Quantity       = s.Quantity,
                Condition      = ItemCondition.NewItem.ToString(),
                QuantityInCase = s.QuantityInCase ?? 0
            })
                                                                             .ToList();

            InboundShipmentPlanRequestItemList inboundShipmentPlanRequestItemList = new InboundShipmentPlanRequestItemList
            {
                member = shipmentPlanRequestItems
            };

            CreateInboundShipmentPlanRequest createInboundShipmentPlanRequest = new CreateInboundShipmentPlanRequest
            {
                InboundShipmentPlanRequestItems = inboundShipmentPlanRequestItemList,
                Marketplace     = m_marketPlaceId,
                SellerId        = m_sellerId,
                ShipFromAddress = shipsFromAddress
            };

            CreateInboundShipmentPlanResponse createInboundShipmentPlanResponse = m_fbaInboundServiceMwsClient.CreateInboundShipmentPlan(createInboundShipmentPlanRequest);

            CreateInboundShipmentPlanResult createInboundShipmentPlanResult = createInboundShipmentPlanResponse.CreateInboundShipmentPlanResult;

            if (createInboundShipmentPlanResult.InboundShipmentPlans.member.Any())
            {
                List <InboundShipmentPlan> inboundShipmentPlans = createInboundShipmentPlanResult
                                                                  .InboundShipmentPlans
                                                                  .member
                                                                  .ToList();

                Dictionary <string, ShipmentItem> itemsToBeAddedToShipment = createShipmentRequest
                                                                             .ShipmentItems.ToDictionary(k => k.Sku, v => v);

                DateTime today = DateTime.UtcNow.Date;

                List <CreatedShipment> createdShipments = inboundShipmentPlans
                                                          .Select(inboundShipmentPlan => CreateShipment(inboundShipmentPlan, itemsToBeAddedToShipment, shipsFromAddress, createShipmentRequest.ShipmentName, createShipmentRequest.AreCasesRequired, today))
                                                          .ToList();

                createShipmentResponse = new CreateShipmentResponse(createdShipments);
            }

            return(createShipmentResponse);
        }
Esempio n. 3
0
        /// <summary>
        /// Create Inbound Shipment
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCreateInboundShipment_Click(object sender, RoutedEventArgs e)
        {
            string SellerId           = CommonValue.strMerchantId;
            string MarketplaceId      = CommonValue.strMarketplaceId;
            string AccessKeyId        = CommonValue.strAccessKeyId;
            string SecretKeyId        = CommonValue.strSecretKeyId;
            string ApplicationVersion = CommonValue.strApplicationVersion;
            string ApplicationName    = CommonValue.strApplicationName;
            string MWSAuthToken       = CommonValue.strMWSAuthToken;
            string strbuff            = string.Empty;

            FBAInboundServiceMWSConfig config = new FBAInboundServiceMWSConfig();

            config.ServiceURL = CommonValue.strServiceURL;

            FBAInboundServiceMWSClient client = new FBAInboundServiceMWSClient(
                AccessKeyId,
                SecretKeyId,
                ApplicationName,
                ApplicationVersion,
                config);
            CreateInboundShipmentPlanRequest request = new CreateInboundShipmentPlanRequest();

            request.SellerId     = SellerId;
            request.Marketplace  = MarketplaceId;
            request.MWSAuthToken = MWSAuthToken;
            Address shipFromAddress = new Address();

            shipFromAddress.AddressLine1        = txtAddress11.Text;
            shipFromAddress.AddressLine2        = txtAddress21.Text;
            shipFromAddress.City                = txtCity1.Text;
            shipFromAddress.StateOrProvinceCode = txtPrefecture1.Text;
            shipFromAddress.Name                = txtName1.Text;
            shipFromAddress.PostalCode          = txtPostalCode1.Text;
            shipFromAddress.CountryCode         = "JP";
            request.ShipFromAddress             = shipFromAddress;
            request.LabelPrepPreference         = "SELLER_LABEL";
            request.ShipToCountryCode           = "JP";
            InboundShipmentPlanRequestItemList itemList = new InboundShipmentPlanRequestItemList();
            InboundShipmentPlanRequestItem     item     = new InboundShipmentPlanRequestItem();

            item.SellerSKU = txtSKU1.Text;
            item.Quantity  = 1;
            itemList.member.Add(item);
            request.WithInboundShipmentPlanRequestItems(itemList);
            CreateInboundShipmentPlanResponse response = client.CreateInboundShipmentPlan(request);

            if (response.IsSetCreateInboundShipmentPlanResult())
            {
                CreateInboundShipmentPlanResult createInboundShipmentPlanResult = response.CreateInboundShipmentPlanResult;
                if (createInboundShipmentPlanResult.IsSetInboundShipmentPlans())
                {
                    InboundShipmentPlanList    inboundShipmentPlans = createInboundShipmentPlanResult.InboundShipmentPlans;
                    List <InboundShipmentPlan> memberList           = inboundShipmentPlans.member;
                    foreach (InboundShipmentPlan member in memberList)
                    {
                        if (member.IsSetShipmentId())
                        {
                            CreateInboundShipmentRequest request1 = new CreateInboundShipmentRequest();

                            request1.SellerId     = SellerId;
                            request1.Marketplace  = MarketplaceId;
                            request1.MWSAuthToken = MWSAuthToken;
                            request1.ShipmentId   = member.ShipmentId;

                            InboundShipmentHeader inboundShipmentHeader = new InboundShipmentHeader();
                            inboundShipmentHeader.ShipFromAddress     = shipFromAddress;
                            inboundShipmentHeader.LabelPrepPreference = "SELLER_LABEL";
                            inboundShipmentHeader.ShipmentName        = txtSKU1.Text;
                            request1.InboundShipmentHeader            = inboundShipmentHeader;
                            InboundShipmentItemList itemList1 = new InboundShipmentItemList();
                            InboundShipmentItem     item1     = new InboundShipmentItem();
                            item1.SellerSKU       = txtSKU1.Text;
                            item1.QuantityShipped = 1;
                            itemList1.member.Add(item1);
                            request1.WithInboundShipmentItems(itemList1);
                            request1.InboundShipmentHeader.DestinationFulfillmentCenterId = member.DestinationFulfillmentCenterId;
                            CreateInboundShipmentResponse response1 = client.CreateInboundShipment(request1);
                            if (response1.IsSetCreateInboundShipmentResult())
                            {
                                strbuff = "処理が正常に完了しました。";
                            }
                            else
                            {
                                strbuff = "処理時にエラーが発生しました。";
                            }
                        }
                    }
                }
            }
            txtCreateInboundShipment.Text = strbuff;
        }