mirror of
https://github.com/retailcrm/api-client-go.git
synced 2025-04-07 19:12:00 +00:00
Compare commits
91 commits
Author | SHA1 | Date | |
---|---|---|---|
c62a02aa1f | |||
|
871459c8b7 | ||
d0b0dd59d6 | |||
|
cc83657f32 | ||
53e2ab5130 | |||
0123057e86 | |||
a8cae8b200 | |||
5fa64ff23e | |||
e2113a640e | |||
2f33b56cd3 | |||
|
8892fe6895 | ||
|
908f16b173 | ||
2859073353 | |||
a482cd1a2f | |||
92a5741c84 | |||
634ec386b1 | |||
d101ddb097 | |||
|
3186470ed9 | ||
904796f97a | |||
|
2f0f55be42 | ||
c79e6c0497 | |||
2587dd786a | |||
|
2333dbf493 | ||
|
d195460141 | ||
|
e6fc8f1e0e | ||
c9e5b1f79d | |||
3282ab045e | |||
4398f85214 | |||
|
77b49e04ab | ||
29062b8bf0 | |||
7c8e142cab | |||
e28631dcb2 | |||
a4de6df146 | |||
81a09e24d4 | |||
b5e7c3ff33 | |||
76135226fb | |||
a72a57fbe1 | |||
c2a33378b8 | |||
|
583362bfe3 | ||
|
ab648cd06a | ||
|
5c6d2ebead | ||
407ecf5066 | |||
|
2875b8620a | ||
b445dfdfe5 | |||
1e9692ec15 | |||
|
0ed90e8351 | ||
076ce77bdb | |||
|
8377a8789d | ||
280f078632 | |||
|
e6efd56497 | ||
|
9bd3d646fc | ||
|
16e2bc304c | ||
d08ed4e1b2 | |||
|
afb7c1b881 | ||
e513134df9 | |||
5b7ed8697e | |||
107a4d150b | |||
a51bab6df4 | |||
|
49905ab9c6 | ||
06b0395a93 | |||
67d72f2fe1 | |||
|
bafdf24755 | ||
6c5eb72848 | |||
|
141c247482 | ||
|
22cbdd7fcf | ||
|
1bd5b77b3f | ||
|
ddc2b3f785 | ||
|
90f790e148 | ||
|
921d4c1295 | ||
|
2f6ab28d85 | ||
573cbb9679 | |||
|
50e25d61bc | ||
|
a29e2419ff | ||
37df181264 | |||
26e66ab630 | |||
c482546e07 | |||
|
2117664f1f | ||
|
5e45297368 | ||
|
6f7fb5ceb9 | ||
|
f6b4a15f78 | ||
|
e316e3565c | ||
|
995d19007d | ||
|
1355012c58 | ||
|
06433b7c19 | ||
|
b39f9d3f69 | ||
|
3b5f7826ba | ||
|
b0a082d2bc | ||
|
94d281d2c8 | ||
|
9c7c641217 | ||
31ede381e4 | |||
cd567755e7 |
15 changed files with 6807 additions and 1411 deletions
25
.github/workflows/ci.yml
vendored
25
.github/workflows/ci.yml
vendored
|
@ -20,10 +20,10 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: Check out code into the Go module directory
|
- name: Check out code into the Go module directory
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: Set up Go 1.17
|
- name: Set up Go 1.23
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: '1.17'
|
go-version: '1.23'
|
||||||
- name: Get dependencies
|
- name: Get dependencies
|
||||||
run: |
|
run: |
|
||||||
go mod tidy
|
go mod tidy
|
||||||
|
@ -31,21 +31,22 @@ jobs:
|
||||||
- name: Lint code with golangci-lint
|
- name: Lint code with golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v3
|
uses: golangci/golangci-lint-action@v3
|
||||||
with:
|
with:
|
||||||
version: v1.45.2
|
version: v1.62.2
|
||||||
only-new-issues: true
|
only-new-issues: true
|
||||||
skip-pkg-cache: true
|
skip-pkg-cache: true
|
||||||
|
args: --build-tags=testutils
|
||||||
tests:
|
tests:
|
||||||
name: Tests
|
name: Tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version: ['1.13', '1.14', '1.15', '1.16', '1.17']
|
go-version: ['1.19', '1.20', '1.21', '1.22', '1.23', 'stable']
|
||||||
include:
|
include:
|
||||||
- go-version: '1.17'
|
- go-version: '1.23'
|
||||||
coverage: 1
|
coverage: 1
|
||||||
steps:
|
steps:
|
||||||
- name: Set up Go ${{ matrix.go-version }}
|
- name: Set up Go ${{ matrix.go-version }}
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: ${{ matrix.go-version }}
|
go-version: ${{ matrix.go-version }}
|
||||||
- name: Check out code into the Go module directory
|
- name: Check out code into the Go module directory
|
||||||
|
@ -58,17 +59,21 @@ jobs:
|
||||||
env:
|
env:
|
||||||
COVERAGE: ${{ matrix.coverage }}
|
COVERAGE: ${{ matrix.coverage }}
|
||||||
if: env.COVERAGE != 1
|
if: env.COVERAGE != 1
|
||||||
run: go test ./...
|
run: |
|
||||||
|
go install gotest.tools/gotestsum@latest
|
||||||
|
gotestsum --format testdox ./... -tags=testutils -v -cpu 2 -timeout 60s -race
|
||||||
- name: Tests with coverage
|
- name: Tests with coverage
|
||||||
env:
|
env:
|
||||||
COVERAGE: ${{ matrix.coverage }}
|
COVERAGE: ${{ matrix.coverage }}
|
||||||
if: env.COVERAGE == 1
|
if: env.COVERAGE == 1
|
||||||
run: |
|
run: |
|
||||||
go test ./... -race -coverprofile=coverage.txt -covermode=atomic "$d"
|
go install gotest.tools/gotestsum@latest
|
||||||
|
gotestsum --format testdox ./... -tags=testutils -v -cpu 2 -timeout 60s -race -cover -coverprofile=coverage.txt -covermode=atomic "$d"
|
||||||
- name: Coverage
|
- name: Coverage
|
||||||
env:
|
env:
|
||||||
COVERAGE: ${{ matrix.coverage }}
|
COVERAGE: ${{ matrix.coverage }}
|
||||||
if: env.COVERAGE == 1
|
if: env.COVERAGE == 1
|
||||||
run: |
|
run: |
|
||||||
|
go install github.com/axw/gocov/gocov@latest
|
||||||
|
gocov convert ./coverage.txt | gocov report
|
||||||
bash <(curl -s https://codecov.io/bash)
|
bash <(curl -s https://codecov.io/bash)
|
||||||
rm coverage.txt
|
|
||||||
|
|
102
.golangci.yml
102
.golangci.yml
|
@ -2,29 +2,69 @@ run:
|
||||||
skip-dirs-use-default: true
|
skip-dirs-use-default: true
|
||||||
allow-parallel-runners: true
|
allow-parallel-runners: true
|
||||||
|
|
||||||
|
issues:
|
||||||
|
exclude-files:
|
||||||
|
- testutils.go
|
||||||
|
exclude-rules:
|
||||||
|
- path: _test\.go
|
||||||
|
linters:
|
||||||
|
- lll
|
||||||
|
- errcheck
|
||||||
|
- misspell
|
||||||
|
- ineffassign
|
||||||
|
- whitespace
|
||||||
|
- makezero
|
||||||
|
- errcheck
|
||||||
|
- funlen
|
||||||
|
- goconst
|
||||||
|
- gocognit
|
||||||
|
- gocyclo
|
||||||
|
- godot
|
||||||
|
- unused
|
||||||
|
- errchkjson
|
||||||
|
- varnamelen
|
||||||
|
exclude-use-default: true
|
||||||
|
exclude-case-sensitive: false
|
||||||
|
max-issues-per-linter: 0
|
||||||
|
max-same-issues: 0
|
||||||
|
fix: true
|
||||||
|
|
||||||
output:
|
output:
|
||||||
format: colored-line-number
|
formats:
|
||||||
|
- format: colored-line-number
|
||||||
sort-results: true
|
sort-results: true
|
||||||
|
|
||||||
|
# Linters below do not support go1.18 yet because of generics.
|
||||||
|
# See https://github.com/golangci/golangci-lint/issues/2649
|
||||||
|
# - bodyclose
|
||||||
|
# - sqlclosecheck
|
||||||
|
|
||||||
linters:
|
linters:
|
||||||
disable-all: true
|
disable-all: true
|
||||||
enable:
|
enable:
|
||||||
- deadcode
|
- asciicheck
|
||||||
|
- asasalint
|
||||||
|
- varnamelen
|
||||||
|
- reassign
|
||||||
|
- nilnil
|
||||||
|
- nilerr
|
||||||
|
- nakedret
|
||||||
|
- goprintffuncname
|
||||||
|
- typecheck
|
||||||
|
- errchkjson
|
||||||
- errcheck
|
- errcheck
|
||||||
- gosimple
|
- gosimple
|
||||||
- govet
|
- govet
|
||||||
- ineffassign
|
- ineffassign
|
||||||
- staticcheck
|
- staticcheck
|
||||||
- structcheck
|
|
||||||
- unused
|
- unused
|
||||||
- unparam
|
- unparam
|
||||||
- varcheck
|
|
||||||
- bodyclose
|
|
||||||
- dogsled
|
- dogsled
|
||||||
- dupl
|
- dupl
|
||||||
- errorlint
|
- errorlint
|
||||||
- exhaustive
|
- exhaustive
|
||||||
- exportloopref
|
- exportloopref
|
||||||
|
- copyloopvar
|
||||||
- funlen
|
- funlen
|
||||||
- gocognit
|
- gocognit
|
||||||
- goconst
|
- goconst
|
||||||
|
@ -33,16 +73,13 @@ linters:
|
||||||
- godot
|
- godot
|
||||||
- goimports
|
- goimports
|
||||||
- revive
|
- revive
|
||||||
- gomnd
|
|
||||||
- gosec
|
- gosec
|
||||||
- ifshort
|
|
||||||
- lll
|
- lll
|
||||||
- makezero
|
- makezero
|
||||||
- misspell
|
- misspell
|
||||||
- nestif
|
- nestif
|
||||||
- prealloc
|
- prealloc
|
||||||
- predeclared
|
- predeclared
|
||||||
- sqlclosecheck
|
|
||||||
- unconvert
|
- unconvert
|
||||||
- whitespace
|
- whitespace
|
||||||
|
|
||||||
|
@ -53,6 +90,7 @@ linters-settings:
|
||||||
enable:
|
enable:
|
||||||
- assign
|
- assign
|
||||||
- atomic
|
- atomic
|
||||||
|
- atomicalign
|
||||||
- bools
|
- bools
|
||||||
- buildtag
|
- buildtag
|
||||||
- copylocks
|
- copylocks
|
||||||
|
@ -67,7 +105,6 @@ linters-settings:
|
||||||
- unmarshal
|
- unmarshal
|
||||||
- unreachable
|
- unreachable
|
||||||
- unsafeptr
|
- unsafeptr
|
||||||
- unused
|
|
||||||
settings:
|
settings:
|
||||||
printf:
|
printf:
|
||||||
funcs:
|
funcs:
|
||||||
|
@ -135,11 +172,13 @@ linters-settings:
|
||||||
threshold: 200
|
threshold: 200
|
||||||
errorlint:
|
errorlint:
|
||||||
errorf: true
|
errorf: true
|
||||||
|
asserts: false
|
||||||
|
comparison: false
|
||||||
exhaustive:
|
exhaustive:
|
||||||
check-generated: false
|
check-generated: false
|
||||||
default-signifies-exhaustive: false
|
default-signifies-exhaustive: false
|
||||||
funlen:
|
funlen:
|
||||||
lines: 60
|
lines: 90
|
||||||
statements: 40
|
statements: 40
|
||||||
gocognit:
|
gocognit:
|
||||||
min-complexity: 25
|
min-complexity: 25
|
||||||
|
@ -149,8 +188,6 @@ linters-settings:
|
||||||
local-prefixes: github.com/retailcrm/api-client-go/v2
|
local-prefixes: github.com/retailcrm/api-client-go/v2
|
||||||
lll:
|
lll:
|
||||||
line-length: 160
|
line-length: 160
|
||||||
maligned:
|
|
||||||
suggest-new: true
|
|
||||||
misspell:
|
misspell:
|
||||||
locale: US
|
locale: US
|
||||||
nestif:
|
nestif:
|
||||||
|
@ -158,40 +195,19 @@ linters-settings:
|
||||||
whitespace:
|
whitespace:
|
||||||
multi-if: false
|
multi-if: false
|
||||||
multi-func: false
|
multi-func: false
|
||||||
|
varnamelen:
|
||||||
issues:
|
max-distance: 10
|
||||||
exclude-rules:
|
ignore-map-index-ok: true
|
||||||
- path: _test\.go
|
ignore-type-assert-ok: true
|
||||||
linters:
|
ignore-chan-recv-ok: true
|
||||||
- gomnd
|
ignore-decls:
|
||||||
- lll
|
- t *testing.T
|
||||||
- bodyclose
|
- e error
|
||||||
- errcheck
|
- i int
|
||||||
- sqlclosecheck
|
|
||||||
- misspell
|
|
||||||
- ineffassign
|
|
||||||
- whitespace
|
|
||||||
- makezero
|
|
||||||
- maligned
|
|
||||||
- ifshort
|
|
||||||
- errcheck
|
|
||||||
- funlen
|
|
||||||
- goconst
|
|
||||||
- gocognit
|
|
||||||
- gocyclo
|
|
||||||
- godot
|
|
||||||
- gocritic
|
|
||||||
- gosec
|
|
||||||
- staticcheck
|
|
||||||
exclude-use-default: true
|
|
||||||
exclude-case-sensitive: false
|
|
||||||
max-issues-per-linter: 0
|
|
||||||
max-same-issues: 0
|
|
||||||
fix: true
|
|
||||||
|
|
||||||
severity:
|
severity:
|
||||||
default-severity: error
|
default-severity: error
|
||||||
case-sensitive: false
|
case-sensitive: false
|
||||||
|
|
||||||
service:
|
service:
|
||||||
golangci-lint-version: 1.36.x
|
golangci-lint-version: 1.62.x
|
||||||
|
|
2154
client_test.go
2154
client_test.go
File diff suppressed because it is too large
Load diff
8
enum.go
Normal file
8
enum.go
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
package retailcrm
|
||||||
|
|
||||||
|
var UserGroupSuperadmins UserGroupType = "superadmins"
|
||||||
|
|
||||||
|
var (
|
||||||
|
NotificationTypeError NotificationType = "api.error"
|
||||||
|
NotificationTypeInfo NotificationType = "api.info"
|
||||||
|
)
|
2
error.go
2
error.go
|
@ -9,6 +9,8 @@ import (
|
||||||
|
|
||||||
var missingParameterMatcher = regexp.MustCompile(`^Parameter \'([\w\]\[\_\-]+)\' is missing$`)
|
var missingParameterMatcher = regexp.MustCompile(`^Parameter \'([\w\]\[\_\-]+)\' is missing$`)
|
||||||
var (
|
var (
|
||||||
|
// ErrRateLimited will be returned if request was rate limited.
|
||||||
|
ErrRateLimited = NewAPIError("rate limit exceeded")
|
||||||
// ErrMissingCredentials will be returned if no API key was provided to the API.
|
// ErrMissingCredentials will be returned if no API key was provided to the API.
|
||||||
ErrMissingCredentials = NewAPIError(`apiKey is missing`)
|
ErrMissingCredentials = NewAPIError(`apiKey is missing`)
|
||||||
// ErrInvalidCredentials will be returned if provided API key is invalid.
|
// ErrInvalidCredentials will be returned if provided API key is invalid.
|
||||||
|
|
82
filters.go
82
filters.go
|
@ -199,6 +199,7 @@ type OrdersFilter struct {
|
||||||
PaymentStatuses []string `url:"paymentStatuses,omitempty,brackets"`
|
PaymentStatuses []string `url:"paymentStatuses,omitempty,brackets"`
|
||||||
PaymentTypes []string `url:"paymentTypes,omitempty,brackets"`
|
PaymentTypes []string `url:"paymentTypes,omitempty,brackets"`
|
||||||
DeliveryTypes []string `url:"deliveryTypes,omitempty,brackets"`
|
DeliveryTypes []string `url:"deliveryTypes,omitempty,brackets"`
|
||||||
|
DeliveryServices []string `url:"deliveryServices,omitempty,brackets"`
|
||||||
OrderMethods []string `url:"orderMethods,omitempty,brackets"`
|
OrderMethods []string `url:"orderMethods,omitempty,brackets"`
|
||||||
ShipmentStores []string `url:"shipmentStores,omitempty,brackets"`
|
ShipmentStores []string `url:"shipmentStores,omitempty,brackets"`
|
||||||
Couriers []string `url:"couriers,omitempty,brackets"`
|
Couriers []string `url:"couriers,omitempty,brackets"`
|
||||||
|
@ -207,6 +208,8 @@ type OrdersFilter struct {
|
||||||
Sites []string `url:"sites,omitempty,brackets"`
|
Sites []string `url:"sites,omitempty,brackets"`
|
||||||
CreatedAtFrom string `url:"createdAtFrom,omitempty"`
|
CreatedAtFrom string `url:"createdAtFrom,omitempty"`
|
||||||
CreatedAtTo string `url:"createdAtTo,omitempty"`
|
CreatedAtTo string `url:"createdAtTo,omitempty"`
|
||||||
|
PaidAtFrom string `url:"paidAtFrom,omitempty"`
|
||||||
|
PaidAtTo string `url:"paidAtTo,omitempty"`
|
||||||
FullPaidAtFrom string `url:"fullPaidAtFrom,omitempty"`
|
FullPaidAtFrom string `url:"fullPaidAtFrom,omitempty"`
|
||||||
FullPaidAtTo string `url:"fullPaidAtTo,omitempty"`
|
FullPaidAtTo string `url:"fullPaidAtTo,omitempty"`
|
||||||
DeliveryDateFrom string `url:"deliveryDateFrom,omitempty"`
|
DeliveryDateFrom string `url:"deliveryDateFrom,omitempty"`
|
||||||
|
@ -349,6 +352,7 @@ type ProductsFilter struct {
|
||||||
ExternalID string `url:"externalId,omitempty"`
|
ExternalID string `url:"externalId,omitempty"`
|
||||||
Manufacturer string `url:"manufacturer,omitempty"`
|
Manufacturer string `url:"manufacturer,omitempty"`
|
||||||
URL string `url:"url,omitempty"`
|
URL string `url:"url,omitempty"`
|
||||||
|
URLLike string `url:"urlLike,omitempty"`
|
||||||
PriceType string `url:"priceType,omitempty"`
|
PriceType string `url:"priceType,omitempty"`
|
||||||
OfferExternalID string `url:"offerExternalId,omitempty"`
|
OfferExternalID string `url:"offerExternalId,omitempty"`
|
||||||
Sites []string `url:"sites,omitempty,brackets"`
|
Sites []string `url:"sites,omitempty,brackets"`
|
||||||
|
@ -377,22 +381,22 @@ type ShipmentFilter struct {
|
||||||
|
|
||||||
// CostsFilter type.
|
// CostsFilter type.
|
||||||
type CostsFilter struct {
|
type CostsFilter struct {
|
||||||
MinSumm string `url:"minSumm,omitempty"`
|
MinSumm int `url:"minSumm,omitempty"`
|
||||||
MaxSumm string `url:"maxSumm,omitempty"`
|
MaxSumm int `url:"maxSumm,omitempty"`
|
||||||
OrderNumber string `url:"orderNumber,omitempty"`
|
OrderNumber string `url:"orderNumber,omitempty"`
|
||||||
Comment string `url:"orderNumber,omitempty"`
|
Comment string `url:"orderNumber,omitempty"`
|
||||||
Ids []string `url:"ids,omitempty,brackets"`
|
IDs []int `url:"ids,omitempty,brackets"`
|
||||||
Sites []string `url:"sites,omitempty,brackets"`
|
Sites []string `url:"sites,omitempty,brackets"`
|
||||||
CreatedBy []string `url:"createdBy,omitempty,brackets"`
|
CreatedBy []int `url:"createdBy,omitempty,brackets"`
|
||||||
CostGroups []string `url:"costGroups,omitempty,brackets"`
|
CostGroups []string `url:"costGroups,omitempty,brackets"`
|
||||||
CostItems []string `url:"costItems,omitempty,brackets"`
|
CostItems []string `url:"costItems,omitempty,brackets"`
|
||||||
Users []string `url:"users,omitempty,brackets"`
|
Users []int `url:"users,omitempty,brackets"`
|
||||||
DateFrom string `url:"dateFrom,omitempty"`
|
DateFrom string `url:"dateFrom,omitempty"`
|
||||||
DateTo string `url:"dateTo,omitempty"`
|
DateTo string `url:"dateTo,omitempty"`
|
||||||
CreatedAtFrom string `url:"createdAtFrom,omitempty"`
|
CreatedAtFrom string `url:"createdAtFrom,omitempty"`
|
||||||
CreatedAtTo string `url:"createdAtTo,omitempty"`
|
CreatedAtTo string `url:"createdAtTo,omitempty"`
|
||||||
OrderIds []string `url:"orderIds,omitempty,brackets"`
|
OrderIDs []int `url:"orderIds,omitempty,brackets"`
|
||||||
OrderExternalIds []string `url:"orderIds,omitempty,brackets"`
|
OrderExternalIDs []string `url:"orderExternalIds,omitempty,brackets"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// FilesFilter type.
|
// FilesFilter type.
|
||||||
|
@ -427,3 +431,67 @@ type CustomDictionariesFilter struct {
|
||||||
Name string `url:"name,omitempty"`
|
Name string `url:"name,omitempty"`
|
||||||
Code string `url:"code,omitempty"`
|
Code string `url:"code,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BonusOperationsFilter type.
|
||||||
|
type BonusOperationsFilter struct {
|
||||||
|
Loyalties []int `url:"loyalties,omitempty,brackets"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AccountBonusOperationsFilter struct {
|
||||||
|
CreatedAtFrom string `url:"createdAtFrom,omitempty"`
|
||||||
|
CreatedAtTo string `url:"createdAtTo,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type LoyaltyBonusAPIFilterType struct {
|
||||||
|
Date string `url:"date,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type LoyaltyAccountAPIFilter struct {
|
||||||
|
ID string `url:"id,omitempty"`
|
||||||
|
Status string `url:"status,,omitempty"`
|
||||||
|
Customer string `url:"customer,omitempty"`
|
||||||
|
MinOrderSum string `url:"minOrdersSum,omitempty"`
|
||||||
|
MaxOrderSum string `url:"maxOrdersSum,omitempty"`
|
||||||
|
MinAmount string `url:"minAmount,omitempty"`
|
||||||
|
MaxAmount string `url:"maxAmount,omitempty"`
|
||||||
|
PhoneNumber string `url:"phoneNumber,omitempty"`
|
||||||
|
CardNumber string `url:"cardNumber,omitempty"`
|
||||||
|
Ids []int `url:"ids,omitempty,brackets"`
|
||||||
|
Loyalties []int `url:"loyalties,omitempty,brackets"`
|
||||||
|
Sites []string `url:"sites,omitempty,brackets"`
|
||||||
|
Level int `url:"level,omitempty"`
|
||||||
|
CreatedAtFrom string `url:"createdAtFrom,omitempty"`
|
||||||
|
CreatedAtTo string `url:"createdAtTo,omitempty"`
|
||||||
|
BurnDateFrom string `url:"burnDateFrom,omitempty"`
|
||||||
|
BurnDateTo string `url:"burnDateTo,omitempty"`
|
||||||
|
CustomFields []string `url:"customFields,omitempty,brackets"`
|
||||||
|
CustomerID string `url:"customerId,omitempty"`
|
||||||
|
CustomerExternalID string `url:"customerExternalId,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type LoyaltyAPIFilter struct {
|
||||||
|
Active *int `url:"active,omitempty"`
|
||||||
|
Blocked *int `url:"blocked,omitempty"`
|
||||||
|
Ids []int `url:"ids,omitempty,brackets"`
|
||||||
|
Sites []string `url:"sites,omitempty,brackets"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type OffersFilter struct {
|
||||||
|
Ids []int `url:"ids,omitempty,brackets"`
|
||||||
|
Active *int `url:"active,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SiteFilter struct {
|
||||||
|
// SiteBy contains information about what is betrayed site id or site code.
|
||||||
|
// id|code, default is code.
|
||||||
|
SiteBy string `url:"siteBy,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetCartFilter struct {
|
||||||
|
// SiteBy contains information about what is betrayed site id or site code.
|
||||||
|
// id|code, default is code.
|
||||||
|
SiteBy string `url:"siteBy,omitempty"`
|
||||||
|
// By contains information about what is betrayed: customer id or customer externalId.
|
||||||
|
// id|externalId, default is externalId.
|
||||||
|
By string `url:"by,omitempty"`
|
||||||
|
}
|
||||||
|
|
|
@ -58,6 +58,30 @@ func (l *StringMap) UnmarshalJSON(data []byte) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (l *CustomFieldMap) UnmarshalJSON(data []byte) error {
|
||||||
|
var i interface{}
|
||||||
|
var items CustomFieldMap
|
||||||
|
if err := json.Unmarshal(data, &i); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
switch e := i.(type) {
|
||||||
|
case map[string]interface{}:
|
||||||
|
items = make(CustomFieldMap, len(e))
|
||||||
|
for idx, val := range e {
|
||||||
|
items[idx] = val
|
||||||
|
}
|
||||||
|
case []interface{}:
|
||||||
|
items = make(CustomFieldMap, len(e))
|
||||||
|
for idx, val := range e {
|
||||||
|
items[strconv.Itoa(idx)] = val
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*l = items
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (p *OrderPayments) UnmarshalJSON(data []byte) error {
|
func (p *OrderPayments) UnmarshalJSON(data []byte) error {
|
||||||
var i interface{}
|
var i interface{}
|
||||||
var m OrderPayments
|
var m OrderPayments
|
||||||
|
|
|
@ -44,7 +44,7 @@ func TestAPIErrorsList_UnmarshalJSON(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCustomFieldsList_UnmarshalJSON(t *testing.T) {
|
func TestCustomFieldsList_UnmarshalJSON(t *testing.T) {
|
||||||
var list StringMap
|
var list CustomFieldMap
|
||||||
|
|
||||||
require.NoError(t, json.Unmarshal([]byte(`["first", "second"]`), &list))
|
require.NoError(t, json.Unmarshal([]byte(`["first", "second"]`), &list))
|
||||||
assert.Len(t, list, 2)
|
assert.Len(t, list, 2)
|
||||||
|
@ -56,6 +56,13 @@ func TestCustomFieldsList_UnmarshalJSON(t *testing.T) {
|
||||||
assert.Equal(t, list["a"], "first")
|
assert.Equal(t, list["a"], "first")
|
||||||
assert.Equal(t, list["b"], "second")
|
assert.Equal(t, list["b"], "second")
|
||||||
|
|
||||||
|
require.NoError(t, json.Unmarshal([]byte(`{"a": ["first", "second"], "b": "second"}`), &list))
|
||||||
|
assert.Len(t, list, 2)
|
||||||
|
assert.Len(t, list["a"].([]interface{}), 2)
|
||||||
|
assert.Equal(t, list["a"].([]interface{})[0], "first")
|
||||||
|
assert.Equal(t, list["a"].([]interface{})[1], "second")
|
||||||
|
assert.Equal(t, list["b"], "second")
|
||||||
|
|
||||||
require.NoError(t, json.Unmarshal([]byte(`[]`), &list))
|
require.NoError(t, json.Unmarshal([]byte(`[]`), &list))
|
||||||
assert.Len(t, list, 0)
|
assert.Len(t, list, 0)
|
||||||
}
|
}
|
||||||
|
|
77
request.go
77
request.go
|
@ -194,6 +194,22 @@ type DeliveryShipmentsRequest struct {
|
||||||
Page int `url:"page,omitempty"`
|
Page int `url:"page,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ClearCartRequest type.
|
||||||
|
type ClearCartRequest struct {
|
||||||
|
ClearedAt string `url:"clearedAt,omitempty"`
|
||||||
|
Customer CartCustomer `url:"customer,omitempty"`
|
||||||
|
Order ClearCartOrder `url:"order,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetCartRequest type.
|
||||||
|
type SetCartRequest struct {
|
||||||
|
ExternalID string `url:"externalId,omitempty"`
|
||||||
|
DroppedAt string `url:"droppedAt,omitempty"`
|
||||||
|
Link string `url:"link,omitempty"`
|
||||||
|
Customer CartCustomer `url:"customer,omitempty"`
|
||||||
|
Items []SetCartItem `url:"items,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// CostsRequest type.
|
// CostsRequest type.
|
||||||
type CostsRequest struct {
|
type CostsRequest struct {
|
||||||
Filter CostsFilter `url:"filter,omitempty"`
|
Filter CostsFilter `url:"filter,omitempty"`
|
||||||
|
@ -232,6 +248,63 @@ type ConnectRequest struct {
|
||||||
URL string `json:"systemUrl"`
|
URL string `json:"systemUrl"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BonusOperationsRequest type.
|
||||||
|
type BonusOperationsRequest struct {
|
||||||
|
Filter BonusOperationsFilter `url:"filter,omitempty"`
|
||||||
|
Limit int `url:"limit,omitempty"`
|
||||||
|
Cursor string `url:"cursor,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// AccountBonusOperationsRequest type.
|
||||||
|
type AccountBonusOperationsRequest struct {
|
||||||
|
Filter AccountBonusOperationsFilter `url:"filter,omitempty"`
|
||||||
|
Limit int `url:"limit,omitempty"`
|
||||||
|
Page int `url:"page,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type LoyaltyBonusCreditRequest struct {
|
||||||
|
Amount float64 `url:"amount"`
|
||||||
|
ActivationDate string `url:"activationDate,omitempty"`
|
||||||
|
ExpiredDate string `url:"expireDate,omitempty"`
|
||||||
|
Comment string `url:"comment,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type LoyaltyBonusStatusDetailsRequest struct {
|
||||||
|
Limit int `url:"limit,omitempty"`
|
||||||
|
Page int `url:"page,omitempty"`
|
||||||
|
Filter LoyaltyBonusAPIFilterType `url:"filter,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type LoyaltyAccountsRequest struct {
|
||||||
|
Limit int `url:"limit,omitempty"`
|
||||||
|
Page int `url:"page,omitempty"`
|
||||||
|
Filter LoyaltyAccountAPIFilter `url:"filter,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type LoyaltyCalculateRequest struct {
|
||||||
|
Site string
|
||||||
|
Order Order
|
||||||
|
Bonuses float32
|
||||||
|
}
|
||||||
|
|
||||||
|
type LoyaltiesRequest struct {
|
||||||
|
Limit int `url:"limit,omitempty"`
|
||||||
|
Page int `url:"page,omitempty"`
|
||||||
|
Filter LoyaltyAPIFilter `url:"filter,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type NotificationsSendRequest struct {
|
||||||
|
UserGroups []UserGroupType `json:"userGroups,omitempty"`
|
||||||
|
Type NotificationType `json:"type"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
UserIDs []string `json:"userIds,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type EditMGChannelTemplateRequest struct {
|
||||||
|
Templates []MGChannelTemplate `json:"templates"`
|
||||||
|
Removed []int `json:"removed"`
|
||||||
|
}
|
||||||
|
|
||||||
// SystemURL returns system URL from the connection request without trailing slash.
|
// SystemURL returns system URL from the connection request without trailing slash.
|
||||||
func (r ConnectRequest) SystemURL() string {
|
func (r ConnectRequest) SystemURL() string {
|
||||||
if r.URL == "" {
|
if r.URL == "" {
|
||||||
|
@ -253,3 +326,7 @@ func (r ConnectRequest) Verify(secret string) bool {
|
||||||
}
|
}
|
||||||
return hmac.Equal([]byte(r.Token), []byte(hex.EncodeToString(mac.Sum(nil))))
|
return hmac.Equal([]byte(r.Token), []byte(hex.EncodeToString(mac.Sum(nil))))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type OffersRequest struct {
|
||||||
|
OffersFilter `url:"filter,omitempty"`
|
||||||
|
}
|
||||||
|
|
149
response.go
149
response.go
|
@ -2,7 +2,18 @@ package retailcrm
|
||||||
|
|
||||||
// SuccessfulResponse type.
|
// SuccessfulResponse type.
|
||||||
type SuccessfulResponse struct {
|
type SuccessfulResponse struct {
|
||||||
Success bool `json:"success,omitempty"`
|
Success bool `json:"success"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CreateLoyaltyAccountResponse struct {
|
||||||
|
SuccessfulResponse
|
||||||
|
LoyaltyAccount LoyaltyAccount `json:"loyaltyAccount,omitempty"`
|
||||||
|
Warnings []string `json:"warnings,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type EditLoyaltyAccountResponse struct {
|
||||||
|
SuccessfulResponse
|
||||||
|
LoyaltyAccount LoyaltyAccount `json:"loyaltyAccount,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateResponse type.
|
// CreateResponse type.
|
||||||
|
@ -112,6 +123,7 @@ type CorporateCustomerChangeResponse CustomerChangeResponse
|
||||||
type CustomersUploadResponse struct {
|
type CustomersUploadResponse struct {
|
||||||
Success bool `json:"success"`
|
Success bool `json:"success"`
|
||||||
UploadedCustomers []IdentifiersPair `json:"uploadedCustomers,omitempty"`
|
UploadedCustomers []IdentifiersPair `json:"uploadedCustomers,omitempty"`
|
||||||
|
FailedCustomers []ExternalID `json:"failedCustomers,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CorporateCustomersUploadResponse type.
|
// CorporateCustomersUploadResponse type.
|
||||||
|
@ -156,6 +168,7 @@ type OrdersStatusesResponse struct {
|
||||||
type OrdersUploadResponse struct {
|
type OrdersUploadResponse struct {
|
||||||
Success bool `json:"success"`
|
Success bool `json:"success"`
|
||||||
UploadedOrders []IdentifiersPair `json:"uploadedOrders,omitempty"`
|
UploadedOrders []IdentifiersPair `json:"uploadedOrders,omitempty"`
|
||||||
|
FailedOrders []ExternalID `json:"failedOrders,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// OrdersHistoryResponse type.
|
// OrdersHistoryResponse type.
|
||||||
|
@ -370,6 +383,23 @@ type ProductsResponse struct {
|
||||||
Products []Product `json:"products,omitempty"`
|
Products []Product `json:"products,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ProductEditNotFoundResponse struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
ExternalID string `json:"externalId,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProductsBatchEditResponse struct {
|
||||||
|
SuccessfulResponse
|
||||||
|
ProcessedProductsCount int `json:"processedProductsCount,omitempty"`
|
||||||
|
NotFoundProducts []ProductEditNotFoundResponse `json:"notFoundProducts,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProductsBatchCreateResponse struct {
|
||||||
|
SuccessfulResponse
|
||||||
|
ProcessedProductsCount int `json:"processedProductsCount,omitempty"`
|
||||||
|
AddedProducts []int `json:"addedProducts,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// ProductsPropertiesResponse type.
|
// ProductsPropertiesResponse type.
|
||||||
type ProductsPropertiesResponse struct {
|
type ProductsPropertiesResponse struct {
|
||||||
Success bool `json:"success"`
|
Success bool `json:"success"`
|
||||||
|
@ -377,6 +407,12 @@ type ProductsPropertiesResponse struct {
|
||||||
Properties []Property `json:"properties,omitempty"`
|
Properties []Property `json:"properties,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CartResponse type.
|
||||||
|
type CartResponse struct {
|
||||||
|
SuccessfulResponse
|
||||||
|
Cart Cart `json:"cart"`
|
||||||
|
}
|
||||||
|
|
||||||
// DeliveryShipmentsResponse type.
|
// DeliveryShipmentsResponse type.
|
||||||
type DeliveryShipmentsResponse struct {
|
type DeliveryShipmentsResponse struct {
|
||||||
Success bool `json:"success"`
|
Success bool `json:"success"`
|
||||||
|
@ -420,6 +456,7 @@ type ResponseInfo struct {
|
||||||
MgTransportInfo MgInfo `json:"mgTransport,omitempty"`
|
MgTransportInfo MgInfo `json:"mgTransport,omitempty"`
|
||||||
MgBotInfo MgInfo `json:"mgBot,omitempty"`
|
MgBotInfo MgInfo `json:"mgBot,omitempty"`
|
||||||
BillingInfo *BillingInfo `json:"billingInfo,omitempty"`
|
BillingInfo *BillingInfo `json:"billingInfo,omitempty"`
|
||||||
|
DeliveryTypeInfo DeliveryTypeInfo `json:"deliveryType,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type BillingInfo struct {
|
type BillingInfo struct {
|
||||||
|
@ -550,3 +587,113 @@ func NewConnectResponse(accountURL string) ConnectResponse {
|
||||||
AccountURL: accountURL,
|
AccountURL: accountURL,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BonusOperationsResponse type.
|
||||||
|
type BonusOperationsResponse struct {
|
||||||
|
Success bool `json:"success"`
|
||||||
|
Pagination *CursorPagination `json:"pagination,omitempty"`
|
||||||
|
BonusOperations []BonusOperation `json:"bonusOperations,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// AccountBonusOperationsResponse type.
|
||||||
|
type AccountBonusOperationsResponse struct {
|
||||||
|
Success bool `json:"success"`
|
||||||
|
Pagination *Pagination `json:"pagination,omitempty"`
|
||||||
|
BonusOperations []BonusOperation `json:"bonusOperations,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClientIDResponse type.
|
||||||
|
type ClientIDResponse struct {
|
||||||
|
ErrorMsg string `json:"errorMsg,omitempty"`
|
||||||
|
Errors map[string]string `json:"errors,omitempty"`
|
||||||
|
FailedClientIds []ClientID `json:"failed_client_ids,omitempty"`
|
||||||
|
Success bool `json:"success"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SourcesResponse type.
|
||||||
|
type SourcesResponse struct {
|
||||||
|
ErrorMsg string `json:"errorMsg,omitempty"`
|
||||||
|
Errors map[string]string `json:"errors,omitempty"`
|
||||||
|
FailedSources []Source `json:"failed_sources,omitempty"`
|
||||||
|
Success bool `json:"success"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CurrencyResponse type.
|
||||||
|
type CurrencyResponse struct {
|
||||||
|
Currencies []Currency `json:"currencies,omitempty"`
|
||||||
|
Success bool `json:"success"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CurrencyCreateResponse type.
|
||||||
|
type CurrencyCreateResponse struct {
|
||||||
|
Success bool `json:"success"`
|
||||||
|
ID int `json:"id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type LoyaltyAccountResponse struct {
|
||||||
|
SuccessfulResponse
|
||||||
|
LoyaltyAccount `json:"loyaltyAccount"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type LoyaltyAccountActivateResponse struct {
|
||||||
|
SuccessfulResponse
|
||||||
|
LoyaltyAccount `json:"loyaltyAccount"`
|
||||||
|
Verification SmsVerification `json:"verification,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type LoyaltyBonusCreditResponse struct {
|
||||||
|
SuccessfulResponse
|
||||||
|
LoyaltyBonus LoyaltyBonus `json:"loyaltyBonus"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type LoyaltyBonusDetailsResponse struct {
|
||||||
|
SuccessfulResponse
|
||||||
|
Pagination `json:"pagination"`
|
||||||
|
Statistic LoyaltyBonusStatisticResponse `json:"statistic"`
|
||||||
|
Bonuses []BonusDetail `json:"bonuses,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type LoyaltyBonusStatisticResponse struct {
|
||||||
|
TotalAmount float64 `json:"totalAmount"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type LoyaltyAccountsResponse struct {
|
||||||
|
SuccessfulResponse
|
||||||
|
Pagination *Pagination `json:"pagination"`
|
||||||
|
LoyaltyAccounts []LoyaltyAccount `json:"loyaltyAccounts,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type LoyaltyCalculateResponse struct {
|
||||||
|
SuccessfulResponse
|
||||||
|
Order SerializedLoyaltyOrder `json:"order,omitempty"`
|
||||||
|
Calculations []LoyaltyCalculation `json:"calculations,omitempty"`
|
||||||
|
Loyalty SerializedLoyalty `json:"loyalty,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type LoyaltiesResponse struct {
|
||||||
|
SuccessfulResponse
|
||||||
|
Pagination *Pagination `json:"pagination"`
|
||||||
|
Loyalties []Loyalty `json:"loyalties,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type LoyaltyResponse struct {
|
||||||
|
SuccessfulResponse
|
||||||
|
Loyalty Loyalty `json:"loyalty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ActionProductsGroupResponse struct {
|
||||||
|
SuccessfulResponse
|
||||||
|
ID int `json:"id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type MGChannelTemplatesResponse struct {
|
||||||
|
Pagination *Pagination `json:"pagination"`
|
||||||
|
Templates []MGChannelTemplate `json:"templates"`
|
||||||
|
SuccessfulResponse
|
||||||
|
}
|
||||||
|
|
||||||
|
type StoreOffersResponse struct {
|
||||||
|
Pagination *Pagination `json:"pagination"`
|
||||||
|
SuccessfulResponse
|
||||||
|
Offers []Offer `json:"offers,omitempty"`
|
||||||
|
}
|
||||||
|
|
30
system_time.go
Normal file
30
system_time.go
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
package retailcrm
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SystemTime time.Time
|
||||||
|
|
||||||
|
const systemTimeLayout = "2006-01-02 15:04:05"
|
||||||
|
|
||||||
|
// UnmarshalJSON parses time.Time from system format.
|
||||||
|
func (st *SystemTime) UnmarshalJSON(b []byte) (err error) {
|
||||||
|
s := strings.Trim(string(b), `"`)
|
||||||
|
nt, err := time.Parse(systemTimeLayout, s)
|
||||||
|
*st = SystemTime(nt)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalJSON will marshal time.Time to system format.
|
||||||
|
func (st SystemTime) MarshalJSON() ([]byte, error) {
|
||||||
|
return []byte(st.String()), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// String returns the time in the custom format.
|
||||||
|
func (st *SystemTime) String() string {
|
||||||
|
t := time.Time(*st)
|
||||||
|
return fmt.Sprintf("%q", t.Format(systemTimeLayout))
|
||||||
|
}
|
122
template.go
Normal file
122
template.go
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
package retailcrm
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// TemplateItemTypeText is a type for text chunk in template.
|
||||||
|
TemplateItemTypeText uint8 = iota
|
||||||
|
// TemplateItemTypeVar is a type for variable in template.
|
||||||
|
TemplateItemTypeVar
|
||||||
|
QuickReply ButtonType = "QUICK_REPLY"
|
||||||
|
PhoneNumber ButtonType = "PHONE_NUMBER"
|
||||||
|
URL ButtonType = "URL"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// TemplateVarCustom is a custom variable type.
|
||||||
|
TemplateVarCustom = "custom"
|
||||||
|
// TemplateVarName is a name variable type.
|
||||||
|
TemplateVarName = "name"
|
||||||
|
// TemplateVarFirstName is a first name variable type.
|
||||||
|
TemplateVarFirstName = "first_name"
|
||||||
|
// TemplateVarLastName is a last name variable type.
|
||||||
|
TemplateVarLastName = "last_name"
|
||||||
|
)
|
||||||
|
|
||||||
|
// templateVarAssoc for checking variable validity, only for internal use.
|
||||||
|
var templateVarAssoc = map[string]interface{}{
|
||||||
|
TemplateVarCustom: nil,
|
||||||
|
TemplateVarName: nil,
|
||||||
|
TemplateVarFirstName: nil,
|
||||||
|
TemplateVarLastName: nil,
|
||||||
|
}
|
||||||
|
|
||||||
|
type Text struct {
|
||||||
|
Parts []TextTemplateItem `json:"parts"`
|
||||||
|
Example []string `json:"example,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Media struct {
|
||||||
|
Example string `json:"example,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Header struct {
|
||||||
|
Text *Text `json:"text,omitempty"`
|
||||||
|
Document *Media `json:"document,omitempty"`
|
||||||
|
Image *Media `json:"image,omitempty"`
|
||||||
|
Video *Media `json:"video,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type TemplateItemList []TextTemplateItem
|
||||||
|
|
||||||
|
// TextTemplateItem is a part of template.
|
||||||
|
type TextTemplateItem struct {
|
||||||
|
Text string
|
||||||
|
VarType string
|
||||||
|
Type uint8
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalJSON controls how TextTemplateItem will be marshaled into JSON.
|
||||||
|
func (t TextTemplateItem) MarshalJSON() ([]byte, error) {
|
||||||
|
switch t.Type {
|
||||||
|
case TemplateItemTypeText:
|
||||||
|
return json.Marshal(t.Text)
|
||||||
|
case TemplateItemTypeVar:
|
||||||
|
return json.Marshal(map[string]interface{}{
|
||||||
|
"var": t.VarType,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, errors.New("unknown TextTemplateItem type")
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalJSON will correctly unmarshal TextTemplateItem.
|
||||||
|
func (t *TextTemplateItem) UnmarshalJSON(b []byte) error {
|
||||||
|
var obj interface{}
|
||||||
|
err := json.Unmarshal(b, &obj)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
switch bodyPart := obj.(type) {
|
||||||
|
case string:
|
||||||
|
t.Type = TemplateItemTypeText
|
||||||
|
t.Text = bodyPart
|
||||||
|
case map[string]interface{}:
|
||||||
|
// {} case
|
||||||
|
if len(bodyPart) == 0 {
|
||||||
|
t.Type = TemplateItemTypeText
|
||||||
|
t.Text = "{}"
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if varTypeCurr, ok := bodyPart["var"].(string); ok {
|
||||||
|
if _, ok := templateVarAssoc[varTypeCurr]; !ok {
|
||||||
|
return fmt.Errorf("invalid placeholder var '%s'", varTypeCurr)
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Type = TemplateItemTypeVar
|
||||||
|
t.VarType = varTypeCurr
|
||||||
|
} else {
|
||||||
|
return errors.New("invalid TextTemplateItem")
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return errors.New("invalid TextTemplateItem")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type ButtonType string
|
||||||
|
|
||||||
|
type Button struct {
|
||||||
|
Type ButtonType `json:"type"`
|
||||||
|
URL string `json:"url,omitempty"`
|
||||||
|
Text string `json:"text,omitempty"`
|
||||||
|
PhoneNumber string `json:"phoneNumber,omitempty"`
|
||||||
|
Example []string `json:"example,omitempty"`
|
||||||
|
}
|
565
testutils.go
Normal file
565
testutils.go
Normal file
|
@ -0,0 +1,565 @@
|
||||||
|
//go:build testutils
|
||||||
|
// +build testutils
|
||||||
|
|
||||||
|
package retailcrm
|
||||||
|
|
||||||
|
func getProductsCreate() []ProductCreate {
|
||||||
|
products := []ProductCreate{
|
||||||
|
{
|
||||||
|
CatalogID: 3,
|
||||||
|
BaseProduct: BaseProduct{
|
||||||
|
Name: "Product 1",
|
||||||
|
URL: "https://example.com/p/1",
|
||||||
|
Article: "p1",
|
||||||
|
ExternalID: "ext1",
|
||||||
|
Manufacturer: "man1",
|
||||||
|
Description: "Description 1",
|
||||||
|
Popular: true,
|
||||||
|
Stock: true,
|
||||||
|
Novelty: true,
|
||||||
|
Recommended: true,
|
||||||
|
Active: true,
|
||||||
|
Markable: true,
|
||||||
|
},
|
||||||
|
Groups: []ProductEditGroupInput{{ID: 19}},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
CatalogID: 3,
|
||||||
|
BaseProduct: BaseProduct{
|
||||||
|
Name: "Product 2",
|
||||||
|
URL: "https://example.com/p/2",
|
||||||
|
Article: "p2",
|
||||||
|
ExternalID: "ext2",
|
||||||
|
Manufacturer: "man2",
|
||||||
|
Description: "Description 2",
|
||||||
|
Popular: true,
|
||||||
|
Stock: true,
|
||||||
|
Novelty: true,
|
||||||
|
Recommended: true,
|
||||||
|
Active: true,
|
||||||
|
Markable: true,
|
||||||
|
},
|
||||||
|
Groups: []ProductEditGroupInput{{ID: 19}},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return products
|
||||||
|
}
|
||||||
|
|
||||||
|
func getProductsCreateResponse() ProductsBatchCreateResponse {
|
||||||
|
return ProductsBatchCreateResponse{
|
||||||
|
SuccessfulResponse: SuccessfulResponse{Success: true},
|
||||||
|
ProcessedProductsCount: 2,
|
||||||
|
AddedProducts: []int{1, 2},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getProductsEdit() []ProductEdit {
|
||||||
|
products := []ProductEdit{
|
||||||
|
{
|
||||||
|
BaseProduct: getProductsCreate()[0].BaseProduct,
|
||||||
|
ID: 194,
|
||||||
|
CatalogID: 3,
|
||||||
|
Site: "second",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
BaseProduct: getProductsCreate()[1].BaseProduct,
|
||||||
|
ID: 195,
|
||||||
|
CatalogID: 3,
|
||||||
|
Site: "second",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return products
|
||||||
|
}
|
||||||
|
|
||||||
|
func getProductsEditResponse() ProductsBatchEditResponse {
|
||||||
|
return ProductsBatchEditResponse{
|
||||||
|
SuccessfulResponse: SuccessfulResponse{Success: true},
|
||||||
|
ProcessedProductsCount: 2,
|
||||||
|
NotFoundProducts: nil,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getLoyaltyAccountCreate() SerializedCreateLoyaltyAccount {
|
||||||
|
return SerializedCreateLoyaltyAccount{
|
||||||
|
SerializedBaseLoyaltyAccount: SerializedBaseLoyaltyAccount{
|
||||||
|
PhoneNumber: "89151005004",
|
||||||
|
CustomFields: []interface{}{"dog"},
|
||||||
|
},
|
||||||
|
Customer: SerializedEntityCustomer{
|
||||||
|
ID: 123,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getLoyaltyAccountCreateResponse() CreateLoyaltyAccountResponse {
|
||||||
|
return CreateLoyaltyAccountResponse{
|
||||||
|
SuccessfulResponse: SuccessfulResponse{Success: true},
|
||||||
|
LoyaltyAccount: LoyaltyAccount{
|
||||||
|
Active: true,
|
||||||
|
ID: 13,
|
||||||
|
PhoneNumber: "89151005004",
|
||||||
|
LoyaltyLevel: LoyaltyLevel{},
|
||||||
|
CreatedAt: "2022-11-24 12:39:37",
|
||||||
|
ActivatedAt: "2022-11-24 12:39:37",
|
||||||
|
CustomFields: map[string]interface{}{
|
||||||
|
"animal": "dog",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getLoyaltyAccountEditResponse() EditLoyaltyAccountResponse {
|
||||||
|
return EditLoyaltyAccountResponse{
|
||||||
|
SuccessfulResponse: SuccessfulResponse{Success: true},
|
||||||
|
LoyaltyAccount: LoyaltyAccount{
|
||||||
|
Active: true,
|
||||||
|
ID: 13,
|
||||||
|
PhoneNumber: "89142221020",
|
||||||
|
LoyaltyLevel: LoyaltyLevel{},
|
||||||
|
CreatedAt: "2022-11-24 12:39:37",
|
||||||
|
ActivatedAt: "2022-11-24 12:39:37",
|
||||||
|
CustomFields: map[string]interface{}{
|
||||||
|
"animal": "dog",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getLoyaltyAccountResponse() string {
|
||||||
|
return `{
|
||||||
|
"success": true,
|
||||||
|
"loyaltyAccount": {
|
||||||
|
"active": true,
|
||||||
|
"id": 13,
|
||||||
|
"loyalty": {
|
||||||
|
"id": 2
|
||||||
|
},
|
||||||
|
"customer": {
|
||||||
|
"id": 123,
|
||||||
|
"customFields": {},
|
||||||
|
"firstName": "Руслан1",
|
||||||
|
"lastName": "Ефанов",
|
||||||
|
"patronymic": ""
|
||||||
|
},
|
||||||
|
"phoneNumber": "89142221020",
|
||||||
|
"amount": 0,
|
||||||
|
"ordersSum": 0,
|
||||||
|
"nextLevelSum": 10000,
|
||||||
|
"level": {
|
||||||
|
"type": "bonus_percent",
|
||||||
|
"id": 5,
|
||||||
|
"name": "Новичок",
|
||||||
|
"sum": 0,
|
||||||
|
"privilegeSize": 5,
|
||||||
|
"privilegeSizePromo": 3
|
||||||
|
},
|
||||||
|
"createdAt": "2022-11-24 12:39:37",
|
||||||
|
"activatedAt": "2022-11-24 12:39:37",
|
||||||
|
"status": "activated",
|
||||||
|
"customFields": {
|
||||||
|
"custom_multiselect": ["test1", "test3"],
|
||||||
|
"custom_select": "test2",
|
||||||
|
"custom_integer": 456,
|
||||||
|
"custom_float": 8.43
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`
|
||||||
|
}
|
||||||
|
|
||||||
|
func getBonusDetailsResponse() string {
|
||||||
|
return `{
|
||||||
|
"success": true,
|
||||||
|
"pagination": {
|
||||||
|
"limit": 20,
|
||||||
|
"totalCount": 41,
|
||||||
|
"currentPage": 3,
|
||||||
|
"totalPageCount": 3
|
||||||
|
},
|
||||||
|
"statistic": {
|
||||||
|
"totalAmount": 240
|
||||||
|
},
|
||||||
|
"bonuses": [
|
||||||
|
{
|
||||||
|
"date": "2022-12-08",
|
||||||
|
"amount": 240
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}`
|
||||||
|
}
|
||||||
|
|
||||||
|
func getLoyaltyAccountsResponse() string {
|
||||||
|
return `{
|
||||||
|
"success": true,
|
||||||
|
"pagination": {
|
||||||
|
"limit": 20,
|
||||||
|
"totalCount": 1,
|
||||||
|
"currentPage": 1,
|
||||||
|
"totalPageCount": 1
|
||||||
|
},
|
||||||
|
"loyaltyAccounts": [
|
||||||
|
{
|
||||||
|
"active": true,
|
||||||
|
"id": 14,
|
||||||
|
"loyalty": {
|
||||||
|
"id": 2
|
||||||
|
},
|
||||||
|
"customer": {
|
||||||
|
"id": 109,
|
||||||
|
"firstName": "Казимир",
|
||||||
|
"lastName": "Эльбрусов"
|
||||||
|
},
|
||||||
|
"phoneNumber": "89185556363",
|
||||||
|
"amount": 0,
|
||||||
|
"ordersSum": 0,
|
||||||
|
"nextLevelSum": 10000,
|
||||||
|
"level": {
|
||||||
|
"type": "bonus_percent",
|
||||||
|
"id": 5,
|
||||||
|
"name": "Новичок",
|
||||||
|
"sum": 0,
|
||||||
|
"privilegeSize": 5,
|
||||||
|
"privilegeSizePromo": 3
|
||||||
|
},
|
||||||
|
"createdAt": "2022-12-07 15:27:04",
|
||||||
|
"activatedAt": "2022-12-07 15:27:04",
|
||||||
|
"status": "activated"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}`
|
||||||
|
}
|
||||||
|
|
||||||
|
func getLoyaltyCalculateReq() LoyaltyCalculateRequest {
|
||||||
|
return LoyaltyCalculateRequest{
|
||||||
|
Site: "main",
|
||||||
|
Order: Order{
|
||||||
|
PrivilegeType: "loyalty_level",
|
||||||
|
Customer: &Customer{
|
||||||
|
ID: 123,
|
||||||
|
},
|
||||||
|
Items: []OrderItem{
|
||||||
|
{
|
||||||
|
InitialPrice: 10000,
|
||||||
|
Quantity: 1,
|
||||||
|
Offer: Offer{ID: 214},
|
||||||
|
PriceType: &PriceType{Code: "base"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Bonuses: 10,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getLoyaltyCalculateResponse() string {
|
||||||
|
return `{
|
||||||
|
"success": true,
|
||||||
|
"order": {
|
||||||
|
"bonusesCreditTotal": 999,
|
||||||
|
"bonusesChargeTotal": 10,
|
||||||
|
"privilegeType": "loyalty_level",
|
||||||
|
"totalSumm": 9990,
|
||||||
|
"loyaltyAccount": {
|
||||||
|
"id": 13,
|
||||||
|
"amount": 240
|
||||||
|
},
|
||||||
|
"loyaltyLevel": {
|
||||||
|
"id": 6,
|
||||||
|
"name": "Любитель"
|
||||||
|
},
|
||||||
|
"customer": {
|
||||||
|
"id": 123,
|
||||||
|
"personalDiscount": 0
|
||||||
|
},
|
||||||
|
"delivery": {
|
||||||
|
"cost": 0
|
||||||
|
},
|
||||||
|
"site": "main",
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"bonusesChargeTotal": 10,
|
||||||
|
"bonusesCreditTotal": 999,
|
||||||
|
"priceType": {
|
||||||
|
"code": "base"
|
||||||
|
},
|
||||||
|
"initialPrice": 10000,
|
||||||
|
"discounts": [
|
||||||
|
{
|
||||||
|
"type": "bonus_charge",
|
||||||
|
"amount": 10
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"discountTotal": 10,
|
||||||
|
"prices": [
|
||||||
|
{
|
||||||
|
"price": 9990,
|
||||||
|
"quantity": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"quantity": 1,
|
||||||
|
"offer": {
|
||||||
|
"xmlId": "696999ed-bc8d-4d0f-9627-527acf7b1d57"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"calculations": [
|
||||||
|
{
|
||||||
|
"privilegeType": "loyalty_level",
|
||||||
|
"discount": 10,
|
||||||
|
"creditBonuses": 999,
|
||||||
|
"maxChargeBonuses": 240,
|
||||||
|
"maximum": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"privilegeType": "none",
|
||||||
|
"discount": 10,
|
||||||
|
"creditBonuses": 0,
|
||||||
|
"maxChargeBonuses": 240,
|
||||||
|
"maximum": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"loyalty": {
|
||||||
|
"name": "Бонусная программа",
|
||||||
|
"chargeRate": 1
|
||||||
|
}
|
||||||
|
}`
|
||||||
|
}
|
||||||
|
|
||||||
|
func getLoyaltiesResponse() string {
|
||||||
|
return `{
|
||||||
|
"success": true,
|
||||||
|
"pagination": {
|
||||||
|
"limit": 20,
|
||||||
|
"totalCount": 1,
|
||||||
|
"currentPage": 1,
|
||||||
|
"totalPageCount": 1
|
||||||
|
},
|
||||||
|
"loyalties": [
|
||||||
|
{
|
||||||
|
"levels": [
|
||||||
|
{
|
||||||
|
"type": "bonus_percent",
|
||||||
|
"id": 5,
|
||||||
|
"name": "Новичок",
|
||||||
|
"sum": 0,
|
||||||
|
"privilegeSize": 5,
|
||||||
|
"privilegeSizePromo": 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "bonus_percent",
|
||||||
|
"id": 6,
|
||||||
|
"name": "Любитель",
|
||||||
|
"sum": 10000,
|
||||||
|
"privilegeSize": 10,
|
||||||
|
"privilegeSizePromo": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "bonus_percent",
|
||||||
|
"id": 7,
|
||||||
|
"name": "Продвинутый покупатель",
|
||||||
|
"sum": 25000,
|
||||||
|
"privilegeSize": 15,
|
||||||
|
"privilegeSizePromo": 7
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "bonus_percent",
|
||||||
|
"id": 8,
|
||||||
|
"name": "Мастер шоппинга",
|
||||||
|
"sum": 50000,
|
||||||
|
"privilegeSize": 20,
|
||||||
|
"privilegeSizePromo": 10
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"active": true,
|
||||||
|
"blocked": false,
|
||||||
|
"id": 2,
|
||||||
|
"name": "Бонусная программа",
|
||||||
|
"confirmSmsCharge": false,
|
||||||
|
"confirmSmsRegistration": false,
|
||||||
|
"createdAt": "2022-01-18 15:40:22",
|
||||||
|
"activatedAt": "2022-12-08 12:05:45"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}`
|
||||||
|
}
|
||||||
|
|
||||||
|
func getLoyaltyResponse() string {
|
||||||
|
return `{
|
||||||
|
"success": true,
|
||||||
|
"loyalty": {
|
||||||
|
"levels": [
|
||||||
|
{
|
||||||
|
"type": "bonus_percent",
|
||||||
|
"id": 5,
|
||||||
|
"name": "Новичок",
|
||||||
|
"sum": 0,
|
||||||
|
"privilegeSize": 5,
|
||||||
|
"privilegeSizePromo": 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "bonus_percent",
|
||||||
|
"id": 6,
|
||||||
|
"name": "Любитель",
|
||||||
|
"sum": 10000,
|
||||||
|
"privilegeSize": 10,
|
||||||
|
"privilegeSizePromo": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "bonus_percent",
|
||||||
|
"id": 7,
|
||||||
|
"name": "Продвинутый покупатель",
|
||||||
|
"sum": 25000,
|
||||||
|
"privilegeSize": 15,
|
||||||
|
"privilegeSizePromo": 7
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "bonus_percent",
|
||||||
|
"id": 8,
|
||||||
|
"name": "Мастер шоппинга",
|
||||||
|
"sum": 50000,
|
||||||
|
"privilegeSize": 20,
|
||||||
|
"privilegeSizePromo": 10
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"active": true,
|
||||||
|
"blocked": false,
|
||||||
|
"id": 2,
|
||||||
|
"name": "Бонусная программа",
|
||||||
|
"confirmSmsCharge": false,
|
||||||
|
"confirmSmsRegistration": false,
|
||||||
|
"createdAt": "2022-01-18 15:40:22",
|
||||||
|
"activatedAt": "2022-12-08 12:05:45"
|
||||||
|
}
|
||||||
|
}`
|
||||||
|
}
|
||||||
|
|
||||||
|
func getMGTemplatesResponse() string {
|
||||||
|
return `{
|
||||||
|
"success": true,
|
||||||
|
"pagination": {
|
||||||
|
"limit": 10,
|
||||||
|
"totalCount": 100,
|
||||||
|
"currentPage": 5,
|
||||||
|
"totalPageCount": 10
|
||||||
|
},
|
||||||
|
"templates": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"externalId": 0,
|
||||||
|
"channel": {
|
||||||
|
"allowedSendByPhone": false,
|
||||||
|
"id": 1,
|
||||||
|
"externalId": 1,
|
||||||
|
"type": "fbmessenger",
|
||||||
|
"active": true,
|
||||||
|
"name": "fbmessenger"
|
||||||
|
},
|
||||||
|
"code": "namespace#NAMEAAA#ru",
|
||||||
|
"name": "NAMEAAA",
|
||||||
|
"active": true,
|
||||||
|
"template": [
|
||||||
|
"Text_0",
|
||||||
|
{
|
||||||
|
"var": "custom"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"templateExample": ["Text_1"],
|
||||||
|
"namespace": "namespace_0",
|
||||||
|
"lang": "en",
|
||||||
|
"category": "test_0",
|
||||||
|
"header": {
|
||||||
|
"text": {
|
||||||
|
"parts": [
|
||||||
|
"JABAAA",
|
||||||
|
{
|
||||||
|
"var": "custom"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"example": [
|
||||||
|
"AAAAAA"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"image": {
|
||||||
|
"example": "https://example.com/file/123.png"
|
||||||
|
},
|
||||||
|
"document": {
|
||||||
|
"example": "https://example.com/file/123.pdf"
|
||||||
|
},
|
||||||
|
"video": {
|
||||||
|
"example": "https://example.com/file/123.mp4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"footer": "footer_0",
|
||||||
|
"buttons": [
|
||||||
|
{
|
||||||
|
"type": "PHONE_NUMBER",
|
||||||
|
"text": "your-phone-button-text",
|
||||||
|
"phoneNumber": "+79895553535"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "QUICK_REPLY",
|
||||||
|
"text": "Yes"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "URL",
|
||||||
|
"url": "https://example.com/file/{{1}}",
|
||||||
|
"text": "button",
|
||||||
|
"example": [
|
||||||
|
"https://www.website.com/dynamic-url-example"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"verificationStatus": "APPROVED"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}`
|
||||||
|
}
|
||||||
|
|
||||||
|
func getMGTemplatesForEdit() string {
|
||||||
|
return `[{"header":{"text":{"parts":["Hello,",{"var":"custom"}],"example":["Henry"]},"document":{"example":"https://example.com/file/123.pdf"},"image":{"example":"https://example.com/file/123.png"},"video":{"example":"https://example.com/file/123.mp4"}},"lang":"en","category":"test_0","code":"namespace#name_0#ru","name":"name_0","namespace":"namespace","footer":"footer_0","verificationStatus":"REJECTED","template":["Text_0",{"var":"custom"}],"buttons":[{"type":"PHONE_NUMBER","text":"your-phone-button-text","phoneNumber":"+79895553535"},{"type":"QUICK_REPLY","text":"Yes"},{"type":"URL","url":"https://example.com/file/{{1}}","text":"button","example":["https://www.website.com/dynamic-url-example"]}],"templateExample":["WIU"],"id":1,"externalId":10,"mgChannelId":110,"active":true}]`
|
||||||
|
}
|
||||||
|
|
||||||
|
func getStoreOfferResponse() string {
|
||||||
|
return `{
|
||||||
|
"success": true,
|
||||||
|
"pagination": {
|
||||||
|
"limit": 20,
|
||||||
|
"totalCount": 1,
|
||||||
|
"currentPage": 1,
|
||||||
|
"totalPageCount": 1
|
||||||
|
},
|
||||||
|
"offers": [
|
||||||
|
{
|
||||||
|
"images": [
|
||||||
|
"https://s3-s1.retailcrm.tech/ru-central1/retailcrm/dev-vega-d32aea7f9a5bc26eba6ad986077cea03/product/65a92fa0bb737-test.jpeg"
|
||||||
|
],
|
||||||
|
"id": 76,
|
||||||
|
"site": "main",
|
||||||
|
"name": "Название\nПеревод строки",
|
||||||
|
"article": "Артикул",
|
||||||
|
"product": {
|
||||||
|
"type": "product",
|
||||||
|
"catalogId": 2,
|
||||||
|
"id": 222
|
||||||
|
},
|
||||||
|
"prices": [
|
||||||
|
{
|
||||||
|
"priceType": "base",
|
||||||
|
"price": 10000,
|
||||||
|
"ordering": 991,
|
||||||
|
"currency": "RUB"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"purchasePrice": 10,
|
||||||
|
"quantity": 5,
|
||||||
|
"active": true,
|
||||||
|
"unit": {
|
||||||
|
"code": "pc",
|
||||||
|
"name": "Штука",
|
||||||
|
"sym": "шт."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}`
|
||||||
|
}
|
579
types.go
579
types.go
|
@ -5,14 +5,28 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ByID is "id" constant to use as `by` property in methods.
|
// ByID is "id" constant to use as `by` property in methods.
|
||||||
const ByID = "id"
|
const ByID = "id"
|
||||||
|
|
||||||
// ByExternalId is "externalId" constant to use as `by` property in methods.
|
// ByExternalID is "externalId" constant to use as `by` property in methods.
|
||||||
const ByExternalID = "externalId"
|
const ByExternalID = "externalId"
|
||||||
|
|
||||||
|
// RateLimiter configuration constants.
|
||||||
|
const (
|
||||||
|
regularPathRPS = 10 // API rate limit (requests per second).
|
||||||
|
telephonyPathRPS = 40 // Telephony API endpoints rate limit (requests per second).
|
||||||
|
regularDelay = time.Second / regularPathRPS // Delay between regular requests.
|
||||||
|
telephonyDelay = time.Second / telephonyPathRPS // Delay between telephony requests.
|
||||||
|
)
|
||||||
|
|
||||||
|
// HTTPStatusUnknown can return for the method `/api/v5/customers/upload`, `/api/v5/customers-corporate/upload`,
|
||||||
|
// `/api/v5/orders/upload`.
|
||||||
|
const HTTPStatusUnknown = 460
|
||||||
|
|
||||||
// Client type.
|
// Client type.
|
||||||
type Client struct {
|
type Client struct {
|
||||||
URL string
|
URL string
|
||||||
|
@ -20,6 +34,15 @@ type Client struct {
|
||||||
Debug bool
|
Debug bool
|
||||||
httpClient *http.Client
|
httpClient *http.Client
|
||||||
logger BasicLogger
|
logger BasicLogger
|
||||||
|
limiter *RateLimiter
|
||||||
|
mutex sync.Mutex
|
||||||
|
}
|
||||||
|
|
||||||
|
// RateLimiter manages API request rates to prevent hitting rate limits.
|
||||||
|
type RateLimiter struct {
|
||||||
|
maxAttempts uint // Maximum number of retry attempts (0 = infinite).
|
||||||
|
lastRequest time.Time // Time of the last request.
|
||||||
|
mutex sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pagination type.
|
// Pagination type.
|
||||||
|
@ -53,13 +76,16 @@ type Address struct {
|
||||||
Text string `json:"text,omitempty"`
|
Text string `json:"text,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GeoID type. Can be empty string.
|
||||||
|
type GeoID json.Number
|
||||||
|
|
||||||
// GeoHierarchyRow type.
|
// GeoHierarchyRow type.
|
||||||
type GeoHierarchyRow struct {
|
type GeoHierarchyRow struct {
|
||||||
Country string `json:"country,omitempty"`
|
Country string `json:"country,omitempty"`
|
||||||
Region string `json:"region,omitempty"`
|
Region string `json:"region,omitempty"`
|
||||||
RegionID int `json:"regionId,omitempty"`
|
RegionID GeoID `json:"regionId,omitempty"`
|
||||||
City string `json:"city,omitempty"`
|
City string `json:"city,omitempty"`
|
||||||
CityID int `json:"cityId,omitempty"`
|
CityID GeoID `json:"cityId,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Source type.
|
// Source type.
|
||||||
|
@ -69,6 +95,10 @@ type Source struct {
|
||||||
Campaign string `json:"campaign,omitempty"`
|
Campaign string `json:"campaign,omitempty"`
|
||||||
Keyword string `json:"keyword,omitempty"`
|
Keyword string `json:"keyword,omitempty"`
|
||||||
Content string `json:"content,omitempty"`
|
Content string `json:"content,omitempty"`
|
||||||
|
ClientID string `json:"client_id,omitempty"`
|
||||||
|
Site string `json:"site,omitempty"`
|
||||||
|
Order LinkedOrder `json:"order,omitempty"`
|
||||||
|
Customer SerializedEntityCustomer `json:"customer,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Contragent type.
|
// Contragent type.
|
||||||
|
@ -155,7 +185,7 @@ type Customer struct {
|
||||||
BrowserID string `json:"browserId,omitempty"`
|
BrowserID string `json:"browserId,omitempty"`
|
||||||
MgCustomerID string `json:"mgCustomerId,omitempty"`
|
MgCustomerID string `json:"mgCustomerId,omitempty"`
|
||||||
PhotoURL string `json:"photoUrl,omitempty"`
|
PhotoURL string `json:"photoUrl,omitempty"`
|
||||||
CustomFields StringMap `json:"customFields,omitempty"`
|
CustomFields CustomFieldMap `json:"customFields,omitempty"`
|
||||||
Tags []Tag `json:"tags,omitempty"`
|
Tags []Tag `json:"tags,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +197,7 @@ type CorporateCustomer struct {
|
||||||
CreatedAt string `json:"createdAt,omitempty"`
|
CreatedAt string `json:"createdAt,omitempty"`
|
||||||
Vip bool `json:"vip,omitempty"`
|
Vip bool `json:"vip,omitempty"`
|
||||||
Bad bool `json:"bad,omitempty"`
|
Bad bool `json:"bad,omitempty"`
|
||||||
CustomFields StringMap `json:"customFields,omitempty"`
|
CustomFields CustomFieldMap `json:"customFields,omitempty"`
|
||||||
PersonalDiscount float32 `json:"personalDiscount,omitempty"`
|
PersonalDiscount float32 `json:"personalDiscount,omitempty"`
|
||||||
DiscountCardNumber string `json:"discountCardNumber,omitempty"`
|
DiscountCardNumber string `json:"discountCardNumber,omitempty"`
|
||||||
ManagerID int `json:"managerId,omitempty"`
|
ManagerID int `json:"managerId,omitempty"`
|
||||||
|
@ -217,6 +247,15 @@ type CorporateCustomerContactCustomer struct {
|
||||||
Site string `json:"site,omitempty"`
|
Site string `json:"site,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CartCustomer type.
|
||||||
|
type CartCustomer struct {
|
||||||
|
ID int `json:"id,omitempty"`
|
||||||
|
ExternalID string `json:"externalId,omitempty"`
|
||||||
|
Site string `json:"site,omitempty"`
|
||||||
|
BrowserID string `json:"browserId,omitempty"`
|
||||||
|
GaClientID string `json:"gaClientId,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
type Company struct {
|
type Company struct {
|
||||||
ID int `json:"id,omitempty"`
|
ID int `json:"id,omitempty"`
|
||||||
IsMain bool `json:"isMain,omitempty"`
|
IsMain bool `json:"isMain,omitempty"`
|
||||||
|
@ -228,7 +267,7 @@ type Company struct {
|
||||||
CreatedAt string `json:"createdAt,omitempty"`
|
CreatedAt string `json:"createdAt,omitempty"`
|
||||||
Contragent *Contragent `json:"contragent,omitempty"`
|
Contragent *Contragent `json:"contragent,omitempty"`
|
||||||
Address *IdentifiersPair `json:"address,omitempty"`
|
Address *IdentifiersPair `json:"address,omitempty"`
|
||||||
CustomFields StringMap `json:"customFields,omitempty"`
|
CustomFields CustomFieldMap `json:"customFields,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CorporateCustomerNote type.
|
// CorporateCustomerNote type.
|
||||||
|
@ -251,9 +290,19 @@ type CustomerHistoryRecord struct {
|
||||||
Deleted bool `json:"deleted,omitempty"`
|
Deleted bool `json:"deleted,omitempty"`
|
||||||
Source string `json:"source,omitempty"`
|
Source string `json:"source,omitempty"`
|
||||||
Field string `json:"field,omitempty"`
|
Field string `json:"field,omitempty"`
|
||||||
|
OldValue interface{} `json:"oldValue,omitempty"`
|
||||||
|
NewValue interface{} `json:"newValue,omitempty"`
|
||||||
User *User `json:"user,omitempty"`
|
User *User `json:"user,omitempty"`
|
||||||
APIKey *APIKey `json:"apiKey,omitempty"`
|
APIKey *APIKey `json:"apiKey,omitempty"`
|
||||||
Customer *Customer `json:"customer,omitempty"`
|
Customer *Customer `json:"customer,omitempty"`
|
||||||
|
Address *CustomerAddressWithIsMain `json:"address,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CustomerAddressWithIsMain struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
ExternalID string `json:"externalId,omitempty"`
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
IsMain bool `json:"isMain"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CorporateCustomerHistoryRecord type.
|
// CorporateCustomerHistoryRecord type.
|
||||||
|
@ -264,6 +313,8 @@ type CorporateCustomerHistoryRecord struct {
|
||||||
Deleted bool `json:"deleted,omitempty"`
|
Deleted bool `json:"deleted,omitempty"`
|
||||||
Source string `json:"source,omitempty"`
|
Source string `json:"source,omitempty"`
|
||||||
Field string `json:"field,omitempty"`
|
Field string `json:"field,omitempty"`
|
||||||
|
OldValue interface{} `json:"oldValue,omitempty"`
|
||||||
|
NewValue interface{} `json:"newValue,omitempty"`
|
||||||
User *User `json:"user,omitempty"`
|
User *User `json:"user,omitempty"`
|
||||||
APIKey *APIKey `json:"apiKey,omitempty"`
|
APIKey *APIKey `json:"apiKey,omitempty"`
|
||||||
CorporateCustomer *CorporateCustomer `json:"corporateCustomer,omitempty"`
|
CorporateCustomer *CorporateCustomer `json:"corporateCustomer,omitempty"`
|
||||||
|
@ -275,6 +326,7 @@ Order related types
|
||||||
|
|
||||||
type OrderPayments map[string]OrderPayment
|
type OrderPayments map[string]OrderPayment
|
||||||
type StringMap map[string]string
|
type StringMap map[string]string
|
||||||
|
type CustomFieldMap map[string]interface{}
|
||||||
type Properties map[string]Property
|
type Properties map[string]Property
|
||||||
|
|
||||||
// Order type.
|
// Order type.
|
||||||
|
@ -326,8 +378,61 @@ type Order struct {
|
||||||
Delivery *OrderDelivery `json:"delivery,omitempty"`
|
Delivery *OrderDelivery `json:"delivery,omitempty"`
|
||||||
Marketplace *OrderMarketplace `json:"marketplace,omitempty"`
|
Marketplace *OrderMarketplace `json:"marketplace,omitempty"`
|
||||||
Items []OrderItem `json:"items,omitempty"`
|
Items []OrderItem `json:"items,omitempty"`
|
||||||
CustomFields StringMap `json:"customFields,omitempty"`
|
CustomFields CustomFieldMap `json:"customFields,omitempty"`
|
||||||
Payments OrderPayments `json:"payments,omitempty"`
|
Payments OrderPayments `json:"payments,omitempty"`
|
||||||
|
ApplyRound *bool `json:"applyRound,omitempty"`
|
||||||
|
PrivilegeType string `json:"privilegeType,omitempty"`
|
||||||
|
DialogID int `json:"dialogId,omitempty"`
|
||||||
|
Links []OrderLink `json:"links,omitempty"`
|
||||||
|
Currency string `json:"currency,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// LinkedOrder type.
|
||||||
|
type LinkedOrder struct {
|
||||||
|
Number string `json:"number,omitempty"`
|
||||||
|
ExternalID string `json:"externalID,omitempty"`
|
||||||
|
ID int `json:"id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// OrderLink type.
|
||||||
|
type OrderLink struct {
|
||||||
|
Comment string `json:"comment,omitempty"`
|
||||||
|
CreatedAt string `json:"createdAt,omitempty"`
|
||||||
|
Order LinkedOrder `json:"order,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SerializedOrderLink type.
|
||||||
|
type SerializedOrderLink struct {
|
||||||
|
Comment string `json:"comment,omitempty"`
|
||||||
|
CreatedAt string `json:"createdAt,omitempty"`
|
||||||
|
Orders []LinkedOrder `json:"orders,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearCartOrder type.
|
||||||
|
type ClearCartOrder struct {
|
||||||
|
ID int `json:"id,omitempty"`
|
||||||
|
ExternalID string `json:"externalID,omitempty"`
|
||||||
|
Number string `json:"number,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClientID type.
|
||||||
|
type ClientID struct {
|
||||||
|
Value string `json:"value"`
|
||||||
|
CreateAt string `json:"createAt,omitempty"`
|
||||||
|
Site string `json:"site,omitempty"`
|
||||||
|
Customer SerializedEntityCustomer `json:"customer,omitempty"`
|
||||||
|
Order LinkedOrder `json:"order,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Currency type.
|
||||||
|
type Currency struct {
|
||||||
|
Code string `json:"code,omitempty"`
|
||||||
|
ID int `json:"id,omitempty"`
|
||||||
|
ManualConvertNominal int `json:"manualConvertNominal,omitempty"`
|
||||||
|
AutoConvertExtraPercent int `json:"autoConvertExtraPercent,omitempty"`
|
||||||
|
IsBase bool `json:"isBase,omitempty"`
|
||||||
|
IsAutoConvert bool `json:"isAutoConvert,omitempty"`
|
||||||
|
ManualConvertValue float32 `json:"manualConvertValue,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// OrdersStatus type.
|
// OrdersStatus type.
|
||||||
|
@ -380,6 +485,59 @@ type OrderDeliveryData struct {
|
||||||
AdditionalFields map[string]interface{}
|
AdditionalFields map[string]interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetCartItem type.
|
||||||
|
type SetCartItem struct {
|
||||||
|
Quantity float64 `json:"quantity,omitempty"`
|
||||||
|
Price float64 `json:"price,omitempty"`
|
||||||
|
Offer SetCartOffer `json:"offer,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetCartOffer type.
|
||||||
|
type SetCartOffer struct {
|
||||||
|
ID int `json:"id,omitempty"`
|
||||||
|
ExternalID string `json:"externalID,omitempty"`
|
||||||
|
XMLID string `json:"xmlId,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cart type.
|
||||||
|
type Cart struct {
|
||||||
|
Currency string `json:"currency,omitempty"`
|
||||||
|
ExternalID string `json:"externalId,omitempty"`
|
||||||
|
DroppedAt string `json:"droppedAt,omitempty"`
|
||||||
|
ClearedAt string `json:"clearedAt,omitempty"`
|
||||||
|
Link string `json:"link,omitempty"`
|
||||||
|
Items []CartItem `json:"items,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CartItem type.
|
||||||
|
type CartItem struct {
|
||||||
|
ID int `json:"id,omitempty"`
|
||||||
|
Quantity float64 `json:"quantity,omitempty"`
|
||||||
|
Price float64 `json:"price,omitempty"`
|
||||||
|
Offer CartOffer `json:"offer,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CartOffer type.
|
||||||
|
type CartOffer struct {
|
||||||
|
DisplayName string `json:"displayName,omitempty"`
|
||||||
|
ID int `json:"id,omitempty"`
|
||||||
|
ExternalID string `json:"externalId,omitempty"`
|
||||||
|
XMLID string `json:"xmlId,omitempty"`
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
Article string `json:"article,omitempty"`
|
||||||
|
VatRate string `json:"vatRate,omitempty"`
|
||||||
|
Properties StringMap `json:"properties,omitempty"`
|
||||||
|
Unit CartUnit `json:"unit,omitempty"`
|
||||||
|
Barcode string `json:"barcode,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CartUnit type.
|
||||||
|
type CartUnit struct {
|
||||||
|
Code string `json:"code"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Sym string `json:"sym"`
|
||||||
|
}
|
||||||
|
|
||||||
// UnmarshalJSON method.
|
// UnmarshalJSON method.
|
||||||
func (v *OrderDeliveryData) UnmarshalJSON(b []byte) error {
|
func (v *OrderDeliveryData) UnmarshalJSON(b []byte) error {
|
||||||
var additionalData map[string]interface{}
|
var additionalData map[string]interface{}
|
||||||
|
@ -469,9 +627,15 @@ type OrdersHistoryRecord struct {
|
||||||
Deleted bool `json:"deleted,omitempty"`
|
Deleted bool `json:"deleted,omitempty"`
|
||||||
Source string `json:"source,omitempty"`
|
Source string `json:"source,omitempty"`
|
||||||
Field string `json:"field,omitempty"`
|
Field string `json:"field,omitempty"`
|
||||||
|
OldValue interface{} `json:"oldValue,omitempty"`
|
||||||
|
NewValue interface{} `json:"newValue,omitempty"`
|
||||||
User *User `json:"user,omitempty"`
|
User *User `json:"user,omitempty"`
|
||||||
APIKey *APIKey `json:"apiKey,omitempty"`
|
APIKey *APIKey `json:"apiKey,omitempty"`
|
||||||
Order *Order `json:"order,omitempty"`
|
Order *Order `json:"order,omitempty"`
|
||||||
|
Ancestor *Order `json:"ancestor,omitempty"`
|
||||||
|
Item *OrderItem `json:"item,omitempty"`
|
||||||
|
Payment *Payment `json:"payment"`
|
||||||
|
CombinedTo *Order `json:"combinedTo,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pack type.
|
// Pack type.
|
||||||
|
@ -503,6 +667,8 @@ type PacksHistoryRecord struct {
|
||||||
Deleted bool `json:"deleted,omitempty"`
|
Deleted bool `json:"deleted,omitempty"`
|
||||||
Source string `json:"source,omitempty"`
|
Source string `json:"source,omitempty"`
|
||||||
Field string `json:"field,omitempty"`
|
Field string `json:"field,omitempty"`
|
||||||
|
OldValue interface{} `json:"oldValue,omitempty"`
|
||||||
|
NewValue interface{} `json:"newValue,omitempty"`
|
||||||
User *User `json:"user,omitempty"`
|
User *User `json:"user,omitempty"`
|
||||||
Pack *Pack `json:"pack,omitempty"`
|
Pack *Pack `json:"pack,omitempty"`
|
||||||
}
|
}
|
||||||
|
@ -527,6 +693,7 @@ type Offer struct {
|
||||||
Prices []OfferPrice `json:"prices,omitempty"`
|
Prices []OfferPrice `json:"prices,omitempty"`
|
||||||
Images []string `json:"images,omitempty"`
|
Images []string `json:"images,omitempty"`
|
||||||
Unit *Unit `json:"unit,omitempty"`
|
Unit *Unit `json:"unit,omitempty"`
|
||||||
|
Product *Product `json:"product,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inventory type.
|
// Inventory type.
|
||||||
|
@ -556,6 +723,7 @@ type OfferPrice struct {
|
||||||
Price float32 `json:"price,omitempty"`
|
Price float32 `json:"price,omitempty"`
|
||||||
Ordering int `json:"ordering,omitempty"`
|
Ordering int `json:"ordering,omitempty"`
|
||||||
PriceType string `json:"priceType,omitempty"`
|
PriceType string `json:"priceType,omitempty"`
|
||||||
|
Currency string `json:"currency,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// OfferPriceUpload type.
|
// OfferPriceUpload type.
|
||||||
|
@ -595,6 +763,7 @@ type User struct {
|
||||||
CreatedAt string `json:"createdAt,omitempty"`
|
CreatedAt string `json:"createdAt,omitempty"`
|
||||||
Active bool `json:"active,omitempty"`
|
Active bool `json:"active,omitempty"`
|
||||||
Online bool `json:"online,omitempty"`
|
Online bool `json:"online,omitempty"`
|
||||||
|
Position string `json:"position,omitempty"`
|
||||||
IsAdmin bool `json:"isAdmin,omitempty"`
|
IsAdmin bool `json:"isAdmin,omitempty"`
|
||||||
IsManager bool `json:"isManager,omitempty"`
|
IsManager bool `json:"isManager,omitempty"`
|
||||||
Email string `json:"email,omitempty"`
|
Email string `json:"email,omitempty"`
|
||||||
|
@ -694,11 +863,59 @@ type SettingsNode struct {
|
||||||
UpdatedAt string `json:"updated_at"`
|
UpdatedAt string `json:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WorkTime type.
|
||||||
|
type WorkTime struct {
|
||||||
|
DayType string `json:"day_type"`
|
||||||
|
StartTime string `json:"start_time"`
|
||||||
|
EndTime string `json:"end_time"`
|
||||||
|
LunchStartTime string `json:"lunch_start_time"`
|
||||||
|
LunchEndTime string `json:"lunch_end_time"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// NonWorkingDays type.
|
||||||
|
type NonWorkingDays struct {
|
||||||
|
StartDate string `json:"start_date"`
|
||||||
|
EndDate string `json:"end_date"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SerializedBaseLoyaltyAccount struct {
|
||||||
|
PhoneNumber string `json:"phoneNumber,omitempty"`
|
||||||
|
CardNumber string `json:"cardNumber,omitempty"`
|
||||||
|
CustomFields []interface{} `json:"customFields,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SerializedCreateLoyaltyAccount struct {
|
||||||
|
SerializedBaseLoyaltyAccount
|
||||||
|
Customer SerializedEntityCustomer `json:"customer"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SerializedEditLoyaltyAccount struct {
|
||||||
|
SerializedBaseLoyaltyAccount
|
||||||
|
}
|
||||||
|
|
||||||
|
type ChannelSetting struct {
|
||||||
|
Site string `json:"site"`
|
||||||
|
OrderType string `json:"order_type"`
|
||||||
|
OrderMethod string `json:"order_method"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type MgOrderCreationSettings struct {
|
||||||
|
Channels map[int]ChannelSetting `json:"channels"`
|
||||||
|
Default ChannelSetting `json:"default"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type MgSettings struct {
|
||||||
|
OrderCreation MgOrderCreationSettings `json:"order_creation"`
|
||||||
|
}
|
||||||
|
|
||||||
// Settings type. Contains retailCRM configuration.
|
// Settings type. Contains retailCRM configuration.
|
||||||
type Settings struct {
|
type Settings struct {
|
||||||
DefaultCurrency SettingsNode `json:"default_currency"`
|
DefaultCurrency SettingsNode `json:"default_currency"`
|
||||||
SystemLanguage SettingsNode `json:"system_language"`
|
SystemLanguage SettingsNode `json:"system_language"`
|
||||||
Timezone SettingsNode `json:"timezone"`
|
Timezone SettingsNode `json:"timezone"`
|
||||||
|
MgSettings MgSettings `json:"mg"`
|
||||||
|
WorkTimes []WorkTime `json:"work_times"`
|
||||||
|
NonWorkingDays []NonWorkingDays `json:"non_working_days"`
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -758,7 +975,14 @@ type DeliveryType struct {
|
||||||
VatRate string `json:"vatRate,omitempty"`
|
VatRate string `json:"vatRate,omitempty"`
|
||||||
DefaultForCrm bool `json:"defaultForCrm,omitempty"`
|
DefaultForCrm bool `json:"defaultForCrm,omitempty"`
|
||||||
DeliveryServices []string `json:"deliveryServices,omitempty"`
|
DeliveryServices []string `json:"deliveryServices,omitempty"`
|
||||||
PaymentTypes []string `json:"paymentTypes,omitempty"`
|
PaymentTypes []string `json:"paymentTypes,omitempty"` // Deprecated, use DeliveryPaymentTypes
|
||||||
|
DeliveryPaymentTypes []DeliveryPaymentType `json:"deliveryPaymentTypes,omitempty"`
|
||||||
|
Currency string `json:"currency,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeliveryPaymentType struct {
|
||||||
|
Code string `json:"code"`
|
||||||
|
Cod bool `json:"cod,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// LegalEntity type.
|
// LegalEntity type.
|
||||||
|
@ -783,6 +1007,11 @@ type LegalEntity struct {
|
||||||
BankAccount string `json:"bankAccount,omitempty"`
|
BankAccount string `json:"bankAccount,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SerializedEntityCustomer struct {
|
||||||
|
ID int `json:"id,omitempty"`
|
||||||
|
ExternalID string `json:"externalId,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// OrderMethod type.
|
// OrderMethod type.
|
||||||
type OrderMethod struct {
|
type OrderMethod struct {
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
|
@ -838,6 +1067,7 @@ type PriceType struct {
|
||||||
Ordering int `json:"ordering,omitempty"`
|
Ordering int `json:"ordering,omitempty"`
|
||||||
Groups []string `json:"groups,omitempty"`
|
Groups []string `json:"groups,omitempty"`
|
||||||
Geo []GeoHierarchyRow `json:"geo,omitempty"`
|
Geo []GeoHierarchyRow `json:"geo,omitempty"`
|
||||||
|
Currency string `json:"currency,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProductStatus type.
|
// ProductStatus type.
|
||||||
|
@ -886,6 +1116,12 @@ type Site struct {
|
||||||
CatalogUpdatedAt string `json:"catalogUpdatedAt,omitempty"`
|
CatalogUpdatedAt string `json:"catalogUpdatedAt,omitempty"`
|
||||||
CatalogLoadingAt string `json:"catalogLoadingAt,omitempty"`
|
CatalogLoadingAt string `json:"catalogLoadingAt,omitempty"`
|
||||||
Contragent *LegalEntity `json:"contragent,omitempty"`
|
Contragent *LegalEntity `json:"contragent,omitempty"`
|
||||||
|
DefaultForCRM bool `json:"defaultForCrm,omitempty"`
|
||||||
|
Ordering int `json:"ordering,omitempty"`
|
||||||
|
IsDemo bool `json:"isDemo,omitempty"`
|
||||||
|
CatalogID string `json:"catalogId,omitempty"`
|
||||||
|
IsCatalogMainSite bool `json:"isCatalogMainSite,omitempty"`
|
||||||
|
Currency string `json:"currency,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store type.
|
// Store type.
|
||||||
|
@ -910,29 +1146,69 @@ type ProductGroup struct {
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
Site string `json:"site,omitempty"`
|
Site string `json:"site,omitempty"`
|
||||||
Active bool `json:"active,omitempty"`
|
Active bool `json:"active,omitempty"`
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
ExternalID string `json:"externalId,omitempty"`
|
||||||
|
ParentExternalID string `json:"parentExternalId,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Product type.
|
// BaseProduct type.
|
||||||
type Product struct {
|
type BaseProduct struct {
|
||||||
ID int `json:"id,omitempty"`
|
|
||||||
MaxPrice float32 `json:"maxPrice,omitempty"`
|
|
||||||
MinPrice float32 `json:"minPrice,omitempty"`
|
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
|
Type ProductType `json:"type,omitempty"`
|
||||||
URL string `json:"url,omitempty"`
|
URL string `json:"url,omitempty"`
|
||||||
Article string `json:"article,omitempty"`
|
Article string `json:"article,omitempty"`
|
||||||
ExternalID string `json:"externalId,omitempty"`
|
ExternalID string `json:"externalId,omitempty"`
|
||||||
Manufacturer string `json:"manufacturer,omitempty"`
|
Manufacturer string `json:"manufacturer,omitempty"`
|
||||||
ImageURL string `json:"imageUrl,omitempty"`
|
|
||||||
Description string `json:"description,omitempty"`
|
Description string `json:"description,omitempty"`
|
||||||
Popular bool `json:"popular,omitempty"`
|
Popular bool `json:"popular,omitempty"`
|
||||||
Stock bool `json:"stock,omitempty"`
|
Stock bool `json:"stock,omitempty"`
|
||||||
Novelty bool `json:"novelty,omitempty"`
|
Novelty bool `json:"novelty,omitempty"`
|
||||||
Recommended bool `json:"recommended,omitempty"`
|
Recommended bool `json:"recommended,omitempty"`
|
||||||
Active bool `json:"active,omitempty"`
|
Active bool `json:"active,omitempty"`
|
||||||
|
Markable bool `json:"markable,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProductType string
|
||||||
|
|
||||||
|
const (
|
||||||
|
RegularProduct ProductType = "product"
|
||||||
|
ServiceProduct ProductType = "service"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Product type.
|
||||||
|
type Product struct {
|
||||||
|
BaseProduct
|
||||||
|
ID int `json:"id,omitempty"`
|
||||||
|
Type ProductType `json:"type"`
|
||||||
|
MaxPrice float32 `json:"maxPrice,omitempty"`
|
||||||
|
MinPrice float32 `json:"minPrice,omitempty"`
|
||||||
|
ImageURL string `json:"imageUrl,omitempty"`
|
||||||
Quantity float32 `json:"quantity,omitempty"`
|
Quantity float32 `json:"quantity,omitempty"`
|
||||||
Offers []Offer `json:"offers,omitempty"`
|
Offers []Offer `json:"offers,omitempty"`
|
||||||
Groups []ProductGroup `json:"groups,omitempty"`
|
|
||||||
Properties StringMap `json:"properties,omitempty"`
|
Properties StringMap `json:"properties,omitempty"`
|
||||||
|
Groups []ProductGroup `json:"groups,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProductEditGroupInput type.
|
||||||
|
type ProductEditGroupInput struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
ExternalID int `json:"externalId,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProductCreate type.
|
||||||
|
type ProductCreate struct {
|
||||||
|
BaseProduct
|
||||||
|
Groups []ProductEditGroupInput `json:"groups,omitempty"`
|
||||||
|
CatalogID int `json:"catalogId,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProductEdit type.
|
||||||
|
type ProductEdit struct {
|
||||||
|
BaseProduct
|
||||||
|
ID int `json:"id,omitempty"`
|
||||||
|
CatalogID int `json:"catalogId,omitempty"`
|
||||||
|
Site string `json:"site,omitempty"`
|
||||||
|
Groups []ProductEditGroupInput `json:"groups,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeliveryHistoryRecord type.
|
// DeliveryHistoryRecord type.
|
||||||
|
@ -963,7 +1239,7 @@ type DeliveryShipment struct {
|
||||||
type IntegrationModule struct {
|
type IntegrationModule struct {
|
||||||
Code string `json:"code,omitempty"`
|
Code string `json:"code,omitempty"`
|
||||||
IntegrationCode string `json:"integrationCode,omitempty"`
|
IntegrationCode string `json:"integrationCode,omitempty"`
|
||||||
Active bool `json:"active,omitempty"`
|
Active *bool `json:"active,omitempty"`
|
||||||
Freeze bool `json:"freeze,omitempty"`
|
Freeze bool `json:"freeze,omitempty"`
|
||||||
Native bool `json:"native,omitempty"`
|
Native bool `json:"native,omitempty"`
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
|
@ -977,7 +1253,7 @@ type IntegrationModule struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ScopesRequired struct {
|
type ScopesRequired struct {
|
||||||
Scopes []string
|
Scopes []string `json:"scopes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Integrations type.
|
// Integrations type.
|
||||||
|
@ -1013,6 +1289,8 @@ type DeliveryStatus struct {
|
||||||
Code string `json:"code,omitempty"`
|
Code string `json:"code,omitempty"`
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
IsEditable bool `json:"isEditable,omitempty"`
|
IsEditable bool `json:"isEditable,omitempty"`
|
||||||
|
IsError bool `json:"isError,omitempty"`
|
||||||
|
IsPreprocessing bool `json:"isPreprocessing,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Plate type.
|
// Plate type.
|
||||||
|
@ -1073,10 +1351,20 @@ type Action struct {
|
||||||
// MgTransport type.
|
// MgTransport type.
|
||||||
type MgTransport struct {
|
type MgTransport struct {
|
||||||
WebhookURL string `json:"webhookUrl,omitempty"`
|
WebhookURL string `json:"webhookUrl,omitempty"`
|
||||||
|
RefreshToken bool `json:"refreshToken,omitempty"`
|
||||||
|
Actions *MgTransportActions `json:"actions,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type MgTransportActions struct {
|
||||||
|
Visits string `json:"visits,omitempty"`
|
||||||
|
Online string `json:"online,omitempty"`
|
||||||
|
ManualTemplatesSync string `json:"manualTemplatesSync,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// MgBot type.
|
// MgBot type.
|
||||||
type MgBot struct{}
|
type MgBot struct {
|
||||||
|
RefreshToken bool `json:"refreshToken,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Cost related types
|
Cost related types
|
||||||
|
@ -1137,11 +1425,13 @@ type CustomFields struct {
|
||||||
InGroupActions bool `json:"inGroupActions,omitempty"`
|
InGroupActions bool `json:"inGroupActions,omitempty"`
|
||||||
Type string `json:"type,omitempty"`
|
Type string `json:"type,omitempty"`
|
||||||
Entity string `json:"entity,omitempty"`
|
Entity string `json:"entity,omitempty"`
|
||||||
|
// Deprecated: Use DefaultTyped instead.
|
||||||
Default string `json:"default,omitempty"`
|
Default string `json:"default,omitempty"`
|
||||||
Ordering int `json:"ordering,omitempty"`
|
Ordering int `json:"ordering,omitempty"`
|
||||||
DisplayArea string `json:"displayArea,omitempty"`
|
DisplayArea string `json:"displayArea,omitempty"`
|
||||||
ViewMode string `json:"viewMode,omitempty"`
|
ViewMode string `json:"viewMode,omitempty"`
|
||||||
Dictionary string `json:"dictionary,omitempty"`
|
Dictionary string `json:"dictionary,omitempty"`
|
||||||
|
DefaultTyped interface{} `json:"default_typed,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1168,9 +1458,262 @@ type Activity struct {
|
||||||
Freeze bool `json:"freeze"`
|
Freeze bool `json:"freeze"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ChatCustomerOnline struct {
|
||||||
|
LastOnline SystemTime `json:"lastOnline"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ChatVisitsResponse struct {
|
||||||
|
UTM *ChatUTM `json:"utm,omitempty"`
|
||||||
|
Device ChatDevice `json:"device"`
|
||||||
|
Country string `json:"country"`
|
||||||
|
City string `json:"city"`
|
||||||
|
LastVisit ChatLastVisit `json:"lastVisit"`
|
||||||
|
CountVisits uint `json:"countVisits"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ChatLastVisit struct {
|
||||||
|
CreatedAt SystemTime `json:"createdAt"`
|
||||||
|
EndedAt *SystemTime `json:"endedAt,omitempty"`
|
||||||
|
Source string `json:"source"`
|
||||||
|
Pages []ChatVisitedPage `json:"pages"`
|
||||||
|
Duration uint `json:"duration"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ChatVisitedPage struct {
|
||||||
|
DateTime SystemTime `json:"dateTime"`
|
||||||
|
Title string `json:"title,omitempty"`
|
||||||
|
URL string `json:"url"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ChatDevice struct {
|
||||||
|
Lang string `json:"lang"`
|
||||||
|
Browser string `json:"browser"`
|
||||||
|
OS string `json:"os"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ChatUTM struct {
|
||||||
|
Source string `json:"source"`
|
||||||
|
Medium string `json:"medium"`
|
||||||
|
Campaign string `json:"campaign"`
|
||||||
|
}
|
||||||
|
|
||||||
// Tag struct.
|
// Tag struct.
|
||||||
type Tag struct {
|
type Tag struct {
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
Color string `json:"color,omitempty"`
|
Color string `json:"color,omitempty"`
|
||||||
Attached bool `json:"attached,omitempty"`
|
Attached bool `json:"attached,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BonusOperation struct.
|
||||||
|
type BonusOperation struct {
|
||||||
|
Type string `json:"type,omitempty"`
|
||||||
|
CreatedAt string `json:"createdAt,omitempty"`
|
||||||
|
Amount float32 `json:"amount,omitempty"`
|
||||||
|
Order OperationOrder `json:"order"`
|
||||||
|
Bonus OperationBonus `json:"bonus"`
|
||||||
|
Event OperationEvent `json:"event"`
|
||||||
|
LoyaltyAccount OperationLoyaltyAccount `json:"loyaltyAccount"`
|
||||||
|
Loyalty OperationLoyalty `json:"loyalty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// OperationOrder struct.
|
||||||
|
type OperationOrder struct {
|
||||||
|
ID int `json:"id,omitempty"`
|
||||||
|
ExternalID string `json:"externalId,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// OperationBonus struct.
|
||||||
|
type OperationBonus struct {
|
||||||
|
ActivationDate string `json:"activationDate,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// OperationEvent struct.
|
||||||
|
type OperationEvent struct {
|
||||||
|
ID int `json:"id,omitempty"`
|
||||||
|
Type string `json:"type,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// OperationLoyaltyAccount struct.
|
||||||
|
type OperationLoyaltyAccount struct {
|
||||||
|
ID int `json:"id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// OperationLoyalty struct.
|
||||||
|
type OperationLoyalty struct {
|
||||||
|
ID int `json:"id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CursorPagination type.
|
||||||
|
type CursorPagination struct {
|
||||||
|
NextCursor string `json:"nextCursor,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeliveryTypeInfo type.
|
||||||
|
type DeliveryTypeInfo struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
Code string `json:"code"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoyaltyAccount type.
|
||||||
|
type LoyaltyAccount struct {
|
||||||
|
Active bool `json:"active"`
|
||||||
|
ID int `json:"id"`
|
||||||
|
PhoneNumber string `json:"phoneNumber,omitempty"`
|
||||||
|
CardNumber string `json:"cardNumber,omitempty"`
|
||||||
|
Amount float64 `json:"amount,omitempty"`
|
||||||
|
LoyaltyLevel LoyaltyLevel `json:"level,omitempty"`
|
||||||
|
CreatedAt string `json:"createdAt,omitempty"`
|
||||||
|
ActivatedAt string `json:"activatedAt,omitempty"`
|
||||||
|
ConfirmedPhoneAt string `json:"confirmedPhoneAt,omitempty"`
|
||||||
|
LastCheckID int `json:"lastCheckId,omitempty"`
|
||||||
|
CustomFields CustomFieldMap `json:"customFields,omitempty"`
|
||||||
|
Loyalty Loyalty `json:"loyalty,omitempty"`
|
||||||
|
Customer Customer `json:"customer,omitempty"`
|
||||||
|
Status string `json:"status,omitempty"`
|
||||||
|
OrderSum float64 `json:"orderSum,omitempty"`
|
||||||
|
NextLevelSum float64 `json:"nextLevelSum,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Loyalty type.
|
||||||
|
type Loyalty struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
LoyaltyLevels []LoyaltyLevel `json:"levels,omitempty"`
|
||||||
|
Active bool `json:"active,omitempty"`
|
||||||
|
Blocked bool `json:"blocked,omitempty"`
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
ConfirmSmsCharge bool `json:"confirmSmsCharge,omitempty"`
|
||||||
|
ConfirmSmsRegistration bool `json:"confirmSmsRegistration,omitempty"`
|
||||||
|
CreatedAt string `json:"createdAt,omitempty"`
|
||||||
|
ActivatedAt string `json:"activatedAt,omitempty"`
|
||||||
|
DeactivatedAt string `json:"deactivatedAt,omitempty"`
|
||||||
|
BlockedAt string `json:"blockedAt,omitempty"`
|
||||||
|
Currency string `json:"currency,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoyaltyLevel type.
|
||||||
|
type LoyaltyLevel struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Type string `json:"type,omitempty"`
|
||||||
|
Sum float64 `json:"sum,omitempty"`
|
||||||
|
PrivilegeSize float64 `json:"privilegeSize,omitempty"`
|
||||||
|
PrivilegeSizePromo float64 `json:"privilegeSizePromo,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SmsVerification struct {
|
||||||
|
CreatedAt string `json:"createdAt"`
|
||||||
|
ExpiredAt string `json:"expiredAt"`
|
||||||
|
VerifiedAt string `json:"verifiedAt"`
|
||||||
|
CheckID string `json:"checkId"`
|
||||||
|
ActionType string `json:"actionType"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type LoyaltyBonus struct {
|
||||||
|
Amount float32 `json:"amount"`
|
||||||
|
ActivationDate string `json:"activationDate"`
|
||||||
|
ExpiredDate string `json:"expiredDate,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type BonusDetail struct {
|
||||||
|
Date string `json:"date"`
|
||||||
|
Amount float32 `json:"amount"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SerializedLoyaltyOrder struct {
|
||||||
|
BonusesCreditTotal float32 `json:"bonusesCreditTotal,omitempty"`
|
||||||
|
BonusesChargeTotal float32 `json:"bonusesChargeTotal,omitempty"`
|
||||||
|
PrivilegeType string `json:"privilegeType,omitempty"`
|
||||||
|
TotalSumm float64 `json:"totalSumm,omitempty"`
|
||||||
|
PersonalDiscountPercent float32 `json:"personalDiscountPercent,omitempty"`
|
||||||
|
LoyaltyAccount LoyaltyAccount `json:"loyaltyAccount"`
|
||||||
|
LoyaltyEventDiscount LoyaltyEventDiscount `json:"loyaltyEventDiscount,omitempty"`
|
||||||
|
Customer Customer `json:"customer"`
|
||||||
|
Delivery Delivery `json:"delivery,omitempty"`
|
||||||
|
Site string `json:"site,omitempty"`
|
||||||
|
Items []LoyaltyItems `json:"items,omitempty"`
|
||||||
|
Currency string `json:"currency,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type LoyaltyEventDiscount struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type LoyaltyItems struct {
|
||||||
|
BonusesChargeTotal float32 `json:"bonusesChargeTotal,omitempty"`
|
||||||
|
BonusesCreditTotal float32 `json:"bonusesCreditTotal,omitempty"`
|
||||||
|
ID int `json:"id,omitempty"`
|
||||||
|
ExternalIds []CodeValueModel `json:"externalIds,omitempty"`
|
||||||
|
PriceType PriceType `json:"priceType,omitempty"`
|
||||||
|
InitialPrice float32 `json:"initialPrice,omitempty"`
|
||||||
|
Discounts []AbstractDiscount `json:"discounts,omitempty"`
|
||||||
|
Prices []OrderProductPriceItem `json:"prices,omitempty"`
|
||||||
|
VatRate string `json:"vatRate,omitempty"`
|
||||||
|
CreatedAt string `json:"createdAt"`
|
||||||
|
Quantity float32 `json:"quantity"`
|
||||||
|
Offer Offer `json:"offer,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CodeValueModel struct {
|
||||||
|
Code string `json:"code"`
|
||||||
|
Value string `json:"value,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AbstractDiscount struct {
|
||||||
|
Type string `json:"type"`
|
||||||
|
Amount float32 `json:"amount"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type OrderProductPriceItem struct {
|
||||||
|
Price float64 `json:"price"`
|
||||||
|
Quantity float32 `json:"quantity"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type LoyaltyCalculation struct {
|
||||||
|
PrivilegeType string `json:"privilegeType"`
|
||||||
|
Discount float32 `json:"discount"`
|
||||||
|
CreditBonuses float32 `json:"creditBonuses"`
|
||||||
|
LoyaltyEventDiscount LoyaltyEventDiscount `json:"loyaltyEventDiscount,omitempty"`
|
||||||
|
MaxChargeBonuses float32 `json:"maxChargeBonuses,omitempty"`
|
||||||
|
Maximum *bool `json:"maximum,omitempty"`
|
||||||
|
Loyalty SerializedLoyalty `json:"loyalty,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SerializedLoyalty struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
ChargeRate float32 `json:"chargeRate"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ExternalID struct {
|
||||||
|
ExternalID string `json:"externalId,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserGroupType string
|
||||||
|
type NotificationType string
|
||||||
|
|
||||||
|
type MGChannel struct {
|
||||||
|
Type string `json:"type"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
ID int `json:"id"`
|
||||||
|
ExternalID int `json:"externalId"`
|
||||||
|
AllowedSendByPhone bool `json:"allowedSendByPhone"`
|
||||||
|
Active bool `json:"active"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type MGChannelTemplate struct {
|
||||||
|
Channel *MGChannel `json:"channel,omitempty"`
|
||||||
|
Header *Header `json:"header"`
|
||||||
|
Lang string `json:"lang"`
|
||||||
|
Category string `json:"category"`
|
||||||
|
Code string `json:"code,omitempty"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Namespace string `json:"namespace,omitempty"`
|
||||||
|
Footer string `json:"footer,omitempty"`
|
||||||
|
VerificationStatus string `json:"verificationStatus,omitempty"`
|
||||||
|
BodyTemplate TemplateItemList `json:"template"`
|
||||||
|
Buttons []Button `json:"buttons,omitempty"`
|
||||||
|
BodyTemplateExample []string `json:"templateExample"`
|
||||||
|
ID int `json:"id,omitempty"`
|
||||||
|
ExternalID int `json:"externalId,omitempty"`
|
||||||
|
MGChannelID int `json:"mgChannelId"`
|
||||||
|
Active bool `json:"active"`
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue