frontend

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const Version = "1.5.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 ApiBuildRequestBuilder added in v1.5.0

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

func (*ApiBuildRequestBuilder) Upload added in v1.5.0

type ApiBuildUploadRequestBuilder added in v1.5.0

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

func (*ApiBuildUploadRequestBuilder) Post added in v1.5.0

* * Uploads your backend builds from your custom CI environment to the Studio.

type ApiBuildUploadRequestMethodPost added in v1.5.0

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

func (*ApiBuildUploadRequestMethodPost) Dump added in v1.5.0

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

func (*ApiBuildUploadRequestMethodPost) Execute added in v1.5.0

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

* * Uploads your backend builds from your custom CI environment to the Studio.

func (*ApiBuildUploadRequestMethodPost) WithHeaders added in v1.5.0

type ApiRequestBuilder added in v1.5.0

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

func (*ApiRequestBuilder) Build added in v1.5.0

type BuildMetadata added in v1.5.0

type BuildMetadata struct {
	// Name of the Git branch to deploy.
	Branch string `json:"branch"`
	// Full commit ID hash of the current HEAD.
	Revision string `json:"revision"`
	// Current time represented in the format `YYYY.MM.DD.HH.mm`. This value should be unique and sortable.
	VersionNumber string `json:"versionNumber"`
	// Node.js version for the [Extension runner](/../frontend-getting-started/development-concepts#extension-runner).
	NodeJsVersion *int `json:"nodeJsVersion,omitempty"`
	// If `true`, the build is marked as successful and [displayed in the Studio](/../frontend-studio/using-deployment-in-the-studio).
	BuildSuccessful bool `json:"buildSuccessful"`
	// Date and time of the build in the [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339) format. For example, `2023-11-21T08:14:31.830Z`.
	BuildTime string `json:"buildTime"`
	// Build duration in seconds.
	BuildDuration int `json:"buildDuration"`
	// CI execution logs.
	BuildLog string `json:"buildLog"`
	// If `true`, the build is automatically deployed to the staging environment, if `buildSuccessful` is `true`.
	Deploy *bool `json:"deploy,omitempty"`
}

type BuildUpload added in v1.5.0

type BuildUpload struct {
	// Metadata about the build.
	Metadata BuildMetadata `json:"metadata"`
	// Javascript bundle containing all code of the backend extensions.
	Extension io.Reader `json:"extension"`
	// Map for the build file. When provided, exceptions will be logged with readable stack traces.
	ExtensionMap *io.Reader `json:"extension_map,omitempty"`
}

type BuildUploadResult added in v1.5.0

type BuildUploadResult struct {
	// Status of the build.
	Status string `json:"status"`
	// Description of the upload result.
	Message string `json:"message"`
}

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) Api added in v1.5.0

func (c *Client) Api() *ApiRequestBuilder

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/using-the-page-builder) 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/using-the-page-builder) 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