mobio-admin-sdk


Namemobio-admin-sdk JSON
Version 1.0.15 PyPI version JSON
download
home_pagehttps://github.com/mobiovn
SummaryMobio admin SDK
upload_time2024-08-19 03:47:14
maintainerNone
docs_urlNone
authorMOBIO
requires_python>=3
licenseMIT
keywords mobio admin sdk verify token
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ##  Thư viện Admin SDK dành cho các module.


### Cài đặt:
```bash
 $ pip3 install mobio-admin-sdk
 ```

### Chức năng:
* Verify token 


### Sử dụng:

##### 1. Verify token:
   ```python
    from mobio.sdks.admin import MobioAdminSDK

    MobioAdminSDK().config(
        admin_host="",	# admin host
        redis_uri="",	# redis uri
        module_use="",	# liên hệ admin để khai báo tên của module
        module_encrypt="",	# liên hệ admin để lấy mã
        api_admin_version="api/v2.1",   # danh sách api có thể sử dụng ["v1.0", "api/v2.0", "api/v2.1"]
    )
    auth = MobioAdminSDK().create_mobio_verify_token()
    
    @service_mod.route(url_path, methods=["get"])
    @auth.verify_token
    @try_catch_error
    def get_config(merchant_id):
        return build_response_message(Config(merchant_id).get_data())
   ```

##### 2. Merchant config:
   ```python
    from mobio.sdks.admin import MobioAdminSDK

    MobioAdminSDK().request_get_merchant_config_host(
            merchant_id,
            key=None,       # key muốn lấy giá trị
            admin_version=None, # api version admin muốn gọi trong trường hợp chỉ có version đó hỗ trợ
        )
    MobioAdminSDK().request_get_merchant_config_other(
            merchant_id,
            list_key=None,       # danh sách key muốn lấy giá trị
            admin_version=None, # api version admin muốn gọi trong trường hợp chỉ có version đó hỗ trợ
        )
    MobioAdminSDK().request_check_merchant_is_brand(
            merchant_id,
            admin_version=None, # api version admin muốn gọi trong trường hợp chỉ có version đó hỗ trợ
            token_value=None,  # token_value dạng là Bearer hoặc Basic, nếu nơi gọi là request đã authen thì 
                                # không cần truyền, token_value sẽ lấy từ header của request 
        )
    MobioAdminSDK().request_get_info_staff(
            merchant_id,
            account_id,
            admin_version=None, # api version admin muốn gọi trong trường hợp chỉ có version đó hỗ trợ
            token_value=None,  # token_value dạng là Bearer hoặc Basic, nếu nơi gọi là request đã authen thì
                                # không cần truyền, token_value sẽ lấy từ header của request
        )
    MobioAdminSDK().request_get_list_info_staff(
            merchant_id,
            params=None, # tham số của api  VD: {"per_page": -1}
            admin_version=None, # api version admin muốn gọi trong trường hợp chỉ có version đó hỗ trợ
            token_value=None,  # token_value dạng là Bearer hoặc Basic, nếu nơi gọi là request đã authen thì
                                # không cần truyền, token_value sẽ lấy từ header của request
        )
    MobioAdminSDK().request_get_list_parent_merchant(
            merchant_id,
            admin_version=None, # api version admin muốn gọi trong trường hợp chỉ có version đó hỗ trợ
            token_value=None,  # token_value dạng là Bearer hoặc Basic, nếu nơi gọi là request đã authen thì
                                # không cần truyền, token_value sẽ lấy từ header của request
        )
    MobioAdminSDK().request_get_list_profile_group(
            merchant_id=None,
            params=None,
            admin_version=None, # api version admin muốn gọi trong trường hợp chỉ có version đó hỗ trợ
            token_value=None,  # token_value dạng là Bearer hoặc Basic, nếu nơi gọi là request đã authen thì
                                # không cần truyền, token_value sẽ lấy từ header của request
        )
    MobioAdminSDK().request_get_list_sub_brand(
            params=None,        # tham số của api  VD: {"merchant_id": ""}
            admin_version=None, # api version admin muốn gọi trong trường hợp chỉ có version đó hỗ trợ
            token_value=None,  # token_value dạng là Bearer hoặc Basic, nếu nơi gọi là request đã authen thì
                                # không cần truyền, token_value sẽ lấy từ header của request
        )
    MobioAdminSDK().request_get_info_sub_brand(
            subbrand_id=None,
            admin_version=None, # api version admin muốn gọi trong trường hợp chỉ có version đó hỗ trợ
            token_value=None,  # token_value dạng là Bearer hoặc Basic, nếu nơi gọi là request đã authen thì
                                # không cần truyền, token_value sẽ lấy từ header của request
        )
    MobioAdminSDK().request_get_partner_info(
            partner_key=None,
            decrypt_data=False,
    )   # result: { "code": 200, "data": ""}, {"code": 400, "message": "key not found"}, {"code": 412, "message": "key not active"}, {"code": 413, "message": "key expire"}
        
    MobioAdminSDK().request_get_config_time_and_currency(merchant_id="")   
    # result: { 
    #      "config_time": {
    #             "timezone": 7,
    #             "text": "(UTC+07:00) Bangkok, Hanoi, Jakarta",
    #             "location": "Asia/Saigon",
    #         },
    #         "currency_code": "vnd"
    # }
    
    MobioAdminSDK().convert_datetime_to_format(merchant_id: str, from_date: datetime.datetime,
                                   format_type: int, tz=None, lang=None)
    """
    :param merchant_id: 
    :param from_date: datetime
    :param format_type: FORMAT_ddmm = 1 FORMAT_ddmmYYYY = 2 FORMAT_ddmmYYYYHHMM = 3
    :param tz: number hour
    :param lang: vi en
    :return: string format date 
    """
    
    MobioAdminSDK().gen_jwt_anonymous_user(merchant_id: str, data_jwt: dict, session_time=None)
    """
    :param merchant_id: 
    :param data_jwt: dict, là dữ liệu sẽ được đóng gói vào trong jwt, sau này từ request của client có thể đọc thông tin này.
    :param session_time: int, giây, thời gian hợp lệ của jwt 
    :return: string jwt 
    """
    



```
##### 3. Save log action account:
   ```python
    from mobio.sdks.admin import MobioAdminSDK
    action_account = {
            'account_id': "uuid",# required
            'action_name_vi': 'action name',# required
            'action_name_en': 'action name',# required
            'merchant_id': "uuid",# required
            'created_time': 0129301293  # required (timestamp(utcnow))
        }
    MobioAdminSDK().admin_save_log_action_account(action_account)
   ```
#### Log - 1.0.1
    - release sdk
#### Log - 1.0.2
    - Kiểm tra license server còn hạn sử dụng hay không 
#### Log - 1.0.3
    - Fix lỗi đọc file license 
#### Log - 1.0.4
    - Authen app key data out 
#### Log - 1.0.5
    - update lib kafka v2
#### Log - 1.0.6
    - encrypt, decrypt field by config
#### Log - 1.0.7
    - kiểm tra thông tin field trước khi encrypt, decrypt 
#### Log - 1.0.8
    - sdk tự lấy thông tin REDIS_URI  
#### Log - 1.0.9
    - bỏ encoding trong json.loads  
#### Log - 1.0.10
    - thêm hàm lấy cấu hình múi giờ và tiền tệ
    - cập nhật kết nối redis theo loại
#### Log - 1.0.11
    - thêm hàm định dạng thời gian từ date thành string theo chuẩn
#### Log - 1.0.12
    - thêm hàm gen token jwt anonymous   

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mobiovn",
    "name": "mobio-admin-sdk",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3",
    "maintainer_email": null,
    "keywords": "mobio, admin sdk, verify token",
    "author": "MOBIO",
    "author_email": "contact@mobio.vn",
    "download_url": "https://files.pythonhosted.org/packages/f4/13/cbc6a30d968d89e1bba75825338f99ddcb2433a4e3d9d2453dbba474b4fd/mobio_admin_sdk-1.0.15.tar.gz",
    "platform": null,
    "description": "##  Th\u01b0 vi\u1ec7n Admin SDK d\u00e0nh cho c\u00e1c module.\n\n\n### C\u00e0i \u0111\u1eb7t:\n```bash\n $ pip3 install mobio-admin-sdk\n ```\n\n### Ch\u1ee9c n\u0103ng:\n* Verify token \n\n\n### S\u1eed d\u1ee5ng:\n\n##### 1. Verify token:\n   ```python\n    from mobio.sdks.admin import MobioAdminSDK\n\n    MobioAdminSDK().config(\n        admin_host=\"\",\t# admin host\n        redis_uri=\"\",\t# redis uri\n        module_use=\"\",\t# li\u00ean h\u1ec7 admin \u0111\u1ec3 khai b\u00e1o t\u00ean c\u1ee7a module\n        module_encrypt=\"\",\t# li\u00ean h\u1ec7 admin \u0111\u1ec3 l\u1ea5y m\u00e3\n        api_admin_version=\"api/v2.1\",   # danh s\u00e1ch api c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng [\"v1.0\", \"api/v2.0\", \"api/v2.1\"]\n    )\n    auth = MobioAdminSDK().create_mobio_verify_token()\n    \n    @service_mod.route(url_path, methods=[\"get\"])\n    @auth.verify_token\n    @try_catch_error\n    def get_config(merchant_id):\n        return build_response_message(Config(merchant_id).get_data())\n   ```\n\n##### 2. Merchant config:\n   ```python\n    from mobio.sdks.admin import MobioAdminSDK\n\n    MobioAdminSDK().request_get_merchant_config_host(\n            merchant_id,\n            key=None,       # key mu\u1ed1n l\u1ea5y gi\u00e1 tr\u1ecb\n            admin_version=None, # api version admin mu\u1ed1n g\u1ecdi trong tr\u01b0\u1eddng h\u1ee3p ch\u1ec9 c\u00f3 version \u0111\u00f3 h\u1ed7 tr\u1ee3\n        )\n    MobioAdminSDK().request_get_merchant_config_other(\n            merchant_id,\n            list_key=None,       # danh s\u00e1ch key mu\u1ed1n l\u1ea5y gi\u00e1 tr\u1ecb\n            admin_version=None, # api version admin mu\u1ed1n g\u1ecdi trong tr\u01b0\u1eddng h\u1ee3p ch\u1ec9 c\u00f3 version \u0111\u00f3 h\u1ed7 tr\u1ee3\n        )\n    MobioAdminSDK().request_check_merchant_is_brand(\n            merchant_id,\n            admin_version=None, # api version admin mu\u1ed1n g\u1ecdi trong tr\u01b0\u1eddng h\u1ee3p ch\u1ec9 c\u00f3 version \u0111\u00f3 h\u1ed7 tr\u1ee3\n            token_value=None,  # token_value d\u1ea1ng l\u00e0 Bearer ho\u1eb7c Basic, n\u1ebfu n\u01a1i g\u1ecdi l\u00e0 request \u0111\u00e3 authen th\u00ec \n                                # kh\u00f4ng c\u1ea7n truy\u1ec1n, token_value s\u1ebd l\u1ea5y t\u1eeb header c\u1ee7a request \n        )\n    MobioAdminSDK().request_get_info_staff(\n            merchant_id,\n            account_id,\n            admin_version=None, # api version admin mu\u1ed1n g\u1ecdi trong tr\u01b0\u1eddng h\u1ee3p ch\u1ec9 c\u00f3 version \u0111\u00f3 h\u1ed7 tr\u1ee3\n            token_value=None,  # token_value d\u1ea1ng l\u00e0 Bearer ho\u1eb7c Basic, n\u1ebfu n\u01a1i g\u1ecdi l\u00e0 request \u0111\u00e3 authen th\u00ec\n                                # kh\u00f4ng c\u1ea7n truy\u1ec1n, token_value s\u1ebd l\u1ea5y t\u1eeb header c\u1ee7a request\n        )\n    MobioAdminSDK().request_get_list_info_staff(\n            merchant_id,\n            params=None, # tham s\u1ed1 c\u1ee7a api  VD: {\"per_page\": -1}\n            admin_version=None, # api version admin mu\u1ed1n g\u1ecdi trong tr\u01b0\u1eddng h\u1ee3p ch\u1ec9 c\u00f3 version \u0111\u00f3 h\u1ed7 tr\u1ee3\n            token_value=None,  # token_value d\u1ea1ng l\u00e0 Bearer ho\u1eb7c Basic, n\u1ebfu n\u01a1i g\u1ecdi l\u00e0 request \u0111\u00e3 authen th\u00ec\n                                # kh\u00f4ng c\u1ea7n truy\u1ec1n, token_value s\u1ebd l\u1ea5y t\u1eeb header c\u1ee7a request\n        )\n    MobioAdminSDK().request_get_list_parent_merchant(\n            merchant_id,\n            admin_version=None, # api version admin mu\u1ed1n g\u1ecdi trong tr\u01b0\u1eddng h\u1ee3p ch\u1ec9 c\u00f3 version \u0111\u00f3 h\u1ed7 tr\u1ee3\n            token_value=None,  # token_value d\u1ea1ng l\u00e0 Bearer ho\u1eb7c Basic, n\u1ebfu n\u01a1i g\u1ecdi l\u00e0 request \u0111\u00e3 authen th\u00ec\n                                # kh\u00f4ng c\u1ea7n truy\u1ec1n, token_value s\u1ebd l\u1ea5y t\u1eeb header c\u1ee7a request\n        )\n    MobioAdminSDK().request_get_list_profile_group(\n            merchant_id=None,\n            params=None,\n            admin_version=None, # api version admin mu\u1ed1n g\u1ecdi trong tr\u01b0\u1eddng h\u1ee3p ch\u1ec9 c\u00f3 version \u0111\u00f3 h\u1ed7 tr\u1ee3\n            token_value=None,  # token_value d\u1ea1ng l\u00e0 Bearer ho\u1eb7c Basic, n\u1ebfu n\u01a1i g\u1ecdi l\u00e0 request \u0111\u00e3 authen th\u00ec\n                                # kh\u00f4ng c\u1ea7n truy\u1ec1n, token_value s\u1ebd l\u1ea5y t\u1eeb header c\u1ee7a request\n        )\n    MobioAdminSDK().request_get_list_sub_brand(\n            params=None,        # tham s\u1ed1 c\u1ee7a api  VD: {\"merchant_id\": \"\"}\n            admin_version=None, # api version admin mu\u1ed1n g\u1ecdi trong tr\u01b0\u1eddng h\u1ee3p ch\u1ec9 c\u00f3 version \u0111\u00f3 h\u1ed7 tr\u1ee3\n            token_value=None,  # token_value d\u1ea1ng l\u00e0 Bearer ho\u1eb7c Basic, n\u1ebfu n\u01a1i g\u1ecdi l\u00e0 request \u0111\u00e3 authen th\u00ec\n                                # kh\u00f4ng c\u1ea7n truy\u1ec1n, token_value s\u1ebd l\u1ea5y t\u1eeb header c\u1ee7a request\n        )\n    MobioAdminSDK().request_get_info_sub_brand(\n            subbrand_id=None,\n            admin_version=None, # api version admin mu\u1ed1n g\u1ecdi trong tr\u01b0\u1eddng h\u1ee3p ch\u1ec9 c\u00f3 version \u0111\u00f3 h\u1ed7 tr\u1ee3\n            token_value=None,  # token_value d\u1ea1ng l\u00e0 Bearer ho\u1eb7c Basic, n\u1ebfu n\u01a1i g\u1ecdi l\u00e0 request \u0111\u00e3 authen th\u00ec\n                                # kh\u00f4ng c\u1ea7n truy\u1ec1n, token_value s\u1ebd l\u1ea5y t\u1eeb header c\u1ee7a request\n        )\n    MobioAdminSDK().request_get_partner_info(\n            partner_key=None,\n            decrypt_data=False,\n    )   # result: { \"code\": 200, \"data\": \"\"}, {\"code\": 400, \"message\": \"key not found\"}, {\"code\": 412, \"message\": \"key not active\"}, {\"code\": 413, \"message\": \"key expire\"}\n        \n    MobioAdminSDK().request_get_config_time_and_currency(merchant_id=\"\")   \n    # result: { \n    #      \"config_time\": {\n    #             \"timezone\": 7,\n    #             \"text\": \"(UTC+07:00) Bangkok, Hanoi, Jakarta\",\n    #             \"location\": \"Asia/Saigon\",\n    #         },\n    #         \"currency_code\": \"vnd\"\n    # }\n    \n    MobioAdminSDK().convert_datetime_to_format(merchant_id: str, from_date: datetime.datetime,\n                                   format_type: int, tz=None, lang=None)\n    \"\"\"\n    :param merchant_id: \n    :param from_date: datetime\n    :param format_type: FORMAT_ddmm = 1 FORMAT_ddmmYYYY = 2 FORMAT_ddmmYYYYHHMM = 3\n    :param tz: number hour\n    :param lang: vi en\n    :return: string format date \n    \"\"\"\n    \n    MobioAdminSDK().gen_jwt_anonymous_user(merchant_id: str, data_jwt: dict, session_time=None)\n    \"\"\"\n    :param merchant_id: \n    :param data_jwt: dict, l\u00e0 d\u1eef li\u1ec7u s\u1ebd \u0111\u01b0\u1ee3c \u0111\u00f3ng g\u00f3i v\u00e0o trong jwt, sau n\u00e0y t\u1eeb request c\u1ee7a client c\u00f3 th\u1ec3 \u0111\u1ecdc th\u00f4ng tin n\u00e0y.\n    :param session_time: int, gi\u00e2y, th\u1eddi gian h\u1ee3p l\u1ec7 c\u1ee7a jwt \n    :return: string jwt \n    \"\"\"\n    \n\n\n\n```\n##### 3. Save log action account:\n   ```python\n    from mobio.sdks.admin import MobioAdminSDK\n    action_account = {\n            'account_id': \"uuid\",# required\n            'action_name_vi': 'action name',# required\n            'action_name_en': 'action name',# required\n            'merchant_id': \"uuid\",# required\n            'created_time': 0129301293  # required (timestamp(utcnow))\n        }\n    MobioAdminSDK().admin_save_log_action_account(action_account)\n   ```\n#### Log - 1.0.1\n    - release sdk\n#### Log - 1.0.2\n    - Ki\u1ec3m tra license server c\u00f2n h\u1ea1n s\u1eed d\u1ee5ng hay kh\u00f4ng \n#### Log - 1.0.3\n    - Fix l\u1ed7i \u0111\u1ecdc file license \n#### Log - 1.0.4\n    - Authen app key data out \n#### Log - 1.0.5\n    - update lib kafka v2\n#### Log - 1.0.6\n    - encrypt, decrypt field by config\n#### Log - 1.0.7\n    - ki\u1ec3m tra th\u00f4ng tin field tr\u01b0\u1edbc khi encrypt, decrypt \n#### Log - 1.0.8\n    - sdk t\u1ef1 l\u1ea5y th\u00f4ng tin REDIS_URI  \n#### Log - 1.0.9\n    - b\u1ecf encoding trong json.loads  \n#### Log - 1.0.10\n    - th\u00eam h\u00e0m l\u1ea5y c\u1ea5u h\u00ecnh m\u00fai gi\u1edd v\u00e0 ti\u1ec1n t\u1ec7\n    - c\u1eadp nh\u1eadt k\u1ebft n\u1ed1i redis theo lo\u1ea1i\n#### Log - 1.0.11\n    - th\u00eam h\u00e0m \u0111\u1ecbnh d\u1ea1ng th\u1eddi gian t\u1eeb date th\u00e0nh string theo chu\u1ea9n\n#### Log - 1.0.12\n    - th\u00eam h\u00e0m gen token jwt anonymous   \n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Mobio admin SDK",
    "version": "1.0.15",
    "project_urls": {
        "Homepage": "https://github.com/mobiovn",
        "Source": "https://github.com/mobiovn"
    },
    "split_keywords": [
        "mobio",
        " admin sdk",
        " verify token"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f413cbc6a30d968d89e1bba75825338f99ddcb2433a4e3d9d2453dbba474b4fd",
                "md5": "067e09628ad0141f5245010ef24c27aa",
                "sha256": "efbe108293ee6b89b2c492744b42893093eb0367824740e3b69e77dcfbb5f578"
            },
            "downloads": -1,
            "filename": "mobio_admin_sdk-1.0.15.tar.gz",
            "has_sig": false,
            "md5_digest": "067e09628ad0141f5245010ef24c27aa",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3",
            "size": 25136,
            "upload_time": "2024-08-19T03:47:14",
            "upload_time_iso_8601": "2024-08-19T03:47:14.141965Z",
            "url": "https://files.pythonhosted.org/packages/f4/13/cbc6a30d968d89e1bba75825338f99ddcb2433a4e3d9d2453dbba474b4fd/mobio_admin_sdk-1.0.15.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-19 03:47:14",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "mobio-admin-sdk"
}
        
Elapsed time: 0.47365s