Metadata-Version: 2.1
Name: shopline_sdk
Version: 0.2.0
Summary: Shopline Python SDK
Home-page: https://github.com/jellyfrank/shopline-sdk
Author: blackcat
Author-email: kfx2007@163.com
License: GNU
Description: # Shopline Python SDK
        
        版本：0.2.0
        
        ## 功能概述
        
        - OAuth 授权与 token 刷新
        - Product / Order / Customer OpenAPI 封装
        - Webhook 订阅管理接口
        - Webhook verification token 与签名校验辅助方法
        
        ## Webhook 用法
        
        ```python
        from shopline.api import ShoplineAPI
        
        
        client = ShoplineAPI(
        	client_id="your_app_id",
        	client_secretkey="your_app_secret",
        	handle="Your App",
        	merchant_id="your_merchant_id",
        )
        client.set_access_token("your_access_token")
        
        # 创建 webhook
        webhook = client.webhook.create_webhook(
        	address="https://example.com/shopline/webhook",
        	topics=["order/create", "order/update"],
        )
        
        # 查询 webhook 列表
        webhooks = client.webhook.get_webhooks(per_page=20, page=1)
        
        # 查询单个 webhook
        detail = client.webhook.get_webhook(webhook["id"])
        
        # 更新 webhook
        updated = client.webhook.update_webhook(
        	webhook["id"],
        	topics=["order/create", "order/paid"],
        )
        
        # 删除 webhook
        client.webhook.delete_webhook(webhook["id"])
        ```
        
        ## Webhook 接收辅助
        
        SHOPLINE 在验证 webhook endpoint 时，会先发一个 `{"topic": "webhook/verification"}` 的 `POST` 请求。你的服务需要返回纯文本 verification token。
        
        ```python
        # App token 模式: 返回 base64(app_id)
        plain_text = client.webhook.get_webhook_verification_token(use_app_token=True)
        
        # Merchant token 模式: 返回 base64(merchant_id)
        plain_text = client.webhook.get_webhook_verification_token(use_app_token=False)
        ```
        
        如果后续需要校验 `sign` 参数，可以直接使用 SDK helper：
        
        ```python
        payload = {
        	"topic": "application/uninstall",
        	"merchant_id": "5dad5d2604515400018dcc90",
        }
        timestamp = "1618994178"
        signature = client.webhook.generate_webhook_signature(payload, timestamp)
        is_valid = client.webhook.verify_webhook_signature(payload, timestamp, signature)
        ```
        
        
Keywords: shopline sdk
Platform: UNKNOWN
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
Classifier: Programming Language :: Python
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering :: Astronomy
Classifier: Topic :: Scientific/Engineering :: GIS
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Description-Content-Type: text/markdown
