The Amazon order interface is a chunk of the Amazon MWS development interface that we can use to get order data through an interface call.
Before invoking the interface, we first need to obtain information such as store key for the store merchant. As follows:
Here I define all the information in a class, in a serialized way, to facilitate access to the value.
/// <summary> ///Account Information/// </summary>[Serializable] Public classAccountconfig:baseconfig<accountconfig> { /// <summary> ///Application Name/// </summary> Public stringAppName {Get;Set; } /// <summary> ///Application Version/// </summary> Public stringappversion {Get;Set; } /// <summary> ///Account keyID/// </summary> Public stringAccesskeyid {Get;Set; } /// <summary> ///Key ID/// </summary> Public stringSecretaccesskey {Get;Set; } /// <summary> ///Mall ID/// </summary> Public stringMerchantid {Get;Set; } /// <summary> ///Mall Unique identification ID/// </summary> Public stringMarketplaceid {Get;Set; } /// <summary> ///server-side URL/// </summary> Public stringserviceurl {Get;Set; } }
Then we go back to the documentation, and we'll find that there are two parameters in the request parameter that are required: Createdafter, Marketplaceid. The method of invoking the interface is very simple, it is to construct the complete object, in fact, the main is to maintain the integrity of the required parameters, this time we take the Listorder interface for example:
/// <summary> ///Get account information/// </summary> protectedaccountconfig Account {Get { returnaccountconfig.instance; } } Privatemarketplacewebserviceordersconfig GetConfig () {varConfig =NewMarketplacewebserviceordersconfig (); Config. Serviceurl=Account.serviceurl; returnconfig; } Privatemarketplacewebserviceordersclient getclient () {varConfig = This. GetConfig (); varClient =Newmarketplacewebserviceordersclient (Account.appname, Account.appversion, Account.accesskeyid, ACCOUNT.SECR Etaccesskey, config); returnclient; } #regionGet a list of orders (OrderList)PrivateList<order> Getnextorderlist (ref stringNextToken) { varClient = This. Getclient (); varRequest =Newlistordersbynexttokenrequest (); Request. Sellerid=Account.merchantid; Request. NextToken=NextToken; varResponse =client. Listordersbynexttoken (Request); varresult =Response. Listordersbynexttokenresult; NextToken=result. NextToken; List<Order> orderlist =result. Orders.order; returnorderlist; } /// <summary> ///get a list of orders (Specify request mode)/// </summary> /// <param name= "Request" >listordersrequest</param> /// <returns></returns> PublicList<order>getorderlist (DateTime createdafter, datetime createdbefore) {varRequest =Newlistordersrequest (); Request. Createdafter=amazonhelper.converttoiso8601 (Createdafter); Request. Createdbefore=amazonhelper.converttoiso8601 (Createdbefore); Request. Marketplaceid=Newmarketplaceidlist (); Request. Marketplaceid.id=Newlist<string>{Account.marketplaceid}; Request. Sellerid=Account.merchantid; varClient =getclient (); varResponse =client. Listorders (Request); varresult =Response. Listordersresult; varOrderList =result. Orders.order; stringNextToken =result. NextToken; while(!string. IsNullOrEmpty (NextToken)) {List<Order> templist = Getnextorderlist (refNextToken); OrderList=Orderlist.concat (templist). ToList (); } returnorderlist; } #endregion
Remember, do not neglect to assign a value in the request parameter to the Sellerid in the call.
Amzon MWS API Development Order Interface