Spoleto.Delivery
1.0.0
See the version list below for details.
dotnet add package Spoleto.Delivery --version 1.0.0
NuGet\Install-Package Spoleto.Delivery -Version 1.0.0
<PackageReference Include="Spoleto.Delivery" Version="1.0.0" />
paket add Spoleto.Delivery --version 1.0.0
#r "nuget: Spoleto.Delivery, 1.0.0"
// Install Spoleto.Delivery as a Cake Addin #addin nuget:?package=Spoleto.Delivery&version=1.0.0 // Install Spoleto.Delivery as a Cake Tool #tool nuget:?package=Spoleto.Delivery&version=1.0.0
Spoleto.Delivery
Spoleto.Delivery is a comprehensive solution designed to integrate delivery functionality into your .NET applications. This project provides a maintainable architecture that simplifies interaction with various delivery providers (e.g., Cdek, MasterPost).
This project supports .NET Standard 2.0, .NET 7, and .NET 8.
https://github.com/spoleto-software/Spoleto.Delivery
Features
- Abstraction Layer: Simplifies the integration of delivery services by providing a unified interface.
- Multiple Providers: Supports various delivery providers, allowing you to switch or combine them easily.
- Async Support: Fully supports asynchronous operations for improved performance.
Quick setup
Begin by installing the package through the NuGet package manager with the command:
Install-Package Spoleto.Delivery
.
Usage
Main Interface
The main interface, IDeliveryService
, serves as an abstraction layer for the delivery of goods. Below is a sample implementation:
namespace Spoleto.Delivery
{
public interface IDeliveryService
{
IEnumerable<IDeliveryProvider> Providers { get; }
IDeliveryProvider DefaultProvider { get; }
List<City> GetCities(CityRequest cityRequest);
List<City> GetCities(string providerName, CityRequest cityRequest);
List<City> GetCities(DeliveryProviderName providerName, CityRequest cityRequest);
List<City> GetCities(IDeliveryProvider provider, CityRequest cityRequest);
Task<List<City>> GetCitiesAsync(CityRequest cityRequest);
Task<List<City>> GetCitiesAsync(string providerName, CityRequest cityRequest);
Task<List<City>> GetCitiesAsync(DeliveryProviderName providerName, CityRequest cityRequest);
Task<List<City>> GetCitiesAsync(IDeliveryProvider provider, CityRequest cityRequest);
List<Tariff> GetTariffs(TariffRequest tariffRequest);
List<Tariff> GetTariffs(string providerName, TariffRequest tariffRequest);
List<Tariff> GetTariffs(DeliveryProviderName providerName, TariffRequest tariffRequest);
List<Tariff> GetTariffs(IDeliveryProvider provider, TariffRequest tariffRequest);
Task<List<Tariff>> GetTariffsAsync(TariffRequest tariffRequest);
Task<List<Tariff>> GetTariffsAsync(string providerName, TariffRequest tariffRequest);
Task<List<Tariff>> GetTariffsAsync(DeliveryProviderName providerName, TariffRequest tariffRequest);
Task<List<Tariff>> GetTariffsAsync(IDeliveryProvider provider, TariffRequest tariffRequest);
List<AdditionalService> GetAdditionalServices(Tariff tariff);
List<AdditionalService> GetAdditionalServices(string providerName, Tariff tariff);
List<AdditionalService> GetAdditionalServices(DeliveryProviderName providerName, Tariff tariff);
List<AdditionalService> GetAdditionalServices(IDeliveryProvider provider, Tariff tariff);
Task<List<AdditionalService>> GetAdditionalServicesAsync(Tariff tariff);
Task<List<AdditionalService>> GetAdditionalServicesAsync(string providerName, Tariff tariff);
Task<List<AdditionalService>> GetAdditionalServicesAsync(DeliveryProviderName providerName, Tariff tariff);
Task<List<AdditionalService>> GetAdditionalServicesAsync(IDeliveryProvider provider, Tariff tariff);
DeliveryOrder CreateDeliveryOrder(DeliveryOrderRequest deliveryOrderRequest);
DeliveryOrder CreateDeliveryOrder(string providerName, DeliveryOrderRequest deliveryOrderRequest);
DeliveryOrder CreateDeliveryOrder(DeliveryProviderName providerName, DeliveryOrderRequest deliveryOrderRequest);
DeliveryOrder CreateDeliveryOrder(IDeliveryProvider provider, DeliveryOrderRequest deliveryOrderRequest);
Task<DeliveryOrder> CreateDeliveryOrderAsync(DeliveryOrderRequest deliveryOrderRequest);
Task<DeliveryOrder> CreateDeliveryOrderAsync(string providerName, DeliveryOrderRequest deliveryOrderRequest);
Task<DeliveryOrder> CreateDeliveryOrderAsync(DeliveryProviderName providerName, DeliveryOrderRequest deliveryOrderRequest);
Task<DeliveryOrder> CreateDeliveryOrderAsync(IDeliveryProvider provider, DeliveryOrderRequest deliveryOrderRequest);
}
}
Providers Interface
Each delivery provider must implement the IDeliveryProvider
interface:
namespace Spoleto.Delivery.Providers
{
public interface IDeliveryProvider
{
string Name { get; }
List<City> GetCities(CityRequest cityRequest);
Task<List<City>> GetCitiesAsync(CityRequest cityRequest);
List<Tariff> GetTariffs(TariffRequest tariffRequest);
Task<List<Tariff>> GetTariffsAsync(TariffRequest tariffRequest);
List<AdditionalService> GetAdditionalServices(Tariff tariff);
Task<List<AdditionalService>> GetAdditionalServicesAsync(Tariff tariff);
DeliveryOrder CreateDeliveryOrder(DeliveryOrderRequest deliveryOrderRequest);
Task<DeliveryOrder> CreateDeliveryOrderAsync(DeliveryOrderRequest deliveryOrderRequest);
}
}
Example
Here is a simple example to demonstrate how to use Spoleto.Delivery in your project:
using Spoleto.Delivery;
using Spoleto.Delivery.Providers;
public class Example
{
public async Task Run()
{
var deliveryService = new DeliveryServiceFactory()
.WithOptions(x => x.DefaultProvider == CdekProvider.ProviderName)
.AddProvider(new CdekProvider(cdekOptions))
.AddProvider(new MasterPostProvider(masterPostOptions))
.Build();
var cityRequest = new CityRequest
{
Name = "Москва"
};
var cities = await deliveryService.GetCitiesAsync(cityRequest);
var tariffRequest = new TariffRequest
{
FromLocation = new() { Code = "270" },
ToLocation = new() { Code = "44" },
Packages =
[
new()
{
Weight = 4000,
Height = 10,
Width = 10,
Length = 10
}
],
};
var tariffs = await deliveryService.GetTariffsAsync(tariffRequest);
var deliveryOrderRequest = new DeliveryOrderRequest
{
Type = OrderType.RegularDelivery,
Comment = "Just another test order",
FromLocation = new()
{
Code = "44",
Address = "пр. Ленинградский, д.4",
},
ToLocation = new()
{
Code = "44",
FiasGuid = Guid.Parse("0c5b2444-70a0-4932-980c-b4dc0d3f02b5"),
Address = "ул. Блюхера, 32"
},
NumTariffCode = tariffs.First().NumCode,
Packages =
[
new()
{
Number = "1",
Comment = "Test",
Weight = 1000,
Width = 10,
Height = 10,
Length = 10,
},
],
Sender = new()
{
Company = "Roga",
Name = "Copyta",
Email = "roga@copyta.com",
Phones =
[
new() { Number = "+71111111111" },
],
},
Recipient = new()
{
Company = "Ushi",
Name = "Hvost",
Email = "ushi@hvost.com",
Phones =
[
new() { Number = "+72222222222" },
],
},
};
var order = await deliveryService.CreateDeliveryOrderAsync(deliveryOrderRequest);
Console.WriteLine($"Order created with ID: {order.Uuid} and Number: {order.Number}");
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Spoleto.Common (>= 2.6.7.1130)
-
net7.0
- Spoleto.Common (>= 2.6.7.1130)
-
net8.0
- Spoleto.Common (>= 2.6.7.1130)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Spoleto.Delivery:
Package | Downloads |
---|---|
Spoleto.Delivery.Extensions
Delivery sender with different Delivery providers such as CDEK, MasterPost |
|
Spoleto.Delivery.MasterPost
MasterPost provider for Spoleto.Delivery |
|
Spoleto.Delivery.Cdek
CDEK provider for Spoleto.Delivery |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.43 | 246 | 11/12/2024 |
1.0.42 | 216 | 11/12/2024 |
1.0.41 | 224 | 11/11/2024 |
1.0.40 | 230 | 11/8/2024 |
1.0.39 | 234 | 11/6/2024 |
1.0.38 | 217 | 11/6/2024 |
1.0.37 | 264 | 10/4/2024 |
1.0.36 | 206 | 10/4/2024 |
1.0.35 | 224 | 10/4/2024 |
1.0.34 | 212 | 10/4/2024 |
1.0.33 | 224 | 10/4/2024 |
1.0.32 | 212 | 10/4/2024 |
1.0.31 | 226 | 10/3/2024 |
1.0.30 | 206 | 10/3/2024 |
1.0.29 | 216 | 10/3/2024 |
1.0.28 | 206 | 10/3/2024 |
1.0.27 | 209 | 10/3/2024 |
1.0.26 | 210 | 10/3/2024 |
1.0.25 | 216 | 10/3/2024 |
1.0.24 | 218 | 10/3/2024 |
1.0.23 | 239 | 10/2/2024 |
1.0.22 | 213 | 10/2/2024 |
1.0.21 | 226 | 10/1/2024 |
1.0.20 | 246 | 9/30/2024 |
1.0.19 | 223 | 9/29/2024 |
1.0.18 | 225 | 9/28/2024 |
1.0.17 | 230 | 9/28/2024 |
1.0.16 | 241 | 9/25/2024 |
1.0.15 | 234 | 9/24/2024 |
1.0.14 | 225 | 9/24/2024 |
1.0.13 | 232 | 9/24/2024 |
1.0.12 | 238 | 9/23/2024 |
1.0.11 | 239 | 9/23/2024 |
1.0.10 | 242 | 9/23/2024 |
1.0.9 | 218 | 9/19/2024 |
1.0.8 | 251 | 9/19/2024 |
1.0.7 | 243 | 9/18/2024 |
1.0.6 | 237 | 9/18/2024 |
1.0.5 | 258 | 9/17/2024 |
1.0.4 | 309 | 9/12/2024 |
1.0.3 | 309 | 9/6/2024 |
1.0.2 | 277 | 8/7/2024 |
1.0.1 | 333 | 6/13/2024 |
1.0.0 | 261 | 6/12/2024 |