Skip to content

Commit 884f35d

Browse files
authored
Move End Shipper to general availability (#178)
* - Copy EndShipper class to main namespace - Mark EndShipper beta class as deprecated - Update EndShipper.all to return EndShipperCollection - New EndShipperCollection class to wrap list of End Shipper objects - Update unit tests - Fix bad docstrings
1 parent 30ab3ab commit 884f35d

File tree

9 files changed

+257
-113
lines changed

9 files changed

+257
-113
lines changed

src/main/java/com/easypost/model/AddressCollection.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public final class AddressCollection extends EasyPostResource {
1111
/**
1212
* Get a list of addresses.
1313
*
14-
* @return List of Batch objects
14+
* @return List of Address objects
1515
*/
1616
public List<Address> getAddresses() {
1717
return addresses;
@@ -20,7 +20,7 @@ public List<Address> getAddresses() {
2020
/**
2121
* Set a list of addresses.
2222
*
23-
* @param addresses List of Batch objects
23+
* @param addresses List of Address objects
2424
*/
2525
public void setAddresses(final List<Address> addresses) {
2626
this.addresses = addresses;
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
package com.easypost.model;
2+
3+
import com.easypost.EasyPost;
4+
import com.easypost.exception.EasyPostException;
5+
6+
import java.util.HashMap;
7+
import java.util.Map;
8+
9+
public final class EndShipper extends BaseAddress {
10+
/**
11+
* Create EndShipper object from parameter map.
12+
*
13+
* @param params Map of EndShipper parameters.
14+
* @return EndShipper object.
15+
* @throws EasyPostException when the request fails.
16+
*/
17+
public static EndShipper create(final Map<String, Object> params) throws EasyPostException {
18+
return create(params, null);
19+
}
20+
21+
/**
22+
* Create EndShipper object from parameter map.
23+
*
24+
* @param params Map of EndShipper parameters.
25+
* @param apiKey Optional API key to use for this request.
26+
* @return EndShipper object.
27+
* @throws EasyPostException when the request fails.
28+
*/
29+
public static EndShipper create(final Map<String, Object> params, final String apiKey) throws EasyPostException {
30+
Map<String, Object> wrappedParams = new HashMap<String, Object>();
31+
32+
wrappedParams.put("address", params);
33+
34+
return request(RequestMethod.POST, String.format("%s/%s", EasyPost.API_BASE, "end_shippers"),
35+
wrappedParams, EndShipper.class, apiKey);
36+
}
37+
38+
/**
39+
* Retrieve EndShipper object from API.
40+
*
41+
* @param id ID of EndShipper to retrieve.
42+
* @return EndShipper object.
43+
* @throws EasyPostException when the request fails.
44+
*/
45+
public static EndShipper retrieve(final String id) throws EasyPostException {
46+
return retrieve(id, null);
47+
}
48+
49+
/**
50+
* Retrieve EndShipper object from API.
51+
*
52+
* @param id ID of EndShipper to retrieve.
53+
* @param apiKey API key to use in request (overrides default API key).
54+
* @return EndShipper object.
55+
* @throws EasyPostException when the request fails.
56+
*/
57+
public static EndShipper retrieve(final String id, final String apiKey) throws EasyPostException {
58+
return request(RequestMethod.GET, String.format("%s/%s/%s", EasyPost.API_BASE, "end_shippers", id), null,
59+
EndShipper.class, apiKey);
60+
}
61+
62+
/**
63+
* List all EndShipper objects.
64+
*
65+
* @param params Map of parameters.
66+
* @return EndShipperCollection object.
67+
* @throws EasyPostException when the request fails.
68+
*/
69+
public static EndShipperCollection all(final Map<String, Object> params) throws EasyPostException {
70+
return all(params, null);
71+
}
72+
73+
/**
74+
* List all EndShipper objects.
75+
*
76+
* @param params Map of parameters.
77+
* @param apiKey API key to use in request (overrides default API key).
78+
* @return EndShipperCollection object.
79+
* @throws EasyPostException when the request fails.
80+
*/
81+
public static EndShipperCollection all(final Map<String, Object> params, final String apiKey)
82+
throws EasyPostException {
83+
return request(RequestMethod.GET, classURL(EndShipper.class), params, EndShipperCollection.class, apiKey);
84+
}
85+
86+
/**
87+
* Update an EndShipper object.
88+
*
89+
* @param params Map of parameters.
90+
* @return EndShipper object.
91+
* @throws EasyPostException when the request fails.
92+
*/
93+
public EndShipper update(final Map<String, Object> params) throws EasyPostException {
94+
return update(params, null);
95+
}
96+
97+
/**
98+
* Update an EndShipper object.
99+
*
100+
* @param params Map of parameters.
101+
* @param apiKey API key to use in request (overrides default API key).
102+
* @return EndShipper object.
103+
* @throws EasyPostException when the request fails.
104+
*/
105+
public EndShipper update(final Map<String, Object> params, final String apiKey) throws EasyPostException {
106+
Map<String, Object> wrappedParams = new HashMap<String, Object>();
107+
108+
wrappedParams.put("address", params);
109+
110+
EndShipper response = request(RequestMethod.PUT,
111+
String.format("%s/%s/%s", EasyPost.API_BASE, "end_shippers", this.getId()), wrappedParams,
112+
EndShipper.class, apiKey);
113+
114+
this.merge(this, response);
115+
return this;
116+
}
117+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.easypost.model;
2+
3+
import java.util.List;
4+
5+
public class EndShipperCollection {
6+
private List<EndShipper> endShippers;
7+
private Boolean hasMore;
8+
9+
/**
10+
* Get a list of EndShippers.
11+
*
12+
* @return List of EndShipper objects
13+
*/
14+
public List<EndShipper> getEndShippers() {
15+
return endShippers;
16+
}
17+
18+
/**
19+
* Set a list of EndShippers.
20+
*
21+
* @param addresses List of EndShipper objects
22+
*/
23+
public void setEndShippers(final List<EndShipper> addresses) {
24+
this.endShippers = addresses;
25+
}
26+
27+
/**
28+
* Get whether there are more EndShippers to retrieve.
29+
*
30+
* @return whether there are more EndShippers to retrieve
31+
*/
32+
public Boolean getHasMore() {
33+
return hasMore;
34+
}
35+
36+
/**
37+
* Set whether there are more EndShippers to retrieve.
38+
*
39+
* @param hasMore Boolean whether there are more EndShippers to retrieve
40+
*/
41+
public void setHasMore(final Boolean hasMore) {
42+
this.hasMore = hasMore;
43+
}
44+
}

src/main/java/com/easypost/model/beta/EndShipper.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@
99
import java.util.List;
1010
import java.util.Map;
1111

12+
/**
13+
* @deprecated Use {@link com.easypost.model.EndShipper} instead.
14+
* Deprecated: v5.9.0 - v7.0.0
15+
*/
1216
public final class EndShipper extends BaseAddress {
1317
/**
1418
* Create EndShipper object from parameter map.
1519
*
16-
* @param params Map of end shipper parameters.
20+
* @param params Map of EndShipper parameters.
1721
* @return EndShipper object.
1822
* @throws EasyPostException when the request fails.
1923
*/
@@ -24,7 +28,7 @@ public static EndShipper create(final Map<String, Object> params) throws EasyPos
2428
/**
2529
* Create EndShipper object from parameter map.
2630
*
27-
* @param params Map of end shipper parameters.
31+
* @param params Map of EndShipper parameters.
2832
* @param apiKey Optional API key to use for this request.
2933
* @return EndShipper object.
3034
* @throws EasyPostException when the request fails.
@@ -41,7 +45,7 @@ public static EndShipper create(final Map<String, Object> params, final String a
4145
/**
4246
* Retrieve EndShipper object from API.
4347
*
44-
* @param id ID of end shipper to retrieve.
48+
* @param id ID of EndShipper to retrieve.
4549
* @return EndShipper object.
4650
* @throws EasyPostException when the request fails.
4751
*/
@@ -52,7 +56,7 @@ public static EndShipper retrieve(final String id) throws EasyPostException {
5256
/**
5357
* Retrieve EndShipper object from API.
5458
*
55-
* @param id ID of end shipper to retrieve.
59+
* @param id ID of EndShipper to retrieve.
5660
* @param apiKey API key to use in request (overrides default API key).
5761
* @return EndShipper object.
5862
* @throws EasyPostException when the request fails.

src/test/cassettes/end_shipper/all.json

Lines changed: 14 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/test/cassettes/end_shipper/create.json

Lines changed: 12 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)