Pachca.Sdk 1.0.11

dotnet add package Pachca.Sdk --version 1.0.11
                    
NuGet\Install-Package Pachca.Sdk -Version 1.0.11
                    
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="Pachca.Sdk" Version="1.0.11" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Pachca.Sdk" Version="1.0.11" />
                    
Directory.Packages.props
<PackageReference Include="Pachca.Sdk" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Pachca.Sdk --version 1.0.11
                    
#r "nuget: Pachca.Sdk, 1.0.11"
                    
#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.
#:package Pachca.Sdk@1.0.11
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Pachca.Sdk&version=1.0.11
                    
Install as a Cake Addin
#tool nuget:?package=Pachca.Sdk&version=1.0.11
                    
Install as a Cake Tool

Pachca C# SDK

C# клиент для Pachca API.

Установка

dotnet add package Pachca.Sdk

Использование

using Pachca.Sdk;

var client = new PachcaClient("YOUR_TOKEN");

// Отправка сообщения
var message = await client.Messages.CreateMessageAsync(new MessageCreateRequest
{
    Message = new MessageCreateRequestMessage
    {
        EntityId = chatId,
        Content = "Привет из C# SDK!"
    }
});

// Получение сообщения
var fetched = await client.Messages.GetMessageAsync(message.Id);

// Список пользователей
var users = await client.Users.ListUsersAsync();

Конвенции

  • Вход: path-параметры и body-поля передаются как аргументы метода или объект-запрос.
  • Выход: если ответ API содержит единственное поле data, SDK возвращает его содержимое напрямую.
// Реакция на сообщение
await client.Reactions.AddReactionAsync(messageId, new ReactionRequest { Code = "👍" });

// Закрепление сообщения
await client.Messages.PinMessageAsync(messageId);

// Создание сообщения (объект-запрос)
await client.Messages.CreateMessageAsync(new MessageCreateRequest
{
    Message = new MessageCreateRequestMessage { EntityId = 123, Content = "..." }
});

// Ответ: API возвращает { "data": Message }, SDK возвращает Message
var message = await client.Messages.CreateMessageAsync(...); // Message, не MessageDataWrapper

Пагинация

Для эндпоинтов с курсорной пагинацией SDK генерирует *AllAsync-методы, которые автоматически обходят все страницы:

// Вручную
var chats = new List<Chat>();
string? cursor = null;
do
{
    var response = await client.Chats.ListChatsAsync(cursor: cursor);
    chats.AddRange(response.Data);
    cursor = response.Meta?.Paginate?.NextPage;
} while (cursor != null);

// Автоматически
var allChats = await client.Chats.ListChatsAllAsync();

Доступные методы: ListChatsAllAsync, ListUsersAllAsync, ListTasksAllAsync, ListTagsAllAsync, ListMembersAllAsync, ListChatMessagesAllAsync, ListReactionsAllAsync, SearchChatsAllAsync, SearchMessagesAllAsync, SearchUsersAllAsync и др.

Повторные запросы

SDK автоматически повторяет запросы при получении ответа 429 Too Many Requests. Используется заголовок Retry-After для определения задержки, с экспоненциальным backoff (до 3 попыток).

Загрузка файлов

Загрузка файла — трёхшаговый процесс:

// 1. Получить параметры загрузки
var uploadParams = await client.Common.GetUploadParamsAsync();

// 2. Загрузить файл на S3
using var fileStream = File.OpenRead("photo.png");
await client.Common.UploadFileAsync(uploadParams, fileStream, "photo.png");

// 3. Прикрепить к сообщению (используя key из uploadParams)

Обработка ошибок

using Pachca.Sdk;

try
{
    await client.Messages.GetMessageAsync(999999);
}
catch (OAuthError e)
{
    Console.WriteLine($"Ошибка авторизации: {e.ErrorDescription}");
}
catch (ApiError e)
{
    Console.WriteLine($"Ошибка API: {string.Join(", ", e.Errors.Select(err => err.Message))}");
}

Отмена запросов

Все асинхронные методы поддерживают CancellationToken:

using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(10));
var users = await client.Users.ListUsersAsync(cancellationToken: cts.Token);
Product Compatible and additional computed target framework versions.
.NET 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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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.0.11 42 3/27/2026
1.0.10 34 3/27/2026
1.0.9 33 3/27/2026