🇧🇷🚚 Mandaê API .NET client wrapper
Para a versão em português, por favor siga me.
This is an unofficial client for the Mandaê API V2
Build status | Last commit | Tests | Coverage | Code Smells | LoC |
---|---|---|---|---|---|
Download the latest zip file from the Release page.
Package | Version | Downloads |
---|---|---|
GuiStracini.Mandae |
This client supports the following operations/features of the API:
- Get rates for a delivery (postal code and package dimensions)
- Schedule a collect (register a collect in the customer distribution centre with one or more packages. Each package can have one or more items/SKU)
- Get tracking data of a shipment (Get all tracking data available from one package - tracking code is set by the customer or provided by webhook)
- WebHooks schema ready (The webhooks models, ready for implementation)
- Experimental Querying orders (API V1 - non-public API)
- Experimental Querying occurrences (API V1 - non-public API). Issue #1
- Experimental Querying reverses (API V1 - non-public API). Issue #2
- Experimental Request reverse (API V1 - non-public API). Issue #3
Initializes a new instance of MandaeClient class.
Example:
//Request your API token to [email protected]
//Each environment has its own API token!
var apiToken = "my API token";
//Call the constructor with the API token and the API environment (SANDBOX | PRODUCTION).
//var client = new MandaeClient(apiToken); //<= Environment.SANDBOX is the default environment.
var client = new MandaeClient(apiToken, Environment.PRODUCTION);
Get the rates (Rápido & Econômico) values and delivery time for a specified postal code and package dimensions.
Example:
//The MandaeClient
var client = new MandaeClient("my API token");
//The RatesModel
var delivery = new RatesModel {
PostalCode = "22041080",
...
}
var rates = client.GetRates(delivery);
var fast = rates.ShippingServices.Single(s => s.Name == "Rápido");
var economic = rates.ShippingServices.Single(s => s.Name == "Econômico");
var option = ShippingService.ECONOMICO;
if(fast.Price < economic.Price)
option = ShippingService.RAPIDO;
//The OrderModel (order collect request model)
var order = new OrderModel { ... };
order.Items = new [] {
new NewItem
{
....
ShippingService = option
}
};
var order = client.RegisterOrderCollectRequest(order);
Schedule a collect request (pickup in a distribution center/origin location).
Inform which type of Vehicle, when, which rate (Rapido | Economico) and the order items (a.k.a packages or clients orders).
Each package means an order/volume, that can have one or more items (SKUs).
Example:
//The MandaeClient
var client = new MandaeClient("my API token");
//The OrderModel (order collect request model)
var order = new OrderModel { ... };
order.Items = new [] {
new NewItem
{
....
ShippingService = option
}
};
//Makes the request
var order = client.RegisterOrderCollectRequest(order);
**
//order.Id is the id for further use (maybe cancel the request ?)
Example:
//The MandaeClient
var client = new MandaeClient("my API token");
//The tracking identifier (Generated by the Mandae or sent by the order collection request
var trackingId = "MyCompany-00001";
var tracking = client.GetTracking(tracking);
//tracking.CarrierName;
//tracking.CarrierCode;
//tracking.Events;
For the V1 you'll need to use the e-mail/password combination of the Mandaê panel to log in V1 API.
Example:
//The MandaeClient
var client = new MandaeClient("V2 API token");
client.ConfigureV1Authentication("[email protected]", "password");
var trackingCode = "XYZ000001";//The tracking code of some order
var result = client.Search(SearchMethod.TRACKING_CODE, trackingCode);
if(result.Total == 1)
Console.WriteLine(result.Orders.Single().SituationDescription);
- Release v6.0.0 and higher DEPRECATED methods: Get Latest Order
- Release v5.0.0 and higher DEPRECATED methods: Large Request, Cancel Request, Cancel Item Request
- Release v3.0.0 and higher changes the V1 authentication method. Now use your e-mail/password of the Mandaê panel to log in to the V1 API.
- Release v1.4.1 and higher also includes an experimental (non-public) V1 endpoint for search/querying orders (the same interface as available through the Mandaê administration panel).
Warning
The API V1 is not officially public, so there is no warranty that it will still be working