openapi

package
v4.0.0-rc.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2024 License: MIT Imports: 6 Imported by: 0

README

Go API client for

The Twilio SendGrid Marketing Campaigns Segments V2 API allows you to create, edit, and delete segments as well as retrieve a list of segments or an individual segment by ID.

Segments are similar to contact lists, except they update dynamically over time as information stored about your contacts or the criteria used to define your segments changes. When you segment your audience, you are able to create personalized Automation emails and Single Sends that directly address the wants and needs of your particular audience.

Note that Twilio SendGrid checks for newly added or modified contacts who meet a segment's criteria on an hourly schedule. Only existing contacts who meet a segment's criteria will be included in the segment searches within 15 minutes.

Segments built using engagement data such as "was sent" or "clicked" will take approximately 30 minutes to begin populating.

Segment samples and counts are refreshed approximately once per hour; they do not update immediately. If no contacts are added to or removed from a segment since the last refresh, the sample and UI count displayed will be refreshed at increasing time intervals with a maximum sample and count refresh delay of 24 hours.

You can also manage your Segments with the Marketing Campaigns application user interface. See Segmenting Your Contacts for more information.

Overview

This API client was generated by the OpenAPI Generator project from the OpenAPI specs located at twilio/sendgrid-oai. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version: 1.0.0
  • Package version:
  • Build date: 2024-10-24T13:26:01.613406Z[Etc/UTC]
  • Build package: com.sendgrid.oai.go.SendgridGoGenerator For more information, please visit https://support.sendgrid.com/hc/en-us

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 "./"

Documentation for API Endpoints

All URIs are relative to https://api.sendgrid.com

Class Method HTTP request Description
CreateSegment CreateSegment Post /v3/marketing/segments/2.0 Create Segment
DeleteSegment DeleteSegment Delete /v3/marketing/segments/2.0/{SegmentId} Delete segment
GetSegment GetSegment Get /v3/marketing/segments/2.0/{SegmentId} Get Segment by ID
ListSegment ListSegment Get /v3/marketing/segments/2.0 Get List of Segments
RefreshSegment RefreshSegment Post /v3/marketing/segments/2.0/refresh/{SegmentId} Manually refresh a segment
UpdateSegment UpdateSegment Patch /v3/marketing/segments/2.0/{SegmentId} Update Segment

Documentation For Models

Documentation For Authorization

BearerAuth

  • Type: HTTP basic authentication

Example

auth := context.WithValue(context.Background(), sw.ContextBasicAuth, sw.BasicAuth{
    UserName: "username",
    Password: "password",
})
r, err := client.Service.Operation(auth, args)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllSegments200

type AllSegments200 struct {
	// ID assigned to the segment when created.
	Id string `json:"id"`
	// Name of the segment.
	Name string `json:"name"`
	// Total number of contacts present in the segment
	ContactsCount int32 `json:"contacts_count"`
	// ISO8601 timestamp of when the object was created
	CreatedAt string `json:"created_at"`
	// ISO8601 timestamp of when the object was last updated
	UpdatedAt string `json:"updated_at"`
	// ISO8601 timestamp of when the samples were last updated
	SampleUpdatedAt string `json:"sample_updated_at"`
	// ISO8601 timestamp of when the samples will be next updated
	NextSampleUpdate string `json:"next_sample_update"`
	// The array of list ids to filter contacts on when building this segment. It allows only one such list id for now. We will support more in future
	ParentListIds []string `json:"parent_list_ids"`
	// If not set, segment contains a query for use with Segment v1 APIs. If set to '2', segment contains a SQL query for use in v2.
	QueryVersion string                `json:"query_version"`
	Metadata     *Metadata             `json:"_metadata,omitempty"`
	Status       SegmentStatusResponse `json:"status"`
}

AllSegments200 struct for AllSegments200

type ApiService

type ApiService struct {
	// contains filtered or unexported fields
}

func NewApiService

func NewApiService(requestHandler *sendgrid.RequestHandler) *ApiService

func NewApiServiceWithClient

func NewApiServiceWithClient(client sendgrid.BaseClient) *ApiService

func (*ApiService) CreateSegment

func (c *ApiService) CreateSegment(params *CreateSegmentParam) (interface{}, error)

Segment `name` has to be unique. A user can not create a new segment with an existing segment name.

func (*ApiService) DeleteSegment

func (c *ApiService) DeleteSegment(params *DeleteSegmentParam) (interface{}, error)

**This endpoint allows you to delete a segment by ID.**

func (*ApiService) GetSegment

func (c *ApiService) GetSegment(params *GetSegmentParam) (interface{}, error)

Get Marketing Campaigns Segment by ID

func (*ApiService) ListSegment

func (c *ApiService) ListSegment(params *ListSegmentParam) (interface{}, error)

**This endpoint allows you to retrieve a list of segments.** The query param `parent_list_ids` is treated as a filter. Any match will be returned. Zero matches will return a response code of 200 with an empty `results` array. `parent_list_ids` | `no_parent_list_id` | `ids` | `result` -----------------:|:--------------------:|:-------------:|:-------------: empty | false | empty | all segments values list_ids | false | empty | segments filtered by list_ids values list_ids |true | empty | segments filtered by list_ids and segments with no parent list_ids empty empty | true | empty | segments with no parent list_ids anything | anything | ids | segments with matching segment ids |

func (*ApiService) RefreshSegment

func (c *ApiService) RefreshSegment(params *RefreshSegmentParam) (interface{}, error)

Manually refresh a segment by segment ID.

func (*ApiService) UpdateSegment

func (c *ApiService) UpdateSegment(params *UpdateSegmentParam) (interface{}, error)

Segment `name` has to be unique. A user can not create a new segment with an existing segment name.

type ContactResponse

type ContactResponse struct {
	// ID assigned to a contact when added to the system.
	Id string `json:"id"`
	// Email of the contact. This is a reserved field.
	Email *string `json:"email,omitempty"`
	// The contact's Phone Number ID. This must be a valid phone number.
	PhoneNumberId *string `json:"phone_number_id,omitempty"`
	// The contact's External ID.
	ExternalId *string `json:"external_id,omitempty"`
	// The contact's Anonymous ID.
	AnonymousId *string `json:"anonymous_id,omitempty"`
	// Alternate emails of the contact. This is a reserved field.
	AlternateEmails []string `json:"alternate_emails"`
	// First name of the contact. This is a reserved field.
	FirstName string `json:"first_name"`
	// Last name of the contact. This is a reserved field.
	LastName string `json:"last_name"`
	// First line of address of the contact. This is a reserved field.
	AddressLine1 string `json:"address_line_1"`
	// Second line of address of the contact. This is a reserved field.
	AddressLine2 string `json:"address_line_2"`
	// City associated with the contact. This is a reserved field.
	City string `json:"city"`
	// State associated with the contact. This is a reserved field.
	StateProvinceRegion string `json:"state_province_region"`
	// Zipcode associated with the address of the contact. This is a reserved field.
	PostalCode int32 `json:"postal_code"`
	// Country associated with the address of the contact. This is a reserved field.
	Country string `json:"country"`
	// IDs of all lists the contact is part of
	ListIds      *[]string                   `json:"list_ids,omitempty"`
	CustomFields ContactResponseCustomFields `json:"custom_fields"`
	// IDs of all segments the contact is part of
	SegmentIds *[]string `json:"segment_ids,omitempty"`
}

ContactResponse struct for ContactResponse

type ContactResponseCustomFields

type ContactResponseCustomFields struct {
	CustomFieldName1 *string `json:"custom_field_name1,omitempty"`
	CustomFieldName2 *string `json:"custom_field_name2,omitempty"`
}

ContactResponseCustomFields The user may choose to create up to 120 custom fields or none at all. This is not a reserved field.

type CreateSegmentParam

type CreateSegmentParam struct {
	//
	SegmentWriteV2 *SegmentWriteV2 `json:"SegmentWriteV2,omitempty"`
}

func (*CreateSegmentParam) SetSegmentWriteV2

func (params *CreateSegmentParam) SetSegmentWriteV2(SegmentWriteV2 SegmentWriteV2) *CreateSegmentParam

type DeleteSegmentParam

type DeleteSegmentParam struct {
	//
	SegmentId *string `json:"segment_id"`
}

func (*DeleteSegmentParam) SetSegmentId

func (params *DeleteSegmentParam) SetSegmentId(SegmentId string) *DeleteSegmentParam

type ErrorsSegmentV2

type ErrorsSegmentV2 struct {
	Errors []ErrorsSegmentV2ErrorsInner `json:"errors"`
}

ErrorsSegmentV2 If the request is incorrect, an array of errors will be returned.

type ErrorsSegmentV2ErrorsInner

type ErrorsSegmentV2ErrorsInner struct {
	// the field in the request body that is incorrect
	Field string `json:"field"`
	// a description of what is specifically wrong with the field passed in the request
	Message string `json:"message"`
}

ErrorsSegmentV2ErrorsInner struct for ErrorsSegmentV2ErrorsInner

type GetSegmentParam

type GetSegmentParam struct {
	//
	SegmentId *string `json:"segment_id"`
	// Defaults to `true`. Set to `false` to exclude the contacts_sample in the response.
	ContactsSample *bool `json:"contacts_sample,omitempty"`
}

func (*GetSegmentParam) SetContactsSample

func (params *GetSegmentParam) SetContactsSample(ContactsSample bool) *GetSegmentParam

func (*GetSegmentParam) SetSegmentId

func (params *GetSegmentParam) SetSegmentId(SegmentId string) *GetSegmentParam

type ListSegmentParam

type ListSegmentParam struct {
	// A list of segment IDs to retrieve. When this parameter is included, the `no_parent_list_ids` and `parent_list_ids` parameters are ignored and only segments with given IDs are returned.
	Ids *[]string `json:"ids,omitempty"`
	// A comma separated list up to 50 in size, to filter segments on.  Only segments that have any of these list ids as the parent list will be retrieved. This is different from the parameter of the same name used when creating a segment.
	ParentListIds *string `json:"parent_list_ids,omitempty"`
	// If set to `true`, segments with an empty value of `parent_list_id` will be returned in the filter.  If the value is not present, it defaults to 'false'.
	NoParentListId *bool `json:"no_parent_list_id,omitempty"`
}

func (*ListSegmentParam) SetIds

func (params *ListSegmentParam) SetIds(Ids []string) *ListSegmentParam

func (*ListSegmentParam) SetNoParentListId

func (params *ListSegmentParam) SetNoParentListId(NoParentListId bool) *ListSegmentParam

func (*ListSegmentParam) SetParentListIds

func (params *ListSegmentParam) SetParentListIds(ParentListIds string) *ListSegmentParam

type Metadata

type Metadata struct {
	Prev  *string `json:"prev,omitempty"`
	Self  *string `json:"self,omitempty"`
	Next  *string `json:"next,omitempty"`
	Count *int32  `json:"count,omitempty"`
}

Metadata struct for Metadata

type RefreshSegmentParam

type RefreshSegmentParam struct {
	//
	SegmentId *string `json:"segment_id"`
	//
	SegmentRefreshRequest *SegmentRefreshRequest `json:"SegmentRefreshRequest"`
}

func (*RefreshSegmentParam) SetSegmentId

func (params *RefreshSegmentParam) SetSegmentId(SegmentId string) *RefreshSegmentParam

func (*RefreshSegmentParam) SetSegmentRefreshRequest

func (params *RefreshSegmentParam) SetSegmentRefreshRequest(SegmentRefreshRequest SegmentRefreshRequest) *RefreshSegmentParam

type Segment2xx

type Segment2xx struct {
	// ID assigned to the segment when created.
	Id string `json:"id"`
	// Name of the segment.
	Name string `json:"name"`
	// SQL query which will filter contacts based on the conditions provided
	QueryDsl string `json:"query_dsl"`
	// Total number of contacts present in the segment
	ContactsCount int32 `json:"contacts_count"`
	// A subset of all contacts that are in this segment
	ContactsSample []ContactResponse `json:"contacts_sample"`
	// ISO8601 timestamp of when the object was created
	CreatedAt string `json:"created_at"`
	// ISO8601 timestamp of when the object was last updated
	UpdatedAt string `json:"updated_at"`
	// ISO8601 timestamp of when the samples were last updated
	SampleUpdatedAt string `json:"sample_updated_at"`
	// ISO8601 timestamp of when the samples will be next updated
	NextSampleUpdate string `json:"next_sample_update"`
	// The array of list ids to filter contacts on when building this segment. It allows only one such list id for now. We will support more in future
	ParentListIds []string `json:"parent_list_ids"`
	// If not set, segment contains a Query for use with Segment v1 APIs. If set to '2', segment contains a SQL query for use in v2.
	QueryVersion string                `json:"query_version"`
	Status       SegmentStatusResponse `json:"status"`
	// The number of times a segment has been manually refreshed since start of today in the user's timezone.
	RefreshesUsed *int32 `json:"refreshes_used,omitempty"`
	// The maximum number of manual refreshes allowed per day for this segment. Currently, only 2 are allowed.
	MaxRefreshes *int32 `json:"max_refreshes,omitempty"`
	// The ISO8601 timestamp when the segment was last refreshed in UTC time.
	LastRefreshedAt *string `json:"last_refreshed_at,omitempty"`
}

Segment2xx struct for Segment2xx

type SegmentError

type SegmentError struct {
	// A description of the error.
	Error string `json:"error"`
}

SegmentError struct for SegmentError

type SegmentRefresh202

type SegmentRefresh202 struct {
	// The ID of the manual refresh job. Used only for internal purposes.
	JobId *string `json:"job_id,omitempty"`
}

SegmentRefresh202 struct for SegmentRefresh202

type SegmentRefreshRequest

type SegmentRefreshRequest struct {
	// The user's timezone. The timezone is used to reset the refresh count at midnight in the user's local time. Only [IANA time zone format](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) is accepted.
	UserTimeZone string `json:"user_time_zone"`
}

SegmentRefreshRequest struct for SegmentRefreshRequest

type SegmentStatusResponse

type SegmentStatusResponse struct {
	// Status of query validation. PENDING, VALID, or INVALID
	QueryValidation string `json:"query_validation"`
	// Describes any errors that were encountered during query validation
	ErrorMessage *string `json:"error_message,omitempty"`
}

SegmentStatusResponse Segment status indicates whether the segment's contacts will be updated periodically

type SegmentUpdate

type SegmentUpdate struct {
	// Name of the segment.
	Name *string `json:"name,omitempty"`
	// SQL query which will filter contacts based on the conditions provided
	QueryDsl *string `json:"query_dsl,omitempty"`
}

SegmentUpdate struct for SegmentUpdate

type SegmentWriteV2

type SegmentWriteV2 struct {
	// Name of the segment.
	Name string `json:"name"`
	// The array of list ids to filter contacts on when building this segment. It allows only one such list id for now. We will support more in future
	ParentListIds *[]string `json:"parent_list_ids,omitempty"`
	// SQL query which will filter contacts based on the conditions provided
	QueryDsl string `json:"query_dsl"`
}

SegmentWriteV2 struct for SegmentWriteV2

type UpdateSegmentParam

type UpdateSegmentParam struct {
	//
	SegmentId *string `json:"segment_id"`
	//
	SegmentUpdate *SegmentUpdate `json:"SegmentUpdate,omitempty"`
}

func (*UpdateSegmentParam) SetSegmentId

func (params *UpdateSegmentParam) SetSegmentId(SegmentId string) *UpdateSegmentParam

func (*UpdateSegmentParam) SetSegmentUpdate

func (params *UpdateSegmentParam) SetSegmentUpdate(SegmentUpdate SegmentUpdate) *UpdateSegmentParam

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL