gchatcardbuilder


Namegchatcardbuilder JSON
Version 0.1.7 PyPI version JSON
download
home_pagehttps://github.com/pkarl/gchatcardbuilder
SummaryA clean, type-safe interface for generating rich chat responses to the Google Chat API using the CardsV2 schema.
upload_time2023-09-17 15:06:48
maintainer
docs_urlNone
authorPete Karl II
requires_python
license
keywords google chat api cardsv2 gchat chatbot chat bot google chat
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # GChat Card Builder (v2)

Gchat Card Builder is a Python library that assists in the creation and management of chat "cards" for Google Chat responses via API. Supports CardsV2 format.

[![codecov](https://codecov.io/github/pkarl/gchatcardbuilder/graph/badge.svg?token=DQC6S9XHR0)](https://codecov.io/github/pkarl/gchatcardbuilder) [![Python CI with Pytest and Coverage](https://github.com/pkarl/gchatcardbuilder/actions/workflows/python-versions-ci.yml/badge.svg)](https://github.com/pkarl/gchatcardbuilder/actions/workflows/python-versions-ci.yml)

---

## Table of Contents
1. [Description](#description)
2. [Installation](#installation)
3. [Usage](#usage)
4. [Documentation](#documentation)
5. [Tests](#tests)

---

## Description
Gchat Card Builder provides an easy-to-use interface for creating richly formatted cards compatible with Google Chat. The goal is to stop mucking around with deeply nested structures just to send a slightly rich chat message.

Here's an example of how this could help clean up code:

```python
# broken onto several lines for readability
gchat_response = copy.deepcopy(BIG_OLD_DICT_TEMPLATE)
widgets = gchat_response["cardsV2"][0]["card"]["sections"][0]["widgets"]
button = widgets[0]["buttonList"]["buttons"][0]
button["text"] = "click to get rick rolled"
button["onClick"]["openLink"]["url"] = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
```

becomes this:

```python
builder = CardBuilder.create()
builder.add_section(
    W.ButtonList(
        buttons=[
            W.Button(
                text="click to get rick rolled",
                onClick=W.OnClick(
                    openLink=W.OpenLink(
                        url='https://www.youtube.com/watch?v=dQw4w9WgXcQ',
                    )
                )
            )
        ]
    ),
)

gchat_response = builder.build()
```

---

## Installation

### Prerequisites

- Python (versions tested: 3.10, 3.11)
- may support others

### Installation Steps
```bash
pip install gchatcardbuilder
```

---

## Usage

Google Chat Card Builder provides an easy-to-use interface for creating richly formatted cards compatible with Google Chat. Here's how you can quickly start building cards using the factory method:

### Basic Example:

```python
from gchatcardbuilder import CardBuilder, CardWidgets as W

# Get builder instance using the factory method
builder = CardBuilder.create()

# Add card details
builder.set_card_id("sample_id")
builder.set_header(W.CardHeader(title="Test Header"))
builder.add_section(W.Section(header="Test Section", widgets=[]))

# Build the card
card = builder.build()
```

---

## Documentation
You're looking at it.

---

## Tests

If you're planning on contributing or wish to run tests to ensure the library functions as expected in your environment:

1. Clone the repository:
```bash
git clone https://github.com/pkarl/gchatcardbuilder
```

2. Navigate to the cloned directory and install the requirements:
```bash
pip install -r requirements.txt
```

3. Run the tests:
```bash
pytest
```

---

If you have any questions, issues, or feedback, feel free to open an issue in the repository. Contributions are always welcome!

---

Maintained by PK2

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/pkarl/gchatcardbuilder",
    "name": "gchatcardbuilder",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "google chat api,cardsv2,gchat,chatbot,chat bot,google chat",
    "author": "Pete Karl II",
    "author_email": "pete.karl@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/89/f7/918540fc24ede5dc5b121c458573fa6a6d40c480493ac817b1ec121553f0/gchatcardbuilder-0.1.7.tar.gz",
    "platform": null,
    "description": "# GChat Card Builder (v2)\n\nGchat Card Builder is a Python library that assists in the creation and management of chat \"cards\" for Google Chat responses via API. Supports CardsV2 format.\n\n[![codecov](https://codecov.io/github/pkarl/gchatcardbuilder/graph/badge.svg?token=DQC6S9XHR0)](https://codecov.io/github/pkarl/gchatcardbuilder) [![Python CI with Pytest and Coverage](https://github.com/pkarl/gchatcardbuilder/actions/workflows/python-versions-ci.yml/badge.svg)](https://github.com/pkarl/gchatcardbuilder/actions/workflows/python-versions-ci.yml)\n\n---\n\n## Table of Contents\n1. [Description](#description)\n2. [Installation](#installation)\n3. [Usage](#usage)\n4. [Documentation](#documentation)\n5. [Tests](#tests)\n\n---\n\n## Description\nGchat Card Builder provides an easy-to-use interface for creating richly formatted cards compatible with Google Chat. The goal is to stop mucking around with deeply nested structures just to send a slightly rich chat message.\n\nHere's an example of how this could help clean up code:\n\n```python\n# broken onto several lines for readability\ngchat_response = copy.deepcopy(BIG_OLD_DICT_TEMPLATE)\nwidgets = gchat_response[\"cardsV2\"][0][\"card\"][\"sections\"][0][\"widgets\"]\nbutton = widgets[0][\"buttonList\"][\"buttons\"][0]\nbutton[\"text\"] = \"click to get rick rolled\"\nbutton[\"onClick\"][\"openLink\"][\"url\"] = \"https://www.youtube.com/watch?v=dQw4w9WgXcQ\"\n```\n\nbecomes this:\n\n```python\nbuilder = CardBuilder.create()\nbuilder.add_section(\n    W.ButtonList(\n        buttons=[\n            W.Button(\n                text=\"click to get rick rolled\",\n                onClick=W.OnClick(\n                    openLink=W.OpenLink(\n                        url='https://www.youtube.com/watch?v=dQw4w9WgXcQ',\n                    )\n                )\n            )\n        ]\n    ),\n)\n\ngchat_response = builder.build()\n```\n\n---\n\n## Installation\n\n### Prerequisites\n\n- Python (versions tested: 3.10, 3.11)\n- may support others\n\n### Installation Steps\n```bash\npip install gchatcardbuilder\n```\n\n---\n\n## Usage\n\nGoogle Chat Card Builder provides an easy-to-use interface for creating richly formatted cards compatible with Google Chat. Here's how you can quickly start building cards using the factory method:\n\n### Basic Example:\n\n```python\nfrom gchatcardbuilder import CardBuilder, CardWidgets as W\n\n# Get builder instance using the factory method\nbuilder = CardBuilder.create()\n\n# Add card details\nbuilder.set_card_id(\"sample_id\")\nbuilder.set_header(W.CardHeader(title=\"Test Header\"))\nbuilder.add_section(W.Section(header=\"Test Section\", widgets=[]))\n\n# Build the card\ncard = builder.build()\n```\n\n---\n\n## Documentation\nYou're looking at it.\n\n---\n\n## Tests\n\nIf you're planning on contributing or wish to run tests to ensure the library functions as expected in your environment:\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/pkarl/gchatcardbuilder\n```\n\n2. Navigate to the cloned directory and install the requirements:\n```bash\npip install -r requirements.txt\n```\n\n3. Run the tests:\n```bash\npytest\n```\n\n---\n\nIf you have any questions, issues, or feedback, feel free to open an issue in the repository. Contributions are always welcome!\n\n---\n\nMaintained by PK2\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A clean, type-safe interface for generating rich chat responses to the Google Chat API using the CardsV2 schema.",
    "version": "0.1.7",
    "project_urls": {
        "Homepage": "https://github.com/pkarl/gchatcardbuilder"
    },
    "split_keywords": [
        "google chat api",
        "cardsv2",
        "gchat",
        "chatbot",
        "chat bot",
        "google chat"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dab358e058c7e5d22ce04dd42b46165c47354f03bd732e0945275b186f3137dd",
                "md5": "9f1ce4fbf077f2d0f91cc6e9ff3fcb06",
                "sha256": "9dbebed1c344401a1efee45753a3cfeecfe96cea61cb0e95c870c6ec0ad0f1f9"
            },
            "downloads": -1,
            "filename": "gchatcardbuilder-0.1.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9f1ce4fbf077f2d0f91cc6e9ff3fcb06",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 14162,
            "upload_time": "2023-09-17T15:06:46",
            "upload_time_iso_8601": "2023-09-17T15:06:46.198551Z",
            "url": "https://files.pythonhosted.org/packages/da/b3/58e058c7e5d22ce04dd42b46165c47354f03bd732e0945275b186f3137dd/gchatcardbuilder-0.1.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "89f7918540fc24ede5dc5b121c458573fa6a6d40c480493ac817b1ec121553f0",
                "md5": "6cdd5870690bd8b9843bf49dafaff1b7",
                "sha256": "a44115f9481914c00df87f3f22f62289081d768f49b5dce3b9b1a4cf110b63ac"
            },
            "downloads": -1,
            "filename": "gchatcardbuilder-0.1.7.tar.gz",
            "has_sig": false,
            "md5_digest": "6cdd5870690bd8b9843bf49dafaff1b7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 13172,
            "upload_time": "2023-09-17T15:06:48",
            "upload_time_iso_8601": "2023-09-17T15:06:48.503888Z",
            "url": "https://files.pythonhosted.org/packages/89/f7/918540fc24ede5dc5b121c458573fa6a6d40c480493ac817b1ec121553f0/gchatcardbuilder-0.1.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-17 15:06:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pkarl",
    "github_project": "gchatcardbuilder",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "gchatcardbuilder"
}
        
Elapsed time: 0.11029s