-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathexportContacts.py
38 lines (33 loc) · 1.63 KB
/
exportContacts.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import ElasticEmail
from ElasticEmail.apis.tags import contacts_api
from ElasticEmail.model.export_file_formats import ExportFileFormats
from ElasticEmail.model.compression_format import CompressionFormat
from pprint import pprint
# Defining the host is optional and defaults to https://api.elasticemail.com/v4
configuration = ElasticEmail.Configuration()
# Configure API key authorization: apikey
configuration.api_key['apikey'] = 'YOUR_API_KEY'
"""
Export contacts
Example api call that exports selected contacts to downloadable file.
Options:
fileFormat: "Csv" "Xml" "Json" – Format of the exported file
emails: [mail@contact.com,mail1@contact.com,mail2@contact.com] – Array of contact emails
compressionFormat: "None" "Zip"
fileName=filename.txt – Name of your file including extension.
rule: rule="Status%20=%20Engaged" – Query used for filtering.
"""
with ElasticEmail.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = contacts_api.ContactsApi(api_client)
query_params = {
'fileFormat': ExportFileFormats("Csv"), # ExportFileFormats | Format of the exported file (optional)
'compressionFormat': CompressionFormat("None"), # CompressionFormat | FileResponse compression format. None or Zip. (optional)
'fileName': "exported.csv", # str | Name of your file including extension. (optional)
}
try:
# Export Contacts
api_response = api_instance.contacts_export_post(query_params = query_params)
pprint(api_response)
except ElasticEmail.ApiException as e:
print("Exception when calling ContactsApi->contacts_export_post: %s\n" % e)