common

package
v1.27.6 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2025 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	MaxBulkRequestsCount       = 100
	MaxCountPerBulkRequestItem = 100
)
View Source
const DefaultMaxFetchersCount = 1
View Source
const DefaultMaxRequestsCountPerSecond = 0

Variables

This section is empty.

Functions

func CeilDivisionInt added in v1.6.1

func CeilDivisionInt(x, y int) int

Types

type Address added in v1.4.0

type Address struct {
	AddressID        int
	OwnerID          int
	TypeID           int
	TypeActivelyUsed int
	Added            int64
	Address2         string
	TypeName         string
	Address          string
	Street           string
	PostalCode       string
	City             string
	State            string
	Country          string
	LastModified
	Attributes
}

Address from getAddresses

func (*Address) UnmarshalJSON added in v1.17.1

func (u *Address) UnmarshalJSON(data []byte) error

type Addresses added in v1.4.0

type Addresses []Address

Addresses from getAddresses

type ApiError added in v1.15.0

type ApiError int
const (
	ServerMaintenance                                        ApiError = 1000
	AccountNotFound                                          ApiError = 1001
	HourlyRequestQuota                                       ApiError = 1002
	AccountDbConnError                                       ApiError = 1003
	UnknownApi                                               ApiError = 1005
	ApiNotAvailable                                          ApiError = 1006
	UnknownOutputFormat                                      ApiError = 1007
	DbError                                                  ApiError = 1008
	MissingAuth                                              ApiError = 1009
	RequiredParamMissing                                     ApiError = 1010
	InvalidClassifierID                                      ApiError = 1011
	ParamIsNotUnique                                         ApiError = 1012
	InconsistentParam                                        ApiError = 1013
	InvalidFormat                                            ApiError = 1014
	MalformedRequest                                         ApiError = 1015
	InvalidValue                                             ApiError = 1016
	IsAlreadyConfirmed                                       ApiError = 1017
	MultipleMatchesFound                                     ApiError = 1018
	NoRecordsFound                                           ApiError = 1019
	TooManyBulkSubRequests                                   ApiError = 1020
	SameInstanceIsRunning                                    ApiError = 1021
	RelatedDeletionError                                     ApiError = 1022
	WrongRowsSequence                                        ApiError = 1023
	MasterListLimitation                                     ApiError = 1024
	BinNotEmpty                                              ApiError = 1025
	IdenticalRecordExists                                    ApiError = 1026
	NotAllowedToChangeValue                                  ApiError = 1027
	NotUsableField                                           ApiError = 1028
	IncorrectList                                            ApiError = 1029
	ArrayValueRequired                                       ApiError = 1030
	MissingCouponError                                       ApiError = 1040
	CouponAlredyUsedError                                    ApiError = 1041
	NotEnoughRewardPoints                                    ApiError = 1042
	AppointmentBusyError                                     ApiError = 1043
	NotPossibleTimeSlots                                     ApiError = 1044
	CouponExpired                                            ApiError = 1045
	ConflictingRequirements                                  ApiError = 1046
	NoPromotionRequirements                                  ApiError = 1047
	ConflictingAwards                                        ApiError = 1048
	AwardsNotSpecified                                       ApiError = 1049
	AuthMissing                                              ApiError = 1050
	LoginFailed                                              ApiError = 1051
	UserBlocked                                              ApiError = 1052
	MissingSavedPassword                                     ApiError = 1053
	APISessionExpired                                        ApiError = 1054
	InvalidSession                                           ApiError = 1055
	SessionTooOld                                            ApiError = 1056
	DemoAccountExpired                                       ApiError = 1057
	PinLoginNotSupported                                     ApiError = 1058
	NoUserGroupDetected                                      ApiError = 1059
	NoViewingRights                                          ApiError = 1060
	NoAddingRights                                           ApiError = 1061
	NoEditingRights                                          ApiError = 1062
	NoDeletingRights                                         ApiError = 1063
	NoLocationAccess                                         ApiError = 1064
	NoAPIAccess                                              ApiError = 1065
	NoGroupManagementRights                                  ApiError = 1066
	WrongAccountFranchise                                    ApiError = 1067
	AccountNotConfirmed                                      ApiError = 1068
	BuyUpfrontOnly                                           ApiError = 1071
	NoPointsEarned                                           ApiError = 1072
	InconsistentDocumentsForInvoice                          ApiError = 1073
	WrongSourceDocument                                      ApiError = 1074
	MultiComponentsTax                                       ApiError = 1075
	WrongSalesPromotionType                                  ApiError = 1076
	WrongPriceListAssociation                                ApiError = 1077
	AmountFieldError                                         ApiError = 1078
	ProductIDChangeFailure                                   ApiError = 1079
	PrintingServiceFailure                                   ApiError = 1080
	EmailSendingFailure                                      ApiError = 1081
	EmailSettingFailure                                      ApiError = 1082
	WrongMasterListSetup                                     ApiError = 1083
	WrongMasterListUniqueField                               ApiError = 1084
	NoFileAttached                                           ApiError = 1090
	WrongFileEncoding                                        ApiError = 1091
	TooBigFile                                               ApiError = 1092
	PasswordLengthFailure                                    ApiError = 1100
	WrongLettersInPassword                                   ApiError = 1101
	PasswordComplexityError                                  ApiError = 1102
	PasswordChangeLimitFailure                               ApiError = 1103
	MultipleConflictingSettingsInSalesPromotion              ApiError = 1110
	SalesPromotionPurchasedAmountConflict                    ApiError = 1111
	SalesPromotionMultipleConflictingPurchaseOptions         ApiError = 1112
	SalesPromotionAwardedProductWithSumOffConflict           ApiError = 1113
	SalesPromotionAwardedProductConflict                     ApiError = 1114
	SalesPromotionPercentageOffConflict                      ApiError = 1115
	SalesPromotionSumOffConflict                             ApiError = 1116
	SalesPromotionPriceWithPurchasedAmountConflict           ApiError = 1117
	SalesPromotionMaxPointsDiscountWithRewardPointsConflict  ApiError = 1118
	SalesPromotionLowestPriceWithSumOffConflict              ApiError = 1119
	CustomerRegistryServiceUsed                              ApiError = 1120
	CannotChangeTypeOfDocument                               ApiError = 1121
	SalesPromotionSpecialPriceWithPurchasedAmountConflict    ApiError = 1122
	SalesPromotionPercentageOffWithPurchasedAmountConflict   ApiError = 1123
	SalesDocumentAccountNeedsUpdate                          ApiError = 1124
	AccountLimitationOnIntegration                           ApiError = 1126
	AccountInputFieldIsNotAllowed                            ApiError = 1127
	GreekAccountsOnly                                        ApiError = 1128
	OnlyOneValueForSalesPromotion                            ApiError = 1129
	WrongBillingAssociation                                  ApiError = 1130
	SalesPromotionWrongReasonCode                            ApiError = 1131
	SalesPromotionPurchasedProductWithSumOffConflict         ApiError = 1132
	SalesPromotionPurchasedProductSameAmountError            ApiError = 1133
	SalesPromotionAwardedProductAmountError                  ApiError = 1134
	NoAssortmentPossibleForLocation                          ApiError = 1136
	TooManyProducts                                          ApiError = 1137
	TooManyBillingIds                                        ApiError = 1138
	SalesPromotionSpecialUnitPurchasedAmountConflict         ApiError = 1139
	SalesPromotionMaxItemsBiggerThanPurchasedAmount          ApiError = 1140
	SalesPromotionPurchasedAmountMissingPurchasedProductData ApiError = 1141
	ExternalCouponRegistryService                            ApiError = 1142
	ExternalCouponRegistryServiceWrongInputField             ApiError = 1143
	SalesPromotionRedemptionLimitTooBig                      ApiError = 1144
	SalesPromotionRedemptionLimitWithMaxItemsConflict        ApiError = 1145
	NoEmployeeRecord                                         ApiError = 1146
	ComplianceAlreadyConfirmed                               ApiError = 1147
	NoAccessToCustomerData                                   ApiError = 1148
	NonEuCountry                                             ApiError = 1149
	IntegrationSpecificFieldMissingInputParameter            ApiError = 1150
	ProductAlreadyAppearsInSpecialPriceList                  ApiError = 1151
	PriceListOverlapsWithSpecialPriceList                    ApiError = 1152
	WrongPurposeForReasonCode                                ApiError = 1153
	OldInventoryModule                                       ApiError = 1154
	CreateAccountError                                       ApiError = 1155
	ValueLengthError                                         ApiError = 1156
	BulkSubRequestDocumentError                              ApiError = 1157
	BulkSubRequestDuplicateError                             ApiError = 1158
	EuAccountsField                                          ApiError = 1159
	GiftCardVatRateWithPaymentTypeConflict                   ApiError = 1160
	PosAppRequestType                                        ApiError = 1161
	TooLongListOfElements                                    ApiError = 1162
	CustomerCodeMissingInJWT                                 ApiError = 1170
	NoRightsForBackOffice                                    ApiError = 1171
	MissingUsernameInJWT                                     ApiError = 1172
	MissingUserName                                          ApiError = 1173
	PendingStatusForUser                                     ApiError = 1174
	UsernameAlreadyExists                                    ApiError = 1175
	NotPossibleToExtendSessionForJWT                         ApiError = 1176
	SignupNotAllowedForCountry                               ApiError = 1177
	ContactPersonBelongsToAnotherContact                     ApiError = 1178
	DateIsNotFutureError                                     ApiError = 1179
	WrongVersionNumberForInvoice                             ApiError = 1180
	StockTakingIsConfirmed                                   ApiError = 1181
	SalesPromotionFlagExcludePromotionWrongValue             ApiError = 1182
	CDNIntegrationRequired                                   ApiError = 1183
	SalesPromotionMaxNrOfMatchingItemsConflictingValue       ApiError = 1184
	SalesPromotionMaxNrOfMatchingItemsWrongValue             ApiError = 1185
	StocktakingAlreadyConnectedToDocumentType                ApiError = 1186
	ConfigurationCallIsMissing                               ApiError = 1187
	ConfigurationCallIsInvalid                               ApiError = 1188
	WarehouseNoLocalQuickButtonEnabled                       ApiError = 1189
	WrongJWTAccount                                          ApiError = 1190
	JWTDecodingFailure                                       ApiError = 1191
	JWTExpired                                               ApiError = 1194
	WrongLanguageCode                                        ApiError = 1195
	NotNewPassword                                           ApiError = 1196
)

func (ApiError) String added in v1.15.0

func (s ApiError) String() string

type Attributes added in v1.15.0

type Attributes struct {
	Attributes []ObjAttribute `json:"attributes"`
}

type Connector added in v1.15.0

type Connector struct {
	SessionCleaner        func() error
	Connect               func() (err error)
	AttemptsCount         uint
	Waiter                Waiter
	WaitingInterval       time.Duration
	WaitingIncrementCoeff uint
}

func (Connector) Run added in v1.15.0

func (c Connector) Run() error

type Cursor added in v1.6.1

type Cursor struct {
	Limit  int
	Offset int
}

type DataProvider added in v1.6.1

type DataProvider interface {
	Count(ctx context.Context, filters map[string]interface{}) (int, error)
	Read(ctx context.Context, bulkFilters []map[string]interface{}, callback func(item interface{})) error
}

type ErplyError added in v1.15.0

type ErplyError struct {
	Status  string
	Message string
	Code    ApiError
	// contains filtered or unexported fields
}

func NewErplyError added in v1.15.0

func NewErplyError(status, msg string, code ApiError) *ErplyError

func NewErplyErrorf added in v1.15.0

func NewErplyErrorf(status, msg string, code ApiError, args ...interface{}) *ErplyError

func NewFromError added in v1.15.0

func NewFromError(msg string, err error, code ApiError) *ErplyError

func NewFromResponseStatus added in v1.15.0

func NewFromResponseStatus(status *Status) *ErplyError

func (*ErplyError) Error added in v1.15.0

func (e *ErplyError) Error() string

type Item added in v1.6.1

type Item struct {
	Err        error
	TotalCount int
	Payload    interface{}
}

type ItemsStream added in v1.6.1

type ItemsStream chan Item

type ItemsStreamGrouped added in v1.7.0

type ItemsStreamGrouped chan []Item

type LastModified added in v1.15.0

type LastModified struct {
	LastModified           int64  `json:"lastModified"`
	LastModifierEmployeeID int64  `json:"lastModifierEmployeeID"`
	LastModifierUsername   string `json:"lastModifierUsername"`
}

type Lister added in v1.6.1

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

func NewLister added in v1.6.1

func NewLister(settings ListingSettings, dataProvider DataProvider, sl Sleeper) *Lister

func (*Lister) Get added in v1.6.1

func (p *Lister) Get(ctx context.Context, filters map[string]interface{}) ItemsStream

func (*Lister) GetGrouped added in v1.7.0

func (p *Lister) GetGrouped(ctx context.Context, filters map[string]interface{}, groupSize int) ItemsStreamGrouped

func (*Lister) SetRequestThrottler added in v1.7.5

func (p *Lister) SetRequestThrottler(thrl Throttler)

SetRequestThrottler concurrent unsafe setter, call it before calling any Get or GetGrouped method

type ListingSettings added in v1.6.1

type ListingSettings struct {
	MaxRequestsCountPerSecond int
	StreamBufferLength        int
	MaxFetchersCount          int
	MaxItemsPerRequest        int
}

type LongAttribute added in v1.15.0

type LongAttribute struct {
	AttributeName  string `json:"attributeName"`
	AttributeValue string `json:"attributeValue"`
}

type LongAttributes added in v1.15.0

type LongAttributes struct {
	LongAttributes []LongAttribute `json:"longAttributes"`
}

type ObjAttribute added in v1.4.0

type ObjAttribute struct {
	AttributeName  string `json:"attributeName"`
	AttributeType  string `json:"attributeType"`
	AttributeValue string `json:"attributeValue"`
}

type SleepThrottler added in v1.6.1

type SleepThrottler struct {
	LimitPerSecond int
	LastTimestamp  int64
	Count          int
	// contains filtered or unexported fields
}

SleepThrottler implements sleeping logic for requests throttling

func NewSleepThrottler added in v1.6.1

func NewSleepThrottler(limitPerSecond int, sl Sleeper) *SleepThrottler

NewSleepThrottler creates SleepThrottler

func (*SleepThrottler) Throttle added in v1.6.1

func (rt *SleepThrottler) Throttle()

Throttle implements throttling method

type SleepWaiter added in v1.15.0

type SleepWaiter struct{}

func (SleepWaiter) Wait added in v1.15.0

func (sw SleepWaiter) Wait(dur time.Duration)

type Sleeper added in v1.6.1

type Sleeper func(sleepTime time.Duration)

type Status

type Status struct {
	Request           string   `json:"request"`
	RequestUnixTime   int      `json:"requestUnixTime"`
	ResponseStatus    string   `json:"responseStatus"`
	ErrorCode         ApiError `json:"errorCode"`
	ErrorField        string   `json:"errorField"`
	GenerationTime    float64  `json:"generationTime"`
	RecordsTotal      int      `json:"recordsTotal"`
	RecordsInResponse int      `json:"recordsInResponse"`
}

type StatusBulk

type StatusBulk struct {
	RequestName string `json:"requestName"`
	RequestID   string `json:"requestID"`
	Status
}

type Throttler added in v1.6.1

type Throttler interface {
	Throttle()
}

Throttler abstracts limiting of API requests

type ThrottlerMock added in v1.6.1

type ThrottlerMock struct {
	WasTriggered bool
}

func (*ThrottlerMock) Throttle added in v1.6.1

func (tm *ThrottlerMock) Throttle()

type Waiter added in v1.15.0

type Waiter interface {
	Wait(dur time.Duration)
}

Jump to

Keyboard shortcuts

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