frontend

package
v0.0.0-...-e2bdc13 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const Version = "1.3.0"

Version identifies the current library version. Should match the git tag

Variables

View Source
var ErrNotFound = errors.New("resource not found")

Functions

func GetUserAgent

func GetUserAgent() string

Types

type Client

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

func NewClient

func NewClient(cfg *ClientConfig) (*Client, error)

NewClient creates a new client based on the provided ClientConfig

func (*Client) Frontastic

func (c *Client) Frontastic() *FrontasticRequestBuilder

type ClientConfig

type ClientConfig struct {
	URL         string
	Credentials *clientcredentials.Config
	LogLevel    int
	HTTPClient  *http.Client
	UserAgent   string
}

type DataSourceConfiguration

type DataSourceConfiguration struct {
	DataSourceId  string      `json:"dataSourceId"`
	Type          string      `json:"type"`
	Name          string      `json:"name"`
	Configuration interface{} `json:"configuration"`
}

type DataSourceResponse

type DataSourceResponse struct {
	DataSourcePayload interface{} `json:"dataSourcePayload"`
	PreviewPayload    interface{} `json:"previewPayload"`
}

type DataSources

type DataSources map[string]interface{}

* * Object containing the data sources configured for the page folder and referenced in the page.

type Date

type Date struct {
	Year  int
	Month time.Month
	Day   int
}

Date holds date information for Commercetools API format

func NewDate

func NewDate(year int, month time.Month, day int) Date

NewDate initializes a Date struct

func (*Date) MarshalJSON

func (d *Date) MarshalJSON() ([]byte, error)

MarshalJSON marshals into the commercetools date format

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes JSON data into a Date struct

type DecodeStruct

type DecodeStruct interface {
	DecodeStruct(map[string]interface{}) error
}

type Environment

type Environment string
const (
	EnvironmentProduction  Environment = "production"
	EnvironmentDevelopment Environment = "development"
)

type Error

type Error struct {
	Ok      bool   `json:"ok"`
	Message string `json:"message"`
}

func (Error) Error

func (obj Error) Error() string
type Footer struct {
	LayoutElements []LayoutElement `json:"layoutElements"`
}

type FrontasticActionByNamespaceByActionRequestBuilder

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

func (*FrontasticActionByNamespaceByActionRequestBuilder) Get

* * Use the GET method to allow the frontend to fetch data from a backend system. For the response, we recommend to use standard HTTP codes and `application/json` encoded content. The response will be structured [as defined by the `body` property of the action](/../frontend-development/developing-an-action-extension#1-implement-the-action). The following response example contains information about a cart.

func (*FrontasticActionByNamespaceByActionRequestBuilder) Post

* * Use the POST method to write data to a backend system. Any JSON serializable payload is accepted. The following request example adds a product to a cart. For the response, we recommend to use standard HTTP codes and `application/json` encoded content. The response will be structured [as defined by the `body` property of the action](/../frontend-development/developing-an-action-extension#1-implement-the-action). The following response example contains the updated cart information, which includes the added product.

func (*FrontasticActionByNamespaceByActionRequestBuilder) Put

* * Use the PUT method to write data to a backend system. Any JSON serializable payload is accepted. The following request example adds a product to a cart. For the response, we recommend to use standard HTTP codes and `application/json` encoded content. The response will be structured [as defined by the `body` property of the action](/../frontend-development/developing-an-action-extension#1-implement-the-action). The following response example contains the updated cart information, which includes the added product.

type FrontasticActionByNamespaceByActionRequestMethodGet

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

func (*FrontasticActionByNamespaceByActionRequestMethodGet) Dump

func (*FrontasticActionByNamespaceByActionRequestMethodGet) Execute

func (rb *FrontasticActionByNamespaceByActionRequestMethodGet) Execute(ctx context.Context) (result *interface{}, err error)

* * Use the GET method to allow the frontend to fetch data from a backend system. For the response, we recommend to use standard HTTP codes and `application/json` encoded content. The response will be structured [as defined by the `body` property of the action](/../frontend-development/developing-an-action-extension#1-implement-the-action). The following response example contains information about a cart.

func (*FrontasticActionByNamespaceByActionRequestMethodGet) WithHeaders

type FrontasticActionByNamespaceByActionRequestMethodPost

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

func (*FrontasticActionByNamespaceByActionRequestMethodPost) Dump

func (*FrontasticActionByNamespaceByActionRequestMethodPost) Execute

func (rb *FrontasticActionByNamespaceByActionRequestMethodPost) Execute(ctx context.Context) (result *interface{}, err error)

* * Use the POST method to write data to a backend system. Any JSON serializable payload is accepted. The following request example adds a product to a cart. For the response, we recommend to use standard HTTP codes and `application/json` encoded content. The response will be structured [as defined by the `body` property of the action](/../frontend-development/developing-an-action-extension#1-implement-the-action). The following response example contains the updated cart information, which includes the added product.

func (*FrontasticActionByNamespaceByActionRequestMethodPost) WithHeaders

type FrontasticActionByNamespaceByActionRequestMethodPut

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

func (*FrontasticActionByNamespaceByActionRequestMethodPut) Dump

func (*FrontasticActionByNamespaceByActionRequestMethodPut) Execute

func (rb *FrontasticActionByNamespaceByActionRequestMethodPut) Execute(ctx context.Context) (result *interface{}, err error)

* * Use the PUT method to write data to a backend system. Any JSON serializable payload is accepted. The following request example adds a product to a cart. For the response, we recommend to use standard HTTP codes and `application/json` encoded content. The response will be structured [as defined by the `body` property of the action](/../frontend-development/developing-an-action-extension#1-implement-the-action). The following response example contains the updated cart information, which includes the added product.

func (*FrontasticActionByNamespaceByActionRequestMethodPut) WithHeaders

type FrontasticActionRequestBuilder

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

func (*FrontasticActionRequestBuilder) WithNamespaceValueWithActionValue

func (rb *FrontasticActionRequestBuilder) WithNamespaceValueWithActionValue(namespace string, action string) *FrontasticActionByNamespaceByActionRequestBuilder

type FrontasticContextRequestBuilder

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

func (*FrontasticContextRequestBuilder) Get

* * Returns information about the project locales setup and the environment in which the requested host acts in. \ * * Headers: * * - `Accept` - `application/json` - Required *

type FrontasticContextRequestMethodGet

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

func (*FrontasticContextRequestMethodGet) Dump

func (r *FrontasticContextRequestMethodGet) Dump() map[string]interface{}

func (*FrontasticContextRequestMethodGet) Execute

func (rb *FrontasticContextRequestMethodGet) Execute(ctx context.Context) (result *ProjectContext, err error)

* * Returns information about the project locales setup and the environment in which the requested host acts in. \ * * Headers: * * - `Accept` - `application/json` - Required *

func (*FrontasticContextRequestMethodGet) WithHeaders

type FrontasticDataSourceByIdentifierRequestBuilder

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

func (*FrontasticDataSourceByIdentifierRequestBuilder) Get

* * Returns data and preview from the data source.

type FrontasticDataSourceByIdentifierRequestMethodGet

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

func (*FrontasticDataSourceByIdentifierRequestMethodGet) Dump

func (r *FrontasticDataSourceByIdentifierRequestMethodGet) Dump() map[string]interface{}

func (*FrontasticDataSourceByIdentifierRequestMethodGet) Execute

* * Returns data and preview from the data source.

func (*FrontasticDataSourceByIdentifierRequestMethodGet) WithHeaders

type FrontasticDataSourceRequestBuilder

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

func (*FrontasticDataSourceRequestBuilder) WithIdentifierValue

type FrontasticPageRequestBuilder

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

func (*FrontasticPageRequestBuilder) Get

* * Returns the structure and data of the published page displayed from commercetools Frontend. \ * * Headers: * * - `Frontastic-Path` - `^/.*$` - Required * - `Accept` - `application/json` - Required * - `Frontastic-Locale` - [Locale](ctp:frontend-api:type:Locale) - Required *

type FrontasticPageRequestMethodGet

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

func (*FrontasticPageRequestMethodGet) Dump

func (r *FrontasticPageRequestMethodGet) Dump() map[string]interface{}

func (*FrontasticPageRequestMethodGet) Execute

func (rb *FrontasticPageRequestMethodGet) Execute(ctx context.Context) (result *PageDataResponse, err error)

* * Returns the structure and data of the published page displayed from commercetools Frontend. \ * * Headers: * * - `Frontastic-Path` - `^/.*$` - Required * - `Accept` - `application/json` - Required * - `Frontastic-Locale` - [Locale](ctp:frontend-api:type:Locale) - Required *

func (*FrontasticPageRequestMethodGet) WithHeaders

type FrontasticPreviewRequestBuilder

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

func (*FrontasticPreviewRequestBuilder) Get

* * Returns the page structure and data for a specific [preview](/../frontend-studio/previewing-page-versions#accessing-page-version-preview) by its `previewId`. \ * * Headers: * * - `Accept` - `application/json` - Required *

type FrontasticPreviewRequestMethodGet

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

func (*FrontasticPreviewRequestMethodGet) Dump

func (r *FrontasticPreviewRequestMethodGet) Dump() map[string]interface{}

func (*FrontasticPreviewRequestMethodGet) Execute

* * Returns the page structure and data for a specific [preview](/../frontend-studio/previewing-page-versions#accessing-page-version-preview) by its `previewId`. \ * * Headers: * * - `Accept` - `application/json` - Required *

func (*FrontasticPreviewRequestMethodGet) Locale

func (*FrontasticPreviewRequestMethodGet) PreviewId

func (*FrontasticPreviewRequestMethodGet) WithHeaders

func (*FrontasticPreviewRequestMethodGet) WithQueryParams

type FrontasticPreviewRequestMethodGetInput

type FrontasticPreviewRequestMethodGetInput struct {
	Locale    string
	PreviewId string
}

func (*FrontasticPreviewRequestMethodGetInput) Values

type FrontasticRequestBuilder

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

func (*FrontasticRequestBuilder) Action

func (*FrontasticRequestBuilder) Context

func (*FrontasticRequestBuilder) DataSource

func (*FrontasticRequestBuilder) Page

func (*FrontasticRequestBuilder) Preview

type GenericRequestError

type GenericRequestError struct {
	Content    []byte
	StatusCode int
	Response   *http.Response
}

func (GenericRequestError) Error

func (e GenericRequestError) Error() string
type Head struct {
	LayoutElements []LayoutElement `json:"layoutElements"`
}

type LayoutElement

type LayoutElement struct {
	LayoutElementId string                     `json:"layoutElementId"`
	Configuration   LayoutElementConfiguration `json:"configuration"`
	Tastics         []Tastic                   `json:"tastics"`
}

type LayoutElementConfiguration

type LayoutElementConfiguration struct {
	Size    float64 `json:"size"`
	Mobile  bool    `json:"mobile"`
	Tablet  bool    `json:"tablet"`
	Desktop bool    `json:"desktop"`
}

type Main

type Main struct {
	LayoutElements []LayoutElement `json:"layoutElements"`
}

type Page

type Page struct {
	PageId   string   `json:"pageId"`
	Sections Sections `json:"sections"`
	State    string   `json:"state"`
}

* * Page represents the structure and data of the published page displayed through commercetools Frontend. *

type PageDataResponse

type PageDataResponse struct {
	PageFolder PageFolder `json:"pageFolder"`
	// Page represents the structure and data of the published page displayed through commercetools Frontend.
	Page Page     `json:"page"`
	Data ViewData `json:"data"`
}

type PageFolder

type PageFolder struct {
	PageFolderId                string                    `json:"pageFolderId"`
	IsDynamic                   bool                      `json:"isDynamic"`
	PageFolderType              string                    `json:"pageFolderType"`
	Configuration               interface{}               `json:"configuration"`
	DataSourceConfigurations    []DataSourceConfiguration `json:"dataSourceConfigurations"`
	Name                        *string                   `json:"name,omitempty"`
	AncestorIdsMaterializedPath string                    `json:"ancestorIdsMaterializedPath"`
	Depth                       float64                   `json:"depth"`
	Sort                        float64                   `json:"sort"`
}

type PagePreviewContext

type PagePreviewContext struct {
	CustomerName string `json:"customerName"`
}

type PagePreviewDataResponse

type PagePreviewDataResponse struct {
	PageFolder PageFolder `json:"pageFolder"`
	// Page represents the structure and data of the published page displayed through commercetools Frontend.
	Page           Page               `json:"page"`
	Data           ViewData           `json:"data"`
	PreviewId      string             `json:"previewId"`
	PreviewContext PagePreviewContext `json:"previewContext"`
}

type PathConfiguration

type PathConfiguration struct {
	Path             string   `json:"path"`
	PathTranslations []string `json:"pathTranslations"`
}

type ProjectContext

type ProjectContext struct {
	// Indicates whether the project is intended as production or development environment.
	Environment Environment `json:"environment"`
	// Locales that can be used in the project.
	Locales []string `json:"locales"`
	// Locale used by default in the project.
	DefaultLocale string `json:"defaultLocale"`
}

type RedirectResponse

type RedirectResponse struct {
	StatusCode float64 `json:"statusCode"`
	Reason     string  `json:"reason"`
	TargetType string  `json:"targetType"`
	Target     string  `json:"target"`
}

type Sections

type Sections struct {
	Head   Head   `json:"head"`
	Main   Main   `json:"main"`
	Footer Footer `json:"footer"`
}

type SetUserAgentTransport

type SetUserAgentTransport struct {
	T http.RoundTripper
	// contains filtered or unexported fields
}

func (*SetUserAgentTransport) RoundTrip

func (sat *SetUserAgentTransport) RoundTrip(req *http.Request) (*http.Response, error)

type Tastic

type Tastic struct {
	TasticId      string              `json:"tasticId"`
	TasticType    string              `json:"tasticType"`
	Configuration TasticConfiguration `json:"configuration"`
}

type TasticConfiguration

type TasticConfiguration struct {
	Desktop bool `json:"desktop"`
	Mobile  bool `json:"mobile"`
	Tablet  bool `json:"tablet"`
}

type ViewData

type ViewData struct {
	// Data sources configured for the page folder and referenced in the page. They are indexed by data source identifier.
	DataSources DataSources `json:"dataSources"`
}

Jump to

Keyboard shortcuts

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