The Foxdeli
client is a Java client for the Foxdeli API, allowing you to interact with the API to manage parcels and
orders.
The documentation for the Foxdeli API can be found here.
Foxdeli-java-sdk uses Maven. At present the jars are available from Maven central.
Use the following dependency in your project to grab via Maven:
<dependency>
<groupId>com.foxdeli</groupId>
<artifactId>foxdeli-java-sdk</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
or Gradle:
implementation "com.foxdeli:foxdeli-java-sdk:1.0.0"
To start using the Foxdeli API, you need to initialize the Foxdeli
class with your authentication credentials. There
are two methods available for initialization:
- With only username and password:
String username = "your_username";
String password = "your_password";
Foxdeli.init(username, password);
- With username, password, eshopId, and marketId:
String username = "your_username";
String password = "your_password";
UUID eshopId = UUID.fromString("your_eshop_id");
UUID marketId = UUID.fromString("your_market_id");
Foxdeli.init(username, password, eshopId, marketId);
- Both above mentioned methods can be used with additional boolean param
stage
. This can be used in case of testing your app against stage environment. The default value isfalse
.
...
Foxdeli.init(username, password, stage);
or
...
Foxdeli.init(username, password, eshopId, marketId, stage);
The Foxdeli
client provides methods to create, retrieve, update, and cancel orders.
You can create an order using different methods with varying parameters. For example:
- Create an order with full details:
OrderRequest orderRequest = OrderRequest.builder().build(); // Replace this with actual order details
UUID marketId = UUID.fromString("your_market_id");
UUID eshopId = UUID.fromString("your_eshop_id");
Order createdOrder = Foxdeli.createOrder(orderRequest, marketId, eshopId);
- Create an order with default
eshopId
but custommarketId
(requires prior initialization):
OrderRequest orderRequest = OrderRequest.builder().build(); // Replace this with actual order details
UUID marketId = UUID.fromString("your_market_id"); // Only required if not initialized with eshopId and marketId
Order createdOrder = Foxdeli.createOrder(orderRequest, marketId);
- Create an order with default
marketId
andeshopId
(requires prior initialization):
OrderRequest orderRequest = OrderRequest.builder().build(); // Replace this with actual order details
Order createdOrder = Foxdeli.createOrder(orderRequest);
You can retrieve an order using its orderId
:
UUID orderId = UUID.fromString("your_order_id");
Order retrievedOrder = Foxdeli.getOrder(orderId);
To update an existing order, provide the updated order details and the orderId
:
OrderRequest updatedOrderRequest = OrderRequest.builder().build(); // Replace this with actual updated order details
UUID orderId = UUID.fromString("your_order_id");
Order updatedOrder = Foxdeli.updateOrder(updatedOrderRequest, orderId);
You can cancel an order by providing its orderId
:
UUID orderId = UUID.fromString("your_order_id");
Order canceledOrder = Foxdeli.cancelOrder(orderId);
The Foxdeli
client also provides methods to create, retrieve, update, and delete parcels.
To create a parcel, provide the orderId
and the ParcelRequest
object with parcel details:
UUID orderId = UUID.fromString("your_order_id");
ParcelRequest parcelRequest = ParcelRequest.builder().build(); // Replace this with actual parcel details
Parcel createdParcel = Foxdeli.createParcel(orderId, parcelRequest);
To retrieve a parcel, provide the orderId
and the parcelId
:
UUID orderId = UUID.fromString("your_order_id");
UUID parcelId = UUID.fromString("your_parcel_id");
Parcel retrievedParcel = Foxdeli.getParcel(orderId, parcelId);
To update an existing parcel, provide the orderId
, parcelId
, and the ParcelRequest
object with updated parcel
details:
UUID orderId = UUID.fromString("your_order_id");
UUID parcelId = UUID.fromString("your_parcel_id");
ParcelRequest updatedParcelRequest = ParcelRequest.builder().build(); // Replace this with actual updated parcel details
Parcel updatedParcel = Foxdeli.updateParcel(orderId, parcelId, updatedParcelRequest);
To delete a parcel, provide the orderId
and the parcelId
:
UUID orderId = UUID.fromString("your_order_id");
UUID parcelId = UUID.fromString("your_parcel_id");
Foxdeli.deleteParcel(orderId, parcelId);
Methods mentioned above can also create orders and parcels in one simple method call.
To create an order with a parcel at one request, use one of the createOrder
available methods. In the request specify
one or more parcels that should be created and linked to the order.
OrderRequest orderRequest = OrderRequest.builder()
.parcels(List.of(ParcelRequest.builder().build()))
.build();
Order createdOrder = Foxdeli.createOrder(orderRequest);