From ebf4745c22866bd303eba51260f88b8b9f5a6e7d Mon Sep 17 00:00:00 2001 From: CoprDistGit Date: Mon, 10 Apr 2023 19:06:08 +0000 Subject: automatic import of python-mailjet-rest --- python-mailjet-rest.spec | 1051 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1051 insertions(+) create mode 100644 python-mailjet-rest.spec (limited to 'python-mailjet-rest.spec') diff --git a/python-mailjet-rest.spec b/python-mailjet-rest.spec new file mode 100644 index 0000000..20b1018 --- /dev/null +++ b/python-mailjet-rest.spec @@ -0,0 +1,1051 @@ +%global _empty_manifest_terminate_build 0 +Name: python-mailjet-rest +Version: 1.3.4 +Release: 1 +Summary: Mailjet V3 API wrapper +License: MIT +URL: https://github.com/mailjet/mailjet-apiv3-python +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/ad/68/e72ee94650da7cfd902bfdde3f019a5ae9b86dc31ba58c806055fa12e537/mailjet_rest-1.3.4.tar.gz +BuildArch: noarch + +Requires: python3-requests + +%description + +[mailjet]:(http://www.mailjet.com/) +[api_credential]: https://app.mailjet.com/account/api_keys +[doc]: http://dev.mailjet.com/guides/?python# +[api_doc]: https://github.com/mailjet/api-documentation + +![alt text](https://www.mailjet.com/images/email/transac/logo_header.png "Mailjet") + +# Official Mailjet Python Wrapper + +[![Build Status](https://travis-ci.org/mailjet/mailjet-apiv3-python.svg?branch=master)](https://travis-ci.org/mailjet/mailjet-apiv3-python) +![Current Version](https://img.shields.io/badge/version-1.3.2-green.svg) + +## Overview + +Welcome to the [Mailjet][mailjet] official Python API wrapper! + +Check out all the resources and Python code examples in the official [Mailjet Documentation][doc]. + +## Table of contents + +- [Compatibility](#compatibility) +- [Installation](#installation) +- [Authentication](#authentication) +- [Make your first call](#make-your-first-call) +- [Client / Call configuration specifics](#client--call-configuration-specifics) + - [API versioning](#api-versioning) + - [Base URL](#base-url) +- [Request examples](#request-examples) + - [POST request](#post-request) + - [Simple POST request](#simple-post-request) + - [Using actions](#using-actions) + - [GET request](#get-request) + - [Retrieve all objects](#retrieve-all-objects) + - [Use filtering](#use-filtering) + - [Retrieve a single object](#retrieve-a-single-object) + - [PUT request](#put-request) + - [DELETE request](#delete-request) +- [Contribute](#contribute) + +## Compatibility + +This library officially supports the following Python versions: + + - v2.7 + - v3.5 + - v3.6 + +## Installation + +Use the below code to install the wrapper: + +``` bash +(sudo) pip install mailjet_rest +``` + +## Authentication + +The Mailjet Email API uses your API and Secret keys for authentication. [Grab][api_credential] and save your Mailjet API credentials. + +```bash +export MJ_APIKEY_PUBLIC='your api key' +export MJ_APIKEY_PRIVATE='your api secret' +``` + +Initialize your [Mailjet][mailjet] client: + +```python +# import the mailjet wrapper +from mailjet_rest import Client +import os + +# Get your environment Mailjet keys +API_KEY = os.environ['MJ_APIKEY_PUBLIC'] +API_SECRET = os.environ['MJ_APIKEY_PRIVATE'] + +mailjet = Client(auth=(API_KEY, API_SECRET)) +``` + +## Make your first call + +Here's an example on how to send an email: + +```python +from mailjet_rest import Client +import os +api_key = os.environ['MJ_APIKEY_PUBLIC'] +api_secret = os.environ['MJ_APIKEY_PRIVATE'] +mailjet = Client(auth=(api_key, api_secret), version='v3.1') +data = { + 'Messages': [ + { + "From": { + "Email": "$SENDER_EMAIL", + "Name": "Me" + }, + "To": [ + { + "Email": "$RECIPIENT_EMAIL", + "Name": "You" + } + ], + "Subject": "My first Mailjet Email!", + "TextPart": "Greetings from Mailjet!", + "HTMLPart": "

Dear passenger 1, welcome to Mailjet!


May the delivery force be with you!" + } + ] +} +result = mailjet.send.create(data=data) +print result.status_code +print result.json() +``` + +## Client / Call Configuration Specifics + +### API Versioning + +The Mailjet API is spread among three distinct versions: + +- `v3` - The Email API +- `v3.1` - Email Send API v3.1, which is the latest version of our Send API +- `v4` - SMS API (not supported in Python) + +Since most Email API endpoints are located under `v3`, it is set as the default one and does not need to be specified when making your request. For the others you need to specify the version using `version`. For example, if using Send API `v3.1`: + +``` python +# import the mailjet wrapper +from mailjet_rest import Client +import os + +# Get your environment Mailjet keys +API_KEY = os.environ['MJ_APIKEY_PUBLIC'] +API_SECRET = os.environ['MJ_APIKEY_PRIVATE'] + +mailjet = Client(auth=(API_KEY, API_SECRET), version='v3.1') +``` + +For additional information refer to our [API Reference](https://dev.preprod.mailjet.com/reference/overview/versioning/). + +### Base URL + +The default base domain name for the Mailjet API is `api.mailjet.com`. You can modify this base URL by setting a value for `api_url` in your call: + +```python +mailjet = Client(auth=(api_key, api_secret),api_url="https://api.us.mailjet.com/") +``` + +If your account has been moved to Mailjet's **US architecture**, the URL value you need to set is `https://api.us.mailjet.com`. + +## Request examples + +### POST request + +#### Simple POST request + +```python +""" +Create a new contact: +""" +from mailjet_rest import Client +import os +api_key = os.environ['MJ_APIKEY_PUBLIC'] +api_secret = os.environ['MJ_APIKEY_PRIVATE'] +mailjet = Client(auth=(api_key, api_secret)) +data = { + 'Email': 'Mister@mailjet.com' +} +result = mailjet.contact.create(data=data) +print result.status_code +print result.json() +``` + +#### Using actions + +```python +""" +Manage the subscription status of a contact to multiple lists: +""" +from mailjet_rest import Client +import os +api_key = os.environ['MJ_APIKEY_PUBLIC'] +api_secret = os.environ['MJ_APIKEY_PRIVATE'] +mailjet = Client(auth=(api_key, api_secret)) +id = '$ID' +data = { + 'ContactsLists': [ + { + "ListID": "$ListID_1", + "Action": "addnoforce" + }, + { + "ListID": "$ListID_2", + "Action": "addforce" + } + ] +} +result = mailjet.contact_managecontactslists.create(id=id, data=data) +print result.status_code +print result.json() +``` + +### GET Request + +#### Retrieve all objects + +```python +""" +Retrieve all contacts: +""" +from mailjet_rest import Client +import os +api_key = os.environ['MJ_APIKEY_PUBLIC'] +api_secret = os.environ['MJ_APIKEY_PRIVATE'] +mailjet = Client(auth=(api_key, api_secret)) +result = mailjet.contact.get() +print result.status_code +print result.json() +``` + +#### Using filtering + +```python +""" +Retrieve all contacts that are not in the campaign exclusion list: +""" +from mailjet_rest import Client +import os +api_key = os.environ['MJ_APIKEY_PUBLIC'] +api_secret = os.environ['MJ_APIKEY_PRIVATE'] +mailjet = Client(auth=(api_key, api_secret)) +filters = { + 'IsExcludedFromCampaigns': false, +} +result = mailjet.contact.get(filters=filters) +print result.status_code +print result.json() +``` + +#### Retrieve a single object + +```python +""" +Retrieve a specific contact ID: +""" +from mailjet_rest import Client +import os +api_key = os.environ['MJ_APIKEY_PUBLIC'] +api_secret = os.environ['MJ_APIKEY_PRIVATE'] +mailjet = Client(auth=(api_key, api_secret)) +id = 'Contact_ID' +result = mailjet.contact.get(id=id) +print result.status_code +print result.json() +``` + +### PUT request + +A `PUT` request in the Mailjet API will work as a `PATCH` request - the update will affect only the specified properties. The other properties of an existing resource will neither be modified, nor deleted. It also means that all non-mandatory properties can be omitted from your payload. + +Here's an example of a `PUT` request: + +```python +""" +Update the contact properties for a contact: +""" +from mailjet_rest import Client +import os +api_key = os.environ['MJ_APIKEY_PUBLIC'] +api_secret = os.environ['MJ_APIKEY_PRIVATE'] +mailjet = Client(auth=(api_key, api_secret)) +id = '$CONTACT_ID' +data = { + 'Data': [ + { + "Name": "first_name", + "value": "John" + }, + { + "Name": "last_name", + "value": "Smith" + } + ] +} +result = mailjet.contactdata.update(id=id, data=data) +print result.status_code +print result.json() +``` + +### DELETE request + +Upon a successful `DELETE` request the response will not include a response body, but only a `204 No Content` response code. + +Here's an example of a `DELETE` request: + +```python +""" +Delete an email template: +""" +from mailjet_rest import Client +import os +api_key = os.environ['MJ_APIKEY_PUBLIC'] +api_secret = os.environ['MJ_APIKEY_PRIVATE'] +mailjet = Client(auth=(api_key, api_secret)) +id = 'Template_ID' +result = mailjet.template.delete(id=id) +print result.status_code +print result.json() +``` + +## Contribute + +Mailjet loves developers. You can be part of this project! + +This wrapper is a great introduction to the open source world, check out the code! + +Feel free to ask anything, and contribute: + +- Fork the project. +- Create a new branch. +- Implement your feature or bug fix. +- Add documentation to it. +- Commit, push, open a pull request and voila. + +If you have suggestions on how to improve the guides, please submit an issue in our [Official API Documentation repo](https://github.com/mailjet/api-documentation). + + + + +%package -n python3-mailjet-rest +Summary: Mailjet V3 API wrapper +Provides: python-mailjet-rest +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-mailjet-rest + +[mailjet]:(http://www.mailjet.com/) +[api_credential]: https://app.mailjet.com/account/api_keys +[doc]: http://dev.mailjet.com/guides/?python# +[api_doc]: https://github.com/mailjet/api-documentation + +![alt text](https://www.mailjet.com/images/email/transac/logo_header.png "Mailjet") + +# Official Mailjet Python Wrapper + +[![Build Status](https://travis-ci.org/mailjet/mailjet-apiv3-python.svg?branch=master)](https://travis-ci.org/mailjet/mailjet-apiv3-python) +![Current Version](https://img.shields.io/badge/version-1.3.2-green.svg) + +## Overview + +Welcome to the [Mailjet][mailjet] official Python API wrapper! + +Check out all the resources and Python code examples in the official [Mailjet Documentation][doc]. + +## Table of contents + +- [Compatibility](#compatibility) +- [Installation](#installation) +- [Authentication](#authentication) +- [Make your first call](#make-your-first-call) +- [Client / Call configuration specifics](#client--call-configuration-specifics) + - [API versioning](#api-versioning) + - [Base URL](#base-url) +- [Request examples](#request-examples) + - [POST request](#post-request) + - [Simple POST request](#simple-post-request) + - [Using actions](#using-actions) + - [GET request](#get-request) + - [Retrieve all objects](#retrieve-all-objects) + - [Use filtering](#use-filtering) + - [Retrieve a single object](#retrieve-a-single-object) + - [PUT request](#put-request) + - [DELETE request](#delete-request) +- [Contribute](#contribute) + +## Compatibility + +This library officially supports the following Python versions: + + - v2.7 + - v3.5 + - v3.6 + +## Installation + +Use the below code to install the wrapper: + +``` bash +(sudo) pip install mailjet_rest +``` + +## Authentication + +The Mailjet Email API uses your API and Secret keys for authentication. [Grab][api_credential] and save your Mailjet API credentials. + +```bash +export MJ_APIKEY_PUBLIC='your api key' +export MJ_APIKEY_PRIVATE='your api secret' +``` + +Initialize your [Mailjet][mailjet] client: + +```python +# import the mailjet wrapper +from mailjet_rest import Client +import os + +# Get your environment Mailjet keys +API_KEY = os.environ['MJ_APIKEY_PUBLIC'] +API_SECRET = os.environ['MJ_APIKEY_PRIVATE'] + +mailjet = Client(auth=(API_KEY, API_SECRET)) +``` + +## Make your first call + +Here's an example on how to send an email: + +```python +from mailjet_rest import Client +import os +api_key = os.environ['MJ_APIKEY_PUBLIC'] +api_secret = os.environ['MJ_APIKEY_PRIVATE'] +mailjet = Client(auth=(api_key, api_secret), version='v3.1') +data = { + 'Messages': [ + { + "From": { + "Email": "$SENDER_EMAIL", + "Name": "Me" + }, + "To": [ + { + "Email": "$RECIPIENT_EMAIL", + "Name": "You" + } + ], + "Subject": "My first Mailjet Email!", + "TextPart": "Greetings from Mailjet!", + "HTMLPart": "

Dear passenger 1, welcome to Mailjet!


May the delivery force be with you!" + } + ] +} +result = mailjet.send.create(data=data) +print result.status_code +print result.json() +``` + +## Client / Call Configuration Specifics + +### API Versioning + +The Mailjet API is spread among three distinct versions: + +- `v3` - The Email API +- `v3.1` - Email Send API v3.1, which is the latest version of our Send API +- `v4` - SMS API (not supported in Python) + +Since most Email API endpoints are located under `v3`, it is set as the default one and does not need to be specified when making your request. For the others you need to specify the version using `version`. For example, if using Send API `v3.1`: + +``` python +# import the mailjet wrapper +from mailjet_rest import Client +import os + +# Get your environment Mailjet keys +API_KEY = os.environ['MJ_APIKEY_PUBLIC'] +API_SECRET = os.environ['MJ_APIKEY_PRIVATE'] + +mailjet = Client(auth=(API_KEY, API_SECRET), version='v3.1') +``` + +For additional information refer to our [API Reference](https://dev.preprod.mailjet.com/reference/overview/versioning/). + +### Base URL + +The default base domain name for the Mailjet API is `api.mailjet.com`. You can modify this base URL by setting a value for `api_url` in your call: + +```python +mailjet = Client(auth=(api_key, api_secret),api_url="https://api.us.mailjet.com/") +``` + +If your account has been moved to Mailjet's **US architecture**, the URL value you need to set is `https://api.us.mailjet.com`. + +## Request examples + +### POST request + +#### Simple POST request + +```python +""" +Create a new contact: +""" +from mailjet_rest import Client +import os +api_key = os.environ['MJ_APIKEY_PUBLIC'] +api_secret = os.environ['MJ_APIKEY_PRIVATE'] +mailjet = Client(auth=(api_key, api_secret)) +data = { + 'Email': 'Mister@mailjet.com' +} +result = mailjet.contact.create(data=data) +print result.status_code +print result.json() +``` + +#### Using actions + +```python +""" +Manage the subscription status of a contact to multiple lists: +""" +from mailjet_rest import Client +import os +api_key = os.environ['MJ_APIKEY_PUBLIC'] +api_secret = os.environ['MJ_APIKEY_PRIVATE'] +mailjet = Client(auth=(api_key, api_secret)) +id = '$ID' +data = { + 'ContactsLists': [ + { + "ListID": "$ListID_1", + "Action": "addnoforce" + }, + { + "ListID": "$ListID_2", + "Action": "addforce" + } + ] +} +result = mailjet.contact_managecontactslists.create(id=id, data=data) +print result.status_code +print result.json() +``` + +### GET Request + +#### Retrieve all objects + +```python +""" +Retrieve all contacts: +""" +from mailjet_rest import Client +import os +api_key = os.environ['MJ_APIKEY_PUBLIC'] +api_secret = os.environ['MJ_APIKEY_PRIVATE'] +mailjet = Client(auth=(api_key, api_secret)) +result = mailjet.contact.get() +print result.status_code +print result.json() +``` + +#### Using filtering + +```python +""" +Retrieve all contacts that are not in the campaign exclusion list: +""" +from mailjet_rest import Client +import os +api_key = os.environ['MJ_APIKEY_PUBLIC'] +api_secret = os.environ['MJ_APIKEY_PRIVATE'] +mailjet = Client(auth=(api_key, api_secret)) +filters = { + 'IsExcludedFromCampaigns': false, +} +result = mailjet.contact.get(filters=filters) +print result.status_code +print result.json() +``` + +#### Retrieve a single object + +```python +""" +Retrieve a specific contact ID: +""" +from mailjet_rest import Client +import os +api_key = os.environ['MJ_APIKEY_PUBLIC'] +api_secret = os.environ['MJ_APIKEY_PRIVATE'] +mailjet = Client(auth=(api_key, api_secret)) +id = 'Contact_ID' +result = mailjet.contact.get(id=id) +print result.status_code +print result.json() +``` + +### PUT request + +A `PUT` request in the Mailjet API will work as a `PATCH` request - the update will affect only the specified properties. The other properties of an existing resource will neither be modified, nor deleted. It also means that all non-mandatory properties can be omitted from your payload. + +Here's an example of a `PUT` request: + +```python +""" +Update the contact properties for a contact: +""" +from mailjet_rest import Client +import os +api_key = os.environ['MJ_APIKEY_PUBLIC'] +api_secret = os.environ['MJ_APIKEY_PRIVATE'] +mailjet = Client(auth=(api_key, api_secret)) +id = '$CONTACT_ID' +data = { + 'Data': [ + { + "Name": "first_name", + "value": "John" + }, + { + "Name": "last_name", + "value": "Smith" + } + ] +} +result = mailjet.contactdata.update(id=id, data=data) +print result.status_code +print result.json() +``` + +### DELETE request + +Upon a successful `DELETE` request the response will not include a response body, but only a `204 No Content` response code. + +Here's an example of a `DELETE` request: + +```python +""" +Delete an email template: +""" +from mailjet_rest import Client +import os +api_key = os.environ['MJ_APIKEY_PUBLIC'] +api_secret = os.environ['MJ_APIKEY_PRIVATE'] +mailjet = Client(auth=(api_key, api_secret)) +id = 'Template_ID' +result = mailjet.template.delete(id=id) +print result.status_code +print result.json() +``` + +## Contribute + +Mailjet loves developers. You can be part of this project! + +This wrapper is a great introduction to the open source world, check out the code! + +Feel free to ask anything, and contribute: + +- Fork the project. +- Create a new branch. +- Implement your feature or bug fix. +- Add documentation to it. +- Commit, push, open a pull request and voila. + +If you have suggestions on how to improve the guides, please submit an issue in our [Official API Documentation repo](https://github.com/mailjet/api-documentation). + + + + +%package help +Summary: Development documents and examples for mailjet-rest +Provides: python3-mailjet-rest-doc +%description help + +[mailjet]:(http://www.mailjet.com/) +[api_credential]: https://app.mailjet.com/account/api_keys +[doc]: http://dev.mailjet.com/guides/?python# +[api_doc]: https://github.com/mailjet/api-documentation + +![alt text](https://www.mailjet.com/images/email/transac/logo_header.png "Mailjet") + +# Official Mailjet Python Wrapper + +[![Build Status](https://travis-ci.org/mailjet/mailjet-apiv3-python.svg?branch=master)](https://travis-ci.org/mailjet/mailjet-apiv3-python) +![Current Version](https://img.shields.io/badge/version-1.3.2-green.svg) + +## Overview + +Welcome to the [Mailjet][mailjet] official Python API wrapper! + +Check out all the resources and Python code examples in the official [Mailjet Documentation][doc]. + +## Table of contents + +- [Compatibility](#compatibility) +- [Installation](#installation) +- [Authentication](#authentication) +- [Make your first call](#make-your-first-call) +- [Client / Call configuration specifics](#client--call-configuration-specifics) + - [API versioning](#api-versioning) + - [Base URL](#base-url) +- [Request examples](#request-examples) + - [POST request](#post-request) + - [Simple POST request](#simple-post-request) + - [Using actions](#using-actions) + - [GET request](#get-request) + - [Retrieve all objects](#retrieve-all-objects) + - [Use filtering](#use-filtering) + - [Retrieve a single object](#retrieve-a-single-object) + - [PUT request](#put-request) + - [DELETE request](#delete-request) +- [Contribute](#contribute) + +## Compatibility + +This library officially supports the following Python versions: + + - v2.7 + - v3.5 + - v3.6 + +## Installation + +Use the below code to install the wrapper: + +``` bash +(sudo) pip install mailjet_rest +``` + +## Authentication + +The Mailjet Email API uses your API and Secret keys for authentication. [Grab][api_credential] and save your Mailjet API credentials. + +```bash +export MJ_APIKEY_PUBLIC='your api key' +export MJ_APIKEY_PRIVATE='your api secret' +``` + +Initialize your [Mailjet][mailjet] client: + +```python +# import the mailjet wrapper +from mailjet_rest import Client +import os + +# Get your environment Mailjet keys +API_KEY = os.environ['MJ_APIKEY_PUBLIC'] +API_SECRET = os.environ['MJ_APIKEY_PRIVATE'] + +mailjet = Client(auth=(API_KEY, API_SECRET)) +``` + +## Make your first call + +Here's an example on how to send an email: + +```python +from mailjet_rest import Client +import os +api_key = os.environ['MJ_APIKEY_PUBLIC'] +api_secret = os.environ['MJ_APIKEY_PRIVATE'] +mailjet = Client(auth=(api_key, api_secret), version='v3.1') +data = { + 'Messages': [ + { + "From": { + "Email": "$SENDER_EMAIL", + "Name": "Me" + }, + "To": [ + { + "Email": "$RECIPIENT_EMAIL", + "Name": "You" + } + ], + "Subject": "My first Mailjet Email!", + "TextPart": "Greetings from Mailjet!", + "HTMLPart": "

Dear passenger 1, welcome to Mailjet!


May the delivery force be with you!" + } + ] +} +result = mailjet.send.create(data=data) +print result.status_code +print result.json() +``` + +## Client / Call Configuration Specifics + +### API Versioning + +The Mailjet API is spread among three distinct versions: + +- `v3` - The Email API +- `v3.1` - Email Send API v3.1, which is the latest version of our Send API +- `v4` - SMS API (not supported in Python) + +Since most Email API endpoints are located under `v3`, it is set as the default one and does not need to be specified when making your request. For the others you need to specify the version using `version`. For example, if using Send API `v3.1`: + +``` python +# import the mailjet wrapper +from mailjet_rest import Client +import os + +# Get your environment Mailjet keys +API_KEY = os.environ['MJ_APIKEY_PUBLIC'] +API_SECRET = os.environ['MJ_APIKEY_PRIVATE'] + +mailjet = Client(auth=(API_KEY, API_SECRET), version='v3.1') +``` + +For additional information refer to our [API Reference](https://dev.preprod.mailjet.com/reference/overview/versioning/). + +### Base URL + +The default base domain name for the Mailjet API is `api.mailjet.com`. You can modify this base URL by setting a value for `api_url` in your call: + +```python +mailjet = Client(auth=(api_key, api_secret),api_url="https://api.us.mailjet.com/") +``` + +If your account has been moved to Mailjet's **US architecture**, the URL value you need to set is `https://api.us.mailjet.com`. + +## Request examples + +### POST request + +#### Simple POST request + +```python +""" +Create a new contact: +""" +from mailjet_rest import Client +import os +api_key = os.environ['MJ_APIKEY_PUBLIC'] +api_secret = os.environ['MJ_APIKEY_PRIVATE'] +mailjet = Client(auth=(api_key, api_secret)) +data = { + 'Email': 'Mister@mailjet.com' +} +result = mailjet.contact.create(data=data) +print result.status_code +print result.json() +``` + +#### Using actions + +```python +""" +Manage the subscription status of a contact to multiple lists: +""" +from mailjet_rest import Client +import os +api_key = os.environ['MJ_APIKEY_PUBLIC'] +api_secret = os.environ['MJ_APIKEY_PRIVATE'] +mailjet = Client(auth=(api_key, api_secret)) +id = '$ID' +data = { + 'ContactsLists': [ + { + "ListID": "$ListID_1", + "Action": "addnoforce" + }, + { + "ListID": "$ListID_2", + "Action": "addforce" + } + ] +} +result = mailjet.contact_managecontactslists.create(id=id, data=data) +print result.status_code +print result.json() +``` + +### GET Request + +#### Retrieve all objects + +```python +""" +Retrieve all contacts: +""" +from mailjet_rest import Client +import os +api_key = os.environ['MJ_APIKEY_PUBLIC'] +api_secret = os.environ['MJ_APIKEY_PRIVATE'] +mailjet = Client(auth=(api_key, api_secret)) +result = mailjet.contact.get() +print result.status_code +print result.json() +``` + +#### Using filtering + +```python +""" +Retrieve all contacts that are not in the campaign exclusion list: +""" +from mailjet_rest import Client +import os +api_key = os.environ['MJ_APIKEY_PUBLIC'] +api_secret = os.environ['MJ_APIKEY_PRIVATE'] +mailjet = Client(auth=(api_key, api_secret)) +filters = { + 'IsExcludedFromCampaigns': false, +} +result = mailjet.contact.get(filters=filters) +print result.status_code +print result.json() +``` + +#### Retrieve a single object + +```python +""" +Retrieve a specific contact ID: +""" +from mailjet_rest import Client +import os +api_key = os.environ['MJ_APIKEY_PUBLIC'] +api_secret = os.environ['MJ_APIKEY_PRIVATE'] +mailjet = Client(auth=(api_key, api_secret)) +id = 'Contact_ID' +result = mailjet.contact.get(id=id) +print result.status_code +print result.json() +``` + +### PUT request + +A `PUT` request in the Mailjet API will work as a `PATCH` request - the update will affect only the specified properties. The other properties of an existing resource will neither be modified, nor deleted. It also means that all non-mandatory properties can be omitted from your payload. + +Here's an example of a `PUT` request: + +```python +""" +Update the contact properties for a contact: +""" +from mailjet_rest import Client +import os +api_key = os.environ['MJ_APIKEY_PUBLIC'] +api_secret = os.environ['MJ_APIKEY_PRIVATE'] +mailjet = Client(auth=(api_key, api_secret)) +id = '$CONTACT_ID' +data = { + 'Data': [ + { + "Name": "first_name", + "value": "John" + }, + { + "Name": "last_name", + "value": "Smith" + } + ] +} +result = mailjet.contactdata.update(id=id, data=data) +print result.status_code +print result.json() +``` + +### DELETE request + +Upon a successful `DELETE` request the response will not include a response body, but only a `204 No Content` response code. + +Here's an example of a `DELETE` request: + +```python +""" +Delete an email template: +""" +from mailjet_rest import Client +import os +api_key = os.environ['MJ_APIKEY_PUBLIC'] +api_secret = os.environ['MJ_APIKEY_PRIVATE'] +mailjet = Client(auth=(api_key, api_secret)) +id = 'Template_ID' +result = mailjet.template.delete(id=id) +print result.status_code +print result.json() +``` + +## Contribute + +Mailjet loves developers. You can be part of this project! + +This wrapper is a great introduction to the open source world, check out the code! + +Feel free to ask anything, and contribute: + +- Fork the project. +- Create a new branch. +- Implement your feature or bug fix. +- Add documentation to it. +- Commit, push, open a pull request and voila. + +If you have suggestions on how to improve the guides, please submit an issue in our [Official API Documentation repo](https://github.com/mailjet/api-documentation). + + + + +%prep +%autosetup -n mailjet-rest-1.3.4 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-mailjet-rest -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Mon Apr 10 2023 Python_Bot - 1.3.4-1 +- Package Spec generated -- cgit v1.2.3