Skip to content
This repository was archived by the owner on Sep 1, 2025. It is now read-only.

Repository files navigation

Stuart C# Client

Created and provided by OrderYOYO

For a complete documentation of all endpoints offered by the Stuart API, you can visit Stuart API documentation.

Install

Via NuGet Package Manager:

$ PM> Install-Package stuart-client-csharp -Version 1.3.4

Usage

  1. Initialize Client
  2. Create a Job
    1. Minimalist
    2. Complete
      1. With scheduling at pickup
      2. With scheduling at drop off
      3. With stacking (multi-drop)
  3. Get a Job
  4. Cancel a Job
  5. Validate a Job
  6. Cancel a delivery
  7. Get a pricing
  8. Get a job eta to pickup

Initialize client

varclientId="<put_your_ID_here>";// can be found here: https://admin.sandbox.stuart.com/client/apivarclientSecret="<put_your_secret_here>";// can be found here: https://admin.sandbox.stuart.com/client/apivarenvironment=Environment.Sandbox;varstuartApi=StuartApi.Initialize(environment,clientId,clientSecret);

Create a Job

Important: Even if you can create a Job with a minimal set of parameters, we highly recommend that you fill as many information as you can in order to ensure the delivery process goes well.

Minimalist

Package size based
varjob=newJobRequest{Job=newJob{PickUps=newList<PickUp>{newPickUp{Address="12 rue rivoli, 75001 Paris"}},DropOffs=newList<DropOff>{newDropOff{Address="42 rue rivoli, 75001 Paris",PackageType=PackageSizeType.small}}}};varcreatedJob=awaitStuartApi.Job.CreateJob(job);
Transport type based (France only)
varjob=newJobRequest{Job=newJob{TransportType=TransportType.bike
PickUps =newList<PickUp>{newPickUp{Address="12 rue rivoli, 75001 Paris"}},DropOffs=newList<DropOff>{newDropOff{Address="42 rue rivoli, 75001 Paris"}}}};varcreatedJob=awaitStuartApi.Job.CreateJob(job);

Complete

Package size based
varjob=newJobRequest{Job=newJob{PickUps=newList<PickUp>{newPickUp{Address="12 rue rivoli, 75001 Paris",Comment="Wait outside for an employee to come.",Contact=newContact{FirstName="Martin",LastName="Pont",Phone="+33698348756",Company="KFC Paris Barbès"}}},DropOffs=newList<DropOff>{newDropOff{PackageType=PackageSizeType.small,PackageDescription="Pizza box",ClientReference="12345678ABCDE",// Must be uniqueAddress="42 rue rivoli, 75001 Paris",Comment="code: 3492B. 3e étage droite. Sonner à Durand.",Contact=newContact{FirstName="Alex",LastName="Durand",Phone="+33634981209",}}}}};varcreatedJob=awaitStuartApi.Job.CreateJob(job);
Transport type based (France only)
varjob=newJobRequest{Job=newJob{TransportType=TransportType.bike
PickUps =newList<PickUp>{newPickUp{Address="12 rue rivoli, 75001 Paris",Comment="Wait outside for an employee to come.",Contact=newContact{FirstName="Martin",LastName="Pont",Phone="+33698348756",Company="KFC Paris Barbès"}}},DropOffs=newList<DropOff>{newDropOff{PackageDescription="Pizza box",ClientReference="12345678ABCDE",// Must be uniqueAddress="42 rue rivoli, 75001 Paris",Comment="code: 3492B. 3e étage droite. Sonner à Durand.",Contact=newContact{FirstName="Alex",LastName="Durand",Phone="+33634981209",}}}}};varcreatedJob=awaitStuartApi.Job.CreateJob(job);

With scheduling at pickup

For more information about job scheduling you should check our API documentation.

varjob=newJobRequest{Job=newJob{PickUpAt=DateTime.UtcNow.AddHours(2),PickUps=newList<PickUp>{newPickUp{Address="12 rue rivoli, 75001 Paris"}},DropOffs=newList<DropOff>{newDropOff{Address="42 rue rivoli, 75001 Paris",PackageType=PackageSizeType.small}}}};varcreatedJob=awaitStuartApi.Job.CreateJob(job);

With scheduling at dropoff

For more information about job scheduling you should check our API documentation.

Please note that this feature can only be used with only one dropoff.

varjob=newJobRequest{Job=newJob{DropOffAt=DateTime.UtcNow.AddHours(2),PickUps=newList<PickUp>{newPickUp{Address="12 rue rivoli, 75001 Paris"}},DropOffs=newList<DropOff>{newDropOff{Address="42 rue rivoli, 75001 Paris",PackageType=PackageSizeType.small}}}};varcreatedJob=awaitStuartApi.Job.CreateJob(job);

With stacking (multi-drop)

Package size based
varjob=newJobRequest{Job=newJob{PickUps=newList<PickUp>{newPickUp{Address="12 rue rivoli, 75001 Paris",Comment="Wait outside for an employee to come.",Contact=newContact{FirstName="Martin",LastName="Pont",Phone="+33698348756",Company="KFC Paris Barbès"}}},DropOffs=newList<DropOff>{newDropOff{PackageType=PackageSizeType.small,PackageDescription="Red packet.",ClientReference="12345678ABCDE",// Must be uniqueAddress="42 rue rivoli, 75001 Paris",Comment="code: 3492B. 3e étage droite. Sonner à Durand.",Contact=newContact{FirstName="Alex",LastName="Durand",Phone="+33634981209",}},newDropOff{PackageType=PackageSizeType.small,PackageDescription="Blue packet.",ClientReference="ABCDE213124",// Must be uniqueAddress="156 rue de Charonne, 75011 Paris",Comment="code: 92A42. 2e étage gauche",Contact=newContact{FirstName="Maximilien",LastName="Lebluc",Phone="+33632341209",}}}}};varcreatedJob=awaitStuartApi.Job.CreateJob(job);
Transport type based (France only)
varjob=newJobRequest{Job=newJob{TransportType=TransportType.bike
PickUps =newList<PickUp>{newPickUp{Address="12 rue rivoli, 75001 Paris",Comment="Wait outside for an employee to come.",Contact=newContact{FirstName="Martin",LastName="Pont",Phone="+33698348756",Company="KFC Paris Barbès"}}},DropOffs=newList<DropOff>{newDropOff{PackageDescription="Red packet.",ClientReference="12345678ABCDE",// Must be uniqueAddress="42 rue rivoli, 75001 Paris",Comment="code: 3492B. 3e étage droite. Sonner à Durand.",Contact=newContact{FirstName="Alex",LastName="Durand",Phone="+33634981209",}},newDropOff{PackageDescription="Blue packet.",ClientReference="ABCDE213124",// Must be uniqueAddress="156 rue de Charonne, 75011 Paris",Comment="code: 92A42. 2e étage gauche",Contact=newContact{FirstName="Maximilien",LastName="Lebluc",Phone="+33632341209",}}}}};varcreatedJob=awaitStuartApi.Job.CreateJob(job);

Get a Job

Once you successfully created a Job you can retrieve it this way:

varjobId=126532;varjob=awaitStuartApi.Job.GetJob(jobId);

Or when you create a new Job:

varjob=newJobRequest{Job=newJob{PickUps=newList<PickUp>{newPickUp{Address="12 rue rivoli, 75001 Paris"}},DropOffs=newList<DropOff>{newDropOff{Address="42 rue rivoli, 75001 Paris",PackageType=PackageSizeType.small}}}};varcreatedJob=awaitStuartApi.Job.CreateJob(job);createdJob.Deliveries

The Stuart API determine the optimal route on your behalf, that's why the createdJob.Deliveries propery will be empty List when the Job has not been created yet. The createdJob.Deliveries propery will contain a List of Delivery as soon as the Job is created.

Cancel a job

Once you successfully created a Job you can cancel it in this way:

varjobId=126532;awaitStuartApi.Job.CancelJob(jobId);

The method CancelJob(); will return only Task if the job was cancelled. If there was an error, it will throw an exception with information about reason.

For more details about how cancellation works, please refer to our dedicated documentation section.

Validate a Job

Before creating a Job you can validate it (control delivery area & address format). Validating a Job is optional and does not prevent you from creating a Job.

varjob=newJobRequest{Job=newJob{PickUps=newList<PickUp>{newPickUp{Address="12 rue rivoli, 75001 Paris"}},DropOffs=newList<DropOff>{newDropOff{Address="42 rue rivoli, 75001 Paris",PackageType=PackageSizeType.small}}}};varresult=awaitStuartApi.Job.ValidateParameters(job);

The result will hold the boolean value true if the job is valid. If there was an error, it will throw an exception with information about reason.

Cancel a delivery

Once you successfully created a Delivery you can cancel it in this way:

vardeliveryId=126532;awaitStuartApi.Job.CancelDelivery(deliveryId);

Get a pricing

Before creating a Job you can ask for a pricing. Asking for a pricing is optional and does not prevent you from creating a Job.

varjob=newJobRequest{Job=newJob{PickUps=newList<PickUp>{newPickUp{Address="12 rue rivoli, 75001 Paris"}},DropOffs=newList<DropOff>{newDropOff{Address="42 rue rivoli, 75001 Paris",PackageType=PackageSizeType.small}}}};varresult=awaitStuartApi.Job.RequestJobPricing(job);result.Amount;// example: 11.5result.Currency;// example: "EUR"

Get a job ETA to pickup

Before creating a Job you can ask for an estimated time of arrival at the pickup location (expressed in seconds). Asking for ETA is optional and does not prevent you from creating a job.

varjob=newJobRequest{Job=newJob{PickUps=newList<PickUp>{newPickUp{Address="12 rue rivoli, 75001 Paris"}},DropOffs=newList<DropOff>{newDropOff{Address="42 rue rivoli, 75001 Paris",PackageType=PackageSizeType.small}}}};vareta=awaitStuartApi.Job.RequestEta(job);eta;// example: 672

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages