testapi

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Code generated by https://github.com/foomo/gocontentful - DO NOT EDIT.

Code generated by https://github.com/foomo/gocontentful - DO NOT EDIT.

Code generated by https://github.com/foomo/gocontentful - DO NOT EDIT.

Code generated by https://github.com/foomo/gocontentful - DO NOT EDIT.

Code generated by https://github.com/foomo/gocontentful - DO NOT EDIT.

Code generated by https://github.com/foomo/gocontentful - DO NOT EDIT.

gocontentful version: latest

Index

Constants

View Source
const (
	FieldTypeLink      string = "Link"
	FieldLinkTypeEntry string = "Entry"
	FieldLinkTypeAsset string = "Asset"

	HtmlHeading1        string = "h1"
	HtmlHeading2        string = "h2"
	HtmlHeading3        string = "h3"
	HtmlHeading4        string = "h4"
	HtmlHeading5        string = "h5"
	HtmlHeading6        string = "h6"
	HtmlParagraph       string = "p"
	HtmlItalic          string = "i"
	HtmlEm              string = "em"
	HtmlBold            string = "b"
	HtmlStrong          string = "strong"
	HtmlUnderline       string = "u"
	HtmlAnchor          string = "a"
	HtmlImage           string = "img"
	HtmlBlockquote      string = "blockquote"
	HtmlCode            string = "code"
	HtmlUnorderedList   string = "ul"
	HtmlOrderedList     string = "ol"
	HtmlListItem        string = "li"
	HtmlBreak           string = "br"
	HtmlHorizontalRule  string = "hr"
	HtmlAttributeHref   string = "href"
	HtmlTable           string = "table"
	HtmlTableRow        string = "tr"
	HtmlTableHeaderCell string = "th"
	HtmlTableCell       string = "td"

	RichTextNodeDocument        string = "document"
	RichTextNodeParagraph       string = "paragraph"
	RichTextNodeHeading1        string = "heading-1"
	RichTextNodeHeading2        string = "heading-2"
	RichTextNodeHeading3        string = "heading-3"
	RichTextNodeHeading4        string = "heading-4"
	RichTextNodeHeading5        string = "heading-5"
	RichTextNodeHeading6        string = "heading-6"
	RichTextNodeHyperlink       string = "hyperlink"
	RichTextNodeEntryHyperlink  string = "entry-hyperlink"
	RichTextNodeAssetHyperlink  string = "asset-hyperlink"
	RichTextNodeEmbeddedAsset   string = "embedded-asset-block"
	RichTextNodeEmbeddedEntry   string = "embedded-entry-block"
	RichTextNodeText            string = "text"
	RichTextNodeUnorderedList   string = "unordered-list"
	RichTextNodeOrderedList     string = "ordered-list"
	RichTextNodeListItem        string = "list-item"
	RichTextNodeBlockquote      string = "blockquote"
	RichTextNodeHR              string = "hr"
	RichTextNodeTable           string = "table"
	RichTextNodeTableRow        string = "table-row"
	RichTextNodeTableHeaderCell string = "table-header-cell"
	RichTextNodeTableCell       string = "table-cell"

	RichTextMarkBold      string = "bold"
	RichTextMarkItalic    string = "italic"
	RichTextMarkUnderline string = "underline"
	RichTextMarkCode      string = "code"
)
View Source
const (
	StatusDraft     = "draft"
	StatusChanged   = "changed"
	StatusPublished = "published"
)
View Source
const (
	LogDebug = 0
	LogInfo  = 1
	LogWarn  = 2
	LogError = 3
)
View Source
const ContentTypeBrand = "brand"
View Source
const ContentTypeCategory = "category"
View Source
const ContentTypeProduct = "product"

Variables

View Source
var (
	ErrLocaleUnsupported             = errors.New("locale not supported by this space")
	ErrNotSet                        = errors.New("field value not set")
	ErrNotSetNoFallback              = errors.New("field value not set and no fallback locale available")
	ErrRefNotIncludes                = errors.New("referenced entry not found in includes")
	ErrNoTypeOfRefEntry              = errors.New("couldn't get contentType of referenced entry")
	ErrNoTypeOfRefAsset              = errors.New("couldn't get contentType of referenced asset")
	InfoUpdatedEntityCache           = "updated cache for entity"
	InfoCachedAllEntries             = "cached all entries of content type"
	InfoCachedAllAssets              = "cached all assets"
	InfoFallingBackToFile            = "gonna use a local file"
	InfoLoadingFromFile              = "loading space from local file"
	InfoCacheIsNil                   = "contentful cache is nil"
	InfoCacheWorkerStart             = "contentful cache worker starting"
	InfoCacheUpdateQueued            = "contentful cache update queued"
	InfoCacheUpdateCanceled          = "contentful cache update canceled"
	InfoCacheUpdateDone              = "contentful cache update returning"
	InfoCacheUpdateSkipped           = "contentful cache update skipped, already one in the queue"
	InfoCacheSyncOp                  = "contentful cache sync op done"
	InfoOfflineEntitiesLoaded        = "downloaded entries and assets from offline file"
	InfoPreservingExistingCache      = "could not connect for cache update, preserving the existing cache"
	InfoUpdateCacheTime              = "space caching done, time recorded"
	ErrorEnvironmentSetToMaster      = "environment was empty string, set to master"
	ErrorEntryIsNil                  = "entry is nil"
	ErrorEntrySysIsNil               = "entry.Sys is nil"
	ErrorEntryNotFound               = "entry not found"
	ErrorEntrySysContentTypeIsNil    = "entry.Sys.ContentType is nil"
	ErrorEntrySysContentTypeSysIsNil = "entry.Sys.ContentType.Sys is nil"
	ErrorEntryCachingFailed          = "entry caching failed"
)
View Source
var SpaceContentTypeInfoMap = ContentTypeInfoMap{
	"brand": ContentTypeInfo{
		ContentType: "brand",
		Title:       "Brand",
		Description: "",
	},
	"category": ContentTypeInfo{
		ContentType: "category",
		Title:       "Category",
		Description: "",
	},
	"product": ContentTypeInfo{
		ContentType: "product",
		Title:       "Product",
		Description: "",
	},
}
View Source
var SpaceLocales = []Locale{
	"de",
	"fr",
}

Functions

func FieldToObject

func FieldToObject(jsonField interface{}, targetObject interface{}) error

func NewAssetFromURL

func NewAssetFromURL(id string, uploadUrl string, imageFileType string, title string, locale ...Locale) *contentful.Asset

func RichTextToHtml

func RichTextToHtml(rt interface{}, linkResolver LinkResolverFunc, entryLinkResolver EntryLinkResolverFunc, imageResolver ImageResolverFunc, embeddedEntryResolver EmbeddedEntryResolverFunc, locale Locale) (string, error)

func RichTextToPlainText added in v1.1.0

func RichTextToPlainText(rt interface{}, locale Locale) (string, error)

Types

type BrokenReference

type BrokenReference struct {
	ParentID   string `json:"parentId"`
	ParentType string `json:"parentType"`
	FromField  string `json:"fromField"`
	ChildID    string `json:"childId"`
}

type CacheStats

type CacheStats struct {
	AssetCount   int
	ContentTypes []string
	EntryCount   int
	ParentCount  int
}

type CfBrand

type CfBrand struct {
	Sys       ContentfulSys     `json:"sys,omitempty"`
	Fields    CfBrandFields     `json:"fields,omitempty"`
	RawFields RawFields         `json:"-"`
	CC        *ContentfulClient `json:"-"`
}

func NewCfBrand

func NewCfBrand(contentfulClient ...*ContentfulClient) (cfBrand *CfBrand)

func (*CfBrand) CompanyDescription

func (vo *CfBrand) CompanyDescription(locale ...Locale) string

func (*CfBrand) CompanyName

func (vo *CfBrand) CompanyName(locale ...Locale) string

func (*CfBrand) DeleteEntry

func (vo *CfBrand) DeleteEntry(ctx context.Context) (err error)

func (*CfBrand) Email

func (vo *CfBrand) Email(locale ...Locale) string

func (*CfBrand) GetParents

func (vo *CfBrand) GetParents(ctx context.Context, contentType ...string) (parents []EntryReference, err error)

func (*CfBrand) GetPublishingStatus

func (vo *CfBrand) GetPublishingStatus() string
func (vo *CfBrand) Logo(ctx context.Context, locale ...Locale) *contentful.AssetNoLocale

func (*CfBrand) Phone

func (vo *CfBrand) Phone(locale ...Locale) []string

func (*CfBrand) PublishEntry

func (vo *CfBrand) PublishEntry(ctx context.Context) (err error)

func (*CfBrand) SetCompanyDescription

func (vo *CfBrand) SetCompanyDescription(companyDescription string, locale ...Locale) (err error)

func (*CfBrand) SetCompanyName

func (vo *CfBrand) SetCompanyName(companyName string, locale ...Locale) (err error)

func (*CfBrand) SetEmail

func (vo *CfBrand) SetEmail(email string, locale ...Locale) (err error)
func (vo *CfBrand) SetLogo(logo ContentTypeSys, locale ...Locale) (err error)

func (*CfBrand) SetPhone

func (vo *CfBrand) SetPhone(phone []string, locale ...Locale) (err error)

func (*CfBrand) SetTwitter

func (vo *CfBrand) SetTwitter(twitter string, locale ...Locale) (err error)

func (*CfBrand) SetWebsite

func (vo *CfBrand) SetWebsite(website string, locale ...Locale) (err error)

func (*CfBrand) ToReference

func (vo *CfBrand) ToReference() (refSys ContentTypeSys)

func (*CfBrand) Twitter

func (vo *CfBrand) Twitter(locale ...Locale) string

func (*CfBrand) UnpublishEntry

func (vo *CfBrand) UnpublishEntry(ctx context.Context) (err error)

func (*CfBrand) UpdateEntry

func (vo *CfBrand) UpdateEntry(ctx context.Context) (err error)

func (*CfBrand) UpsertEntry

func (vo *CfBrand) UpsertEntry(ctx context.Context) (err error)

func (*CfBrand) Website

func (vo *CfBrand) Website(locale ...Locale) string

type CfBrandFields

type CfBrandFields struct {
	CompanyName              map[string]string         `json:"companyName,omitempty"`
	RWLockCompanyName        sync.RWMutex              `json:"-"`
	CompanyDescription       map[string]string         `json:"companyDescription,omitempty"`
	RWLockCompanyDescription sync.RWMutex              `json:"-"`
	Website                  map[string]string         `json:"website,omitempty"`
	RWLockWebsite            sync.RWMutex              `json:"-"`
	Twitter                  map[string]string         `json:"twitter,omitempty"`
	RWLockTwitter            sync.RWMutex              `json:"-"`
	Email                    map[string]string         `json:"email,omitempty"`
	RWLockEmail              sync.RWMutex              `json:"-"`
	Phone                    map[string][]string       `json:"phone,omitempty"`
	RWLockPhone              sync.RWMutex              `json:"-"`
}

CfBrandFields is a CfNameFields VO

type CfBrandFieldsLogo struct {
	Entry *contentful.Asset
	Col   *contentful.Collection
}

type CfCategory

type CfCategory struct {
	Sys       ContentfulSys     `json:"sys,omitempty"`
	Fields    CfCategoryFields  `json:"fields,omitempty"`
	RawFields RawFields         `json:"-"`
	CC        *ContentfulClient `json:"-"`
}

func NewCfCategory

func NewCfCategory(contentfulClient ...*ContentfulClient) (cfCategory *CfCategory)

func (*CfCategory) CategoryDescription

func (vo *CfCategory) CategoryDescription(locale ...Locale) string

func (*CfCategory) DeleteEntry

func (vo *CfCategory) DeleteEntry(ctx context.Context) (err error)

func (*CfCategory) GetParents

func (vo *CfCategory) GetParents(ctx context.Context, contentType ...string) (parents []EntryReference, err error)

func (*CfCategory) GetPublishingStatus

func (vo *CfCategory) GetPublishingStatus() string

func (*CfCategory) Icon

func (vo *CfCategory) Icon(ctx context.Context, locale ...Locale) *contentful.AssetNoLocale

func (*CfCategory) PublishEntry

func (vo *CfCategory) PublishEntry(ctx context.Context) (err error)

func (*CfCategory) SetCategoryDescription

func (vo *CfCategory) SetCategoryDescription(categoryDescription string, locale ...Locale) (err error)

func (*CfCategory) SetIcon

func (vo *CfCategory) SetIcon(icon ContentTypeSys, locale ...Locale) (err error)

func (*CfCategory) SetTitle

func (vo *CfCategory) SetTitle(title string, locale ...Locale) (err error)

func (*CfCategory) Title

func (vo *CfCategory) Title(locale ...Locale) string

func (*CfCategory) ToReference

func (vo *CfCategory) ToReference() (refSys ContentTypeSys)

func (*CfCategory) UnpublishEntry

func (vo *CfCategory) UnpublishEntry(ctx context.Context) (err error)

func (*CfCategory) UpdateEntry

func (vo *CfCategory) UpdateEntry(ctx context.Context) (err error)

func (*CfCategory) UpsertEntry

func (vo *CfCategory) UpsertEntry(ctx context.Context) (err error)

type CfCategoryFields

type CfCategoryFields struct {
	Title                     map[string]string         `json:"title,omitempty"`
	RWLockTitle               sync.RWMutex              `json:"-"`
	Icon                      map[string]ContentTypeSys `json:"icon,omitempty"`
	RWLockIcon                sync.RWMutex              `json:"-"`
	CategoryDescription       map[string]string         `json:"categoryDescription,omitempty"`
	RWLockCategoryDescription sync.RWMutex              `json:"-"`
}

CfCategoryFields is a CfNameFields VO

type CfCategoryFieldsIcon

type CfCategoryFieldsIcon struct {
	Entry *contentful.Asset
	Col   *contentful.Collection
}

type CfProduct

type CfProduct struct {
	Sys       ContentfulSys     `json:"sys,omitempty"`
	Fields    CfProductFields   `json:"fields,omitempty"`
	RawFields RawFields         `json:"-"`
	CC        *ContentfulClient `json:"-"`
}

func NewCfProduct

func NewCfProduct(contentfulClient ...*ContentfulClient) (cfProduct *CfProduct)

func (*CfProduct) Brand

func (vo *CfProduct) Brand(ctx context.Context, locale ...Locale) *EntryReference

func (*CfProduct) Categories

func (vo *CfProduct) Categories(ctx context.Context, locale ...Locale) []*EntryReference

func (*CfProduct) DeleteEntry

func (vo *CfProduct) DeleteEntry(ctx context.Context) (err error)

func (*CfProduct) GetParents

func (vo *CfProduct) GetParents(ctx context.Context, contentType ...string) (parents []EntryReference, err error)

func (*CfProduct) GetPublishingStatus

func (vo *CfProduct) GetPublishingStatus() string

func (*CfProduct) Image

func (vo *CfProduct) Image(ctx context.Context, locale ...Locale) []*contentful.AssetNoLocale

func (*CfProduct) Nodes added in v1.0.16

func (vo *CfProduct) Nodes(locale ...Locale) *interface{}

func (*CfProduct) Price

func (vo *CfProduct) Price(locale ...Locale) float64

func (*CfProduct) ProductDescription

func (vo *CfProduct) ProductDescription(locale ...Locale) string

func (*CfProduct) ProductName

func (vo *CfProduct) ProductName(locale ...Locale) string

func (*CfProduct) PublishEntry

func (vo *CfProduct) PublishEntry(ctx context.Context) (err error)

func (*CfProduct) Quantity

func (vo *CfProduct) Quantity(locale ...Locale) float64

func (*CfProduct) SeoText added in v1.0.16

func (vo *CfProduct) SeoText(locale ...Locale) *interface{}

func (*CfProduct) SetBrand

func (vo *CfProduct) SetBrand(brand ContentTypeSys, locale ...Locale) (err error)

func (*CfProduct) SetCategories

func (vo *CfProduct) SetCategories(categories []ContentTypeSys, locale ...Locale) (err error)

func (*CfProduct) SetImage

func (vo *CfProduct) SetImage(image []ContentTypeSys, locale ...Locale) (err error)

func (*CfProduct) SetNodes added in v1.0.16

func (vo *CfProduct) SetNodes(nodes interface{}, locale ...Locale) (err error)

func (*CfProduct) SetPrice

func (vo *CfProduct) SetPrice(price float64, locale ...Locale) (err error)

func (*CfProduct) SetProductDescription

func (vo *CfProduct) SetProductDescription(productDescription string, locale ...Locale) (err error)

func (*CfProduct) SetProductName

func (vo *CfProduct) SetProductName(productName string, locale ...Locale) (err error)

func (*CfProduct) SetQuantity

func (vo *CfProduct) SetQuantity(quantity float64, locale ...Locale) (err error)

func (*CfProduct) SetSeoText added in v1.0.16

func (vo *CfProduct) SetSeoText(seoText interface{}, locale ...Locale) (err error)

func (*CfProduct) SetSizetypecolor

func (vo *CfProduct) SetSizetypecolor(sizetypecolor string, locale ...Locale) (err error)

func (*CfProduct) SetSku

func (vo *CfProduct) SetSku(sku string, locale ...Locale) (err error)

func (*CfProduct) SetSlug

func (vo *CfProduct) SetSlug(slug string, locale ...Locale) (err error)

func (*CfProduct) SetSubProduct added in v1.1.0

func (vo *CfProduct) SetSubProduct(subProduct ContentTypeSys, locale ...Locale) (err error)

func (*CfProduct) SetTags

func (vo *CfProduct) SetTags(tags []string, locale ...Locale) (err error)

func (*CfProduct) SetWebsite

func (vo *CfProduct) SetWebsite(website string, locale ...Locale) (err error)

func (*CfProduct) Sizetypecolor

func (vo *CfProduct) Sizetypecolor(locale ...Locale) string

func (*CfProduct) Sku

func (vo *CfProduct) Sku(locale ...Locale) string

func (*CfProduct) Slug

func (vo *CfProduct) Slug(locale ...Locale) string

func (*CfProduct) SubProduct added in v1.1.0

func (vo *CfProduct) SubProduct(ctx context.Context, locale ...Locale) *EntryReference

func (*CfProduct) Tags

func (vo *CfProduct) Tags(locale ...Locale) []string

func (*CfProduct) ToReference

func (vo *CfProduct) ToReference() (refSys ContentTypeSys)

func (*CfProduct) UnpublishEntry

func (vo *CfProduct) UnpublishEntry(ctx context.Context) (err error)

func (*CfProduct) UpdateEntry

func (vo *CfProduct) UpdateEntry(ctx context.Context) (err error)

func (*CfProduct) UpsertEntry

func (vo *CfProduct) UpsertEntry(ctx context.Context) (err error)

func (*CfProduct) Website

func (vo *CfProduct) Website(locale ...Locale) string

type CfProductFields

type CfProductFields struct {
	ProductName              map[string]string           `json:"productName,omitempty"`
	RWLockProductName        sync.RWMutex                `json:"-"`
	Slug                     map[string]string           `json:"slug,omitempty"`
	RWLockSlug               sync.RWMutex                `json:"-"`
	ProductDescription       map[string]string           `json:"productDescription,omitempty"`
	RWLockProductDescription sync.RWMutex                `json:"-"`
	Sizetypecolor            map[string]string           `json:"sizetypecolor,omitempty"`
	RWLockSizetypecolor      sync.RWMutex                `json:"-"`
	Image                    map[string][]ContentTypeSys `json:"image,omitempty"`
	RWLockImage              sync.RWMutex                `json:"-"`
	Tags                     map[string][]string         `json:"tags,omitempty"`
	RWLockTags               sync.RWMutex                `json:"-"`
	Categories               map[string][]ContentTypeSys `json:"categories,omitempty"`
	RWLockCategories         sync.RWMutex                `json:"-"`
	Price                    map[string]float64          `json:"price,omitempty"`
	RWLockPrice              sync.RWMutex                `json:"-"`
	Brand                    map[string]ContentTypeSys   `json:"brand,omitempty"`
	RWLockBrand              sync.RWMutex                `json:"-"`
	SubProduct               map[string]ContentTypeSys   `json:"subProduct,omitempty"`
	RWLockSubProduct         sync.RWMutex                `json:"-"`
	Quantity                 map[string]float64          `json:"quantity,omitempty"`
	RWLockQuantity           sync.RWMutex                `json:"-"`
	Sku                      map[string]string           `json:"sku,omitempty"`
	RWLockSku                sync.RWMutex                `json:"-"`
	Website                  map[string]string           `json:"website,omitempty"`
	RWLockWebsite            sync.RWMutex                `json:"-"`
	SeoText                  map[string]interface{}      `json:"seoText,omitempty"`
	RWLockSeoText            sync.RWMutex                `json:"-"`
	Nodes                    map[string]interface{}      `json:"nodes,omitempty"`
	RWLockNodes              sync.RWMutex                `json:"-"`
}

CfProductFields is a CfNameFields VO

type ClientMode

type ClientMode string
const (
	ClientModeCDA ClientMode = "CDA"
	ClientModeCPA ClientMode = "CPA"
	ClientModeCMA ClientMode = "CMA"
)

type ContentTypeFieldLocation

type ContentTypeFieldLocation struct {
	Lat float64 `json:"lat,omitempty"`
	Lon float64 `json:"lon,omitempty"`
}

type ContentTypeInfo

type ContentTypeInfo struct {
	ContentType string
	Title       string
	Description string
}

type ContentTypeInfoMap

type ContentTypeInfoMap map[string]ContentTypeInfo

type ContentTypeResult

type ContentTypeResult struct {
	EntryID     string
	ContentType string
	References  map[string][]EntryReference
}

type ContentTypeSys

type ContentTypeSys struct {
	Sys ContentTypeSysAttributes `json:"sys,omitempty"`
}

func ToAssetReference

func ToAssetReference(asset *contentful.Asset) (refSys ContentTypeSys)

type ContentTypeSysAttributes

type ContentTypeSysAttributes struct {
	ID       string `json:"id,omitempty"`
	Type     string `json:"type,omitempty"`
	LinkType string `json:"linkType,omitempty"`
}

type ContentfulCache

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

type ContentfulCacheMutex

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

type ContentfulClient

type ContentfulClient struct {
	Cache *ContentfulCache

	Client *contentful.Contentful

	SpaceID string
	// contains filtered or unexported fields
}

func NewContentfulClient

func NewContentfulClient(ctx context.Context, spaceID string, clientMode ClientMode, clientKey string, optimisticPageSize uint16, logFn func(fields map[string]interface{}, level int, args ...interface{}), logLevel int, debug bool) (*ContentfulClient, error)

func NewOfflineContentfulClient

func NewOfflineContentfulClient(file []byte, logFn func(fields map[string]interface{}, level int, args ...interface{}), logLevel int, cacheAssets bool, textJanitor bool) (*ContentfulClient, error)

func (*ContentfulClient) BrokenReferences

func (cc *ContentfulClient) BrokenReferences() (brokenReferences []BrokenReference)

func (*ContentfulClient) CacheHasContentType

func (cc *ContentfulClient) CacheHasContentType(contentTypeID string) bool

func (*ContentfulClient) ClientMode added in v1.1.0

func (cc *ContentfulClient) ClientMode() ClientMode

func (*ContentfulClient) ClientStats

func (cc *ContentfulClient) ClientStats()

func (*ContentfulClient) DeleteAsset

func (cc *ContentfulClient) DeleteAsset(ctx context.Context, asset *contentful.Asset) error

func (*ContentfulClient) DeleteAssetFromCache

func (cc *ContentfulClient) DeleteAssetFromCache(key string) error

func (*ContentfulClient) DisableTextJanitor added in v1.0.16

func (cc *ContentfulClient) DisableTextJanitor()

func (*ContentfulClient) EnableTextJanitor added in v1.0.16

func (cc *ContentfulClient) EnableTextJanitor()

func (*ContentfulClient) GetAllAssets

func (cc *ContentfulClient) GetAllAssets(ctx context.Context) (map[string]*contentful.Asset, error)

func (*ContentfulClient) GetAllBrand

func (cc *ContentfulClient) GetAllBrand(ctx context.Context) (voMap map[string]*CfBrand, err error)

func (*ContentfulClient) GetAllCategory

func (cc *ContentfulClient) GetAllCategory(ctx context.Context) (voMap map[string]*CfCategory, err error)

func (*ContentfulClient) GetAllGenericEntries added in v1.1.0

func (cc *ContentfulClient) GetAllGenericEntries() (map[string]*GenericEntry, error)

func (*ContentfulClient) GetAllProduct

func (cc *ContentfulClient) GetAllProduct(ctx context.Context) (voMap map[string]*CfProduct, err error)

func (*ContentfulClient) GetAssetByID

func (cc *ContentfulClient) GetAssetByID(ctx context.Context, id string, forceNoCache ...bool) (*contentful.Asset, error)

func (*ContentfulClient) GetBrandByID

func (cc *ContentfulClient) GetBrandByID(ctx context.Context, id string, forceNoCache ...bool) (vo *CfBrand, err error)

func (*ContentfulClient) GetCacheStats

func (cc *ContentfulClient) GetCacheStats() (*CacheStats, error)

func (*ContentfulClient) GetCategoryByID

func (cc *ContentfulClient) GetCategoryByID(ctx context.Context, id string, forceNoCache ...bool) (vo *CfCategory, err error)

func (*ContentfulClient) GetContentTypeOfID

func (cc *ContentfulClient) GetContentTypeOfID(ctx context.Context, id string) (string, error)

func (*ContentfulClient) GetFilteredBrand

func (cc *ContentfulClient) GetFilteredBrand(ctx context.Context, query *contentful.Query) (voMap map[string]*CfBrand, err error)

func (*ContentfulClient) GetFilteredCategory

func (cc *ContentfulClient) GetFilteredCategory(ctx context.Context, query *contentful.Query) (voMap map[string]*CfCategory, err error)

func (*ContentfulClient) GetFilteredProduct

func (cc *ContentfulClient) GetFilteredProduct(ctx context.Context, query *contentful.Query) (voMap map[string]*CfProduct, err error)

func (*ContentfulClient) GetGenericEntry added in v1.1.0

func (cc *ContentfulClient) GetGenericEntry(entryID string) (*GenericEntry, error)

func (*ContentfulClient) GetProductByID

func (cc *ContentfulClient) GetProductByID(ctx context.Context, id string, forceNoCache ...bool) (vo *CfProduct, err error)

func (*ContentfulClient) ResetSync

func (cc *ContentfulClient) ResetSync()

func (*ContentfulClient) SetCacheUpdateTimeout

func (cc *ContentfulClient) SetCacheUpdateTimeout(seconds int64)

func (*ContentfulClient) SetEnvironment

func (cc *ContentfulClient) SetEnvironment(environment string)

func (*ContentfulClient) SetOfflineFallback

func (cc *ContentfulClient) SetOfflineFallback(file []byte) error

func (*ContentfulClient) SetProductInCache

func (cc *ContentfulClient) SetProductInCache(product *CfProduct)

func (*ContentfulClient) SetSyncMode

func (cc *ContentfulClient) SetSyncMode(mode bool) error

func (*ContentfulClient) UpdateCache

func (cc *ContentfulClient) UpdateCache(ctx context.Context, contentTypes []string, cacheAssets bool) (map[string][]string, []string, error)

func (*ContentfulClient) UpdateCacheForEntity

func (cc *ContentfulClient) UpdateCacheForEntity(ctx context.Context, sysType string, contentType string, entityID string) error

type ContentfulReferencedEntry

type ContentfulReferencedEntry struct {
	Entry *contentful.Entry
	Col   *contentful.Collection
	LogFn func(
		contentType string,
		entryID string,
		method string,
		err error,
	)
}

func (ContentfulReferencedEntry) ContentType

func (ref ContentfulReferencedEntry) ContentType() (contentType string)

type ContentfulSys

type ContentfulSys struct {
	ID               string         `json:"id,omitempty"`
	Type             string         `json:"type,omitempty"`
	LinkType         string         `json:"linkType,omitempty"`
	ContentType      ContentTypeSys `json:"contentType,omitempty"`
	Environment      ContentTypeSys `json:"environment,omitempty"`
	Space            ContentTypeSys `json:"space,omitempty"`
	CreatedAt        string         `json:"createdAt,omitempty"`
	UpdatedAt        string         `json:"updatedAt,omitempty"`
	Revision         float64        `json:"revision,omitempty"`
	Version          float64        `json:"version,omitempty"`
	PublishedCounter float64        `json:"publishedCounter,omitempty"`
	PublishedVersion float64        `json:"publishedVersion,omitempty"`
}

type EmbeddedEntryResolverFunc

type EmbeddedEntryResolverFunc func(entryID string, locale Locale) (htmlSnippet string, resolveError error)

type EntryLinkResolverFunc

type EntryLinkResolverFunc func(entryID string, locale Locale) (resolvedAttrs map[string]string, resolveError error)

type EntryReference

type EntryReference struct {
	ContentType string
	ID          string
	VO          interface{}
	FromField   string
}

func (*EntryReference) GetParents

func (ref *EntryReference) GetParents(cc *ContentfulClient) (parents []EntryReference, err error)

type GenericEntry added in v1.1.0

type GenericEntry struct {
	Sys       ContentfulSys     `json:"sys,omitempty"`
	RawFields RawFields         `json:"fields,omitempty"`
	CC        *ContentfulClient `json:"-"`
}

func (*GenericEntry) FieldAsAny added in v1.1.0

func (genericEntry *GenericEntry) FieldAsAny(fieldName string, locale ...Locale) (any, error)

func (*GenericEntry) FieldAsAsset added in v1.1.0

func (genericEntry *GenericEntry) FieldAsAsset(ctx context.Context, fieldName string, locale ...Locale) (*contentful.AssetNoLocale, error)

func (*GenericEntry) FieldAsBool added in v1.1.0

func (genericEntry *GenericEntry) FieldAsBool(fieldName string, locale ...Locale) (bool, error)

func (*GenericEntry) FieldAsFloat64 added in v1.1.0

func (genericEntry *GenericEntry) FieldAsFloat64(fieldName string, locale ...Locale) (float64, error)

func (*GenericEntry) FieldAsMultipleReference added in v1.1.0

func (genericEntry *GenericEntry) FieldAsMultipleReference(fieldName string, locale ...Locale) ([]*EntryReference, error)

func (*GenericEntry) FieldAsReference added in v1.1.0

func (genericEntry *GenericEntry) FieldAsReference(fieldName string, locale ...Locale) (*EntryReference, error)

func (*GenericEntry) FieldAsString added in v1.1.0

func (genericEntry *GenericEntry) FieldAsString(fieldName string, locale ...Locale) (string, error)

func (*GenericEntry) FieldAsStringSlice added in v1.1.0

func (genericEntry *GenericEntry) FieldAsStringSlice(fieldName string, locale ...Locale) ([]string, error)

func (*GenericEntry) InheritAsAny added in v1.1.0

func (genericEntry *GenericEntry) InheritAsAny(ctx context.Context, fieldName string, parentTypes []string, locale ...Locale) (any, error)

func (*GenericEntry) InheritAsBool added in v1.1.0

func (genericEntry *GenericEntry) InheritAsBool(ctx context.Context, fieldName string, parentTypes []string, locale ...Locale) (bool, error)

func (*GenericEntry) InheritAsFloat64 added in v1.1.0

func (genericEntry *GenericEntry) InheritAsFloat64(ctx context.Context, fieldName string, parentTypes []string, locale ...Locale) (float64, error)

func (*GenericEntry) InheritAsMultipleReference added in v1.1.0

func (genericEntry *GenericEntry) InheritAsMultipleReference(ctx context.Context, fieldName string, parentTypes []string, locale ...Locale) ([]*EntryReference, error)

func (*GenericEntry) InheritAsReference added in v1.1.0

func (genericEntry *GenericEntry) InheritAsReference(ctx context.Context, fieldName string, parentTypes []string, locale ...Locale) (*EntryReference, error)

func (*GenericEntry) InheritAsString added in v1.1.0

func (genericEntry *GenericEntry) InheritAsString(ctx context.Context, fieldName string, parentTypes []string, locale ...Locale) (string, error)

func (*GenericEntry) InheritAsStringSlice added in v1.1.0

func (genericEntry *GenericEntry) InheritAsStringSlice(ctx context.Context, fieldName string, parentTypes []string, locale ...Locale) ([]string, error)

func (*GenericEntry) SetField added in v1.1.0

func (genericEntry *GenericEntry) SetField(fieldName string, fieldValue interface{}, locale ...Locale) error

func (*GenericEntry) Upsert added in v1.1.0

func (genericEntry *GenericEntry) Upsert(ctx context.Context) error

type ImageResolverFunc

type ImageResolverFunc func(assetID string, locale Locale) (attrs map[string]string, customHTML string, resolveError error)

type LinkResolverFunc

type LinkResolverFunc func(url string) (resolvedAttrs map[string]string, resolveError error)

type Locale

type Locale string
const DefaultLocale Locale = SpaceLocaleGerman
const SpaceLocaleFrench Locale = "fr"
const SpaceLocaleGerman Locale = "de"

type RawFields added in v1.1.0

type RawFields map[string]interface{}

func (RawFields) GetChildIDs added in v1.1.0

func (rawFields RawFields) GetChildIDs() (childIDs []string)

type RawItem added in v1.1.0

type RawItem struct {
	Fields RawFields `json:"fields"`
}

type RichTextData

type RichTextData struct {
	URI    string          `json:"uri,omitempty"`
	Target *ContentTypeSys `json:"target,omitempty"`
}

type RichTextGenericNode

type RichTextGenericNode struct {
	NodeType string                 `json:"nodeType"`
	Content  []*RichTextGenericNode `json:"content"`
	Data     map[string]interface{} `json:"data"`
	Value    string                 `json:"value"`
	Marks    []RichTextMark         `json:"marks"`
}

type RichTextMark

type RichTextMark struct {
	Type string `json:"type,omitempty"`
}

type RichTextNode

type RichTextNode struct {
	NodeType string        `json:"nodeType"`
	Content  []interface{} `json:"content"`
	Data     RichTextData  `json:"data"`
}

func HtmlToRichText

func HtmlToRichText(htmlSrc string) *RichTextNode

type RichTextNodeTextNode

type RichTextNodeTextNode struct {
	NodeType string         `json:"nodeType"`
	Data     RichTextData   `json:"data"`
	Value    string         `json:"value"`
	Marks    []RichTextMark `json:"marks"`
}

Jump to

Keyboard shortcuts

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