FBA Inventory 関数概要

処理フロー

  • 1 ステップ1
  • 2 ステップ2
Step 利用関数 処理概要
ステップ1 ListInventorySupply FBA在庫情報を取得します。
ステップ2 ListInventorySupplyByNextToken FBA在庫情報が多い場合、次の情報を取得する場合利用します。

FBA Inventory 関数一覧

オペレーション 概要
ListInventorySupply FBA在庫情報を取得します。
ListInventorySupplyByNextToken FBA在庫情報の次の情報を取得します。
GetServiceStatus FBA Inventory APIの状状況を取得します。

FBA Inventory 関数利用例

private void btnListInventorySupply_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;
 
    FBAInventoryServiceMWSConfig config = new FBAInventoryServiceMWSConfig();
    config.ServiceURL = CommonValue.strServiceURL;
 
    FBAInventoryServiceMWSClient client = new FBAInventoryServiceMWSClient(
                                                    AccessKeyId,
                                                    SecretKeyId,
                                                    ApplicationName,
                                                    ApplicationVersion,
                                                    config);
    ListInventorySupplyRequest request = new ListInventorySupplyRequest();
    request.SellerId = SellerId;
    request.Marketplace = MarketplaceId;
    request.MWSAuthToken = MWSAuthToken;
    request.QueryStartDateTime = DateTime.Now.AddMonths(1);
    request.ResponseGroup = "Detailed";
 
    ListInventorySupplyResponse response = client.ListInventorySupply(request);
    if (response.IsSetListInventorySupplyResult())
    {
        ListInventorySupplyResult listInventorySupplyResult = response.ListInventorySupplyResult;
        if (listInventorySupplyResult.IsSetInventorySupplyList())
        {
            InventorySupplyList inventorySupplyList = listInventorySupplyResult.InventorySupplyList;
            List<InventorySupply> memberList = inventorySupplyList.member;
            if (memberList.Count > 0)
            {
                foreach (InventorySupply member in memberList)
                {
                    if (member.IsSetSupplyDetail())
                    {
                        InventorySupplyDetailList supplyDetail = member.SupplyDetail;
                        List<InventorySupplyDetail> member1List = supplyDetail.member;
                        foreach (InventorySupplyDetail member1 in member1List)
                        {
                            if (member1.IsSetQuantity())
                            {
                                strbuff += "数量:" + member1.Quantity;
                            }
                        }
                    }
                }
            }
            else
            {
                strbuff = "在庫情報が見つかりませんでした。";
            }
        }
    }
    txtListInventorySupply.Text = strbuff;
}

private void btnListInventorySupplyByNextToken_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;
 
    FBAInventoryServiceMWSConfig config = new FBAInventoryServiceMWSConfig();
    config.ServiceURL = CommonValue.strServiceURL;
 
    FBAInventoryServiceMWSClient client = new FBAInventoryServiceMWSClient(
                                                    AccessKeyId,
                                                    SecretKeyId,
                                                    ApplicationName,
                                                    ApplicationVersion,
                                                    config);
    ListInventorySupplyRequest request = new ListInventorySupplyRequest();
    request.SellerId = SellerId;
    request.Marketplace = MarketplaceId;
    request.MWSAuthToken = MWSAuthToken;
    request.QueryStartDateTime = DateTime.Now.AddMonths(1);
    request.ResponseGroup = "Detailed";
 
    ListInventorySupplyResponse response = client.ListInventorySupply(request);
    if (response.IsSetListInventorySupplyResult())
    {
        ListInventorySupplyResult listInventorySupplyResult = response.ListInventorySupplyResult;
        if (listInventorySupplyResult.IsSetInventorySupplyList())
        {
            if (listInventorySupplyResult.NextToken != null)
            {
                ListInventorySupplyByNextTokenRequest request1 = new ListInventorySupplyByNextTokenRequest();
                request1.SellerId = SellerId;
                request1.Marketplace = MarketplaceId;
                request1.MWSAuthToken = MWSAuthToken;
                request1.NextToken = listInventorySupplyResult.NextToken;
 
                ListInventorySupplyByNextTokenResponse response1 = client.ListInventorySupplyByNextToken(request1);
                if (response1.IsSetListInventorySupplyByNextTokenResult())
                {
                    ListInventorySupplyByNextTokenResult listInventorySupplyByNextTokenResult = response1.ListInventorySupplyByNextTokenResult;
                    if (listInventorySupplyByNextTokenResult.IsSetInventorySupplyList())
                    {
                        InventorySupplyList inventorySupplyList = listInventorySupplyByNextTokenResult.InventorySupplyList;
                        List<InventorySupply> memberList = inventorySupplyList.member;
                        if (memberList.Count > 0)
                        {
                            foreach (InventorySupply member in memberList)
                            {
                                if (member.IsSetTotalSupplyQuantity())
                                {
                                    strbuff += "数量:" + member.TotalSupplyQuantity;
                                }
                            }
                        }
                        else
                        {
                            strbuff = "次の在庫情報が見つかりませんでした。";
                        }
                    }
                }
            }
        }
    }
    txtListInventorySupplyByNextToken.Text = strbuff;
}

private void btnGetServiceStatus_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;
 
    FBAInventoryServiceMWSConfig config = new FBAInventoryServiceMWSConfig();
    config.ServiceURL = CommonValue.strServiceURL;
 
    FBAInventoryServiceMWSClient client = new FBAInventoryServiceMWSClient(
                                                    AccessKeyId,
                                                    SecretKeyId,
                                                    ApplicationName,
                                                    ApplicationVersion,
                                                    config);
    GetServiceStatusRequest request = new GetServiceStatusRequest();
    request.SellerId = SellerId;
    request.Marketplace = MarketplaceId;
    request.MWSAuthToken = MWSAuthToken;
    GetServiceStatusResponse response = client.GetServiceStatus(request);
    if (response.IsSetGetServiceStatusResult())
    {
        GetServiceStatusResult getServiceStatusResult = response.GetServiceStatusResult;
        if (getServiceStatusResult.IsSetStatus())
        {
            strbuff = "状態:" + getServiceStatusResult.Status;
        }
    }
    txtGetServiceStatus.Text = strbuff;
}