adapter-client


Nameadapter-client JSON
Version 3.0.0 PyPI version JSON
download
home_pageNone
SummaryКлиент для взаимодействия со СМЭВ3 посредством Адаптера
upload_time2024-07-05 07:14:50
maintainerNone
docs_urlNone
authorBARS Group
requires_pythonNone
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Клиент для взаимодействия со СМЭВ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 в фоновом режиме.

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

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

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "adapter-client",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "BARS Group",
    "author_email": "education_dev@bars-open.ru",
    "download_url": "https://files.pythonhosted.org/packages/a2/c3/b8001b040abe29331d3843469eccbcdf8ef3f94413f85f4c9ecfcecc5f80/adapter_client-3.0.0.tar.gz",
    "platform": null,
    "description": "# \u041a\u043b\u0438\u0435\u043d\u0442 \u0434\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441\u043e \u0421\u041c\u042d\u04123 \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0410\u0434\u0430\u043f\u0442\u0435\u0440\u0430\n## \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\nsettings:\n\n    INSTALLED_APPS = [\n        'adapter_client'\n    ]\n\nservices:\n    \n    from adapter_client.adapters.smev.adapter import adapter\n    from adapter_client.adapters.smev.services.base import AbstractService\n    from adapter_client.core.domain.model import Message\n\n\n    class ROGDINFService(AbstractService):\n        \"\"\"\n        \u0421\u0435\u0440\u0432\u0438\u0441 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0441\u043e \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u044f\u043c\u0438 \u043e \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u0438.\n        \"\"\"\n        message_type = 'urn://x-artefacts-zags-rogdinf/root/112-51/4.0.1'\n    \n        def process_message(self, message: Message):\n\t\t\t# \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d \u043e\u0442\u0432\u0435\u0442\n\t\t\treply_to = message.reply.to\n            ...\n    \n    class ApplicationRequestService(AbstractService):\n        \"\"\"\n        \u0421\u0435\u0440\u0432\u0438\u0441 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430 \u0437\u0430\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 (\u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u0430).\n        \"\"\"\n        message_type = (\n            'http://epgu.gosuslugi.ru/concentrator/kindergarten/3.2.1'\n        )\n        def process_message(self, message: Message):\n            # \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435-\u0437\u0430\u043f\u0440\u043e\u0441\n            ...\n\n            # \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\n            adapter.send(\n                Message(\n                    # \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0447\u0442\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0442\u0432\u0435\u0442\u043e\u043c\n                    reply_to=message,\n                    # \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043b\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\n                    ...\n                )\n            )\n\n\napps:\n\n    from django.apps.config import AppConfig as AppConfigBase\n\n    class AppConfig(AppConfigBase):\n\n        name = __package__\n\n        def ready(self):\n            self._init_adapter_client()\n            self._register_services()\n\n        def _init_adapter_client(self):\n            from adapter_client.config import ProductConfig, set_config\n            from tasks import BaseTask\n\n            set_config(ProductConfig(async_task_base=BaseTask))\n        \n        def _register_services(self):\n        from adapter_client.adapters.smev.adapter import adapter\n        from .services import ApplicationRequestService, ROGDINFService\n        \n        adapter.register_service(ApplicationRequestService(), ROGDINFService())\n\n\n## \u0417\u0430\u043f\u0443\u0441\u043a \u0442\u0435\u0441\u0442\u043e\u0432\n    $ tox\n\n## API\n\n### \u041f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\n\n    from adapter_client.adapters.smev.adapter import adapter\n    from adapter_client.core.domain.model import Message\n\n    message = Message(\n        message_type='Foo',\n        body='<foo>bar</foo>',\n        attachments=['http://domain.com/attach1', 'http://domain.com/attach2'],\n        test=True\n    )\n\n    adapter.send(message)\n\n\u0414\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f Celery \u0432 \u0444\u043e\u043d\u043e\u0432\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435.\n\n### \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435\n\n\u041e\u0442\u0432\u0435\u0442\u044b \u043d\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \n\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "\u041a\u043b\u0438\u0435\u043d\u0442 \u0434\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441\u043e \u0421\u041c\u042d\u04123 \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0410\u0434\u0430\u043f\u0442\u0435\u0440\u0430",
    "version": "3.0.0",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3b53c6d962439ce5df448f18f1bdf475d2f152707da11371cd84c42dbdbd7487",
                "md5": "cd833131635dcc036480b2e9877f9853",
                "sha256": "48304aaf25c5888a82d1bb5d5b10a64461dff6fede7215d305e1e8c060f7fdbc"
            },
            "downloads": -1,
            "filename": "adapter_client-3.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "cd833131635dcc036480b2e9877f9853",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 45039,
            "upload_time": "2024-07-05T07:14:48",
            "upload_time_iso_8601": "2024-07-05T07:14:48.535473Z",
            "url": "https://files.pythonhosted.org/packages/3b/53/c6d962439ce5df448f18f1bdf475d2f152707da11371cd84c42dbdbd7487/adapter_client-3.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a2c3b8001b040abe29331d3843469eccbcdf8ef3f94413f85f4c9ecfcecc5f80",
                "md5": "5c61da9881f87bb8265fab764e8abe5b",
                "sha256": "c5f2fc24c4808de6ae9337ce1eac211e214d56ad1a1b467626fd502fc320b4e9"
            },
            "downloads": -1,
            "filename": "adapter_client-3.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "5c61da9881f87bb8265fab764e8abe5b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 34251,
            "upload_time": "2024-07-05T07:14:50",
            "upload_time_iso_8601": "2024-07-05T07:14:50.479502Z",
            "url": "https://files.pythonhosted.org/packages/a2/c3/b8001b040abe29331d3843469eccbcdf8ef3f94413f85f4c9ecfcecc5f80/adapter_client-3.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-05 07:14:50",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "adapter-client"
}
        
Elapsed time: 0.52666s