contentchef

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 27, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	BaseURL    *url.URL
	SpaceID    string
	TargetDate time.Time
	// contains filtered or unexported fields
}

Client manages the communication with the ContenChef API.

func NewClient

func NewClient(o *ClientOptions) (*Client, error)

NewClient return a new Client reference

It takes a ClientOptions reference.

func (*Client) GetOnlineChannel

func (c *Client) GetOnlineChannel(name, apiKey string) (*OnlineChannel, error)

GetOnlineChannel returns an OnlineChannel instance.

It takes the name and the apiKey used to communicate with online channels, both fields must not be an empty string.

func (*Client) GetPreviewChannel

func (c *Client) GetPreviewChannel(name, apiKey, state string) (*PreviewChannel, error)

GetPreviewChannel retruns a preview channel reference It will retrieve for contents that are not visible in the current date.

It takes the name and the apiKey used to communicate with preview channels, and the publishing status of the content you want to retrieve.

type ClientOptions

type ClientOptions struct {
	// The base URL of your Content Chef instance REQUIRED
	BaseURL string
	// Your Content Chef SpaceID REQUIRED
	SpaceID string
	// If you don't want to use the default HTTP client you can set a custom one
	Client *http.Client
	// TargetDate is used to retrieve contents in the preview channel in a specific dare different from the current date
	TargetDate time.Time
}

ClientOptions is the configuration object passed to the Client constructor

type ContentOptions

type ContentOptions struct {
	LegacyMetadata bool `url:"legacyMetadata,omitempty"`
	// The publicId of the content you want to retrieve
	PublicID string `url:"publicId"`
}

ContentOptions specifies the parameters to the Channel's Content method.

type Metadata

type Metadata struct {
	ID                      int       `json:"id"`
	AuthoringContentID      int       `json:"authoringContentId"`
	ContentVersion          int       `json:"contentVersion"`
	ContentLastModifiedDate time.Time `json:"contentLastModifiedDate"`
	Tags                    []string  `json:"tags"`
	PublishedOn             time.Time `json:"publishedOn"`
}

type OnlineChannel

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

OnlineChannel retrieves contents that are in live status

func (*OnlineChannel) Content

func (s *OnlineChannel) Content(ctx context.Context, config *ContentOptions) (*Response, error)

Content returns a Response reference. It will retrieve for a single content using the content's publicID and returns a Content reference.

It takes a context and a a reference to a ContentOptions struct if you are not sure about the context to use, use context.TODO()

func (*OnlineChannel) Search

func (s *OnlineChannel) Search(ctx context.Context, config *SearchOptions) (*PaginatedResponse, error)

Search returns a PaginatedResponse reference. It will retrieve for a range of contents using multiple matching criteria like content definition name, publishing dates and more.

It takes a context and a a reference to a SearchOptions struct if you are not sure about the context to use, use context.TODO()

type PaginatedResponse

type PaginatedResponse struct {
	Items          []Response     `json:"items"`
	Total          int            `json:"total"`
	Skip           int            `json:"skip"`
	Take           int            `json:"take"`
	RequestContext RequestContext `json:"requestContext"`
}

type PreviewChannel

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

PreviewChannel retrieves the contents that are in both in live stage and live state and event contents

func (*PreviewChannel) Content

func (s *PreviewChannel) Content(ctx context.Context, config *ContentOptions) (*Response, error)

Content returns a Response reference. It will retrieve for a single content using the content's publicID and returns a Content reference.

It takes a context and a a reference to a ContentOptions struct if you are not sure about the context to use, use context.TODO()

func (*PreviewChannel) Search

func (s *PreviewChannel) Search(ctx context.Context, config *SearchOptions) (*PaginatedResponse, error)

Search returns a PaginatedResponse reference. It will retrieve for a range of contents using multiple matching criteria like content definition name, publishing dates and more.

It takes a context and a a reference to a SearchOptions struct if you are not sure about the context to use, use context.TODO()

type PropFilterItem

type PropFilterItem struct {
	Field string `json:"field,omitempty"`
	// The operator you want to apply.
	// Possible values:
	// CONTAINS, CONTAINS_IC, EQUALS, EQUALS_IC, IN, IN_IC, STARTS_WITH, STARTS_WITH_IC
	Operator string      `json:"operator,omitempty"`
	Value    interface{} `json:"value,omitempty"`
}

type PropFilters

type PropFilters struct {
	// The logical operator you want to apply.
	// Possible values:
	// AND, OR
	Condition string           `json:"condition,omitempty"`
	Items     []PropFilterItem `json:"items,omitempty"`
}

func (PropFilters) EncodeValues

func (p PropFilters) EncodeValues(key string, v *url.Values) error

type RequestContext

type RequestContext struct {
	PublishingChannel string    `json:"publishingChannel"`
	CloudName         string    `json:"cloudName"`
	Timestamp         time.Time `json:"timestamp"`
}

type Response

type Response struct {
	PublicID       string         `json:"publicId"`
	Definition     string         `json:"definition"`
	Repository     string         `json:"repository"`
	Payload        interface{}    `json:"payload"`
	OnlineDate     time.Time      `json:"onlineDate"`
	OfflineDate    time.Time      `json:"offlineDate"`
	Metadata       Metadata       `json:"metadata"`
	RequestContext RequestContext `json:"requestContext"`
}

Response response represents a ContentChef content.

type SearchOptions

type SearchOptions struct {
	// The offset you want to have in the search result.
	Skip int `url:"skip"`
	// The number of contents you want to retrieve
	Take int `url:"take"`
	// A slice containing the publicIds of the content you want to retrieve
	PublicID []string `url:"publicId,omitempty"`
	// A slice containing the definitions of the content you want to retrieve
	ContentDefinition []string `url:"contentDefinition,omitempty"`
	Repositories      []string `url:"repositories,omitempty"`
	LegacyMetadata    bool     `url:"legacyMetadata,omitempty"`
	// A slice containing the tags of the content you want to retrieve
	Tags []string `url:"tags,omitempty"`
	// Properties filters you want to apply
	PropFilters PropFilters `url:"propFilters,omitempty"`
	// How you want to sort your content
	Sorting Sorting `url:"sorting,omitempty"`
}

SearchOptions specifies the parameters to the Channel's and Online Channel's Search method.

type Sorting

type Sorting []SortingField

func (Sorting) EncodeValues

func (s Sorting) EncodeValues(key string, v *url.Values) error

type SortingField

type SortingField struct {
	FieldName string `url:"fieldName"`
	Ascending bool   `url:"ascending"`
}

Jump to

Keyboard shortcuts

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