XyloCode.ThirdPartyServices.RussianPost 1.1.0

Prefix Reserved
dotnet add package XyloCode.ThirdPartyServices.RussianPost --version 1.1.0                
NuGet\Install-Package XyloCode.ThirdPartyServices.RussianPost -Version 1.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="XyloCode.ThirdPartyServices.RussianPost" Version="1.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add XyloCode.ThirdPartyServices.RussianPost --version 1.1.0                
#r "nuget: XyloCode.ThirdPartyServices.RussianPost, 1.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install XyloCode.ThirdPartyServices.RussianPost as a Cake Addin
#addin nuget:?package=XyloCode.ThirdPartyServices.RussianPost&version=1.1.0

// Install XyloCode.ThirdPartyServices.RussianPost as a Cake Tool
#tool nuget:?package=XyloCode.ThirdPartyServices.RussianPost&version=1.1.0                

Russian Post API client library

Unofficial .NET library for accessing the Russian Post API with partial implementation (postoffice list, calculator, normalization of postal addresses, names and telephone numbers).

Supported Platforms
  • .NET 6.0 LTS;
  • .NET 7.0.

Russian Post

Russian Post (Russian: Почта России, Pochta Rossii) is the national postal operator of Russia. The company is responsible for the delivery of mail in Russia, and the issuing of postage stamps. Russian Post employs about 390,000 people and has over 42,000 post offices, with its headquarters in Moscow.

Official website: https://www.pochta.ru/.

Supported Methods

  • List of post offices
  • Normalization of postal address
  • Normalization of the surname and given names of the correspondent
  • Phone number normalization
  • Shipping cost calculation
  • Information about the user's limits (the total number of requests per day allowed for the user and the balance in the current day)

How to use

using XyloCode.ThirdPartyServices.RussianPost;
using XyloCode.ThirdPartyServices.RussianPost.Calculation.Req;
using XyloCode.ThirdPartyServices.RussianPost.CleanAddress;
using XyloCode.ThirdPartyServices.RussianPost.CleanPersonName;
using XyloCode.ThirdPartyServices.RussianPost.CleanPhoneNumber;
using XyloCode.ThirdPartyServices.RussianPost.Enums;
using XyloCode.ThirdPartyServices.RussianPost.Helpers;

namespace RussianPostTest
{
    internal class Program
    {
        static void Main(string[] args)
        {
        
            // Get an access token on the website:
            // https://otpravka.pochta.ru/settings#/api-settings
            const string accessToken = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
            const string login = "i.ivanov@example.com"; // login for https://otpravka.pochta.ru/
            const string password = "xxxxxxxxxxxxxxxx"; // password for https://otpravka.pochta.ru/

            var tracer = new LoggingHandler();
            var api = new RussianPostClient(accessToken, login, password, httpMessageHandler: tracer);

            var req1 = new CleanAddressRequest
            {
                Id = Guid.NewGuid().ToString(),
                OriginalAddress = "125252, РОССИЯ, Г. МОСКВА, ВН.ТЕР.Г. МУНИЦИПАЛЬНЫЙ ОКРУГ ХОРОШЕВСКИЙ, 3-Я ПЕСЧАНАЯ УЛ., Д. 2А",
            };
            var res1 = api.CleanAddresses(req1);

            var req2 = new CleanPersonNameRequest
            {
                Id = Guid.NewGuid().ToString(),
                OriginalName = "Тинькофф Олег Юрьевич",
            };
            var res2 = api.CleanPersonNames(req2);

            var req3 = new CleanPhoneNumberRequest
            {
                Id = Guid.NewGuid().ToString(),
                OriginalPhone = "+7 (495) 739-47-12"
            };
            var res3 = api.CleanPhoneNumbers(req3);

            var res4 = api.GetPostOffices();

            var req5 = new CalculationRequest
            {
                IndexFrom = "125252",
                IndexTo = "630090",
                Mass = 1_300,
                PaymentMethod = PaymentMethod.CASHLESS, 
                Courier = true,
                DeclaredValue = 80_000_00,
                EntriesType = EntriesType.SALE_OF_GOODS,
                MailType = MailType.EMS,
                MailCategory = MailCategory.WITH_DECLARED_VALUE,
                TransportType = TransportType.STANDARD,
                DimensionType = DimensionType.S,
                SmsNoticeRecipient = 1,
            };
            var res5 = api.Calculation(req5);
            ;

        }
    }
}

License

MIT License

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 170 11/16/2023
1.0.2 129 11/8/2023
1.0.1 133 11/2/2023
1.0.0 128 10/19/2023

NET 8.0 support.