ElasticEmail / elasticemail-bash

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Elastic Email REST API Bash client

Overview

This is a Bash client script for accessing Elastic Email REST API service.

The script uses cURL underneath for making all REST calls.

Usage

# Make sure the script has executable rights
$ chmod u+x ElasticEmail

# Print the list of operations available on the service
$ ./ElasticEmail -h

# Print the service description
$ ./ElasticEmail --about

# Print detailed information about specific operation
$ ./ElasticEmail <operationId> -h

# Make GET request
./ElasticEmail --host http://<hostname>:<port> --accept xml <operationId> <queryParam1>=<value1> <header_key1>:<header_value2>

# Make GET request using arbitrary curl options (must be passed before <operationId>) to an SSL service using username:password
ElasticEmail -k -sS --tlsv1.2 --host https://<hostname> -u <user>:<password> --accept xml <operationId> <queryParam1>=<value1> <header_key1>:<header_value2>

# Make POST request
$ echo '<body_content>' | ElasticEmail --host <hostname> --content-type json <operationId> -

# Make POST request with simple JSON content, e.g.:
# {
#   "key1": "value1",
#   "key2": "value2",
#   "key3": 23
# }
$ echo '<body_content>' | ElasticEmail --host <hostname> --content-type json <operationId> key1==value1 key2=value2 key3:=23 -

# Make POST request with form data
$ ElasticEmail --host <hostname> <operationId> key1:=value1 key2:=value2 key3:=23

# Preview the cURL command without actually executing it
$ ElasticEmail --host http://<hostname>:<port> --dry-run <operationid>

Docker image

You can easily create a Docker image containing a preconfigured environment for using the REST Bash client including working autocompletion and short welcome message with basic instructions, using the generated Dockerfile:

docker build -t my-rest-client .
docker run -it my-rest-client

By default you will be logged into a Zsh environment which has much more advanced auto completion, but you can switch to Bash, where basic autocompletion is also available.

Shell completion

Bash

The generated bash-completion script can be either directly loaded to the current Bash session using:

source ElasticEmail.bash-completion

Alternatively, the script can be copied to the /etc/bash-completion.d (or on OSX with Homebrew to /usr/local/etc/bash-completion.d):

sudo cp ElasticEmail.bash-completion /etc/bash-completion.d/ElasticEmail

OS X

On OSX you might need to install bash-completion using Homebrew:

brew install bash-completion

and add the following to the ~/.bashrc:

if [ -f $(brew --prefix)/etc/bash_completion ]; then
  . $(brew --prefix)/etc/bash_completion
fi

Zsh

In Zsh, the generated _ElasticEmail Zsh completion file must be copied to one of the folders under $FPATH variable.

Examples

Function
addCampaign readme
addContacts readme
addList readme
addTemplate readme
deleteCampaign readme
deleteContact readme
deleteList readme
deleteTemplate readme
exportContacts readme
loadCampaign readme
loadCampaignsStats readme
loadChannelsStats readme
loadList readme
loadStatistics readme
loadTemplate readme
sendBulkEmails readme
sendTransactionalEmails readme
updateCampaign readme
uploadContacts readme

Documentation for API Endpoints

All URIs are relative to /v4

Class Method HTTP request Description
CampaignsApi campaignsByNameDelete DELETE /campaigns/{name} Delete Campaign
CampaignsApi campaignsByNameGet GET /campaigns/{name} Load Campaign
CampaignsApi campaignsByNamePut PUT /campaigns/{name} Update Campaign
CampaignsApi campaignsGet GET /campaigns Load Campaigns
CampaignsApi campaignsPost POST /campaigns Add Campaign
ContactsApi contactsByEmailDelete DELETE /contacts/{email} Delete Contact
ContactsApi contactsByEmailGet GET /contacts/{email} Load Contact
ContactsApi contactsByEmailPut PUT /contacts/{email} Update Contact
ContactsApi contactsDeletePost POST /contacts/delete Delete Contacts Bulk
ContactsApi contactsExportByIdStatusGet GET /contacts/export/{id}/status Check Export Status
ContactsApi contactsExportPost POST /contacts/export Export Contacts
ContactsApi contactsGet GET /contacts Load Contacts
ContactsApi contactsImportPost POST /contacts/import Upload Contacts
ContactsApi contactsPost POST /contacts Add Contact
EmailsApi emailsByMsgidViewGet GET /emails/{msgid}/view View Email
EmailsApi emailsMergefilePost POST /emails/mergefile Send Bulk Emails CSV
EmailsApi emailsPost POST /emails Send Bulk Emails
EmailsApi emailsTransactionalPost POST /emails/transactional Send Transactional Email
EventsApi eventsByTransactionidGet GET /events/{transactionid} Load Email Events
EventsApi eventsChannelsByNameExportPost POST /events/channels/{name}/export Export Channel Events
EventsApi eventsChannelsByNameGet GET /events/channels/{name} Load Channel Events
EventsApi eventsChannelsExportByIdStatusGet GET /events/channels/export/{id}/status Check Channel Export Status
EventsApi eventsExportByIdStatusGet GET /events/export/{id}/status Check Export Status
EventsApi eventsExportPost POST /events/export Export Events
EventsApi eventsGet GET /events Load Events
FilesApi filesByNameDelete DELETE /files/{name} Delete File
FilesApi filesByNameGet GET /files/{name} Download File
FilesApi filesByNameInfoGet GET /files/{name}/info Load File Details
FilesApi filesGet GET /files List Files
FilesApi filesPost POST /files Upload File
InboundRouteApi inboundrouteByIdDelete DELETE /inboundroute/{id} Delete Route
InboundRouteApi inboundrouteByIdGet GET /inboundroute/{id} Get Route
InboundRouteApi inboundrouteByIdPut PUT /inboundroute/{id} Update Route
InboundRouteApi inboundrouteGet GET /inboundroute Get Routes
InboundRouteApi inboundrouteOrderPut PUT /inboundroute/order Update Sorting
InboundRouteApi inboundroutePost POST /inboundroute Create Route
ListsApi listsByNameContactsPost POST /lists/{name}/contacts Add Contacts to List
ListsApi listsByNameContactsRemovePost POST /lists/{name}/contacts/remove Remove Contacts from List
ListsApi listsByNameDelete DELETE /lists/{name} Delete List
ListsApi listsByNameGet GET /lists/{name} Load List
ListsApi listsByNamePut PUT /lists/{name} Update List
ListsApi listsGet GET /lists Load Lists
ListsApi listsPost POST /lists Add List
SecurityApi securityApikeysByNameDelete DELETE /security/apikeys/{name} Delete ApiKey
SecurityApi securityApikeysByNameGet GET /security/apikeys/{name} Load ApiKey
SecurityApi securityApikeysByNamePut PUT /security/apikeys/{name} Update ApiKey
SecurityApi securityApikeysGet GET /security/apikeys List ApiKeys
SecurityApi securityApikeysPost POST /security/apikeys Add ApiKey
SecurityApi securitySmtpByNameDelete DELETE /security/smtp/{name} Delete SMTP Credential
SecurityApi securitySmtpByNameGet GET /security/smtp/{name} Load SMTP Credential
SecurityApi securitySmtpByNamePut PUT /security/smtp/{name} Update SMTP Credential
SecurityApi securitySmtpGet GET /security/smtp List SMTP Credentials
SecurityApi securitySmtpPost POST /security/smtp Add SMTP Credential
SegmentsApi segmentsByNameDelete DELETE /segments/{name} Delete Segment
SegmentsApi segmentsByNameGet GET /segments/{name} Load Segment
SegmentsApi segmentsByNamePut PUT /segments/{name} Update Segment
SegmentsApi segmentsGet GET /segments Load Segments
SegmentsApi segmentsPost POST /segments Add Segment
StatisticsApi statisticsCampaignsByNameGet GET /statistics/campaigns/{name} Load Campaign Stats
StatisticsApi statisticsCampaignsGet GET /statistics/campaigns Load Campaigns Stats
StatisticsApi statisticsChannelsByNameGet GET /statistics/channels/{name} Load Channel Stats
StatisticsApi statisticsChannelsGet GET /statistics/channels Load Channels Stats
StatisticsApi statisticsGet GET /statistics Load Statistics
SubAccountsApi subaccountsByEmailCreditsPatch PATCH /subaccounts/{email}/credits Add, Subtract Email Credits
SubAccountsApi subaccountsByEmailDelete DELETE /subaccounts/{email} Delete SubAccount
SubAccountsApi subaccountsByEmailGet GET /subaccounts/{email} Load SubAccount
SubAccountsApi subaccountsByEmailSettingsEmailPut PUT /subaccounts/{email}/settings/email Update SubAccount Email Settings
SubAccountsApi subaccountsGet GET /subaccounts Load SubAccounts
SubAccountsApi subaccountsPost POST /subaccounts Add SubAccount
SuppressionsApi suppressionsBouncesGet GET /suppressions/bounces Get Bounce List
SuppressionsApi suppressionsBouncesImportPost POST /suppressions/bounces/import Add Bounces Async
SuppressionsApi suppressionsBouncesPost POST /suppressions/bounces Add Bounces
SuppressionsApi suppressionsByEmailDelete DELETE /suppressions/{email} Delete Suppression
SuppressionsApi suppressionsByEmailGet GET /suppressions/{email} Get Suppression
SuppressionsApi suppressionsComplaintsGet GET /suppressions/complaints Get Complaints List
SuppressionsApi suppressionsComplaintsImportPost POST /suppressions/complaints/import Add Complaints Async
SuppressionsApi suppressionsComplaintsPost POST /suppressions/complaints Add Complaints
SuppressionsApi suppressionsGet GET /suppressions Get Suppressions
SuppressionsApi suppressionsUnsubscribesGet GET /suppressions/unsubscribes Get Unsubscribes List
SuppressionsApi suppressionsUnsubscribesImportPost POST /suppressions/unsubscribes/import Add Unsubscribes Async
SuppressionsApi suppressionsUnsubscribesPost POST /suppressions/unsubscribes Add Unsubscribes
TemplatesApi templatesByNameDelete DELETE /templates/{name} Delete Template
TemplatesApi templatesByNameGet GET /templates/{name} Load Template
TemplatesApi templatesByNamePut PUT /templates/{name} Update Template
TemplatesApi templatesGet GET /templates Load Templates
TemplatesApi templatesPost POST /templates Add Template
VerificationsApi verificationsByEmailDelete DELETE /verifications/{email} Delete Email Verification Result
VerificationsApi verificationsByEmailGet GET /verifications/{email} Get Email Verification Result
VerificationsApi verificationsByEmailPost POST /verifications/{email} Verify Email
VerificationsApi verificationsFilesByIdDelete DELETE /verifications/files/{id} Delete File Verification Result
VerificationsApi verificationsFilesByIdResultDownloadGet GET /verifications/files/{id}/result/download Download File Verification Result
VerificationsApi verificationsFilesByIdResultGet GET /verifications/files/{id}/result Get Detailed File Verification Result
VerificationsApi verificationsFilesByIdVerificationPost POST /verifications/files/{id}/verification Start verification
VerificationsApi verificationsFilesPost POST /verifications/files Upload File with Emails
VerificationsApi verificationsFilesResultGet GET /verifications/files/result Get Files Verification Results
VerificationsApi verificationsGet GET /verifications Get Emails Verification Results

Documentation For Models

Documentation For Authorization

apikey

  • Type: API key
  • API key parameter name: X-ElasticEmail-ApiKey
  • Location: HTTP header

About


Languages

Language:Shell 99.5%Language:Dockerfile 0.5%