mirror of
https://github.com/hanzo-go/sdk.git
synced 2026-11-20 20:13:42 +00:00
1322 lines
45 KiB
Go
1322 lines
45 KiB
Go
/*
|
|
Hanzo Cloud API
|
|
|
|
The Hanzo Cloud API as a customer calls it: every operation under /v1/ except the operator's admin product, relay routes, legacy spellings and capabilities still reached by flag. Tagged by product: the first path segment after /v1/.
|
|
|
|
API version: v1
|
|
*/
|
|
|
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
|
|
|
package hanzoai
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"io"
|
|
"net/http"
|
|
"net/url"
|
|
"strings"
|
|
)
|
|
|
|
// EmailAPIService EmailAPI service
|
|
type EmailAPIService service
|
|
|
|
type EmailAPIGetEmailRequest struct {
|
|
ctx context.Context
|
|
ApiService *EmailAPIService
|
|
limit *int64
|
|
status *string
|
|
provider *string
|
|
since *string
|
|
until *string
|
|
recipient *string
|
|
cursor *string
|
|
}
|
|
|
|
// Limit is the most messages on the page (default 50, max 200).
|
|
func (r EmailAPIGetEmailRequest) Limit(limit int64) EmailAPIGetEmailRequest {
|
|
r.limit = &limit
|
|
return r
|
|
}
|
|
|
|
// Status is one status to list: queued, sent, failed, delivered, opened, clicked, bounced or complained.
|
|
func (r EmailAPIGetEmailRequest) Status(status string) EmailAPIGetEmailRequest {
|
|
r.status = &status
|
|
return r
|
|
}
|
|
|
|
// Provider is ses or sendgrid.
|
|
func (r EmailAPIGetEmailRequest) Provider(provider string) EmailAPIGetEmailRequest {
|
|
r.provider = &provider
|
|
return r
|
|
}
|
|
|
|
// Since is the earliest send time listed, RFC 3339.
|
|
func (r EmailAPIGetEmailRequest) Since(since string) EmailAPIGetEmailRequest {
|
|
r.since = &since
|
|
return r
|
|
}
|
|
|
|
// Until is the send time listing stops before, RFC 3339.
|
|
func (r EmailAPIGetEmailRequest) Until(until string) EmailAPIGetEmailRequest {
|
|
r.until = &until
|
|
return r
|
|
}
|
|
|
|
// Recipient lists the messages to one address.
|
|
func (r EmailAPIGetEmailRequest) Recipient(recipient string) EmailAPIGetEmailRequest {
|
|
r.recipient = &recipient
|
|
return r
|
|
}
|
|
|
|
// Cursor is the next of the page before; empty is the newest page.
|
|
func (r EmailAPIGetEmailRequest) Cursor(cursor string) EmailAPIGetEmailRequest {
|
|
r.cursor = &cursor
|
|
return r
|
|
}
|
|
|
|
func (r EmailAPIGetEmailRequest) Execute() (*EmailListMessagesResult, *http.Response, error) {
|
|
return r.ApiService.GetEmailExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetEmail Reads a page of the org's ledger, newest first: every message sent through POST /v1/email, and every message SES or SendGrid told of by its events, sent from anywhere on the org's account.
|
|
|
|
Reads a page of the org's ledger, newest first: every message sent
|
|
through POST /v1/email, and every message SES or SendGrid told of by its events,
|
|
sent from anywhere on the org's account. It narrows by status, provider, a range
|
|
of send time (since, until) and one recipient, and pages by cursor: pass the
|
|
answer's next to read the page after.
|
|
|
|
GET /v1/email
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return EmailAPIGetEmailRequest
|
|
*/
|
|
func (a *EmailAPIService) GetEmail(ctx context.Context) EmailAPIGetEmailRequest {
|
|
return EmailAPIGetEmailRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return EmailListMessagesResult
|
|
func (a *EmailAPIService) GetEmailExecute(r EmailAPIGetEmailRequest) (*EmailListMessagesResult, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *EmailListMessagesResult
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EmailAPIService.GetEmail")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/email"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
if r.limit != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "limit", r.limit, "form", "")
|
|
}
|
|
if r.status != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "status", r.status, "form", "")
|
|
}
|
|
if r.provider != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "provider", r.provider, "form", "")
|
|
}
|
|
if r.since != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "since", r.since, "form", "")
|
|
}
|
|
if r.until != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "until", r.until, "form", "")
|
|
}
|
|
if r.recipient != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "recipient", r.recipient, "form", "")
|
|
}
|
|
if r.cursor != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "cursor", r.cursor, "form", "")
|
|
}
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type EmailAPIGetEmailByIdRequest struct {
|
|
ctx context.Context
|
|
ApiService *EmailAPIService
|
|
id string
|
|
}
|
|
|
|
func (r EmailAPIGetEmailByIdRequest) Execute() (*EmailMessageRecord, *http.Response, error) {
|
|
return r.ApiService.GetEmailByIdExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetEmailById Reads one message of the org's ledger, sent through this API or told of by its provider, with what became of it.
|
|
|
|
Reads one message of the org's ledger, sent through this API or told of
|
|
by its provider, with what became of it.
|
|
|
|
GET /v1/email/:id
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@param id ID is our id for the message (msg_…).
|
|
@return EmailAPIGetEmailByIdRequest
|
|
*/
|
|
func (a *EmailAPIService) GetEmailById(ctx context.Context, id string) EmailAPIGetEmailByIdRequest {
|
|
return EmailAPIGetEmailByIdRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
id: id,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return EmailMessageRecord
|
|
func (a *EmailAPIService) GetEmailByIdExecute(r EmailAPIGetEmailByIdRequest) (*EmailMessageRecord, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *EmailMessageRecord
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EmailAPIService.GetEmailById")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/email/{id}"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1)
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type EmailAPIGetEmailSendgridStatusRequest struct {
|
|
ctx context.Context
|
|
ApiService *EmailAPIService
|
|
domain *string
|
|
}
|
|
|
|
// Domain is an optional sending domain to generate SendGrid whitelabel DKIM, Return-Path, and DMARC records for.
|
|
func (r EmailAPIGetEmailSendgridStatusRequest) Domain(domain string) EmailAPIGetEmailSendgridStatusRequest {
|
|
r.domain = &domain
|
|
return r
|
|
}
|
|
|
|
func (r EmailAPIGetEmailSendgridStatusRequest) Execute() (*EmailSendGridStatusResult, *http.Response, error) {
|
|
return r.ApiService.GetEmailSendgridStatusExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetEmailSendgridStatus Reports the org's SendGrid configuration: whether it holds the credentials a send needs, the account's credits as SendGrid answers them, what the org's ledger counted sent by SendGrid in the last 24 hours, and the DNS records of the sending domain.
|
|
|
|
Reports the org's SendGrid configuration: whether it holds the
|
|
credentials a send needs, the account's credits as SendGrid answers them, what
|
|
the org's ledger counted sent by SendGrid in the last 24 hours, and the DNS
|
|
records of the sending domain.
|
|
|
|
GET /v1/email/sendgrid/status
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return EmailAPIGetEmailSendgridStatusRequest
|
|
*/
|
|
func (a *EmailAPIService) GetEmailSendgridStatus(ctx context.Context) EmailAPIGetEmailSendgridStatusRequest {
|
|
return EmailAPIGetEmailSendgridStatusRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return EmailSendGridStatusResult
|
|
func (a *EmailAPIService) GetEmailSendgridStatusExecute(r EmailAPIGetEmailSendgridStatusRequest) (*EmailSendGridStatusResult, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *EmailSendGridStatusResult
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EmailAPIService.GetEmailSendgridStatus")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/email/sendgrid/status"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
if r.domain != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "domain", r.domain, "form", "")
|
|
}
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type EmailAPIGetEmailSesStatusRequest struct {
|
|
ctx context.Context
|
|
ApiService *EmailAPIService
|
|
domain *string
|
|
}
|
|
|
|
// Domain optionally specifies the sending domain to generate Easy DKIM and MAIL FROM records for.
|
|
func (r EmailAPIGetEmailSesStatusRequest) Domain(domain string) EmailAPIGetEmailSesStatusRequest {
|
|
r.domain = &domain
|
|
return r
|
|
}
|
|
|
|
func (r EmailAPIGetEmailSesStatusRequest) Execute() (*EmailSESStatusResult, *http.Response, error) {
|
|
return r.ApiService.GetEmailSesStatusExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetEmailSesStatus Reports the org's Amazon SES configuration: whether it holds the credentials a send needs, the account's limits as SES answers them (sandbox, sending enabled, 24-hour quota, rate, sent in the last 24 hours), what the org's ledger counted sent by SES in the last 24 hours, and the DNS records of the sending domain.
|
|
|
|
Reports the org's Amazon SES configuration: whether it holds the
|
|
credentials a send needs, the account's limits as SES answers them (sandbox,
|
|
sending enabled, 24-hour quota, rate, sent in the last 24 hours), what the org's
|
|
ledger counted sent by SES in the last 24 hours, and the DNS records of the
|
|
sending domain.
|
|
|
|
GET /v1/email/ses/status
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return EmailAPIGetEmailSesStatusRequest
|
|
*/
|
|
func (a *EmailAPIService) GetEmailSesStatus(ctx context.Context) EmailAPIGetEmailSesStatusRequest {
|
|
return EmailAPIGetEmailSesStatusRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return EmailSESStatusResult
|
|
func (a *EmailAPIService) GetEmailSesStatusExecute(r EmailAPIGetEmailSesStatusRequest) (*EmailSESStatusResult, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *EmailSESStatusResult
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EmailAPIService.GetEmailSesStatus")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/email/ses/status"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
if r.domain != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "domain", r.domain, "form", "")
|
|
}
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type EmailAPIGetEmailStatsRequest struct {
|
|
ctx context.Context
|
|
ApiService *EmailAPIService
|
|
since *string
|
|
until *string
|
|
interval *string
|
|
provider *string
|
|
campaign *string
|
|
}
|
|
|
|
// Since is where the range starts, RFC 3339, rounded down to its day or hour. Empty is 30 days before Until by day, 48 hours by hour.
|
|
func (r EmailAPIGetEmailStatsRequest) Since(since string) EmailAPIGetEmailStatsRequest {
|
|
r.since = &since
|
|
return r
|
|
}
|
|
|
|
// Until is where the range ends, RFC 3339, rounded up to its day or hour. Empty is now.
|
|
func (r EmailAPIGetEmailStatsRequest) Until(until string) EmailAPIGetEmailStatsRequest {
|
|
r.until = &until
|
|
return r
|
|
}
|
|
|
|
// Interval is day (default, at most 400 days) or hour (at most 31 days), in UTC.
|
|
func (r EmailAPIGetEmailStatsRequest) Interval(interval string) EmailAPIGetEmailStatsRequest {
|
|
r.interval = &interval
|
|
return r
|
|
}
|
|
|
|
// Provider counts one rail only: ses or sendgrid.
|
|
func (r EmailAPIGetEmailStatsRequest) Provider(provider string) EmailAPIGetEmailStatsRequest {
|
|
r.provider = &provider
|
|
return r
|
|
}
|
|
|
|
// Campaign counts one campaign only.
|
|
func (r EmailAPIGetEmailStatsRequest) Campaign(campaign string) EmailAPIGetEmailStatsRequest {
|
|
r.campaign = &campaign
|
|
return r
|
|
}
|
|
|
|
func (r EmailAPIGetEmailStatsRequest) Execute() (*EmailStats, *http.Response, error) {
|
|
return r.ApiService.GetEmailStatsExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetEmailStats Counts the org's mail over a range: sent, delivered, opened, clicked, bounced, complained and unsubscribed, each a count of messages, in all, by provider, by campaign and by day or hour (UTC).
|
|
|
|
Counts the org's mail over a range: sent, delivered, opened, clicked,
|
|
bounced, complained and unsubscribed, each a count of messages, in all, by
|
|
provider, by campaign and by day or hour (UTC). Mail sent around this API, from
|
|
the org's own tools on its SES or SendGrid account, is counted from the
|
|
providers' events like mail sent through it.
|
|
|
|
GET /v1/email/stats
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return EmailAPIGetEmailStatsRequest
|
|
*/
|
|
func (a *EmailAPIService) GetEmailStats(ctx context.Context) EmailAPIGetEmailStatsRequest {
|
|
return EmailAPIGetEmailStatsRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return EmailStats
|
|
func (a *EmailAPIService) GetEmailStatsExecute(r EmailAPIGetEmailStatsRequest) (*EmailStats, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *EmailStats
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EmailAPIService.GetEmailStats")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/email/stats"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
if r.since != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "since", r.since, "form", "")
|
|
}
|
|
if r.until != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "until", r.until, "form", "")
|
|
}
|
|
if r.interval != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "interval", r.interval, "form", "")
|
|
}
|
|
if r.provider != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "provider", r.provider, "form", "")
|
|
}
|
|
if r.campaign != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "campaign", r.campaign, "form", "")
|
|
}
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type EmailAPIPostEmailRequest struct {
|
|
ctx context.Context
|
|
ApiService *EmailAPIService
|
|
emailSendMessageInput *EmailSendMessageInput
|
|
idempotencyKey *string
|
|
}
|
|
|
|
func (r EmailAPIPostEmailRequest) EmailSendMessageInput(emailSendMessageInput EmailSendMessageInput) EmailAPIPostEmailRequest {
|
|
r.emailSendMessageInput = &emailSendMessageInput
|
|
return r
|
|
}
|
|
|
|
// IdempotencyKey names the send, so a retried request sends each recipient's message once: the same key and recipient name the same message.
|
|
func (r EmailAPIPostEmailRequest) IdempotencyKey(idempotencyKey string) EmailAPIPostEmailRequest {
|
|
r.idempotencyKey = &idempotencyKey
|
|
return r
|
|
}
|
|
|
|
func (r EmailAPIPostEmailRequest) Execute() (*EmailDispatch, *http.Response, error) {
|
|
return r.ApiService.PostEmailExecute(r)
|
|
}
|
|
|
|
/*
|
|
PostEmail Sends commercial email from the org through SES or SendGrid: one message per recipient, each carrying its own signed unsubscribe link in the footer and in List-Unsubscribe and List-Unsubscribe-Post (RFC 8058), and every http(s) link tagged with utm_source=email, utm_medium=<provider>, utm_campaign=<campaign>, utm_content=link<n> and from=<message id>, each only where the link does not carry it already.
|
|
|
|
Sends commercial email from the org through SES or SendGrid: one
|
|
message per recipient, each carrying its own signed unsubscribe link in the
|
|
footer and in List-Unsubscribe and List-Unsubscribe-Post (RFC 8058), and every
|
|
http(s) link tagged with utm_source=email, utm_medium=<provider>,
|
|
utm_campaign=<campaign>, utm_content=link<n> and from=<message id>, each only
|
|
where the link does not carry it already. Every recipient is first asked of the
|
|
one suppression check (marketing_clearance): an address the org's list holds,
|
|
whose company unsubscribed, or that the platform blocks is not sent to, and is
|
|
answered in refused with status 422 and the reason; when every recipient is
|
|
refused the request is 422. A list that cannot answer sends nothing (503).
|
|
|
|
The rail is the provider the request pins (ses or sendgrid), else the org's
|
|
default (PUT /v1/email/provider), else SES, else SendGrid, whichever the org
|
|
holds credentials for; anything else is 400. Every message is kept in the org's
|
|
ledger (GET /v1/email), counted (GET /v1/email/stats), stated on the event
|
|
stream as email_sent, and put on the CRM record of the person the org holds for
|
|
the address. The same idempotency key and recipient send once. Transactional
|
|
mail (a code, a receipt) is not this route's: it goes by /v1/notify, which no
|
|
opt-out stops.
|
|
|
|
POST /v1/email
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return EmailAPIPostEmailRequest
|
|
*/
|
|
func (a *EmailAPIService) PostEmail(ctx context.Context) EmailAPIPostEmailRequest {
|
|
return EmailAPIPostEmailRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return EmailDispatch
|
|
func (a *EmailAPIService) PostEmailExecute(r EmailAPIPostEmailRequest) (*EmailDispatch, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPost
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *EmailDispatch
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EmailAPIService.PostEmail")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/email"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.emailSendMessageInput == nil {
|
|
return localVarReturnValue, nil, reportError("emailSendMessageInput is required and must be specified")
|
|
}
|
|
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{"application/json"}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
if r.idempotencyKey != nil {
|
|
parameterAddToHeaderOrQuery(localVarHeaderParams, "Idempotency-Key", r.idempotencyKey, "simple", "")
|
|
}
|
|
// body params
|
|
localVarPostBody = r.emailSendMessageInput
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type EmailAPIPostEmailVerifyRequest struct {
|
|
ctx context.Context
|
|
ApiService *EmailAPIService
|
|
emailVerificationInput *EmailVerificationInput
|
|
}
|
|
|
|
func (r EmailAPIPostEmailVerifyRequest) EmailVerificationInput(emailVerificationInput EmailVerificationInput) EmailAPIPostEmailVerifyRequest {
|
|
r.emailVerificationInput = &emailVerificationInput
|
|
return r
|
|
}
|
|
|
|
func (r EmailAPIPostEmailVerifyRequest) Execute() (*EmailVerificationResult, *http.Response, error) {
|
|
return r.ApiService.PostEmailVerifyExecute(r)
|
|
}
|
|
|
|
/*
|
|
PostEmailVerify Evaluates an email address using explicitly selected, composable checks.
|
|
|
|
Evaluates an email address using explicitly selected, composable checks.
|
|
|
|
A signed-in caller only: the SMTP check connects to the address's mail server
|
|
from ours, so an anonymous caller could probe mailboxes and get our addresses
|
|
blocked. Each caller may run 120 checks an hour and 20 of them SMTP probes, and
|
|
the deployment 6,000 and 400; past either is 429.
|
|
|
|
POST /v1/email/verify
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return EmailAPIPostEmailVerifyRequest
|
|
*/
|
|
func (a *EmailAPIService) PostEmailVerify(ctx context.Context) EmailAPIPostEmailVerifyRequest {
|
|
return EmailAPIPostEmailVerifyRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return EmailVerificationResult
|
|
func (a *EmailAPIService) PostEmailVerifyExecute(r EmailAPIPostEmailVerifyRequest) (*EmailVerificationResult, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPost
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *EmailVerificationResult
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EmailAPIService.PostEmailVerify")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/email/verify"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.emailVerificationInput == nil {
|
|
return localVarReturnValue, nil, reportError("emailVerificationInput is required and must be specified")
|
|
}
|
|
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{"application/json"}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
// body params
|
|
localVarPostBody = r.emailVerificationInput
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|
|
|
|
type EmailAPIPostEmailWebhooksSendgridRequest struct {
|
|
ctx context.Context
|
|
ApiService *EmailAPIService
|
|
}
|
|
|
|
func (r EmailAPIPostEmailWebhooksSendgridRequest) Execute() (*http.Response, error) {
|
|
return r.ApiService.PostEmailWebhooksSendgridExecute(r)
|
|
}
|
|
|
|
/*
|
|
PostEmailWebhooksSendgrid Receives SendGrid's Signed Event Webhook: the delivery is an array of events, signed (ECDSA P-256, SHA-256) over its timestamp header followed by the body, under the public key the organization holds (the webhook-public-key credential).
|
|
|
|
Receives SendGrid's Signed Event Webhook: the delivery is an
|
|
array of events, signed (ECDSA P-256, SHA-256) over its timestamp header
|
|
followed by the body, under the public key the organization holds
|
|
(the webhook-public-key credential). A delivery signed more than ten minutes
|
|
from now is refused, so a captured one cannot be replayed.
|
|
|
|
POST /v1/email/webhooks/sendgrid?org=<org>
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return EmailAPIPostEmailWebhooksSendgridRequest
|
|
*/
|
|
func (a *EmailAPIService) PostEmailWebhooksSendgrid(ctx context.Context) EmailAPIPostEmailWebhooksSendgridRequest {
|
|
return EmailAPIPostEmailWebhooksSendgridRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *EmailAPIService) PostEmailWebhooksSendgridExecute(r EmailAPIPostEmailWebhooksSendgridRequest) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPost
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EmailAPIService.PostEmailWebhooksSendgrid")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/email/webhooks/sendgrid"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarHTTPResponse, nil
|
|
}
|
|
|
|
type EmailAPIPostEmailWebhooksSesRequest struct {
|
|
ctx context.Context
|
|
ApiService *EmailAPIService
|
|
}
|
|
|
|
func (r EmailAPIPostEmailWebhooksSesRequest) Execute() (*http.Response, error) {
|
|
return r.ApiService.PostEmailWebhooksSesExecute(r)
|
|
}
|
|
|
|
/*
|
|
PostEmailWebhooksSes Receives Amazon SES events as an SNS HTTPS subscription delivers them.
|
|
|
|
Receives Amazon SES events as an SNS HTTPS subscription delivers
|
|
them. The organization is named in the address (?org=) and holds the SNS topic
|
|
its events arrive on (the sns-topic-arn credential): a message is accepted when
|
|
it is signed by SNS, is from that topic, and its certificate comes from that
|
|
topic's region. A subscription confirmation is completed the same way and
|
|
records nothing.
|
|
|
|
POST /v1/email/webhooks/ses?org=<org>
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return EmailAPIPostEmailWebhooksSesRequest
|
|
*/
|
|
func (a *EmailAPIService) PostEmailWebhooksSes(ctx context.Context) EmailAPIPostEmailWebhooksSesRequest {
|
|
return EmailAPIPostEmailWebhooksSesRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
func (a *EmailAPIService) PostEmailWebhooksSesExecute(r EmailAPIPostEmailWebhooksSesRequest) (*http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPost
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EmailAPIService.PostEmailWebhooksSes")
|
|
if err != nil {
|
|
return nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/email/webhooks/ses"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
return localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarHTTPResponse, nil
|
|
}
|
|
|
|
type EmailAPIPutEmailProviderRequest struct {
|
|
ctx context.Context
|
|
ApiService *EmailAPIService
|
|
emailChoice *EmailChoice
|
|
}
|
|
|
|
func (r EmailAPIPutEmailProviderRequest) EmailChoice(emailChoice EmailChoice) EmailAPIPutEmailProviderRequest {
|
|
r.emailChoice = &emailChoice
|
|
return r
|
|
}
|
|
|
|
func (r EmailAPIPutEmailProviderRequest) Execute() (*EmailChoice, *http.Response, error) {
|
|
return r.ApiService.PutEmailProviderExecute(r)
|
|
}
|
|
|
|
/*
|
|
PutEmailProvider Sets the provider the org's mail leaves by when a send pins none: ses or sendgrid.
|
|
|
|
Sets the provider the org's mail leaves by when a send pins none:
|
|
ses or sendgrid. With none set it is SES, else SendGrid, whichever the org holds
|
|
credentials for; a send that pins one goes by it. Org admin only, and on the
|
|
audit trail (email.provider.set) before it takes effect.
|
|
|
|
PUT /v1/email/provider
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return EmailAPIPutEmailProviderRequest
|
|
*/
|
|
func (a *EmailAPIService) PutEmailProvider(ctx context.Context) EmailAPIPutEmailProviderRequest {
|
|
return EmailAPIPutEmailProviderRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return EmailChoice
|
|
func (a *EmailAPIService) PutEmailProviderExecute(r EmailAPIPutEmailProviderRequest) (*EmailChoice, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodPut
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *EmailChoice
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "EmailAPIService.PutEmailProvider")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/email/provider"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
if r.emailChoice == nil {
|
|
return localVarReturnValue, nil, reportError("emailChoice is required and must be specified")
|
|
}
|
|
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{"application/json"}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
// body params
|
|
localVarPostBody = r.emailChoice
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|