-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
guyi-maple
committed
Jul 28, 2017
1 parent
d9f8fc0
commit 56b107f
Showing
12 changed files
with
309 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/top/guyi/amazon/mws/client/impl/OrdersClient.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package top.guyi.amazon.mws.client.impl | ||
|
||
import com.amazonservices.mws.orders._2013_09_01.MarketplaceWebServiceOrdersClient | ||
import com.amazonservices.mws.orders._2013_09_01.MarketplaceWebServiceOrdersConfig | ||
import top.guyi.amazon.mws.client.SuperAmazonClient | ||
import top.guyi.amazon.mws.conf.AmazonConfigProvider | ||
|
||
/** | ||
* Created by 古逸 on 2017-07-28. | ||
*/ | ||
class OrdersClient implements SuperAmazonClient<MarketplaceWebServiceOrdersConfig,MarketplaceWebServiceOrdersClient>{ | ||
|
||
@Override | ||
MarketplaceWebServiceOrdersClient create(AmazonConfigProvider provider) { | ||
MarketplaceWebServiceOrdersConfig config = this.newConfig(provider) | ||
return this.createByConfig(provider,config) | ||
} | ||
|
||
@Override | ||
MarketplaceWebServiceOrdersClient createByConfig(AmazonConfigProvider provider, MarketplaceWebServiceOrdersConfig config) { | ||
MarketplaceWebServiceOrdersClient client = new MarketplaceWebServiceOrdersClient(provider.accessKey(),provider.secretKey(),config) | ||
return client | ||
} | ||
|
||
@Override | ||
MarketplaceWebServiceOrdersConfig newConfig(AmazonConfigProvider provider) { | ||
MarketplaceWebServiceOrdersConfig config = new MarketplaceWebServiceOrdersConfig() | ||
config.serviceURL = provider.server() | ||
return config | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/top/guyi/amazon/mws/helper/DateHelper.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package top.guyi.amazon.mws.helper | ||
|
||
import javax.xml.datatype.DatatypeFactory | ||
import javax.xml.datatype.XMLGregorianCalendar | ||
|
||
/** | ||
* Created by 古逸 on 2017-07-28. | ||
*/ | ||
class DateHelper { | ||
|
||
static XMLGregorianCalendar convertToXMLGregorianCalendar(Date date) { | ||
GregorianCalendar cal = new GregorianCalendar(); | ||
cal.setTime(date); | ||
XMLGregorianCalendar gc = null; | ||
try { | ||
gc = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
return gc; | ||
} | ||
|
||
static Date toDate(XMLGregorianCalendar calendar){ | ||
if(calendar == null) { | ||
return null; | ||
} | ||
return calendar.toGregorianCalendar().getTime(); | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/top/guyi/amazon/mws/request/enums/OrderStatus.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package top.guyi.amazon.mws.request.enums | ||
|
||
/** | ||
* Created by 古逸 on 2017-07-28. | ||
*/ | ||
enum OrderStatus { | ||
|
||
PendingAvailability, | ||
Pending, | ||
Unshipped, | ||
PartiallyShipped, | ||
Shipped, | ||
InvoiceUnconfirmed, | ||
Canceled, | ||
Unfulfillable | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/top/guyi/amazon/mws/request/impl/orders/ListOrderItemsPackers.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package top.guyi.amazon.mws.request.impl.orders | ||
|
||
import com.amazonservices.mws.orders._2013_09_01.model.ListOrderItemsRequest | ||
import top.guyi.amazon.mws.client.SuperAmazonClient | ||
import top.guyi.amazon.mws.client.impl.OrdersClient | ||
import top.guyi.amazon.mws.request.SuperRequestPackers | ||
import top.guyi.amazon.mws.response.impl.orders.ListOrderItemsHandler | ||
|
||
/** | ||
* Created by 古逸 on 2017-07-28. | ||
*/ | ||
class ListOrderItemsPackers extends SuperRequestPackers<ListOrderItemsPackers,ListOrderItemsRequest,ListOrderItemsHandler>{ | ||
|
||
private ListOrderItemsRequest request | ||
|
||
@Override | ||
Class<? extends SuperAmazonClient> clientClass() { | ||
return OrdersClient.class | ||
} | ||
|
||
@Override | ||
String method() { | ||
return 'listOrderItems' | ||
} | ||
|
||
ListOrderItemsPackers must(String amazonOrderId){ | ||
this.amazonRequest().amazonOrderId = amazonOrderId | ||
return this | ||
} | ||
|
||
@Override | ||
ListOrderItemsRequest amazonRequest() { | ||
if(request == null){ | ||
request = new ListOrderItemsRequest() | ||
request.sellerId = this.config().current().sellerId() | ||
} | ||
return request | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/top/guyi/amazon/mws/request/impl/orders/ListOrdersByNextTokenPackers.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package top.guyi.amazon.mws.request.impl.orders | ||
|
||
import com.amazonservices.mws.orders._2013_09_01.model.ListOrdersByNextTokenRequest | ||
import top.guyi.amazon.mws.client.SuperAmazonClient | ||
import top.guyi.amazon.mws.client.impl.OrdersClient | ||
import top.guyi.amazon.mws.request.SuperRequestPackers | ||
import top.guyi.amazon.mws.response.impl.orders.ListOrdersByNextTokenHandler | ||
|
||
/** | ||
* Created by 古逸 on 2017-07-28. | ||
*/ | ||
class ListOrdersByNextTokenPackers extends SuperRequestPackers<ListOrdersByNextTokenPackers,ListOrdersByNextTokenRequest,ListOrdersByNextTokenHandler> { | ||
|
||
private ListOrdersByNextTokenRequest request | ||
|
||
@Override | ||
Class<? extends SuperAmazonClient> clientClass() { | ||
return OrdersClient.class | ||
} | ||
|
||
@Override | ||
String method() { | ||
return 'listOrdersByNextToken' | ||
} | ||
|
||
ListOrdersByNextTokenPackers must(String nextToken){ | ||
this.amazonRequest().nextToken = nextToken | ||
return this | ||
} | ||
|
||
@Override | ||
ListOrdersByNextTokenRequest amazonRequest() { | ||
if(request == null){ | ||
request = new ListOrdersByNextTokenRequest() | ||
request.sellerId = this.config().current().sellerId() | ||
} | ||
return request | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
src/main/java/top/guyi/amazon/mws/request/impl/orders/ListOrdersPackers.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package top.guyi.amazon.mws.request.impl.orders | ||
|
||
import com.amazonservices.mws.orders._2013_09_01.model.ListOrdersRequest | ||
import top.guyi.amazon.mws.client.SuperAmazonClient | ||
import top.guyi.amazon.mws.client.impl.OrdersClient | ||
import top.guyi.amazon.mws.helper.DateHelper | ||
import top.guyi.amazon.mws.request.SuperRequestPackers | ||
import top.guyi.amazon.mws.response.impl.orders.ListOrdersHandler | ||
|
||
/** | ||
* Created by 古逸 on 2017-07-28. | ||
*/ | ||
class ListOrdersPackers extends SuperRequestPackers<ListOrdersPackers,ListOrdersRequest,ListOrdersHandler>{ | ||
|
||
private ListOrdersRequest request | ||
|
||
@Override | ||
Class<? extends SuperAmazonClient> clientClass() { | ||
return OrdersClient.class | ||
} | ||
|
||
@Override | ||
String method() { | ||
return 'listOrders' | ||
} | ||
|
||
ListOrdersPackers after(Date date){ | ||
this.amazonRequest().createdAfter = DateHelper.convertToXMLGregorianCalendar(date) | ||
return this | ||
} | ||
|
||
ListOrdersPackers before(Date date){ | ||
this.amazonRequest().createdBefore = DateHelper.convertToXMLGregorianCalendar(date) | ||
return this | ||
} | ||
|
||
ListOrdersPackers status(List<String> status){ | ||
this.amazonRequest().orderStatus = status | ||
return this | ||
} | ||
|
||
@Override | ||
ListOrdersRequest amazonRequest() { | ||
if(request == null){ | ||
request = new ListOrdersRequest() | ||
request.sellerId = this.config().current().sellerId() | ||
request.marketplaceId = [this.config().current().marketplaceId()] | ||
} | ||
return request | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/main/java/top/guyi/amazon/mws/response/impl/orders/ListOrderItemsHandler.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package top.guyi.amazon.mws.response.impl.orders | ||
|
||
import com.amazonservices.mws.orders._2013_09_01.model.ListOrderItemsRequest | ||
import com.amazonservices.mws.orders._2013_09_01.model.ListOrderItemsResponse | ||
import top.guyi.amazon.mws.response.SuperResponseHandler | ||
|
||
/** | ||
* Created by 古逸 on 2017-07-28. | ||
*/ | ||
class ListOrderItemsHandler extends SuperResponseHandler<ListOrderItemsResponse,ListOrderItemsRequest>{ | ||
|
||
@Override | ||
String getXML(ListOrderItemsResponse response) { | ||
return response.toXML() | ||
} | ||
|
||
@Override | ||
List<EntityData> pattern() { | ||
return null | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/top/guyi/amazon/mws/response/impl/orders/ListOrdersByNextTokenHandler.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package top.guyi.amazon.mws.response.impl.orders | ||
|
||
import com.amazonservices.mws.orders._2013_09_01.model.ListOrdersByNextTokenRequest | ||
import com.amazonservices.mws.orders._2013_09_01.model.ListOrdersByNextTokenResponse | ||
import top.guyi.amazon.mws.response.SuperResponseHandler | ||
|
||
/** | ||
* Created by 古逸 on 2017-07-28. | ||
*/ | ||
class ListOrdersByNextTokenHandler extends SuperResponseHandler<ListOrdersByNextTokenResponse,ListOrdersByNextTokenRequest>{ | ||
|
||
@Override | ||
String getXML(ListOrdersByNextTokenResponse response) { | ||
return response.toXML() | ||
} | ||
|
||
String nextToken | ||
|
||
@Override | ||
List<EntityData> pattern() { | ||
return null | ||
} | ||
|
||
@Override | ||
void over() { | ||
this.nextToken = this.response().listOrdersByNextTokenResult.nextToken | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/top/guyi/amazon/mws/response/impl/orders/ListOrdersHandler.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package top.guyi.amazon.mws.response.impl.orders | ||
|
||
import com.amazonservices.mws.orders._2013_09_01.model.ListOrdersRequest | ||
import com.amazonservices.mws.orders._2013_09_01.model.ListOrdersResponse | ||
import top.guyi.amazon.mws.response.SuperResponseHandler | ||
|
||
/** | ||
* Created by 古逸 on 2017-07-28. | ||
*/ | ||
class ListOrdersHandler extends SuperResponseHandler<ListOrdersResponse,ListOrdersRequest>{ | ||
|
||
@Override | ||
String getXML(ListOrdersResponse response) { | ||
return response.toXML() | ||
} | ||
|
||
String nextToken | ||
|
||
@Override | ||
List<EntityData> pattern() { | ||
return null | ||
} | ||
|
||
@Override | ||
void over() { | ||
this.nextToken = this.response().listOrdersResult.nextToken | ||
} | ||
} |