@@ -912,123 +912,147 @@ public List<Smartrate> smartrates(final String apiKey) throws EasyPostException
912
912
/**
913
913
* Buy this Shipment.
914
914
*
915
+ * @param params the options for the query.
915
916
* @return Shipment object
916
917
* @throws EasyPostException when the request fails.
917
918
*/
918
- public Shipment buy () throws EasyPostException {
919
- return this .buy (new HashMap < String , Object >() {} , false , null );
919
+ public Shipment buy (final Map < String , Object > params ) throws EasyPostException {
920
+ return this .buy (params , false , null );
920
921
}
921
922
922
923
/**
923
924
* Buy this Shipment.
924
925
*
925
- * @param withCarbonOffset whether to include a carbon offset when buying the shipment .
926
+ * @param rate the Rate to use for this Shipment .
926
927
* @return Shipment object
927
928
* @throws EasyPostException when the request fails.
928
929
*/
929
- public Shipment buy (final boolean withCarbonOffset ) throws EasyPostException {
930
- return this .buy (new HashMap <String , Object >() {}, withCarbonOffset , null );
930
+ public Shipment buy (final Rate rate ) throws EasyPostException {
931
+ Map <String , Object > params = new HashMap <>();
932
+ params .put ("rate" , rate );
933
+
934
+ return this .buy (params , false , null );
931
935
}
932
936
933
937
/**
934
938
* Buy this Shipment.
935
939
*
936
- * @param params the options for the query.
940
+ * @param rate the Rate to use for this Shipment.
941
+ * @param withCarbonOffset whether to include a carbon offset when buying the shipment.
937
942
* @return Shipment object
938
943
* @throws EasyPostException when the request fails.
939
944
*/
940
- public Shipment buy (final Map <String , Object > params ) throws EasyPostException {
941
- return this .buy (params , false , null );
945
+ public Shipment buy (final Rate rate , final boolean withCarbonOffset ) throws EasyPostException {
946
+ Map <String , Object > params = new HashMap <>();
947
+ params .put ("rate" , rate );
948
+
949
+ return this .buy (params , withCarbonOffset , null , null );
942
950
}
943
951
944
952
/**
945
953
* Buy this Shipment.
946
954
*
947
- * @param params the options for the query .
948
- * @param withCarbonOffset whether to include a carbon offset when buying the shipment .
955
+ * @param rate the Rate to use for this Shipment .
956
+ * @param endShipperId the id of the end shipper to use for this purchase .
949
957
* @return Shipment object
950
958
* @throws EasyPostException when the request fails.
951
959
*/
952
- public Shipment buy (final Map <String , Object > params , final boolean withCarbonOffset ) throws EasyPostException {
953
- return this .buy (params , withCarbonOffset , null );
960
+ public Shipment buy (final Rate rate , final String endShipperId ) throws EasyPostException {
961
+ Map <String , Object > params = new HashMap <>();
962
+ params .put ("rate" , rate );
963
+
964
+ return this .buy (params , false , endShipperId , null );
954
965
}
955
966
956
967
/**
957
968
* Buy this Shipment.
958
969
*
970
+ * @param params the options for the query.
959
971
* @param apiKey API key to use in request (overrides default API key).
960
972
* @return Shipment object
961
973
* @throws EasyPostException when the request fails.
962
974
*/
963
- public Shipment buy (final String apiKey ) throws EasyPostException {
964
- return this .buy (new HashMap <String , Object >() {}, false , apiKey );
975
+ public Shipment buy (final Map <String , Object > params , final String apiKey ) throws EasyPostException {
976
+ // TODO: When Java Client Library rewrite happens, the apiKey param will be replaced with endShipperId
977
+ return this .buy (params , false , null , apiKey );
965
978
}
966
979
967
980
/**
968
981
* Buy this Shipment.
969
982
*
983
+ * @param params the options for the query.
970
984
* @param withCarbonOffset whether to include a carbon offset when buying the shipment.
971
- * @param apiKey API key to use in request (overrides default API key).
972
985
* @return Shipment object
973
986
* @throws EasyPostException when the request fails.
974
987
*/
975
- public Shipment buy (final boolean withCarbonOffset , final String apiKey ) throws EasyPostException {
976
- return this .buy (new HashMap < String , Object >() {}, withCarbonOffset , apiKey );
988
+ public Shipment buy (final Map < String , Object > params , final boolean withCarbonOffset ) throws EasyPostException {
989
+ return this .buy (params , withCarbonOffset , null );
977
990
}
978
991
979
992
/**
980
993
* Buy this Shipment.
981
994
*
982
995
* @param rate the Rate to use for this Shipment.
996
+ * @param withCarbonOffset whether to include a carbon offset when buying the shipment.
997
+ * @param endShipperId the id of the end shipper to use for this purchase.
998
+ * @param apiKey API key to use in request (overrides default API key).
983
999
* @return Shipment object
984
1000
* @throws EasyPostException when the request fails.
985
1001
*/
986
- public Shipment buy (final Rate rate ) throws EasyPostException {
987
- Map <String , Object > params = new HashMap <>();
988
- params .put ("rate" , rate );
1002
+ public Shipment buy (final Rate rate , final boolean withCarbonOffset , final String endShipperId , final String apiKey )
1003
+ throws EasyPostException {
1004
+ Map <String , Object > params = new HashMap <>();
1005
+ params .put ("rate" , rate );
989
1006
990
- return this .buy (params , false , null );
1007
+ return this .buy (params , withCarbonOffset , endShipperId , apiKey );
991
1008
}
992
1009
993
1010
/**
994
1011
* Buy this Shipment.
995
1012
*
996
- * @param rate the Rate to use for this Shipment .
1013
+ * @param params the options for the query .
997
1014
* @param withCarbonOffset whether to include a carbon offset when buying the shipment.
1015
+ * @param apiKey API key to use in request (overrides default API key).
998
1016
* @return Shipment object
999
1017
* @throws EasyPostException when the request fails.
1000
1018
*/
1001
- public Shipment buy (final Rate rate , final boolean withCarbonOffset ) throws EasyPostException {
1002
- Map <String , Object > params = new HashMap <>();
1003
- params .put ("rate" , rate );
1004
-
1005
- return this .buy (params , withCarbonOffset , null );
1019
+ public Shipment buy (final Map <String , Object > params , final boolean withCarbonOffset , final String apiKey )
1020
+ throws EasyPostException {
1021
+ return this .buy (params , withCarbonOffset , null , apiKey );
1006
1022
}
1007
1023
1008
1024
/**
1009
1025
* Buy this Shipment.
1010
1026
*
1011
- * @param params the options for the query.
1012
- * @param apiKey API key to use in request (overrides default API key).
1027
+ * @param params the options for the query.
1028
+ * @param endShipperId the id of the end shipper to use for this purchase.
1029
+ * @param apiKey API key to use in request (overrides default API key).
1013
1030
* @return Shipment object
1014
1031
* @throws EasyPostException when the request fails.
1015
1032
*/
1016
- public Shipment buy (final Map <String , Object > params , final String apiKey ) throws EasyPostException {
1017
- return this .buy (params , false , apiKey );
1033
+ public Shipment buy (final Map <String , Object > params , final String endShipperId , final String apiKey )
1034
+ throws EasyPostException {
1035
+ return this .buy (params , false , endShipperId , apiKey );
1018
1036
}
1019
1037
1020
1038
/**
1021
1039
* Buy this Shipment.
1022
1040
*
1023
1041
* @param params the options for the query.
1024
1042
* @param withCarbonOffset whether to include a carbon offset when buying the shipment.
1043
+ * @param endShipperId the id of the end shipper to use for this purchase.
1025
1044
* @param apiKey API key to use in request (overrides default API key).
1026
1045
* @return Shipment object
1027
1046
* @throws EasyPostException when the request fails.
1028
1047
*/
1029
- public Shipment buy (final Map <String , Object > params , final boolean withCarbonOffset , final String apiKey )
1030
- throws EasyPostException {
1048
+ public Shipment buy (final Map <String , Object > params , final boolean withCarbonOffset ,
1049
+ final String endShipperId , final String apiKey ) throws EasyPostException {
1031
1050
params .put ("carbon_offset" , withCarbonOffset );
1051
+
1052
+ if (endShipperId != null && !endShipperId .isEmpty ()) {
1053
+ params .put ("end_shipper_id" , endShipperId );
1054
+ }
1055
+
1032
1056
Shipment response =
1033
1057
request (RequestMethod .POST , String .format ("%s/buy" , instanceURL (Shipment .class , this .getId ())), params ,
1034
1058
Shipment .class , apiKey );
0 commit comments