Categorygithub.com/elasticemail/elasticemail-go
repositorypackage
0.0.0-20241205123740-0d2d7785d6eb
Repository: https://github.com/elasticemail/elasticemail-go.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

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.0.25
  • Generator version: 7.5.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

ClassMethodHTTP requestDescription
CampaignsAPICampaignsByNameDeleteDelete /campaigns/{name}Delete Campaign
CampaignsAPICampaignsByNameGetGet /campaigns/{name}Load Campaign
CampaignsAPICampaignsByNamePausePutPut /campaigns/{name}/pausePause Campaign
CampaignsAPICampaignsByNamePutPut /campaigns/{name}Update Campaign
CampaignsAPICampaignsGetGet /campaignsLoad Campaigns
CampaignsAPICampaignsPostPost /campaignsAdd Campaign
ContactsAPIContactsByEmailDeleteDelete /contacts/{email}Delete Contact
ContactsAPIContactsByEmailGetGet /contacts/{email}Load Contact
ContactsAPIContactsByEmailPutPut /contacts/{email}Update Contact
ContactsAPIContactsDeletePostPost /contacts/deleteDelete Contacts Bulk
ContactsAPIContactsExportByIdStatusGetGet /contacts/export/{id}/statusCheck Export Status
ContactsAPIContactsExportPostPost /contacts/exportExport Contacts
ContactsAPIContactsGetGet /contactsLoad Contacts
ContactsAPIContactsImportPostPost /contacts/importUpload Contacts
ContactsAPIContactsPostPost /contactsAdd Contact
DomainsAPIDomainsByDomainDeleteDelete /domains/{domain}Delete Domain
DomainsAPIDomainsByDomainGetGet /domains/{domain}Load Domain
DomainsAPIDomainsByDomainPutPut /domains/{domain}Update Domain
DomainsAPIDomainsByDomainRestrictedGetGet /domains/{domain}/restrictedCheck for domain restriction
DomainsAPIDomainsByDomainVerificationPutPut /domains/{domain}/verificationVerify Domain
DomainsAPIDomainsByEmailDefaultPatchPatch /domains/{email}/defaultSet Default
DomainsAPIDomainsGetGet /domainsLoad Domains
DomainsAPIDomainsPostPost /domainsAdd Domain
EmailsAPIEmailsByMsgidViewGetGet /emails/{msgid}/viewView Email
EmailsAPIEmailsByTransactionidStatusGetGet /emails/{transactionid}/statusGet Status
EmailsAPIEmailsMergefilePostPost /emails/mergefileSend Bulk Emails CSV
EmailsAPIEmailsPostPost /emailsSend Bulk Emails
EmailsAPIEmailsTransactionalPostPost /emails/transactionalSend Transactional Email
EventsAPIEventsByTransactionidGetGet /events/{transactionid}Load Email Events
EventsAPIEventsChannelsByNameExportPostPost /events/channels/{name}/exportExport Channel Events
EventsAPIEventsChannelsByNameGetGet /events/channels/{name}Load Channel Events
EventsAPIEventsChannelsExportByIdStatusGetGet /events/channels/export/{id}/statusCheck Channel Export Status
EventsAPIEventsExportByIdStatusGetGet /events/export/{id}/statusCheck Export Status
EventsAPIEventsExportPostPost /events/exportExport Events
EventsAPIEventsGetGet /eventsLoad Events
FilesAPIFilesByNameDeleteDelete /files/{name}Delete File
FilesAPIFilesByNameGetGet /files/{name}Download File
FilesAPIFilesByNameInfoGetGet /files/{name}/infoLoad File Details
FilesAPIFilesGetGet /filesList Files
FilesAPIFilesPostPost /filesUpload File
InboundRouteAPIInboundrouteByIdDeleteDelete /inboundroute/{id}Delete Route
InboundRouteAPIInboundrouteByIdGetGet /inboundroute/{id}Get Route
InboundRouteAPIInboundrouteByIdPutPut /inboundroute/{id}Update Route
InboundRouteAPIInboundrouteGetGet /inboundrouteGet Routes
InboundRouteAPIInboundrouteOrderPutPut /inboundroute/orderUpdate Sorting
InboundRouteAPIInboundroutePostPost /inboundrouteCreate Route
ListsAPIListsByListnameContactsGetGet /lists/{listname}/contactsLoad Contacts in List
ListsAPIListsByNameContactsPostPost /lists/{name}/contactsAdd Contacts to List
ListsAPIListsByNameContactsRemovePostPost /lists/{name}/contacts/removeRemove Contacts from List
ListsAPIListsByNameDeleteDelete /lists/{name}Delete List
ListsAPIListsByNameGetGet /lists/{name}Load List
ListsAPIListsByNamePutPut /lists/{name}Update List
ListsAPIListsGetGet /listsLoad Lists
ListsAPIListsPostPost /listsAdd List
SecurityAPISecurityApikeysByNameDeleteDelete /security/apikeys/{name}Delete ApiKey
SecurityAPISecurityApikeysByNameGetGet /security/apikeys/{name}Load ApiKey
SecurityAPISecurityApikeysByNamePutPut /security/apikeys/{name}Update ApiKey
SecurityAPISecurityApikeysGetGet /security/apikeysList ApiKeys
SecurityAPISecurityApikeysPostPost /security/apikeysAdd ApiKey
SecurityAPISecuritySmtpByNameDeleteDelete /security/smtp/{name}Delete SMTP Credential
SecurityAPISecuritySmtpByNameGetGet /security/smtp/{name}Load SMTP Credential
SecurityAPISecuritySmtpByNamePutPut /security/smtp/{name}Update SMTP Credential
SecurityAPISecuritySmtpGetGet /security/smtpList SMTP Credentials
SecurityAPISecuritySmtpPostPost /security/smtpAdd SMTP Credential
SegmentsAPISegmentsByNameDeleteDelete /segments/{name}Delete Segment
SegmentsAPISegmentsByNameGetGet /segments/{name}Load Segment
SegmentsAPISegmentsByNamePutPut /segments/{name}Update Segment
SegmentsAPISegmentsGetGet /segmentsLoad Segments
SegmentsAPISegmentsPostPost /segmentsAdd Segment
StatisticsAPIStatisticsCampaignsByNameGetGet /statistics/campaigns/{name}Load Campaign Stats
StatisticsAPIStatisticsCampaignsGetGet /statistics/campaignsLoad Campaigns Stats
StatisticsAPIStatisticsChannelsByNameGetGet /statistics/channels/{name}Load Channel Stats
StatisticsAPIStatisticsChannelsGetGet /statistics/channelsLoad Channels Stats
StatisticsAPIStatisticsGetGet /statisticsLoad Statistics
SubAccountsAPISubaccountsByEmailCreditsPatchPatch /subaccounts/{email}/creditsAdd, Subtract Email Credits
SubAccountsAPISubaccountsByEmailDeleteDelete /subaccounts/{email}Delete SubAccount
SubAccountsAPISubaccountsByEmailGetGet /subaccounts/{email}Load SubAccount
SubAccountsAPISubaccountsByEmailSettingsEmailPutPut /subaccounts/{email}/settings/emailUpdate SubAccount Email Settings
SubAccountsAPISubaccountsGetGet /subaccountsLoad SubAccounts
SubAccountsAPISubaccountsPostPost /subaccountsAdd SubAccount
SuppressionsAPISuppressionsBouncesGetGet /suppressions/bouncesGet Bounce List
SuppressionsAPISuppressionsBouncesImportPostPost /suppressions/bounces/importAdd Bounces Async
SuppressionsAPISuppressionsBouncesPostPost /suppressions/bouncesAdd Bounces
SuppressionsAPISuppressionsByEmailDeleteDelete /suppressions/{email}Delete Suppression
SuppressionsAPISuppressionsByEmailGetGet /suppressions/{email}Get Suppression
SuppressionsAPISuppressionsComplaintsGetGet /suppressions/complaintsGet Complaints List
SuppressionsAPISuppressionsComplaintsImportPostPost /suppressions/complaints/importAdd Complaints Async
SuppressionsAPISuppressionsComplaintsPostPost /suppressions/complaintsAdd Complaints
SuppressionsAPISuppressionsGetGet /suppressionsGet Suppressions
SuppressionsAPISuppressionsUnsubscribesGetGet /suppressions/unsubscribesGet Unsubscribes List
SuppressionsAPISuppressionsUnsubscribesImportPostPost /suppressions/unsubscribes/importAdd Unsubscribes Async
SuppressionsAPISuppressionsUnsubscribesPostPost /suppressions/unsubscribesAdd Unsubscribes
TemplatesAPITemplatesByNameDeleteDelete /templates/{name}Delete Template
TemplatesAPITemplatesByNameGetGet /templates/{name}Load Template
TemplatesAPITemplatesByNamePutPut /templates/{name}Update Template
TemplatesAPITemplatesGetGet /templatesLoad Templates
TemplatesAPITemplatesPostPost /templatesAdd Template
VerificationsAPIVerificationsByEmailDeleteDelete /verifications/{email}Delete Email Verification Result
VerificationsAPIVerificationsByEmailGetGet /verifications/{email}Get Email Verification Result
VerificationsAPIVerificationsByEmailPostPost /verifications/{email}Verify Email
VerificationsAPIVerificationsFilesByIdDeleteDelete /verifications/files/{id}Delete File Verification Result
VerificationsAPIVerificationsFilesByIdResultDownloadGetGet /verifications/files/{id}/result/downloadDownload File Verification Result
VerificationsAPIVerificationsFilesByIdResultGetGet /verifications/files/{id}/resultGet Detailed File Verification Result
VerificationsAPIVerificationsFilesByIdVerificationPostPost /verifications/files/{id}/verificationStart verification
VerificationsAPIVerificationsFilesPostPost /verifications/filesUpload File with Emails
VerificationsAPIVerificationsFilesResultGetGet /verifications/files/resultGet Files Verification Results
VerificationsAPIVerificationsGetGet /verificationsGet 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

[email protected]