goakeneo

package module
v1.0.28 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2023 License: MIT Imports: 21 Imported by: 0

README

Go Akeneo SDK

The Go Akeneo SDK is a client library for interacting with the Akeneo API in Go applications.

Installation

You can install the library using the go get command:

go get github.com/ezifyio/go-akeneo

To use the Go Akeneo SDK in your Go project, you need to import it:

import "github.com/ezifyio/go-akeneo"

Usage

To get started with the Go Akeneo SDK, you need to create a new client by providing the necessary configuration and options:

connector := goakeneo.Connector{
ClientID:   "your-client-id",
Secret:     "your-secret",
UserName:   "your-username",
Password:   "your-password",
}

client, err := goakeneo.NewClient(connector,
	goakeneo.WithBaseURL("https://your-akeneo-instance.com"),
	goakeneo.WithRateLimit(10, 1*time.Second),
)
if err != nil {
// Handle error
}

Once you have a client instance, you can use it to interact with the Akeneo API. The client provides various services for different API endpoints, such as AuthService, ProductService, FamilyService, etc. You can access these services from the client and make API calls:

// Example: Get products
products,links, err := client.Product.ListWithPagination(nil)
if err != nil {
// Handle error
}

for product := range products {
// Process each product
}

Refer to the Go Akeneo SDK documentation and API reference for more information on available services and methods.

Contributing

If you would like to contribute to the Go Akeneo SDK, feel free to submit pull requests or open issues on the GitHub repository: https://github.com/ezifyio/go-akeneo

License

The Go Akeneo SDK is open-source and available under the MIT License.

Documentation

Index

Constants

View Source
const (
	// AkeneoPimVersion4 is the version 4 of Akeneo PIM
	AkeneoPimVersion4 = iota + 4
	// AkeneoPimVersion5 is the version 5 of Akeneo PIM
	AkeneoPimVersion5
	// AkeneoPimVersion6 is the version 6 of Akeneo PIM
	AkeneoPimVersion6
	// AkeneoPimVersion7 is the version 7 of Akeneo PIM
	AkeneoPimVersion7
)
View Source
const (
	ValueTypeString = iota + 1
	ValueTypeStringCollection
	ValueTypeNumber
	ValueTypeMetric
	ValueTypePrice
	ValueTypeBoolean
	ValueTypeSimpleSelect
	ValueTypeMultiSelect
	ValueTypeTable
	ValueTypeMedia
	ValueTypeMediaSet
)

ValueTypeConst

View Source
const (
	EventTypeProductCreated      = "product.created"
	EventTypeProductUpdated      = "product.updated"
	EventTypeProductRemoved      = "product.removed"
	EventTypeProductModelCreated = "product_model.created"
	EventTypeProductModelUpdated = "product_model.updated"
	EventTypeProductModelRemoved = "product_model.removed"
)

Variables

View Source
var ValueTypeName = map[int]string{
	ValueTypeString:           "string",
	ValueTypeStringCollection: "string_collection",
	ValueTypeNumber:           "number",
	ValueTypeMetric:           "metric",
	ValueTypePrice:            "price",
	ValueTypeBoolean:          "boolean",
	ValueTypeSimpleSelect:     "simple_select",
	ValueTypeMultiSelect:      "multi_select",
	ValueTypeTable:            "table",
	ValueTypeMedia:            "media_link",
	ValueTypeMediaSet:         "media_set",
}

ValueTypeName is the name of the value type

Functions

This section is empty.

Types

type AssociatedProduct added in v1.0.13

type AssociatedProduct struct {
	Identifier string `json:"identifier,omitempty" mapstructure:"identifier"`
	Attribute  string `json:"attribute,omitempty" mapstructure:"attribute"`
	Scope      string `json:"scope,omitempty" mapstructure:"scope"`
	Locale     string `json:"locale,omitempty" mapstructure:"locale"`
}

func (AssociatedProduct) ToJSONString added in v1.0.13

func (p AssociatedProduct) ToJSONString() string

func (AssociatedProduct) Type added in v1.0.13

func (p AssociatedProduct) Type() string

type AssociatedProductModel added in v1.0.13

type AssociatedProductModel struct {
	Code      string `json:"code,omitempty" mapstructure:"code"`
	Attribute string `json:"attribute,omitempty" mapstructure:"attribute"`
	Scope     string `json:"scope,omitempty" mapstructure:"scope"`
	Locale    string `json:"locale,omitempty" mapstructure:"locale"`
}

func (AssociatedProductModel) ToJSONString added in v1.0.13

func (p AssociatedProductModel) ToJSONString() string

func (AssociatedProductModel) Type added in v1.0.13

func (p AssociatedProductModel) Type() string

type AssociationTypeListOptions

type AssociationTypeListOptions struct {
	Page      int  `url:"page,omitempty"`
	Limit     int  `url:"limit,omitempty"`
	WithCount bool `url:"with_count,omitempty"`
}

AssociationTypeListOptions specifies the association type optional parameters

type Attribute

type Attribute struct {
	Links               *Links            `json:"_links,omitempty" mapstructure:"_links"`
	Code                string            `json:"code,omitempty" mapstructure:"code"`
	Type                string            `json:"type,omitempty" mapstructure:"type"`
	Labels              map[string]string `json:"labels,omitempty" mapstructure:"labels"`
	Group               string            `json:"group,omitempty" mapstructure:"group"`
	GroupLabels         map[string]string `json:"group_labels,omitempty" mapstructure:"group_labels"`
	SortOrder           int               `json:"sort_order,omitempty" mapstructure:"sort_order"`
	Localizable         bool              `json:"localizable,omitempty" mapstructure:"localizable"`                       // whether the attribute is localizable or not,i.e. whether it can be translated or not
	Scopable            bool              `json:"scopable,omitempty" mapstructure:"scopable"`                             // whether the attribute is scopable or not,i.e. whether it can have different values depending on the channel or not
	AvailableLocales    []string          `json:"available_locales,omitempty" mapstructure:"available_locales"`           // the list of activated locales for the attribute values
	Unique              bool              `json:"unique,omitempty" mapstructure:"unique"`                                 // whether the attribute value is unique or not
	UseableAsGridFilter bool              `json:"useable_as_grid_filter,omitempty" mapstructure:"useable_as_grid_filter"` // whether the attribute can be used as a filter in the product grid or not
	MaxCharacters       int               `json:"max_characters,omitempty" mapstructure:"max_characters"`                 // the maximum number of characters allowed for the value of the attribute
	ValidationRule      string            `json:"validation_rule,omitempty" mapstructure:"validation_rule"`               // validation rule code to validate the attribute value
	ValidationRegexp    string            `json:"validation_regexp,omitempty" mapstructure:"validation_regexp"`           // validation regexp to validate the attribute value
	WysiwygEnabled      bool              `json:"wysiwyg_enabled,omitempty" mapstructure:"wysiwyg_enabled"`               // whether the attribute can have a value per channel or not
	NumberMin           string            `json:"number_min,omitempty" mapstructure:"number_min"`                         // the minimum value allowed for the value of the attribute
	NumberMax           string            `json:"number_max,omitempty" mapstructure:"number_max"`                         // the maximum value allowed for the value of the attribute
	DecimalsAllowed     bool              `json:"decimals_allowed,omitempty" mapstructure:"decimals_allowed"`             // whether decimals are allowed for the attribute or not
	NegativeAllowed     bool              `json:"negative_allowed,omitempty" mapstructure:"negative_allowed"`             // whether negative numbers are allowed for the attribute or not
	MetricFamily        string            `json:"metric_family,omitempty" mapstructure:"metric_family"`                   // the metric family of the attribute
	DefaultMetricUnit   string            `json:"default_metric_unit,omitempty" mapstructure:"default_metric_unit"`       // the default metric unit of the attribute
	DateMin             string            `json:"date_min,omitempty" mapstructure:"date_min"`                             // the minimum date allowed for the value of the attribute
	DateMax             string            `json:"date_max,omitempty" mapstructure:"date_max"`                             // the maximum date allowed for the value of the attribute
	AllowedExtensions   []string          `json:"allowed_extensions,omitempty" mapstructure:"allowed_extensions"`         // the list of allowed extensions for the value of the attribute
	MaxFileSize         string            `json:"max_file_size,omitempty" mapstructure:"max_file_size"`                   // the maximum file size allowed for the value of the attribute
	ReferenceDataName   string            `json:"reference_data_name,omitempty" mapstructure:"reference_data_name"`       // the reference data name of the attribute
	DefaultValue        bool              `json:"default_value,omitempty" mapstructure:"default_value"`                   // the default value of the attribute
	TableConfiguration  []string          `json:"table_configuration,omitempty" mapstructure:"table_configuration"`       // the table configuration of the attribute
}

Attribute is the struct for an akeneo attribute,see: https://api.akeneo.com/api-reference.html#Attribute

type AttributeGroupListOptions

type AttributeGroupListOptions struct {
	ListOptions
}

AttributeGroupListOptions specifies the attribute group optional parameters

type AttributeListOptions

type AttributeListOptions struct {
	WithTableSelectOptions bool `url:"with_table_select_options,omitempty" json:"with_table_select_options,omitempty" mapstructure:"with_table_select_options"` // false by default,decreases performance when enabled
	ListOptions
}

AttributeListOptions specifies the attribute optional parameters

type AttributeOption

type AttributeOption struct {
	Links     Links             `json:"_links,omitempty" mapstructure:"_links"`
	Code      string            `json:"code,omitempty" mapstructure:"code"`
	Attribute string            `json:"attribute,omitempty" mapstructure:"attribute"`
	SortOrder int               `json:"sort_order,omitempty" mapstructure:"sort_order"`
	Labels    map[string]string `json:"labels,omitempty" mapstructure:"labels"`
}

AttributeOption is the struct for an akeneo attribute option,see:

type AttributeOptionListOptions

type AttributeOptionListOptions struct {
	Page      int  `url:"page,omitempty"`
	Limit     int  `url:"limit,omitempty"`
	WithCount bool `url:"with_count,omitempty"`
}

AttributeOptionListOptions specifies the attribute option optional parameters

type AttributeOptionsResponse

type AttributeOptionsResponse struct {
	Links       Links                `json:"_links" mapstructure:"_links"`
	CurrentPage int                  `json:"current_page" mapstructure:"current_page"`
	Embedded    attributeOptionItems `json:"_embedded" mapstructure:"_embedded"`
}

AttributeOptionsResponse is the struct for a akeneo attribute options response

type AttributeService

type AttributeService interface {
	ListWithPagination(options any) ([]Attribute, Links, error)
	GetAttribute(code string, options any) (*Attribute, error)
	GetAttributeOptions(code string, options any) ([]AttributeOption, Links, error)
}

AttributeService is an interface for interfacing with the attribute

type AttributesResponse

type AttributesResponse struct {
	Links       Links          `json:"_links" mapstructure:"_links"`
	CurrentPage int            `json:"current_page" mapstructure:"current_page"`
	Embedded    attributeItems `json:"_embedded" mapstructure:"_embedded"`
}

AttributesResponse is the struct for a akeneo attributes response

type AuthService

type AuthService interface {
	GrantByPassword() error
	GrantByRefreshToken() error
	ShouldRefreshToken() bool
	AutoRefreshToken() error
}

AuthService is the interface to implement to authenticate to the Akeneo API

type BooleanValue

type BooleanValue struct {
	Locale string `json:"locale,omitempty" mapstructure:"locale"`
	Scope  string `json:"scope,omitempty" mapstructure:"scope"`
	Data   bool   `json:"data,omitempty" mapstructure:"data"`
}

BooleanValue is the struct for an akeneo boolean type product value pim_catalog_boolean : data is a bool

func (BooleanValue) ValueType

func (BooleanValue) ValueType() int

ValueType returns the value type, see ValueTypeConst

type CategoriesResponse

type CategoriesResponse struct {
	Links       Links         `json:"_links,omitempty" mapstructure:"_links"`
	CurrentPage int           `json:"current_page,omitempty" mapstructure:"current_page"`
	Embedded    categoryItems `json:"_embedded,omitempty" mapstructure:"_embedded"`
}

CategoriesResponse is the struct for a akeneo categories response

type Category

type Category struct {
	Links    Links                    `json:"_links,omitempty" mapstructure:"_links"`
	Code     string                   `json:"code,omitempty" mapstructure:"code"`
	Parent   string                   `json:"parent,omitempty" mapstructure:"parent"`
	Updated  string                   `json:"updated,omitempty" mapstructure:"updated"`
	Position int                      `json:"position,omitempty" mapstructure:"position"` // since 7.0 with query parameter "with_positions=true"
	Labels   map[string]string        `json:"labels,omitempty" mapstructure:"labels"`
	Values   map[string]categoryValue `json:"values,omitempty" mapstructure:"values"`
}

Category is the struct for an akeneo category

type CategoryListOptions

type CategoryListOptions struct {
	ListOptions
	WithPosition           bool `url:"with_position,omitempty"`
	WithEnrichedAttributes bool `url:"with_enriched_attributes,omitempty"`
}

CategoryListOptions specifies the category optional parameters

type CategoryService

type CategoryService interface {
	ListWithPagination(options any) ([]Category, Links, error)
	Get(code string) (*Category, error)
}

CategoryService is an interface for interacting with the Akeneo Category API.

type Channel

type Channel struct {
	Links           Links             `json:"_links,omitempty" mapstructure:"_links"`
	Code            string            `json:"code,omitempty" mapstructure:"code"`
	Currencies      []string          `json:"currencies,omitempty" mapstructure:"currencies"`
	Locales         []string          `json:"locales,omitempty" mapstructure:"locales"`
	CategoryTree    string            `json:"category_tree,omitempty" mapstructure:"category_tree"`
	ConversionUnits map[string]string `json:"conversion_units,omitempty" mapstructure:"conversion_units"`
	Labels          map[string]string `json:"labels,omitempty" mapstructure:"labels"`
}

Channel is the struct for an akeneo channel

type ChannelService

type ChannelService interface {
	ListWithPagination(options any) ([]Channel, Links, error)
}

ChannelService is the interface to interact with the Akeneo Channel API

type ChannelsResponse

type ChannelsResponse struct {
	Links       Links        `json:"_links" mapstructure:"_links"`
	CurrentPage int          `json:"current_page" mapstructure:"current_page"`
	Embedded    channelItems `json:"_embedded" mapstructure:"_embedded"`
}

ChannelsResponse is the struct for an akeneo channels response

type Client

type Client struct {
	Auth         AuthService
	Product      ProductService
	Family       FamilyService
	Attribute    AttributeService
	Category     CategoryService
	Channel      ChannelService
	Locale       LocaleService
	MediaFile    MediaFileService
	ProductModel ProductModelService
	// contains filtered or unexported fields
}

Client is the main struct to use to interact with the Akeneo API

func MockDLClient added in v1.0.9

func MockDLClient() *Client

func NewClient

func NewClient(con Connector, opts ...Option) (*Client, error)

NewClient creates a new Akeneo client

func (*Client) GET

func (c *Client) GET(relPath string, ops, data, result any) error

GET creates a get request and execute it result must be a pointer to a struct

func (*Client) PATCH added in v1.0.2

func (c *Client) PATCH(relPath string, ops, data, result any) error

PATCH creates a patch request and execute it

func (*Client) POST

func (c *Client) POST(relPath string, ops, data, result any) error

POST creates a post request and execute it result must be a pointer to a struct

type Connector

type Connector struct {
	ClientID string `json:"client_id" mapstructure:"client_id"`
	Secret   string `json:"secret" mapstructure:"secret"`
	UserName string `json:"username" mapstructure:"username"`
	Password string `json:"password" mapstructure:"password"`
}

Connector is the struct to use to store the Akeneo connection information

func (Connector) NewClient

func (c Connector) NewClient(opts ...Option) (*Client, error)

NewClient creates a new Akeneo client

type ErrorResponse

type ErrorResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type Event added in v1.0.2

type Event struct {
	Action        string       `json:"action,omitempty" mapstructure:"action"`
	Author        string       `json:"author,omitempty" mapstructure:"author"`
	AuthorType    string       `json:"author_type,omitempty" mapstructure:"author_type"`
	EventID       string       `json:"event_id,omitempty" mapstructure:"event_id"`
	EventDatatime string       `json:"event_datetime,omitempty" mapstructure:"event_datetime"`
	PimSource     string       `json:"pim_source,omitempty" mapstructure:"pim_source"`
	Data          dataResource `json:"data,omitempty" mapstructure:"data"`
}

Event akeneo events dispatch as json see: https://api.akeneo.com/events-documentation/subscription.html

func (*Event) EventType added in v1.0.24

func (e *Event) EventType() string

EventType return the event type

func (*Event) ID added in v1.0.24

func (e *Event) ID() string

ID return the resource id

type FamiliesResponse

type FamiliesResponse struct {
	Links       Links       `json:"_links,omitempty" mapstructure:"_links"`
	CurrentPage int         `json:"current_page,omitempty" mapstructure:"current_page"`
	Embedded    familyItems `json:"_embedded,omitempty" mapstructure:"_embedded"`
}

FamiliesResponse is the struct for an akeneo families response

type Family

type Family struct {
	Links                 *Links              `json:"_links,omitempty" mapstructure:"_links"`
	Code                  string              `json:"code,omitempty" mapstructure:"code"`                                     // The code of the family
	Attributes            []string            `json:"attributes,omitempty" mapstructure:"attributes"`                         //  Attributes codes that compose the family
	AttributeAsLabel      string              `json:"attribute_as_label,omitempty" mapstructure:"attribute_as_label"`         // The code of the attribute used as label for the family
	AttributeAsImage      string              `json:"attribute_as_image,omitempty" mapstructure:"attribute_as_image"`         // Attribute code used as the main picture in the user interface (only since v2.fmt
	AttributeRequirements map[string][]string `json:"attribute_requirements,omitempty" mapstructure:"attribute_requirements"` //  • Attributes codes of the family that are required for the completeness calculation for the channel `channelCode`
	Labels                map[string]string   `json:"labels,omitempty" mapstructure:"labels"`                                 //  Translatable labels. Ex: {"en_US": "T-shirt", "fr_FR": "T-shirt"}
}

Family is the struct for an akeneo family

type FamilyListOptions

type FamilyListOptions struct {
	ListOptions
}

FamilyListOptions specifies the family optional parameters see :https://api.akeneo.com/api-reference.html#Family

type FamilyService

type FamilyService interface {
	ListWithPagination(options any) ([]Family, Links, error)
	GetFamily(familyCode string, options any) (*Family, error)
	GetFamilyVariants(familyCode string, options any) ([]FamilyVariant, error)
	GetFamilyVariant(familyCode string, familyVariantCode string) (*FamilyVariant, error)
	CreateFamily(family Family) error
	UpdateOrCreate(familyCode, familyVariantCode string, familyVariant FamilyVariant) error
}

FamilyService is the interface to interact with the Akeneo Family API todo: query parameters check

type FamilyVariant

type FamilyVariant struct {
	Links                Links                 `json:"_links,omitempty" mapstructure:"_links"`
	Code                 string                `json:"code,omitempty" mapstructure:"code"`                                     // The code of the family variant
	Lables               map[string]string     `json:"labels,omitempty" mapstructure:"labels"`                                 // Translatable labels. Ex: {"en_US": "T-shirt", "fr_FR": "T-shirt"}
	VariantAttributeSets []variantAttributeSet `json:"variant_attribute_sets,omitempty" mapstructure:"variant_attribute_sets"` // The variant attribute sets of the family variant
}

FamilyVariant is the struct for an akeneo family variant

type FamilyVariantListOptions

type FamilyVariantListOptions struct {
	Page      int  `url:"page,omitempty"`
	Limit     int  `url:"limit,omitempty"`
	WithCount bool `url:"with_count,omitempty"`
}

FamilyVariantListOptions specifies the family variant optional parameters see :https://api.akeneo.com/api-reference.html#FamilyVariant

type FamilyVariantsResponse

type FamilyVariantsResponse struct {
	Links       Links              `json:"_links,omitempty" mapstructure:"_links"`
	CurrentPage int                `json:"current_page,omitempty" mapstructure:"current_page"`
	Embedded    familyVariantItems `json:"_embedded,omitempty" mapstructure:"_embedded"`
}

FamilyVariantsResponse is the struct for an akeneo family variants response

type Link struct {
	Href string `json:"href,omitempty"`
}

Link is the struct for an akeneo link

type Links struct {
	Self     Link `json:"self,omitempty"`
	First    Link `json:"first,omitempty"`
	Previous Link `json:"previous,omitempty"`
	Next     Link `json:"next,omitempty"`
	Download Link `json:"download,omitempty"`
}

Links is the struct for akeneo links

func (Links) HasNext

func (l Links) HasNext() bool

HasNext returns true if there is a next link

func (Links) NextOptions

func (l Links) NextOptions() url.Values

NextOptions returns the options for the next link

type ListOptions

type ListOptions struct {
	Search    string `url:"search,omitempty"`
	Page      int    `url:"page,omitempty"`
	Limit     int    `url:"limit,omitempty"`
	WithCount bool   `url:"with_count,omitempty"`
}

ListOptions is the struct for common list options

type Locale

type Locale struct {
	Links   Links  `json:"_links,omitempty" mapstructure:"_links"`
	Code    string `json:"code,omitempty" mapstructure:"code"`
	Enabled bool   `json:"enabled,omitempty" mapstructure:"enabled"`
}

Locale is the struct for an akeneo locale

type LocaleService

type LocaleService interface {
	ListWithPagination(options any) ([]Locale, Links, error)
}

LocaleService is the interface to interact with the Akeneo Locale API

type LocalesResponse

type LocalesResponse struct {
	Links       Links       `json:"_links" mapstructure:"_links"`
	CurrentPage int         `json:"current_page" mapstructure:"current_page"`
	Embedded    localeItems `json:"_embedded" mapstructure:"_embedded"`
}

LocalesResponse is the struct for a akeneo locales response

type MediaFile

type MediaFile struct {
	Code             string `json:"code,omitempty" mapstructure:"code"`
	OriginalFilename string `json:"original_filename,omitempty" mapstructure:"original_filename"`
	MimeType         string `json:"mime_type,omitempty" mapstructure:"mime_type"`
	Size             int    `json:"size,omitempty" mapstructure:"size"`
	Extension        string `json:"extension,omitempty" mapstructure:"extension"`
	Links            Links  `json:"_links,omitempty" mapstructure:"_links"`
}

MediaFile is the struct for an akeneo media file

func (*MediaFile) DownloadURL added in v1.0.2

func (m *MediaFile) DownloadURL() string

DownloadURL function returns the download url of the media file

type MediaFileAssociation added in v1.0.13

type MediaFileAssociation interface {
	ToJSONString() string
	Type() string
}

type MediaFileResponse

type MediaFileResponse struct {
	Links       Links      `json:"_links,omitempty" mapstructure:"_links"`
	CurrentPage int        `json:"current_page,omitempty" mapstructure:"current_page"`
	Embedded    mediaItems `json:"_embedded,omitempty" mapstructure:"_embedded"`
}

type MediaFileService

type MediaFileService interface {
	ListPagination(options any) ([]MediaFile, Links, error)
	GetByCode(code string, options any) (*MediaFile, error)
	Download(code, filePath string, options any) error
	Create(filePath string, association MediaFileAssociation) (string, error)
}

MediaFileService see: https://api.akeneo.com/api-reference.html#media-files

type MediaSetValue added in v1.0.27

type MediaSetValue struct {
	Locale string   `json:"locale,omitempty" mapstructure:"locale"`
	Scope  string   `json:"scope,omitempty" mapstructure:"scope"`
	Data   []string `json:"data,omitempty" mapstructure:"data"`
	Links  []*Links `json:"_links,omitempty" mapstructure:"_links"`
}

MeidaSetValue

func (MediaSetValue) DownloadURLs added in v1.0.27

func (v MediaSetValue) DownloadURLs() []string

DownloadURLs returns the download urls of the media set

func (MediaSetValue) Hrefs added in v1.0.27

func (v MediaSetValue) Hrefs() []string

Hrefs returns the hrefs of the media set

func (MediaSetValue) ValueType added in v1.0.27

func (MediaSetValue) ValueType() int

type MediaValue added in v1.0.1

type MediaValue struct {
	Locale string `json:"locale,omitempty" mapstructure:"locale"`
	Scope  string `json:"scope,omitempty" mapstructure:"scope"`
	Data   string `json:"data,omitempty" mapstructure:"data"`
	Links  *Links `json:"_links,omitempty" mapstructure:"_links"`
}

func (MediaValue) DownloadURL added in v1.0.1

func (v MediaValue) DownloadURL() string

DownloadURL returns the download url of the media

func (MediaValue) ValueType added in v1.0.1

func (MediaValue) ValueType() int

type MetricValue

type MetricValue struct {
	Locale string `json:"locale,omitempty" mapstructure:"locale"`
	Scope  string `json:"scope,omitempty" mapstructure:"scope"`
	Data   metric `json:"data,omitempty" mapstructure:"data"`
}

MetricValue is the struct for an akeneo metric type product value pim_catalog_metric : data amount is a float64 string when decimal is true, int when decimal is false

func (MetricValue) Amount

func (v MetricValue) Amount() string

Amount returns the amount as string

func (MetricValue) Unit

func (v MetricValue) Unit() string

Unit returns the unit as string

func (MetricValue) ValueType

func (MetricValue) ValueType() int

ValueType returns the value type, see ValueTypeConst

type MultiSelectValue

type MultiSelectValue struct {
	Locale     string                `json:"locale,omitempty" mapstructure:"locale"`
	Scope      string                `json:"scope,omitempty" mapstructure:"scope"`
	Data       []string              `json:"data,omitempty" mapstructure:"data"`
	LinkedData map[string]linkedData `json:"linked_data,omitempty" mapstructure:"linked_data"`
}

MultiSelectValue is the struct for an akeneo multi select type product value

func (MultiSelectValue) ValueType

func (MultiSelectValue) ValueType() int

ValueType returns the value type, see ValueTypeConst

type NumberValue

type NumberValue struct {
	Locale string `json:"locale,omitempty" mapstructure:"locale"`
	Scope  string `json:"scope,omitempty" mapstructure:"scope"`
	Data   int    `json:"data,omitempty" mapstructure:"data"`
}

NumberValue is the struct for an akeneo number type product value pim_catalog_number : data is an int when decimal is false ,float64 string when decimal is true so the data will be parsed as ValueTypeString when decimal is true

func (NumberValue) ValueType

func (NumberValue) ValueType() int

ValueType returns the value type, see ValueTypeConst

type Option

type Option func(*Client)

Option is client option function

func WithBaseURL

func WithBaseURL(u string) Option

WithBaseURL sets the base URL of the Akeneo API

func WithRateLimit

func WithRateLimit(limit int, t time.Duration) Option

WithRateLimit sets the rate limit of the Akeneo API

func WithRetry added in v1.0.1

func WithRetry(cnt int) Option

WithRetry sets the retry count of the Akeneo API

func WithVersion

func WithVersion(v int) Option

WithVersion sets the version of the Akeneo API

type PatchProductRequest added in v1.0.14

type PatchProductRequest []Product

type PatchProductResponse added in v1.0.14

type PatchProductResponse []PatchProductResponseLine

type PatchProductResponseLine added in v1.0.14

type PatchProductResponseLine struct {
	Line       int    `json:"line,omitempty" mapstructure:"line"`
	Identifier string `json:"identifier,omitempty" mapstructure:"identifier"`
	Code       string `json:"code,omitempty" mapstructure:"code"`
	StatusCode int    `json:"status_code,omitempty" mapstructure:"status_code"`
	Message    string `json:"message,omitempty" mapstructure:"message"`
}

type PimProductValue

type PimProductValue interface {
	ValueType() int
}

type PriceValue

type PriceValue struct {
	Locale string  `json:"locale,omitempty" mapstructure:"locale"`
	Scope  string  `json:"scope,omitempty" mapstructure:"scope"`
	Data   []price `json:"data,omitempty" mapstructure:"data"`
}

PriceValue is the struct for an akeneo price type product value pim_catalog_price : data amount is a float64 string when decimal is true, int when decimal is false

func (PriceValue) Amount

func (v PriceValue) Amount(currency string) string

Amount returns the amount as string

func (PriceValue) ValueType

func (PriceValue) ValueType() int

ValueType returns the value type, see ValueTypeConst

type Product

type Product struct {
	Links                  Links                            `json:"_links,omitempty" mapstructure:"_links"`
	UUID                   string                           `json:"uuid,omitempty" mapstructure:"uuid"` // Since Akeneo 7.0
	Identifier             string                           `json:"identifier,omitempty" mapstructure:"identifier"`
	Enabled                bool                             `json:"enabled,omitempty" mapstructure:"enabled"`
	Family                 string                           `json:"family,omitempty" mapstructure:"family"`
	Categories             []string                         `json:"categories,omitempty" mapstructure:"categories"`
	Groups                 []string                         `json:"groups,omitempty" mapstructure:"groups"`
	Parent                 string                           `json:"parent,omitempty" mapstructure:"parent"` // code of the parent product model when the product is a variant
	Values                 map[string][]ProductValue        `json:"values,omitempty" mapstructure:"values"`
	Associations           map[string]association           `json:"associations,omitempty" mapstructure:"associations"`
	QuantifiedAssociations map[string]quantifiedAssociation `json:"quantified_associations,omitempty" mapstructure:"quantified_associations"` // Since Akeneo 5.0
	Created                string                           `json:"created,omitempty" mapstructure:"created"`
	Updated                string                           `json:"updated,omitempty" mapstructure:"updated"`
	QualityScores          []QualityScore                   `json:"quality_scores,omitempty" mapstructure:"quality_scores"` // Since Akeneo 5.0,WithQualityScores must be true in the request
	Completenesses         []any                            `json:"completenesses,omitempty" mapstructure:"completenesses"` // Since Akeneo 6.0,WithCompleteness must be true in the request
	Metadata               map[string]string                `json:"metadata,omitempty" mapstructure:"metadata"`             // Enterprise Edition only
}

Product is the struct for an akeneo product

type ProductListOptions

type ProductListOptions struct {
	Scope                string `url:"scope,omitempty"`
	Locales              string `url:"locales,omitempty"`
	Attributes           string `url:"attributes,omitempty"`
	PaginationType       string `url:"pagination_type,omitempty"`
	SearchAfter          string `url:"search_after,omitempty"`
	WithAttributeOptions bool   `url:"with_attribute_options,omitempty"`
	WithCompleteness     bool   `url:"with_completeness,omitempty"`
	WithQualityScores    bool   `url:"with_quality_scores,omitempty"`
	ListOptions
}

ProductListOptions specifies the product optional parameters see: https://api.akeneo.com/api-reference.html#get_products

type ProductModel added in v1.0.1

type ProductModel struct {
	Links                  Links                            `json:"_links,omitempty" mapstructure:"_links"`
	Code                   string                           `json:"code,omitempty" mapstructure:"code"`
	Family                 string                           `json:"family,omitempty" mapstructure:"family"`
	FamilyVariant          string                           `json:"family_variant,omitempty" mapstructure:"family_variant"`
	Parent                 string                           `json:"parent,omitempty" mapstructure:"parent"`
	Categories             []string                         `json:"categories,omitempty" mapstructure:"categories"`
	Values                 map[string][]ProductValue        `json:"values,omitempty" mapstructure:"values"`
	Associations           map[string]association           `json:"associations,omitempty" mapstructure:"associations"`
	QuantifiedAssociations map[string]quantifiedAssociation `json:"quantified_associations,omitempty" mapstructure:"quantified_associations"`
	Metadata               map[string]string                `json:"metadata,omitempty" mapstructure:"metadata"`
	Created                string                           `json:"created,omitempty" mapstructure:"created"`
	Updated                string                           `json:"updated,omitempty" mapstructure:"updated"`
	QulityScores           []QualityScore                   `json:"quality_scores,omitempty" mapstructure:"quality_scores"`
}

ProductModel is the struct for an akeneo product model

type ProductModelListOptions

type ProductModelListOptions struct {
	Scope             string `url:"scope,omitempty"`
	Locales           string `url:"locales,omitempty"`
	Attributes        string `url:"attributes,omitempty"`
	PaginationType    string `url:"pagination_type,omitempty"`
	SearchAfter       string `url:"search_after,omitempty"`
	WithQualityScores bool   `url:"with_quality_scores,omitempty"`
	ListOptions
}

ProductModelListOptions specifies the product model optional parameters see :https://api.akeneo.com/api-reference.html#Productmodel

type ProductModelService added in v1.0.1

type ProductModelService interface {
	ListWithPagination(options any) ([]ProductModel, Links, error)
	GetProductModel(code string, options any) (*ProductModel, error)
	Crate(pm ProductModel) error
}

type ProductModelsResponse added in v1.0.1

type ProductModelsResponse struct {
	Links       Links             `json:"_links" mapstructure:"_links"`
	CurrentPage int               `json:"current_page" mapstructure:"current_page"`
	Embedded    productModelItems `json:"_embedded" mapstructure:"_embedded"`
}

ProductModelsResponse is the struct for the response of the ListWithPagination function

type ProductService

type ProductService interface {
	GetAllProducts(ctx context.Context, options any) (<-chan Product, chan error)
	ListWithPagination(options any) ([]Product, Links, error)
	GetProduct(id string, options any) (*Product, error)
	UpdateOrCreateProducts(products []Product) (PatchProductResponse, error)
}

ProductService is the interface to interact with the Akeneo Product API

type ProductValue

type ProductValue struct {
	Locale     string `json:"locale,omitempty" mapstructure:"locale"`
	Scope      string `json:"scope,omitempty" mapstructure:"scope"`
	Data       any    `json:"data,omitempty" mapstructure:"data"`
	Links      any    `json:"_links,omitempty" mapstructure:"_links"`
	LinkedData any    `json:"linked_data,omitempty" mapstructure:"linked_data"`
}

func (ProductValue) IsLocalized added in v1.0.1

func (v ProductValue) IsLocalized() bool

IsLocalized returns true if the value is localized

func (ProductValue) ParseValue

func (v ProductValue) ParseValue() (PimProductValue, error)

ParseValue tries to parse the value to correct type

type ProductsResponse

type ProductsResponse struct {
	Links       Links        `json:"_links,omitempty" mapstructure:"_links"`
	CurrentPage int          `json:"current_page,omitempty" mapstructure:"current_page"`
	Embedded    productItems `json:"_embedded,omitempty" mapstructure:"_embedded"`
}

ProductsResponse is the struct for an akeneo products response

type QualityScore

type QualityScore struct {
	Scope  string `json:"scope,omitempty" validate:"required"`
	Locale string `json:"locale,omitempty" validate:"required"`
	Data   string `json:"data,omitempty" validate:"required"`
}

QualityScore is the struct for quality score

type SearchFilter

type SearchFilter map[string][]map[string]interface{}

SearchFilter is a map of search filters,see : https://api.akeneo.com/documentation/filter.html

func (SearchFilter) Add added in v1.0.22

func (sf SearchFilter) Add(key, operator string, value any)

Add adds a new filter to the search filter

func (SearchFilter) String

func (sf SearchFilter) String() string

type SimpleSelectValue

type SimpleSelectValue struct {
	Locale     string     `json:"locale,omitempty" mapstructure:"locale"`
	Scope      string     `json:"scope,omitempty" mapstructure:"scope"`
	Data       string     `json:"data,omitempty" mapstructure:"data"`
	LinkedData linkedData `json:"linked_data,omitempty" mapstructure:"linked_data"`
}

SimpleSelectValue is the struct for an akeneo simple select type product value

func (SimpleSelectValue) ValueType

func (SimpleSelectValue) ValueType() int

ValueType returns the value type, see ValueTypeConst

type StringCollectionValue

type StringCollectionValue struct {
	Locale string   `json:"locale,omitempty" mapstructure:"locale"`
	Scope  string   `json:"scope,omitempty" mapstructure:"scope"`
	Data   []string `json:"data,omitempty" mapstructure:"data"`
}

StringCollectionValue is the struct for an akeneo collection type product value

func (StringCollectionValue) ValueType

func (StringCollectionValue) ValueType() int

ValueType returns the value type, see ValueTypeConst

type StringValue

type StringValue struct {
	Locale string `json:"locale,omitempty" mapstructure:"locale"`
	Scope  string `json:"scope,omitempty" mapstructure:"scope"`
	Data   string `json:"data,omitempty" mapstructure:"data"`
}

StringValue is the struct for an akeneo text type product value pim_catalog_text or pim_catalog_textarea : data is a string pim_catalog_file or pim_catalog_image: data is the file path pim_catalog_date : data is a string in ISO-8601 format

func (StringValue) ValueType

func (StringValue) ValueType() int

ValueType returns the value type, see ValueTypeConst

type TableValue

type TableValue struct {
	Locale string `json:"locale,omitempty" mapstructure:"locale"`
	Scope  string `json:"scope,omitempty" mapstructure:"scope"`
	Data   []map[string]any
}

TableValue is the struct for an akeneo table type product value pim_catalog_table : data is a []map[string]any

func (TableValue) ValueType

func (TableValue) ValueType() int

ValueType returns the value type, see ValueTypeConst

Jump to

Keyboard shortcuts

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