Skip to content

Commit

Permalink
feat: Add support of Python 3.12 (#17)
Browse files Browse the repository at this point in the history
* feat: Add support of Python 3.12

Add typing_extensions
  • Loading branch information
akalex authored Dec 15, 2023
1 parent d44f756 commit 6953322
Show file tree
Hide file tree
Showing 10 changed files with 514 additions and 493 deletions.
28 changes: 16 additions & 12 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
---
______________________________________________________________________

name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---
______________________________________________________________________

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
1. Click on '....'
1. Scroll down to '....'
1. See error

**Expected behavior**
A clear and concise description of what you expected to happen.
Expand All @@ -24,15 +26,17 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

- OS: \[e.g. iOS\]
- Browser \[e.g. chrome, safari\]
- Version \[e.g. 22\]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

- Device: \[e.g. iPhone6\]
- OS: \[e.g. iOS8.1\]
- Browser \[e.g. stock browser, safari\]
- Version \[e.g. 22\]

**Additional context**
Add any other context about the problem here.
7 changes: 4 additions & 3 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---
______________________________________________________________________

name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---
______________________________________________________________________

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
A clear and concise description of what the problem is. Ex. I'm always frustrated when \[...\]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11' ]
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11', '3.12' ]
steps:
- name: Checkout source code
uses: actions/checkout@v3
Expand Down Expand Up @@ -132,7 +132,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11' ]
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11', '3.12' ]
steps:
- name: source code
uses: actions/checkout@v3
Expand Down
25 changes: 16 additions & 9 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,44 @@
# Changelog

## 1.3.0

- Support of Python 3.12 added.
- [FIX] Add missing dependency `type_extensions` to be able using type annotations on Python 3.7

## 1.2.0
- Added support of sending transactional push notifications. More details of how to send Push Notifications via CustomerIO https://customer.io/docs/journeys/transactional-api/#transactional-push-notifications

- Added support of sending transactional push notifications. More details of how to send Push Notifications via CustomerIO <https://customer.io/docs/journeys/transactional-api/#transactional-push-notifications>

## 1.1.0

- Added helper function for validation of request origin using X-CIO-Signature and X-CIO-Timestamps

## 1.0.0

- [BREAKING] For consistency across APIs following actions have been taken:
- Renamed transactional email request optional arguments ``amp_body`` to ``body_amp`` and ``plaintext_body`` to ``body_plain``
- Changed transactional email request default values for optional boolean arguments ``disable_css_preproceessing``, ``queue_draft``, ``disable_message_retention``, ``tracked``, ``send_to_unsubscribed``
- Renamed transactional email request optional arguments `amp_body` to `body_amp` and `plaintext_body` to `body_plain`
- Changed transactional email request default values for optional boolean arguments `disable_css_preproceessing`, `queue_draft`, `disable_message_retention`, `tracked`, `send_to_unsubscribed`

## 0.5.1

- [FIX] Change parameter name from ``id_`` to ``identifier`` of the method ``identify`` to avoid naming collision.
- [FIX] Change parameter name from `id_` to `identifier` of the method `identify` to avoid naming collision.

## 0.5.0

- Add a couple of new attributes to object ``SendEmailRequest``
- Add a couple of new attributes to object `SendEmailRequest`

## 0.4.1

- The ``Content-Type`` we use has been updated so that Customer.io is happy when we try to send emails.
- The `Content-Type` we use has been updated so that Customer.io is happy when we try to send emails.

## 0.4.0

- Class ``AsyncCustomerIO`` updated with docstrings.
- Class `AsyncCustomerIO` updated with docstrings.

## 0.3.0

- ``AsyncClientBase`` has been adjusted to handle properly non-successful codes and connection retries.
- Class ``SendEmailRequest`` has been updated with type annotations.
- `AsyncClientBase` has been adjusted to handle properly non-successful codes and connection retries.
- Class `SendEmailRequest` has been updated with type annotations.

## 0.2.0

Expand Down
22 changes: 11 additions & 11 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ In the interest of fostering an open and welcoming environment, we as contributo

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
- The use of sexualized language or imagery and unwelcome sexual attention or advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Expand All @@ -34,7 +34,7 @@ This Code of Conduct applies both within project spaces and in public spaces whe

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected]. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at <[email protected]>. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

Expand Down
52 changes: 32 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
# async-customerio is a lightweight asynchronous client to interact with CustomerIO

[![PyPI download month](https://img.shields.io/pypi/dm/async-customerio.svg)](https://pypi.python.org/pypi/async-customerio/)
[![PyPI version fury.io](https://badge.fury.io/py/async-customerio.svg)](https://pypi.python.org/pypi/async-customerio/)
[![PyPI license](https://img.shields.io/pypi/l/async-customerio.svg)](https://pypi.python.org/pypi/async-customerio/)
[![PyPI pyversions](https://img.shields.io/pypi/pyversions/async-customerio.svg)](https://pypi.python.org/pypi/async-customerio/)
[![CI](https://github.com/healthjoy/async-customerio/actions/workflows/ci.yml/badge.svg)](https://github.com/healthjoy/async-customerio/actions/workflows/ci.yml)
[![Codacy Badge](https://app.codacy.com/project/badge/Coverage/3629b50827ef4e89ba0eaa5c09584273)](https://www.codacy.com/gh/healthjoy/async-customerio/dashboard?utm_source=github.com&utm_medium=referral&utm_content=healthjoy/async-customerio&utm_campaign=Badge_Coverage)

* Free software: MIT license
* Requires: Python 3.7+
- Free software: MIT license
- Requires: Python 3.7+

## Features

* Fully async
* Interface preserved as Official Python Client `customerio` has
* Send push notification
* Send messages
- Fully async
- Interface preserved as Official Python Client `customerio` has
- Send push notification
- Send messages

## Installation

```shell script
$ pip install async-customerio
pip install async-customerio
```

## Getting started

```python
import asyncio

Expand All @@ -32,20 +35,27 @@ async def main():
site_id = "Some-id-gotten-from-CustomerIO"
api_key = "Some-key-gotten-from-CustomerIO"
cio = AsyncCustomerIO(site_id, api_key, region=Regions.US)
await cio.identify(id=5, email="[email protected]", first_name="John", last_name="Doh", subscription_plan="premium")
await cio.track(customer_id=5, name="product.purchased", product_sku="XYZ-12345", price=23.45)
await cio.identify(
id=5,
email="[email protected]",
first_name="John",
last_name="Doh",
subscription_plan="premium",
)
await cio.track(
customer_id=5, name="product.purchased", product_sku="XYZ-12345", price=23.45
)


if __name__ == "__main__":
asyncio.run(main())
```

#### Instantiating `AsyncCustomerIO` object
### Instantiating `AsyncCustomerIO` object

Create an instance of the client with your [Customer.io credentials](https://fly.customer.io/settings/api_credentials).

```python

from async_customerio import AsyncCustomerIO, Regions


Expand All @@ -57,25 +67,27 @@ that your account is based in the US (`Regions.US`). If your account is based in
(`Regions.EU`), we'll route requests to our EU data centers accordingly, however, this may cause data to be logged in the US.

## Securely verify requests [doc](https://customer.io/docs/journeys/webhooks/#securely-verify-requests)

```python
from async_customerio import validate_signature


def main():
webhook_signing_key = "755781b5e03a973f3405a85474d5a032a60fd56fabaad66039b12eadd83955fa"
webhook_signing_key = (
"755781b5e03a973f3405a85474d5a032a60fd56fabaad66039b12eadd83955fa"
)
x_cio_timestamp = 1692633432 # header value
x_cio_signature = "d7c655389bb364d3e8bdbb6ec18a7f1b6cf91f39bba647554ada78aa61de37b9" # header value
body = b'{"key": "value"}'
if validate_signature(
signing_key=webhook_signing_key,
timestamp=x_cio_timestamp,
request_body=body,
signature=x_cio_signature
signing_key=webhook_signing_key,
timestamp=x_cio_timestamp,
request_body=body,
signature=x_cio_signature,
):
print('Request is sent from CustomerIO')
print("Request is sent from CustomerIO")
else:
print('Malicious request received')
print("Malicious request received")


if __name__ == "__main__":
Expand All @@ -84,7 +96,7 @@ if __name__ == "__main__":

## License

``async-customerio`` is offered under the MIT license.
`async-customerio` is offered under the MIT license.

## Source code

Expand Down
8 changes: 4 additions & 4 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

As of December 7, 2022:

| Version | Supported |
| ------- | ------------------ |
| < 1.0 | :white_check_mark: Current Stable, Actively developing |
| Version | Supported |
| ------- | ------------------------------------------------------ |
| \< 1.0 | :white_check_mark: Current Stable, Actively developing |

## Reporting a Vulnerability

Please report (suspected) security vulnerabilities to [email protected].
Please report (suspected) security vulnerabilities to <[email protected]>.
You will receive a response from us within 48 hours. If the issue is confirmed,
we will release a patch as soon as possible depending on complexity.
7 changes: 5 additions & 2 deletions async_customerio/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
Implements the client that interacts with Customer.io"s App API using app keys.
"""
import base64
from typing import Dict, Literal, Optional, Union

from typing_extensions import TypedDict

try:
from typing import Dict, Literal, Optional, TypedDict, Union
except ImportError:
from typing_extensions import Dict, Literal, Optional, TypedDict, Union # type: ignore

from async_customerio.client_base import AsyncClientBase
from async_customerio.errors import AsyncCustomerIOError
Expand Down
Loading

0 comments on commit 6953322

Please sign in to comment.