跳转到主要内容

Google应用服务Python接口

项目描述

使用Python 🐍 构建Google Workspace插件!!!

***

Build Status Deployment Code Quality License Contribution PR


📝 目录

❗ 什么是GAPPS?

GAPPS 是一个库,允许开发人员使用Python 🐍 轻松且灵活地构建 Google Workspace插件。使用 GAPPS,您可以为Gmail、Google Chat、Calendar、Sheets、Drive、Docs和其他Google Workspace应用程序创建强大的工具和集成,从而简化您的流程并自动化常见任务。

⚡ 关键特性

  • 一个简单且易于使用的API,用于构建Google Workspace插件。
  • 灵活的接口,适用于各种用例。
  • 内置对Gmail、Google Calendar、Google Drive和其他Google Workspace应用程序的支持。
  • 良好的文档,良好的代码库,易于贡献。

🏁 入门

🚜 安装

此客户端托管在PyPi,名称为gapps,要安装它,只需运行

pip install gapps

或安装开发版本

git clone https://github.com/skoudoro/gapps.git
pip install -e .

⚙️ CardService:选择您的编码风格!

GAPPS 允许您按照喜欢的编码风格构建扩展

Appscript 风格

from gapps import CardService

def create_cat_card(text):
    # Use the "Cat as a service" API to get the cat image. Add a "time" URL
    # parameter to act as a cache buster.
    now = datetime.now()
    caption = text.replace('/', ' ')
    imageUrl = f'https://cataas.com/cat/says/{caption}?time={now.timestamp()}'

    image = CardService.newImage() \
        .setImageUrl(imageUrl)  \
        .setAltText('Meow')

    # Create a button that changes the cat image when pressed.
    # Note: Action parameter keys and values must be strings.
    action = CardService.newAction()  \
        .setFunctionName('on_change_cat') \
        .setParameters({'text': text, 'is_homepage': str(is_homepage)})

    button = CardService.newTextButton()  \
        .setText('Change cat')  \
        .setOnClickAction(action)  \
        .setTextButtonStyle(CardService.TextButtonStyle.FILLED)

    buttonSet = CardService.newButtonSet()  \
        .addButton(button)

    # Assemble the widgets and return the card.
    section = CardService.newCardSection()  \
        .addWidget(image)  \
        .addWidget(buttonSet)

    card = CardService.newCardBuilder()  \
        .addSection(section)

    return card.build()

Pythonic 风格

from gapps import CardService

def create_cat_card(text):
    # Use the "Cat as a service" API to get the cat image. Add a "time" URL
    # parameter to act as a cache buster.
    now = datetime.now()
    caption = text.replace('/', ' ')
    imageUrl = f'https://cataas.com/cat/says/{caption}?time={now.timestamp()}'

    image = CardService.Image(image_url=imageUrl, alt_text='Meow')
    action = CardService.Action(
        function_name='on_change_cat',
        parameters={'text': text, 'is_homepage': str(is_homepage)})
    button = CardService.TextButton(
        text='Change cat', action=action,
        text_button_style=CardService.TextButtonStyle.FILLED)
    button_set = CardService.ButtonSet(button=button)
    section = CardService.CardSection(widget=[image, button_set])

    card = CardService.CardBuilder(section=section)

    return card.build()

⛏️ 卡片构建器

在线卡片构建器可以帮助您原型化应用程序的界面。

🚀 示例

查看示例文件夹以获取示例代码。它包含以下示例

  • cats.py:谷歌猫咪示例的镜像。兼容 Gmail、Google 日历、Google Drive、Google Docs 和 Google Sheets
  • simple_demo.py:最小化示例,展示如何构建基本卡片。
  • card_builder.py:此示例展示如何复制在线卡片构建器中的所有模板。它可以帮助您原型化应用程序的界面。

💬 指南

即将推出...

📄 方法参考

CardService:有关完整参考,请访问官方 Google Workspace Add Ons API 参考

⚠️ 注意事项

我们还需要处理一些小部件/构建器,但其中 90% 都已正确工作

✅ 测试

  • 步骤 1:安装 pytest
  pip install pytest
  • 步骤 2:运行测试
  pytest -svv gapps

✨ 贡献

我们热爱贡献!

您发现了一个错误或想要更改的内容 - 太好了!创建一个问题

您找到了解决问题的方法 - 更好!提交一个Pull Request

贡献指南开始!

你喜欢 GAPPS 吗?

在 GitHub 上用一颗星展示给我们...

Star GAPPS

🎓 许可证

项目采用 MIT 许可证,更多信息在这里

项目详情


下载文件

下载您平台的文件。如果您不确定选择哪个,请了解更多关于安装软件包的信息。

源分布

gapps-0.1.1.tar.gz (274.4 kB 查看哈希值)

上传时间

构建分布

gapps-0.1.1-py3-none-any.whl (19.9 kB 查看哈希值)

上传时间 Python 3

由以下支持