unaswrappergo

package module
Version: v0.0.0-...-0ac47ff Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2021 License: MIT Imports: 11 Imported by: 0

README

Unas API wrapper lib for Golang

Coverage Status

This is an unofficial API wrapper lib for Unas webshop written for Golang. The main goal is to make programming stuff using Unas API more convinient.

Contributions

Big thanks to @ondrejoa for helping me in this.

Maintenance

The largest part of the codebase was written in 2021 summer. We cannot guarantee the correct operation in case of an API update. Feel free to contribute and keep the code up to date.

Code documentation

Unas API has an often poor so we can't figure out some minor stuff either 😕

Usable API requests

Endpoint Support
AuthwithAPIKey ✔️
AuthwithPass ✔️
GetNewsletter
SetNewsletter
GetProduct
SetProduct
GetProductDB
SetProductDB
GetOrder
SetOrder
GetStock
SetStock
GetCategory
SetCategory
GetCustomer
SetCustomer
CheckCustomer
GetScriptTag
SetScriptTag
GetPage
SetPage
GetPageContent
SetPageContent
GetStorage
SetStorage
GetProductParameter
SetProductParameter
GetAutomatism
SetAutomatism
GetNewsletter
SetNewsletter

Documentation

Index

Constants

View Source
const (
	LoginEndPoint       endpointEnumType = "https://api.unas.eu/shop/login"
	GetNewsletter       endpointEnumType = "https://api.unas.eu/shop/getNewsletter"
	SetNewsletter       endpointEnumType = "https://api.unas.eu/shop/setNewsletter"
	GetProduct          endpointEnumType = "https://api.unas.eu/shop/getProduct"
	SetProduct          endpointEnumType = "https://api.unas.eu/shop/setProduct"
	GetProductDB        endpointEnumType = "https://api.unas.eu/shop/getProductDB"
	SetProductDB        endpointEnumType = "https://api.unas.eu/shop/setProductDB"
	GetOrder            endpointEnumType = "https://api.unas.eu/shop/getOrder"
	SetOrder            endpointEnumType = "https://api.unas.eu/shop/setOrder"
	GetStock            endpointEnumType = "https://api.unas.eu/shop/getStock"
	SetStock            endpointEnumType = "https://api.unas.eu/shop/setStock"
	GetCategory         endpointEnumType = "https://api.unas.eu/shop/getCategory"
	SetCategory         endpointEnumType = "https://api.unas.eu/shop/setCategory"
	GetCustomer         endpointEnumType = "https://api.unas.eu/shop/getCustomer"
	SetCustomer         endpointEnumType = "https://api.unas.eu/shop/setCustomer"
	CheckCustomer       endpointEnumType = "https://api.unas.eu/shop/checkCustomer"
	GetScriptTag        endpointEnumType = "https://api.unas.eu/shop/getScriptTag"
	SetScriptTag        endpointEnumType = "https://api.unas.eu/shop/setScriptTag"
	GetPage             endpointEnumType = "https://api.unas.eu/shop/getPage"
	SetPage             endpointEnumType = "https://api.unas.eu/shop/setPage"
	GetPageContent      endpointEnumType = "https://api.unas.eu/shop/getPageContent"
	SetPageContent      endpointEnumType = "https://api.unas.eu/shop/setPageContent"
	GetStorage          endpointEnumType = "https://api.unas.eu/shop/getStorage"
	SetStorage          endpointEnumType = "https://api.unas.eu/shop/setStorage"
	GetProductParameter endpointEnumType = "https://api.unas.eu/shop/getProductParameter"
	SetProductParameter endpointEnumType = "https://api.unas.eu/shop/setProductParameter"
	GetAutomatism       endpointEnumType = "https://api.unas.eu/shop/getAutomatism"
	SetAutomatism       endpointEnumType = "https://api.unas.eu/shop/setAutomatism"
)
View Source
const (
	StatusBaseNotActive statusBaseEnum = iota
	StatusBaseActive
	StatusBaseActiveNew
	StatusBaseActiveNotBuyable
)
View Source
const (
	ContentTypeMinimal = "minimal"
	ContentTypeShort   = "short"
	ContentTypeNormal  = "normal"
	ContentTypeFull    = "full"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth struct {
	Username      string `xml:"Username"`
	PasswordCrypt string `xml:"PasswordCrypt"`
	ShopID        string `xml:"ShopId"`
	AuthCode      string `xml:"AuthCode"`
}

Auth Struct for login with user:pass

type ContentParamList

type ContentParamList []string

func (ContentParamList) MarshalXML

func (contentParam ContentParamList) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*ContentParamList) UnmarshalXML

func (contentParam *ContentParamList) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type GetNewsletterParams

type GetNewsletterParams struct {
	Type      string        `xml:"Params>Type,omitempty"`
	Auth      string        `xml:"Params>Auth,omitempty"` //TODO bool
	TimeStart UnasTimeStamp `xml:"Params>TimeStart,omitempty"`
	TimeEnd   UnasTimeStamp `xml:"Params>TimeEnd,omitempty"`
}

GetNewsletterParams Params to set for querying newsletter subscribers https://unas.hu/tudastar/api/newsletter#getnewsletter-keres

type GetProductDBParameters

type GetProductDBParameters struct {
	Format              string `xml:"Format,omitempty"`
	Compress            string `xml:"Compress,omitempty"`
	LimitStart          string `xml:"LimitStart,omitempty"`
	LimitNum            string `xml:"LimitNum,omitempty"`
	Category            string `xml:"Category,omitempty"`
	Lang                string `xml:"Lang,omitempty"`
	GetName             string `xml:"GetName,omitempty"`
	GetStatus           string `xml:"GetStatus,omitempty"`
	GetPrice            string `xml:"GetPrice,omitempty"`
	GetPriceSale        string `xml:"GetPriceSale,omitempty"`
	GetPriceSpecial     string `xml:"GetPriceSpecial,omitempty"`
	GetCategory         string `xml:"GetCategory,omitempty"`
	GetDescriptionShort string `xml:"GetDescriptionShort,omitempty"`
	GetDescriptionLong  string `xml:"GetDescriptionLong,omitempty"`
	GetLink             string `xml:"GetLink,omitempty"`
	GetMinQty           string `xml:"GetMinQty,omitempty"`
	GetStock            string `xml:"GetStock,omitempty"`
	GetUnit             string `xml:"GetUnit,omitempty"`
	GetAlterUnit        string `xml:"GetAlterUnit,omitempty"`
	GetWeight           string `xml:"GetWeight,omitempty"`
	GetPoint            string `xml:"GetPoint,omitempty"`
	GetParam            string `xml:"GetParam,omitempty"`
	GetData             string `xml:"GetData,omitempty"`
	GetAttach           string `xml:"GetAttach,omitempty"`
	GetPack             string `xml:"GetPack,omitempty"`
	GetVariant          string `xml:"GetVariant,omitempty"`
	GetAlterCategory    string `xml:"GetAlterCategory,omitempty"`
	GetImage            string `xml:"GetImage,omitempty"`
	GetURL              string `xml:"GetURL,omitempty"`
	GetExport           string `xml:"GetExport,omitempty"`
	GetOrder            string `xml:"GetOrder,omitempty"`
	GetExplicit         string `xml:"GetExplicit,omitempty"`
	GetOnlineContent    string `xml:"GetOnlineContent,omitempty"`
	GetSEO              string `xml:"GetSeo,omitempty"`
	GetType             string `xml:"GetType,omitempty"`
	GetImageConnect     string `xml:"GetImageConnect,omitempty"`
	GetDiscount         string `xml:"GetDiscount,omitempty"`
	GetUnitStep         string `xml:"GetUnitStep,omitempty"`
	GetShipping         string `xml:"GetShipping,omitempty"`
	GetPayment          string `xml:"GetPayment,omitempty"`
	GetCustomerGroup    string `xml:"GetCustomerGroup,omitempty"`
	GetAddModDate       string `xml:"GetAddModDate,omitempty"`
	GetService          string `xml:"GetService,omitempty"`
}

Parameters required for GetProductDB request, more info at: https://unas.hu/tudastar/api/product#getproductdb-keres

type GetProductRequestParams

type GetProductRequestParams struct {
	StatusBase   *statusBaseEnum  `xml:"StatusBase,omitempty"`   // termék alap státusza; 0 – nem aktív; 1 – aktív; 2 – aktív, új; 3 – aktív, nem vásárolható;
	ID           string           `xml:"Id,omitempty"`           // termék egyedi azonosítója, ha ezt megadtad, akkor az Sku értéket figyelmen kívül hagyjuk
	Sku          string           `xml:"Sku,omitempty"`          // termék cikkszáma
	Parent       string           `xml:"Parent,omitempty"`       // típus összevonás esetén ezen alap típushoz tartozó termékek listázása
	TimeStart    *UnasTimeStamp   `xml:"TimeStart,omitempty"`    // unix timestamp, ezen időpont után módosult termékek listázása
	TimeEnd      *UnasTimeStamp   `xml:"TimeEnd,omitempty"`      // unix timestamp, ezen időpont előtt módosult termékek listázása
	DateStart    *UnasDate        `xml:"DateStart,omitempty"`    // YYYY.MM.DD formátum, ezen dátum után módosult termékek listázása
	DateEnd      *UnasDate        `xml:"DateEnd,omitempty"`      // YYYY.MM.DD formátum, ezen dátum előtt módosult termékek listázása
	ContentType  string           `xml:"ContentType,omitempty"`  // azt határozhatod meg, hogy milyen adatok jelenjenek meg egy termékről, négy szint közül választhatsz: minimal - gyors adatlekérés, minimális termék adatokkal; short - szűkített lista, bővített törzsadatokkal; normal - normál lista a leggyakrabban használt adatokkal (alapértelmezett); full – teljes lista minden termék adattal (csak valódi szükség esetén használandó)
	ContentParam ContentParamList `xml:"ContentParam,omitempty"` // "full" lekérés esetén vesszővel elválasztva megadhatók paraméter azonosítók, így szűkíthető a lekérendő paraméter értékek köre
	LimitStart   string           `xml:"LimitStart,omitempty"`   // Ha nem az összes terméket szeretnéd letölteni, akkor itt adhatod meg, hogy hányadik terméktől induljon a letöltés, pozitív egész szám, csak a LimitNum paraméterrel együtt használható.
	LimitNum     string           `xml:"LimitNum,omitempty"`     // Ha nem az összes terméket szeretnéd letölteni, akkor itt adhatod meg, hogy hány termék kerüljön letöltésre.
}

type NewsletterSubscriber

type NewsletterSubscriber struct {
	Email      string        `xml:"Email,omitempty"`
	Type       string        `xml:"Type,omitempty"`
	Time       UnasTimeStamp `xml:"Time,omitempty"`
	Name       string        `xml:"Name,omitempty"`
	Address    string        `xml:"Address,omitempty"`
	Lang       string        `xml:"Lang,omitempty"`
	Authorized string        `xml:"Authorized,omitempty"` //TODO bool
}

NewsletterSubscriber One subscriber of the newsletter

type Product

type Product struct {
	Action              string                     `xml:"Action,omitempty"`
	State               string                     `xml:"State"`
	Id                  string                     `xml:"ID"`
	Sku                 string                     `xml:"Sku"`
	SkuNew              string                     `xml:"SkuNew,omitempty"`
	History             []ProductEventType         `xml:"History>Event,omitempty"`
	Statuses            []ProductStatusType        `xml:"Statuses>Status,omitempty"`
	NoList              bool                       `xml:"NoList,omitempty"`
	Inquire             bool                       `xml:"Inquire,omitempty"`
	CustDiscountDisable bool                       `xml:"CustDiscountDisable,omitempty"`
	Explicit            bool                       `xml:"Explicit,omitempty"`
	Export              *ProductExportType         `xml:"Export,omitempty"`
	PublicInterval      *ProductPublicIntervalType `xml:"PublicInterval,omitempty"`
	Name                string                     `xml:"Name,omitempty"`
	Unit                string                     `xml:"Unit,omitempty"`
	MinimumQty          string                     `xml:"MinimumQty,omitempty"`
	MaximumQty          string                     `xml:"MaximumQty,omitempty"`
	AlertQty            *uint64                    `xml:"AlertQty,omitempty"`
	UnitStep            string                     `xml:"UnitStep,omitempty"`
	AlterUnit           *ProductAlterUnitType      `xml:"AlterUnit,omitempty"`
	Weight              *float64                   `xml:"Weight,omitempty"`
	Point               *uint64                    `xml:"Point,omitempty"`
	BuyableWithPoint    *string                    `xml:"BuyableWithPoint,omitempty"`
	Description         *ProductDescriptionType    `xml:"Description,omitempty"`
	Prices              []ProductPriceType         `xml:"Prices>Price,omitempty"`
	Categories          []ProductCategoryType      `xml:"Categories>Category,omitempty"`
	Url                 *string                    `xml:"Url,omitempty"`
	SefUrl              *string                    `xml:"SefUrl,omitempty"`
	Images              *ProductImagesType         `xml:"Images,omitempty"`
	Variants            []ProductVariantType       `xml:"Variants>Variant,omitempty"`
	Datas               []ProductDataType          `xml:"Datas>Data,omitempty"`
	Params              []ProductParamType         `xml:"Params>Param,omitempty"`
}

type ProductAlterUnitType

type ProductAlterUnitType struct {
	Quantity uint64 `xml:"Qty"`
	Unit     string `xml:"Unit"`
}

type ProductCategoryType

type ProductCategoryType struct {
	Type string `xml:"Type"`
	ID   string `xml:"Id"`
	Name string `xml:"Name"`
}

type ProductDataType

type ProductDataType struct {
	Id    uint64 `xml:"Id"`
	Name  string `xml:"Name"`
	Value string `xml:"Value"`
}

type ProductDescriptionType

type ProductDescriptionType struct {
	Short string `xml:"Short"`
	Long  string `xml:"Long"`
}

type ProductEventType

type ProductEventType struct {
	Action string `xml:"Action"`
	Time   string `xml:"Time"`
	Sku    string `xml:"Sku"`
	SkuOld string `xml:"SkuOld,omitempty"`
}

type ProductExportType

type ProductExportType struct {
	Status    bool     `xml:"Status"` // Engedélyezve(1) vagy Tiltva(0)
	Forbidden []string `xml:"Forbidden>Format"`
}

type ProductImageImportType

type ProductImageImportType struct {
	Url     string `xml:"Url"`
	Encoded string `xml:"Encoded"`
}

type ProductImageType

type ProductImageType struct {
	Type     string                  `xml:"Type,omitempty"`
	Id       *uint64                 `xml:"Id,omitempty"`
	SefUrl   string                  `xml:"SefUrl,omitempty"`
	FileName string                  `xml:"FileName,omitempty"`
	Alt      string                  `xml:"Alt,omitempty"`
	Import   *ProductImageImportType `xml:"Import,omitempty"`
}

type ProductImagesType

type ProductImagesType struct {
	DefaultFilename string             `xml:"DefaultFilename,omitempty"`
	DefaultAlt      string             `xml:"DefaultAlt,omitempty"`
	Og              *uint64            `xml:"OG,omitempty"`
	Version         string             `xml:"Version,omitempty"`
	Image           []ProductImageType `xml:"Image,omitempty"`
}

type ProductParamType

type ProductParamType struct {
	Id     string `xml:"Id,omitempty"`
	Type   string `xml:"Type,omitempty"`
	Name   string `xml:"Name,omitempty"`
	Group  string `xml:"Group,omitempty"`
	Value  string `xml:"Value,omitempty"`
	Before string `xml:"Before,omitempty"`
	After  string `xml:"After,omitempty"`
}

type ProductPriceType

type ProductPriceType struct {
	Type      string   `xml:"Type"`
	Area      string   `xml:"Area,omitempty"`
	AreaName  string   `xml:"AreaName,omitempty"`
	Group     string   `xml:"Group,omitempty"`
	GroupName string   `xml:"GroupName,omitempty"`
	Net       float64  `xml:"Net"`
	Gross     float64  `xml:"Gross"`
	Start     *string  `xml:"Start,omitempty"` // TODO: sajat tipus
	End       *string  `xml:"End,omitempty"`   // TODO: sajat tipus
	SaleNet   *float64 `xml:"SaleNet,omitempty"`
	SaleGross *float64 `xml:"SaleGross,omitempty"`
	SaleStart *string  `xml:"SaleStart,omitempty"`
	SaleEnd   *string  `xml:"SaleEnd,omitempty"`
	Percent   *string  `xml:"Percent,omitempty"`
}

type ProductPublicIntervalType

type ProductPublicIntervalType struct {
	Start string `xml:"Start,omitempty"` // TODO: format miatt kulon tipus
	End   string `xml:"End,omitempty"`   // TODO: format miatt kulon tipus
}

type ProductStatusType

type ProductStatusType struct {
	Type  string         `xml:"Type"`
	Id    string         `xml:"Id,omitempty"`
	Name  string         `xml:"Name,omitempty"`
	Value statusBaseEnum `xml:"Value"`
}

type ProductVariantType

type ProductVariantType struct {
	Name   string                    `xml:"Name"`
	Values []ProductVariantValueType `xml:"Values>Value,omitempty"`
}

type ProductVariantValueType

type ProductVariantValueType struct {
	Name       string   `xml:"Name"`
	ExtraPrice *float64 `xml:"ExtraPrice,omitempty"`
}

type SetNewsletterSubscriberParams

type SetNewsletterSubscriberParams struct {
	Action string `xml:"Action,omitempty"`
	Email  string `xml:"Email,omitempty"`
	Name   string `xml:"Name,omitempty"`
}

type SetNewsletterSubscriberStatus

type SetNewsletterSubscriberStatus struct {
	Action string `xml:"Action,omitempty"`
	Email  string `xml:"Email,omitempty"`
	Name   string `xml:"Name,omitempty"`
	Status string `xml:"Status,omitempty"`
}

type SetProductDBParams

type SetProductDBParams struct {
	URL     string `xml:"Url"`
	DB      string `xml:"DB"`
	DelType string `xml:"DelType"`
	Lang    string `xml:"Lang"`
}

Request params for SetProductDB request, where an URL can be set for import, more info at: https://unas.hu/tudastar/api/product#setproductdb-keres

type SetProductDBResponse

type SetProductDBResponse struct {
	ModifiedProducts uint64                     `xml:"setProductDB>Ok>Modify,omitempty"`
	AddedProducts    uint64                     `xml:"setProductDB>Ok>Add,omitempty"`
	DeletedProducts  uint64                     `xml:"setProductDB>Ok>Delete,omitempty"`
	Errors           SetProductDBResponseErrors `xml:"setProductDB>Error,omitempty"`
}

Response from a SetProductDB request that contains logs from the result of the import, more info at: https://unas.hu/tudastar/api/product#setproductdb-valasz

type SetProductDBResponseErrors

type SetProductDBResponseErrors struct {
	UnknownColumns    uint64 `xml:"UnknownColumns,omitempty"`
	FaultyProducts    uint64 `xml:"FaultyProducts,omitempty"`
	SKU_Duplicity     uint64 `xml:"SKU_Duplicity,omitempty"`
	NewProductFewData uint64 `xml:"NewProductFewData,omitempty"`
	LimitError        uint64
}

type UnasDate

type UnasDate time.Time

UnasDate YYYY.MM.DD Date format

func (UnasDate) MarshalXML

func (date UnasDate) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*UnasDate) ToTime

func (date *UnasDate) ToTime() *time.Time

func (*UnasDate) UnmarshalXML

func (date *UnasDate) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type UnasObject

type UnasObject struct {
	Login login
}

func AuthwithAPIKey

func AuthwithAPIKey(apikey string) (*UnasObject, error)

AuthwithAPIKey Authenticating using a API key. https://unas.hu/tudastar/api/authorization#api-kulcs-alapu-azonositas

func AuthwithPass

func AuthwithPass(a Auth) (*UnasObject, error)

AuthwithPass Authenticating using a User:Pass combo. https://unas.hu/tudastar/api/authorization#felhasznalonev-alapu-azonositas

func (UnasObject) GetNewsletter

func (uo UnasObject) GetNewsletter(params *GetNewsletterParams) ([]*NewsletterSubscriber, error)

GetNewsletter Queries newsletter subscribers of the webshop https://unas.hu/tudastar/api/newsletter#getnewsletter-funkcio

func (*UnasObject) GetProduct

func (uo *UnasObject) GetProduct(p *GetProductRequestParams) ([]*Product, error)

func (UnasObject) GetProductDB

func (uo UnasObject) GetProductDB(params *GetProductDBParameters) (*url.URL, error)

Returns an url where all of the products can be downloaded in a .csv file, the link expires after 1 hour more info at: https://unas.hu/tudastar/api/product#getproductdb-funkcio

func (UnasObject) SetNewsletter

func (uo UnasObject) SetNewsletter(subscribers []*SetNewsletterSubscriberParams) ([]*SetNewsletterSubscriberStatus, error)

SetNewsletter Add/Modify/Delete data of newsletter subscribers https://unas.hu/tudastar/api/newsletter#setnewsletter-funkcio

func (UnasObject) SetProduct

func (uo UnasObject) SetProduct(products []*Product) ([]*productStatus, error)

func (UnasObject) SetProductDB

func (uo UnasObject) SetProductDB(params *SetProductDBParams) (*SetProductDBResponse, error)

Importing a csv? from an url into the webshop database, more info at: https://unas.hu/tudastar/api/product#setproductdb-funkcio

type UnasTimeDate

type UnasTimeDate time.Time

UnasTimeDate UnasDate YYYY.MM.DD HH:MM:SS TimeDate format

func (UnasTimeDate) MarshalXML

func (timedate UnasTimeDate) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*UnasTimeDate) ToTime

func (timedate *UnasTimeDate) ToTime() *time.Time

func (*UnasTimeDate) UnmarshalXML

func (timedate *UnasTimeDate) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type UnasTimeStamp

type UnasTimeStamp time.Time

UnasTimeStamp Unix timestamp format

func (UnasTimeStamp) MarhsalXML

func (timestamp UnasTimeStamp) MarhsalXML(e *xml.Encoder, start xml.StartElement) error

func (*UnasTimeStamp) ToTime

func (timestamp *UnasTimeStamp) ToTime() *time.Time

func (*UnasTimeStamp) UnmarshalXML

func (timestamp *UnasTimeStamp) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL