Skip to main content

Клиент для взаимодействия со СМЭВ3 посредством Адаптера

Project description

Клиент для взаимодействия со СМЭВ3 посредством Адаптера

Подключение

settings:

INSTALLED_APPS = [
    'adapter_client'
]

services:

from adapter_client.adapters.smev.adapter import adapter
from adapter_client.adapters.smev.services.base import AbstractService
from adapter_client.core.domain.model import Message


class ROGDINFService(AbstractService):
    """
    Сервис обрабатывающий сообщения со сведениями о рождении.
    """
    message_type = 'urn://x-artefacts-zags-rogdinf/root/112-51/4.0.1'

    def process_message(self, message: Message):
		# сообщение на которое получен ответ
		reply_to = message.reply.to
        ...

class ApplicationRequestService(AbstractService):
    """
    Сервис обрабатывающий запросы на зачисление (в качестве поставщика).
    """
    message_type = (
        'http://epgu.gosuslugi.ru/concentrator/kindergarten/3.2.1'
    )
    def process_message(self, message: Message):
        # обрабатываем сообщение-запрос
        ...

        # отправляем ответ на запрос
        adapter.send(
            Message(
                # необходимо указать что сообщение является ответом
                reply_to=message,
                # остальные поля сообщения
                ...
            )
        )

apps:

from django.apps.config import AppConfig as AppConfigBase

class AppConfig(AppConfigBase):

    name = __package__

    def ready(self):
        self._init_adapter_client()
        self._register_services()

    def _init_adapter_client(self):
        from adapter_client.config import ProductConfig, set_config
        from tasks import BaseTask

        set_config(ProductConfig(async_task_base=BaseTask))
    
    def _register_services(self):
    from adapter_client.adapters.smev.adapter import adapter
    from .services import ApplicationRequestService, ROGDINFService
    
    adapter.register_service(ApplicationRequestService(), ROGDINFService())

Запуск тестов

$ tox

API

Передача сообщения

from adapter_client.adapters.smev.adapter import adapter
from adapter_client.core.domain.model import Message

message = Message(
    message_type='Foo',
    body='<foo>bar</foo>',
    attachments=['http://domain.com/attach1', 'http://domain.com/attach2'],
    test=True
)

adapter.send(message)

Дальнейшая обработка сообщений производится Celery в фоновом режиме.

Получение ответа на сообщение

Ответы на отправленные сообщения собираются периодической задачей и передаются зарегистрированным сервисам.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

adapter_client-3.1.0.tar.gz (34.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

adapter_client-3.1.0-py3-none-any.whl (45.9 kB view details)

Uploaded Python 3

File details

Details for the file adapter_client-3.1.0.tar.gz.

File metadata

  • Download URL: adapter_client-3.1.0.tar.gz
  • Upload date:
  • Size: 34.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.7

File hashes

Hashes for adapter_client-3.1.0.tar.gz
Algorithm Hash digest
SHA256 531ff8d37c2f7373c96e8f4ed307f095954bbc8cb2aa22999e585c76a89a58c7
MD5 0ffe09550f2fb8d465484890bccb6542
BLAKE2b-256 f43514ec9090ea0578421e5bdc2073074373bf4b0a9dda43b860cb16722ae3ff

See more details on using hashes here.

File details

Details for the file adapter_client-3.1.0-py3-none-any.whl.

File metadata

  • Download URL: adapter_client-3.1.0-py3-none-any.whl
  • Upload date:
  • Size: 45.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.7

File hashes

Hashes for adapter_client-3.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 56e8f44ae2f47b462816dcb21f8f26a48131d8bb5768832fe650484b0d4f7fa6
MD5 831cd21ceed925efdbf52280c70e7a8a
BLAKE2b-256 047baaa23d340765859c26ff9f9b652e137210a5e688e51e752595d46d9a6353

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page