ElasticEmail / elasticemail-go

ElasticEmail - Go library for the Elastic Email REST API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Go API client for ElasticEmail

This API is based on the REST API architecture, allowing the user to easily manage their data with this resource-based approach.

Every API call is established on which specific request type (GET, POST, PUT, DELETE) will be used.

The API has a limit of 20 concurrent connections and a hard timeout of 600 seconds per request.

To start using this API, you will need your Access Token (available here). Remember to keep it safe. Required access levels are listed in the given request’s description.

Downloadable library clients can be found in our Github repository here

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version: 4.0.0
  • Package version: 4.1.0
  • Generator version: 7.7.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/net/context

Put the package under your project folder and add the following in import:

import ElasticEmail "github.com/elasticemail/elasticemail-go"

To use a proxy, set the environment variable HTTP_PROXY:

os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")

Configuration of Server URL

Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.

Select Server Configuration

For using other server than the one defined on index 0 set context value ElasticEmail.ContextServerIndex of type int.

ctx := context.WithValue(context.Background(), ElasticEmail.ContextServerIndex, 1)

Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value ElasticEmail.ContextServerVariables of type map[string]string.

ctx := context.WithValue(context.Background(), ElasticEmail.ContextServerVariables, map[string]string{
	"basePath": "v2",
})

Note, enum values are always validated and all unused variables are silently ignored.

URLs Configuration per Operation

Each operation can use different server URL defined using OperationServers map in the Configuration. An operation is uniquely identified by "{classname}Service.{nickname}" string. Similar rules for overriding default operation server index and variables applies by using ElasticEmail.ContextOperationServerIndices and ElasticEmail.ContextOperationServerVariables context maps.

ctx := context.WithValue(context.Background(), ElasticEmail.ContextOperationServerIndices, map[string]int{
	"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), ElasticEmail.ContextOperationServerVariables, map[string]map[string]string{
	"{classname}Service.{nickname}": {
		"port": "8443",
	},
})

All URIs are relative to https://api.elasticemail.com/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 EmailsByTransactionidStatusGet Get /emails/{transactionid}/status Get Status
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 ListsByListnameContactsGet Get /lists/{listname}/contacts Load Contacts in List
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

Authentication schemes defined for the API:

apikey

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

Note, each API key must be added to a map of map[string]APIKey where the key is: X-ElasticEmail-ApiKey and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		ElasticEmail.ContextAPIKeys,
		map[string]ElasticEmail.APIKey{
			"X-ElasticEmail-ApiKey": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime

Author

support@elasticemail.com

About

ElasticEmail - Go library for the Elastic Email REST API