# README
createsend
Campaign Monitor API wrapper in Go
Installation
go get github.com/xitonix/createsend
Example
package main
import (
"fmt"
"log"
"github.com/xitonix/createsend"
)
func main() {
client, err := createsend.New(createsend.WithAPIKey("[Your API Key]"))
if err != nil {
log.Fatal(err)
}
clients, err := client.Accounts().Clients()
if err != nil {
log.Fatal(err)
}
for _, client := range clients {
fmt.Printf("%s: %s\n", client.ID, client.Name)
}
}
You can also use oAuth authentication token:
client, err := createsend.New(createsend.WithOAuthToken("[OAuth Token]"))
if err != nil {
log.Fatal(err)
}
# Functions
New creates a new client.
WithAccountsAPI overrides the internal object for accessing Accounts API.
WithAPIKey enables API key authentication.
WithBaseURL overrides the base URL.
WithClientsAPI overrides the internal object for accessing Clients API.
WithContext sets the context for all the HTTP requests.
WithHTTPClient sets the internal HTTP client.
WithOAuthToken enables Oauth token authentication.
# Constants
DefaultBaseURL the default API base URL.
ErrCodeAuthenticationNotSet neither API key nor Oauth token was provided.
ErrCodeDataProcessing indicates that processing the input/output data has failed.
ErrCodeEmptyAPIKey the provided API key was empty.
ErrCodeEmptyOAuthToken the provided Oauth token was empty.
ErrCodeEmptyURL the requested URL was empty.
ErrCodeInvalidJSON the provided JSON payload was invalid.
ErrCodeInvalidRequestBody the provided request was invalid.
ErrCodeInvalidURL the requested UTL was invalid.
ErrCodeNilHTTPClient the provided internal HTTP client is nil.
# Interfaces
HTTPClient is an interface for the internal HTTP client.
# Type aliases
ClientErrorCode client side error codes.
Option represents an optional client configuration function.