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-1.0.4.tar.gz (28.2 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-1.0.4-py3-none-any.whl (36.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for adapter_client-1.0.4.tar.gz
Algorithm Hash digest
SHA256 3a1a0bb62c401de91159939b81c18b3da9a35c4cd2190933c44c7ecff2e9e537
MD5 4efe40c7cb86794a5f90281f154b393d
BLAKE2b-256 9f5dfbed3a154bf069d35ebee5442c9c0eba6115ae50b6810fe7a98852bee2b1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: adapter_client-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 36.0 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-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 95ceb237151c8cf337e7e6323c52b992c98ab2254f003f386f2d58f02add2f1e
MD5 a177357d9eb4f82b4dc00089a0f63af3
BLAKE2b-256 59b1047f3c13212105bc4e2cc98a445846ecfad1104ecd7b373173034939852a

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