Download the PHP package glsv/diadoc-api without Composer
On this page you can find all versions of the php package glsv/diadoc-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package diadoc-api
Назначение
Обертка для работы с API api-docs.diadoc.ru.
- Осуществляет запросы к API с самостоятельным получение и хранением токена по логину и паролю;
- Формализует использование через работу с абстракциями команд и результатов выполнения оформленных в виде DTO;
Установка
Зависимости
- PHP 7.4+
- guzzlehttp/guzzle
Использование
Общая логика работы с библиотекой
В $result будет возвращен объект, реализующий интерфейс Glsv\DiadocApi\interfaces\ApiResponseInterface
ApiResponseInterface реализует 3 метода:
- isError(): bool
- getError(): string
- getData(): array
Таким образом, можно через методы проверить успешно ли прошло выполнение запроса. Если нет, то получить сообщение об ошибке.
Если запрос выполнен успешно, то получить результаты методом getData()
.
Содержимое getData()
зависит от типа запроса. Формат возвращаемых данных требуется
смотреть в документации к Diadoc.
1. Получение документа (метаданные)
Результаты
В качестве результата возвращается объект SuccessResponse
или ErrorResponse
, имплементирующие интерфейс
Glsv\DiadocApi\interfaces\ApiResponseInterface
.
Сырые данные ответа Diadoc могут быть получены в виде массива методом getData()
данных объектов.
Формат возвращамых данных от Diadoc: developer.kontur.ru/Docs/diadoc-api/proto/Document.html
2. Получение печатной подписанной формы документа
Результаты
В качестве результата возвращается объект SuccessFileResponse
или ErrorResponse
, имплементирующие интерфейс
Glsv\DiadocApi\interfaces\ApiResponseInterface
.
При успешном выполнении SuccessFileResponse->getData() возвращает массив в одним элементом FileDto()
FileDto
содержит содержимое файлы в base64, название и contentType.
All versions of diadoc-api with dependencies
ext-mbstring Version *
ext-json Version *
guzzlehttp/guzzle Version ^7.5