mirror of
https://github.com/retailcrm/api-client-go.git
synced 2024-11-24 05:46:05 +03:00
add support for more methods
This commit is contained in:
commit
6c5eb72848
5
.github/workflows/ci.yml
vendored
5
.github/workflows/ci.yml
vendored
@ -34,6 +34,7 @@ jobs:
|
||||
version: v1.45.2
|
||||
only-new-issues: true
|
||||
skip-pkg-cache: true
|
||||
args: --build-tags=testutils
|
||||
tests:
|
||||
name: Tests
|
||||
runs-on: ubuntu-latest
|
||||
@ -58,13 +59,13 @@ jobs:
|
||||
env:
|
||||
COVERAGE: ${{ matrix.coverage }}
|
||||
if: env.COVERAGE != 1
|
||||
run: go test ./...
|
||||
run: go test -tags=testutils ./...
|
||||
- name: Tests with coverage
|
||||
env:
|
||||
COVERAGE: ${{ matrix.coverage }}
|
||||
if: env.COVERAGE == 1
|
||||
run: |
|
||||
go test ./... -race -coverprofile=coverage.txt -covermode=atomic "$d"
|
||||
go test -tags=testutils ./... -race -coverprofile=coverage.txt -covermode=atomic "$d"
|
||||
- name: Coverage
|
||||
env:
|
||||
COVERAGE: ${{ matrix.coverage }}
|
||||
|
@ -1,6 +1,8 @@
|
||||
run:
|
||||
skip-dirs-use-default: true
|
||||
allow-parallel-runners: true
|
||||
skip-files:
|
||||
- testutils.go
|
||||
|
||||
output:
|
||||
format: colored-line-number
|
||||
|
870
client.go
870
client.go
@ -17,6 +17,10 @@ import (
|
||||
"github.com/google/go-querystring/query"
|
||||
)
|
||||
|
||||
// HTTPStatusUnknown can return for the method `/api/v5/customers/upload`, `/api/v5/customers-corporate/upload`,
|
||||
// `/api/v5/orders/upload`.
|
||||
const HTTPStatusUnknown = 460
|
||||
|
||||
// New initialize client.
|
||||
func New(url string, key string) *Client {
|
||||
return &Client{
|
||||
@ -670,6 +674,8 @@ func (c *Client) CustomerNoteDelete(id int) (SuccessfulResponse, int, error) {
|
||||
|
||||
// CustomersUpload customers batch upload
|
||||
//
|
||||
// # This method can return response together with error if http status is equal 460
|
||||
//
|
||||
// For more information see http://www.simla.com/docs/Developers/API/APIVersions/APIv5#post--api-v5-customers-upload
|
||||
//
|
||||
// Example:
|
||||
@ -716,12 +722,16 @@ func (c *Client) CustomersUpload(customers []Customer, site ...string) (Customer
|
||||
fillSite(&p, site)
|
||||
|
||||
data, status, err := c.PostRequest("/customers/upload", p)
|
||||
if err != nil {
|
||||
if err != nil && status != HTTPStatusUnknown {
|
||||
return resp, status, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(data, &resp)
|
||||
if err != nil {
|
||||
errJSON := json.Unmarshal(data, &resp)
|
||||
if errJSON != nil {
|
||||
return resp, status, errJSON
|
||||
}
|
||||
|
||||
if status == HTTPStatusUnknown {
|
||||
return resp, status, err
|
||||
}
|
||||
|
||||
@ -1145,6 +1155,8 @@ func (c *Client) CorporateCustomerNoteDelete(id int) (SuccessfulResponse, int, e
|
||||
|
||||
// CorporateCustomersUpload corporate customers batch upload
|
||||
//
|
||||
// # This method can return response together with error if http status is equal 460
|
||||
//
|
||||
// For more information see http://help.retailcrm.pro/Developers/ApiVersion5#post--api-v5-customers-corporate-upload
|
||||
//
|
||||
// Example:
|
||||
@ -1187,12 +1199,16 @@ func (c *Client) CorporateCustomersUpload(
|
||||
fillSite(&p, site)
|
||||
|
||||
data, status, err := c.PostRequest("/customers-corporate/upload", p)
|
||||
if err != nil {
|
||||
if err != nil && status != HTTPStatusUnknown {
|
||||
return resp, status, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(data, &resp)
|
||||
if err != nil {
|
||||
errJSON := json.Unmarshal(data, &resp)
|
||||
if errJSON != nil {
|
||||
return resp, status, err
|
||||
}
|
||||
|
||||
if status == HTTPStatusUnknown {
|
||||
return resp, status, err
|
||||
}
|
||||
|
||||
@ -1846,7 +1862,6 @@ func (c *Client) CorporateCustomerEdit(customer CorporateCustomer, by string, si
|
||||
//
|
||||
// log.Fatalf("http status: %d, error: %s", status, err)
|
||||
// }
|
||||
//
|
||||
func (c *Client) DeliveryTracking(parameters []DeliveryTrackingRequest, subcode string) (
|
||||
SuccessfulResponse, int, error,
|
||||
) {
|
||||
@ -2590,6 +2605,8 @@ func (c *Client) OrdersStatuses(request OrdersStatusesRequest) (OrdersStatusesRe
|
||||
|
||||
// OrdersUpload batch orders uploading
|
||||
//
|
||||
// # This method can return response together with error if http status is equal 460
|
||||
//
|
||||
// For more information see http://www.simla.com/docs/Developers/API/APIVersions/APIv5#post--api-v5-orders-upload
|
||||
//
|
||||
// Example:
|
||||
@ -2636,12 +2653,16 @@ func (c *Client) OrdersUpload(orders []Order, site ...string) (OrdersUploadRespo
|
||||
fillSite(&p, site)
|
||||
|
||||
data, status, err := c.PostRequest("/orders/upload", p)
|
||||
if err != nil {
|
||||
if err != nil && status != HTTPStatusUnknown {
|
||||
return resp, status, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(data, &resp)
|
||||
if err != nil {
|
||||
errJSON := json.Unmarshal(data, &resp)
|
||||
if errJSON != nil {
|
||||
return resp, status, err
|
||||
}
|
||||
|
||||
if status == HTTPStatusUnknown {
|
||||
return resp, status, err
|
||||
}
|
||||
|
||||
@ -5643,3 +5664,832 @@ func (c *Client) AccountBonusOperations(id int, parameters AccountBonusOperation
|
||||
|
||||
return resp, status, nil
|
||||
}
|
||||
|
||||
// ProductsBatchEdit perform editing products batch
|
||||
//
|
||||
// For more information see https://docs.retailcrm.ru/Developers/API/APIVersions/APIv5#post--api-v5-store-products-batch-edit
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var client = retailcrm.New("https://demo.url", "09jIJ")
|
||||
//
|
||||
// products := []ProductEdit{{
|
||||
// CatalogID: 3,
|
||||
// BaseProduct: BaseProduct{
|
||||
// Name: "Product 1",
|
||||
// URL: "https://example.com/p/1",
|
||||
// Article: "p1",
|
||||
// ExternalID: "ext1",
|
||||
// },
|
||||
// ID: 194,
|
||||
// Site: "second",
|
||||
// Groups: []ProductEditGroupInput{{ID: 19}},
|
||||
// }}
|
||||
//
|
||||
// data, status, err := client.ProductsBatchEdit(products)
|
||||
//
|
||||
// if err != nil {
|
||||
// if apiErr, ok := retailcrm.AsAPIError(err); ok {
|
||||
// log.Fatalf("http status: %d, %s", status, apiErr.String())
|
||||
// }
|
||||
//
|
||||
// log.Fatalf("http status: %d, error: %s", status, err)
|
||||
// }
|
||||
//
|
||||
// if data.Success == true {
|
||||
// log.Printf("%v", data.ProcessedProductsCount)
|
||||
// }
|
||||
func (c *Client) ProductsBatchEdit(products []ProductEdit) (ProductsBatchEditResponse, int, error) {
|
||||
var resp ProductsBatchEditResponse
|
||||
|
||||
productsEditJSON, _ := json.Marshal(products)
|
||||
p := url.Values{
|
||||
"products": {string(productsEditJSON)},
|
||||
}
|
||||
|
||||
data, status, err := c.PostRequest("/store/products/batch/edit", p)
|
||||
|
||||
if err != nil {
|
||||
return resp, status, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(data, &resp)
|
||||
if err != nil {
|
||||
return resp, status, err
|
||||
}
|
||||
|
||||
return resp, status, nil
|
||||
}
|
||||
|
||||
// ProductsBatchCreate perform adding products batch
|
||||
//
|
||||
// For more information see https://docs.retailcrm.ru/Developers/API/APIVersions/APIv5#post--api-v5-store-products-batch-create
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var client = retailcrm.New("https://demo.url", "09jIJ")
|
||||
//
|
||||
// products := []ProductCreate{{
|
||||
// CatalogID: 3,
|
||||
// BaseProduct: BaseProduct{
|
||||
// Name: "Product 1",
|
||||
// URL: "https://example.com/p/1",
|
||||
// Article: "p1",
|
||||
// ExternalID: "ext1",
|
||||
// },
|
||||
// Groups: []ProductEditGroupInput{{ID: 19}},
|
||||
// }}
|
||||
//
|
||||
// data, status, err := client.ProductsBatchCreate(products)
|
||||
//
|
||||
// if err != nil {
|
||||
// if apiErr, ok := retailcrm.AsAPIError(err); ok {
|
||||
// log.Fatalf("http status: %d, %s", status, apiErr.String())
|
||||
// }
|
||||
//
|
||||
// log.Fatalf("http status: %d, error: %s", status, err)
|
||||
// }
|
||||
//
|
||||
// if data.Success == true {
|
||||
// log.Printf("%v", data.AddedProducts)
|
||||
// }
|
||||
func (c *Client) ProductsBatchCreate(products []ProductCreate) (ProductsBatchEditResponse, int, error) {
|
||||
var resp ProductsBatchEditResponse
|
||||
|
||||
productsEditJSON, _ := json.Marshal(products)
|
||||
p := url.Values{
|
||||
"products": {string(productsEditJSON)},
|
||||
}
|
||||
|
||||
data, status, err := c.PostRequest("/store/products/batch/create", p)
|
||||
|
||||
if err != nil {
|
||||
return resp, status, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(data, &resp)
|
||||
if err != nil {
|
||||
return resp, status, err
|
||||
}
|
||||
|
||||
return resp, status, nil
|
||||
}
|
||||
|
||||
// LoyaltyAccountCreate аdd a client to the loyalty program
|
||||
//
|
||||
// For more information see https://docs.retailcrm.ru/Developers/API/APIVersions/APIv5#post--api-v5-loyalty-account-create
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var client = retailcrm.New("https://demo.url", "09jIJ")
|
||||
// acc := SerializedCreateLoyaltyAccount{
|
||||
// SerializedBaseLoyaltyAccount: SerializedBaseLoyaltyAccount{
|
||||
// PhoneNumber: "89151005004",
|
||||
// CustomFields: []string{"dog"},
|
||||
// },
|
||||
// Customer: SerializedEntityCustomer{
|
||||
// ID: 123,
|
||||
// },
|
||||
// }
|
||||
//
|
||||
// data, status, err := client.LoyaltyAccountCreate("site", acc)
|
||||
//
|
||||
// if err != nil {
|
||||
// if apiErr, ok := retailcrm.AsAPIError(err); ok {
|
||||
// log.Fatalf("http status: %d, %s", status, apiErr.String())
|
||||
// }
|
||||
//
|
||||
// log.Fatalf("http status: %d, error: %s", status, err)
|
||||
// }
|
||||
//
|
||||
// if data.Success == true {
|
||||
// log.Printf("%v", data.LoyaltyAccount.ID)
|
||||
// }
|
||||
func (c *Client) LoyaltyAccountCreate(site string, loyaltyAccount SerializedCreateLoyaltyAccount) (CreateLoyaltyAccountResponse, int, error) {
|
||||
var result CreateLoyaltyAccountResponse
|
||||
|
||||
loyaltyAccountJSON, _ := json.Marshal(loyaltyAccount)
|
||||
p := url.Values{
|
||||
"site": {site},
|
||||
"loyaltyAccount": {string(loyaltyAccountJSON)},
|
||||
}
|
||||
|
||||
resp, status, err := c.PostRequest("/loyalty/account/create", p)
|
||||
|
||||
if err != nil {
|
||||
return result, status, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(resp, &result)
|
||||
|
||||
if err != nil {
|
||||
return result, status, err
|
||||
}
|
||||
|
||||
return result, status, nil
|
||||
}
|
||||
|
||||
// LoyaltyAccountEdit edit a client in the loyalty program
|
||||
//
|
||||
// For more information see https://docs.retailcrm.ru/Developers/API/APIVersions/APIv5#post--api-v5-loyalty-account-id-edit
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var client = retailcrm.New("https://demo.url", "09jIJ")
|
||||
// acc := SerializedEditLoyaltyAccount{
|
||||
// SerializedBaseLoyaltyAccount: SerializedBaseLoyaltyAccount{
|
||||
// PhoneNumber: "89151005004",
|
||||
// CustomFields: []string{"dog"},
|
||||
// },
|
||||
// }
|
||||
//
|
||||
// data, status, err := client.LoyaltyAccountEdit(13, acc)
|
||||
//
|
||||
// if err != nil {
|
||||
// if apiErr, ok := retailcrm.AsAPIError(err); ok {
|
||||
// log.Fatalf("http status: %d, %s", status, apiErr.String())
|
||||
// }
|
||||
//
|
||||
// log.Fatalf("http status: %d, error: %s", status, err)
|
||||
// }
|
||||
//
|
||||
// if data.Success == true {
|
||||
// log.Printf("%v", data.LoyaltyAccount.PhoneNumber)
|
||||
// }
|
||||
func (c *Client) LoyaltyAccountEdit(id int, loyaltyAccount SerializedEditLoyaltyAccount) (EditLoyaltyAccountResponse, int, error) {
|
||||
var result EditLoyaltyAccountResponse
|
||||
|
||||
loyaltyAccountJSON, _ := json.Marshal(loyaltyAccount)
|
||||
p := url.Values{
|
||||
"loyaltyAccount": {string(loyaltyAccountJSON)},
|
||||
}
|
||||
|
||||
resp, status, err := c.PostRequest(fmt.Sprintf("/loyalty/account/%d/edit", id), p)
|
||||
|
||||
if err != nil {
|
||||
return result, status, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(resp, &result)
|
||||
|
||||
if err != nil {
|
||||
return result, status, err
|
||||
}
|
||||
|
||||
return result, status, nil
|
||||
}
|
||||
|
||||
// LoyaltyAccount return information about client in the loyalty program
|
||||
//
|
||||
// For more information see https://docs.retailcrm.ru/Developers/API/APIVersions/APIv5#get--api-v5-loyalty-account-id
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var client = retailcrm.New("https://demo.url", "09jIJ")
|
||||
//
|
||||
// data, status, err := client.LoyaltyAccount(13)
|
||||
//
|
||||
// if err != nil {
|
||||
// if apiErr, ok := retailcrm.AsAPIError(err); ok {
|
||||
// log.Fatalf("http status: %d, %s", status, apiErr.String())
|
||||
// }
|
||||
//
|
||||
// log.Fatalf("http status: %d, error: %s", status, err)
|
||||
// }
|
||||
//
|
||||
// if data.Success == true {
|
||||
// log.Printf("%v", data.LoyaltyAccount.PhoneNumber)
|
||||
// }
|
||||
func (c *Client) LoyaltyAccount(id int) (LoyaltyAccountResponse, int, error) {
|
||||
var result LoyaltyAccountResponse
|
||||
|
||||
resp, status, err := c.GetRequest(fmt.Sprintf("/loyalty/account/%d", id))
|
||||
|
||||
if err != nil {
|
||||
return result, status, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(resp, &result)
|
||||
|
||||
if err != nil {
|
||||
return result, status, err
|
||||
}
|
||||
|
||||
return result, status, nil
|
||||
}
|
||||
|
||||
// LoyaltyAccountActivate activate participation in the loyalty program for client
|
||||
//
|
||||
// For more information see https://docs.retailcrm.ru/Developers/API/APIVersions/APIv5#post--api-v5-loyalty-account-id-activate
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var client = retailcrm.New("https://demo.url", "09jIJ")
|
||||
//
|
||||
// data, status, err := client.LoyaltyAccountActivate(13)
|
||||
//
|
||||
// if err != nil {
|
||||
// if apiErr, ok := retailcrm.AsAPIError(err); ok {
|
||||
// log.Fatalf("http status: %d, %s", status, apiErr.String())
|
||||
// }
|
||||
//
|
||||
// log.Fatalf("http status: %d, error: %s", status, err)
|
||||
// }
|
||||
//
|
||||
// if data.Success == true {
|
||||
// log.Printf("%v", data.LoyaltyAccount.Active)
|
||||
// }
|
||||
func (c *Client) LoyaltyAccountActivate(id int) (LoyaltyAccountActivateResponse, int, error) {
|
||||
var result LoyaltyAccountActivateResponse
|
||||
|
||||
resp, status, err := c.PostRequest(fmt.Sprintf("/loyalty/account/%d/activate", id), strings.NewReader(""))
|
||||
|
||||
if err != nil {
|
||||
return result, status, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(resp, &result)
|
||||
|
||||
if err != nil {
|
||||
return result, status, err
|
||||
}
|
||||
|
||||
return result, status, nil
|
||||
}
|
||||
|
||||
// LoyaltyBonusCredit accrue bonus participation in the program of loyalty
|
||||
//
|
||||
// For more information see https://docs.retailcrm.ru/Developers/API/APIVersions/APIv5#post--api-v5-loyalty-account-id-bonus-credit
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var client = retailcrm.New("https://demo.url", "09jIJ")
|
||||
//
|
||||
// req := LoyaltyBonusCreditRequest{
|
||||
// Amount: 120,
|
||||
// ExpiredDate: "2023-11-24 12:39:37",
|
||||
// Comment: "Test",
|
||||
// }
|
||||
//
|
||||
// data, status, err := client.LoyaltyBonusCredit(13, req)
|
||||
//
|
||||
// if err != nil {
|
||||
// if apiErr, ok := retailcrm.AsAPIError(err); ok {
|
||||
// log.Fatalf("http status: %d, %s", status, apiErr.String())
|
||||
// }
|
||||
//
|
||||
// log.Fatalf("http status: %d, error: %s", status, err)
|
||||
// }
|
||||
//
|
||||
// if data.Success == true {
|
||||
// log.Printf("%v", data.LoyaltyBonus.ActivationDate)
|
||||
// }
|
||||
func (c *Client) LoyaltyBonusCredit(id int, req LoyaltyBonusCreditRequest) (LoyaltyBonusCreditResponse, int, error) {
|
||||
var result LoyaltyBonusCreditResponse
|
||||
p, _ := query.Values(req)
|
||||
|
||||
resp, status, err := c.PostRequest(fmt.Sprintf("/loyalty/account/%d/bonus/credit", id), p)
|
||||
|
||||
if err != nil {
|
||||
return result, status, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(resp, &result)
|
||||
|
||||
if err != nil {
|
||||
return result, status, err
|
||||
}
|
||||
|
||||
return result, status, nil
|
||||
}
|
||||
|
||||
// LoyaltyBonusStatusDetails get details on the bonus account
|
||||
//
|
||||
// For more information see https://docs.retailcrm.ru/Developers/API/APIVersions/APIv5#get--api-v5-loyalty-account-id-bonus-status-details
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var client = retailcrm.New("https://demo.url", "09jIJ")
|
||||
//
|
||||
// req := LoyaltyBonusStatusDetailsRequest{
|
||||
// Limit: 20,
|
||||
// Page: 3,
|
||||
// }
|
||||
//
|
||||
// data, status, err := client.LoyaltyBonusStatusDetails(13, "waiting_activation", req)
|
||||
//
|
||||
// if err != nil {
|
||||
// if apiErr, ok := retailcrm.AsAPIError(err); ok {
|
||||
// log.Fatalf("http status: %d, %s", status, apiErr.String())
|
||||
// }
|
||||
//
|
||||
// log.Fatalf("http status: %d, error: %s", status, err)
|
||||
// }
|
||||
//
|
||||
// if data.Success == true {
|
||||
// for _, bonus := range data.Bonuses {
|
||||
// log.Printf("%v", bonus.Amount)
|
||||
// }
|
||||
// }
|
||||
func (c *Client) LoyaltyBonusStatusDetails(
|
||||
id int, statusType string, request LoyaltyBonusStatusDetailsRequest,
|
||||
) (LoyaltyBonusDetailsResponse, int, error) {
|
||||
var result LoyaltyBonusDetailsResponse
|
||||
|
||||
p, _ := query.Values(request)
|
||||
|
||||
resp, status, err := c.GetRequest(fmt.Sprintf("/loyalty/account/%d/bonus/%s/details?%s", id, statusType, p.Encode()))
|
||||
|
||||
if err != nil {
|
||||
return result, status, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(resp, &result)
|
||||
|
||||
if err != nil {
|
||||
return result, status, err
|
||||
}
|
||||
|
||||
return result, status, nil
|
||||
}
|
||||
|
||||
// LoyaltyAccounts return list of participations in the loyalty program
|
||||
//
|
||||
// For more information see https://docs.retailcrm.ru/Developers/API/APIVersions/APIv5#get--api-v5-loyalty-accounts
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var client = retailcrm.New("https://demo.url", "09jIJ")
|
||||
//
|
||||
// req := LoyaltyAccountsRequest{
|
||||
// Filter: LoyaltyAccountAPIFilter{
|
||||
// Status: "activated",
|
||||
// PhoneNumber: "89185556363",
|
||||
// Ids: []int{14},
|
||||
// Level: 5,
|
||||
// Loyalties: []int{2},
|
||||
// CustomerID: "109",
|
||||
// },
|
||||
// }
|
||||
//
|
||||
// data, status, err := client.LoyaltyAccounts(req)
|
||||
//
|
||||
// if err != nil {
|
||||
// if apiErr, ok := retailcrm.AsAPIError(err); ok {
|
||||
// log.Fatalf("http status: %d, %s", status, apiErr.String())
|
||||
// }
|
||||
//
|
||||
// log.Fatalf("http status: %d, error: %s", status, err)
|
||||
// }
|
||||
//
|
||||
// if data.Success == true {
|
||||
// for _, account := range data.LoyaltyAccounts {
|
||||
// log.Printf("%v", account.Status)
|
||||
// }
|
||||
// }
|
||||
func (c *Client) LoyaltyAccounts(req LoyaltyAccountsRequest) (LoyaltyAccountsResponse, int, error) {
|
||||
var result LoyaltyAccountsResponse
|
||||
|
||||
p, _ := query.Values(req)
|
||||
|
||||
resp, status, err := c.GetRequest(fmt.Sprintf("/loyalty/accounts?%s", p.Encode()))
|
||||
|
||||
if err != nil {
|
||||
return result, status, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(resp, &result)
|
||||
|
||||
if err != nil {
|
||||
return result, status, err
|
||||
}
|
||||
|
||||
return result, status, nil
|
||||
}
|
||||
|
||||
// LoyaltyCalculate calculations of the maximum discount
|
||||
//
|
||||
// For more information see https://docs.retailcrm.ru/Developers/API/APIVersions/APIv5#post--api-v5-loyalty-calculate
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var client = retailcrm.New("https://demo.url", "09jIJ")
|
||||
//
|
||||
// req := 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,
|
||||
// }
|
||||
//
|
||||
// data, status, err := client.LoyaltyCalculate(req)
|
||||
//
|
||||
// if err != nil {
|
||||
// if apiErr, ok := retailcrm.AsAPIError(err); ok {
|
||||
// log.Fatalf("http status: %d, %s", status, apiErr.String())
|
||||
// }
|
||||
//
|
||||
// log.Fatalf("http status: %d, error: %s", status, err)
|
||||
// }
|
||||
//
|
||||
// if data.Success == true {
|
||||
// log.Printf("%v", data.Order.PrivilegeType)
|
||||
// log.Printf("%v", data.Order.BonusesCreditTotal)
|
||||
// }
|
||||
func (c *Client) LoyaltyCalculate(req LoyaltyCalculateRequest) (LoyaltyCalculateResponse, int, error) {
|
||||
var result LoyaltyCalculateResponse
|
||||
|
||||
orderJSON, _ := json.Marshal(req.Order)
|
||||
|
||||
p := url.Values{
|
||||
"site": {req.Site},
|
||||
"order": {string(orderJSON)},
|
||||
"bonuses": {fmt.Sprintf("%f", req.Bonuses)},
|
||||
}
|
||||
|
||||
resp, status, err := c.PostRequest("/loyalty/calculate", p)
|
||||
|
||||
if err != nil {
|
||||
return result, status, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(resp, &result)
|
||||
|
||||
if err != nil {
|
||||
return result, status, err
|
||||
}
|
||||
|
||||
return result, status, nil
|
||||
}
|
||||
|
||||
// GetLoyalties returns list of loyalty programs
|
||||
//
|
||||
// For more information see https://docs.retailcrm.ru/Developers/API/APIVersions/APIv5#get--api-v5-loyalty-loyalties
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var client = retailcrm.New("https://demo.url", "09jIJ")
|
||||
//
|
||||
// req := LoyaltiesRequest{
|
||||
// Filter: LoyaltyAPIFilter{
|
||||
// Active: active,
|
||||
// Ids: []int{2},
|
||||
// Sites: []string{"main"},
|
||||
// },
|
||||
// }
|
||||
//
|
||||
// data, status, err := client.GetLoyalties(req)
|
||||
//
|
||||
// if err != nil {
|
||||
// if apiErr, ok := retailcrm.AsAPIError(err); ok {
|
||||
// log.Fatalf("http status: %d, %s", status, apiErr.String())
|
||||
// }
|
||||
//
|
||||
// log.Fatalf("http status: %d, error: %s", status, err)
|
||||
// }
|
||||
//
|
||||
// if data.Success == true {
|
||||
// for _, l := range data.Loyalties {
|
||||
// log.Printf("%v", l.ID)
|
||||
// log.Printf("%v", l.Active)
|
||||
// }
|
||||
// }
|
||||
func (c *Client) GetLoyalties(req LoyaltiesRequest) (LoyaltiesResponse, int, error) {
|
||||
var result LoyaltiesResponse
|
||||
|
||||
p, _ := query.Values(req)
|
||||
|
||||
resp, status, err := c.GetRequest(fmt.Sprintf("/loyalty/loyalties?%s", p.Encode()))
|
||||
|
||||
if err != nil {
|
||||
return result, status, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(resp, &result)
|
||||
|
||||
if err != nil {
|
||||
return result, status, err
|
||||
}
|
||||
|
||||
return result, status, nil
|
||||
}
|
||||
|
||||
// GetLoyaltyByID return program of loyalty by id
|
||||
//
|
||||
// For more information see https://docs.retailcrm.ru/Developers/API/APIVersions/APIv5#get--api-v5-loyalty-loyalties-id
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var client = retailcrm.New("https://demo.url", "09jIJ")
|
||||
//
|
||||
// data, status, err := client.GetLoyaltyByID(2)
|
||||
//
|
||||
// if err != nil {
|
||||
// if apiErr, ok := retailcrm.AsAPIError(err); ok {
|
||||
// log.Fatalf("http status: %d, %s", status, apiErr.String())
|
||||
// }
|
||||
//
|
||||
// log.Fatalf("http status: %d, error: %s", status, err)
|
||||
// }
|
||||
//
|
||||
// if data.Success == true {
|
||||
// log.Printf("%v", res.Loyalty.ID)
|
||||
// log.Printf("%v", res.Loyalty.Active)
|
||||
// }
|
||||
func (c *Client) GetLoyaltyByID(id int) (LoyaltyResponse, int, error) {
|
||||
var result LoyaltyResponse
|
||||
|
||||
resp, status, err := c.GetRequest(fmt.Sprintf("/loyalty/loyalties/%d", id))
|
||||
|
||||
if err != nil {
|
||||
return result, status, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(resp, &result)
|
||||
|
||||
if err != nil {
|
||||
return result, status, err
|
||||
}
|
||||
|
||||
return result, status, nil
|
||||
}
|
||||
|
||||
// OrderIntegrationDeliveryCancel cancels of integration delivery
|
||||
//
|
||||
// For more information see https://docs.retailcrm.ru/Developers/API/APIVersions/APIv5#post--api-v5-orders-externalId-delivery-cancel
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var client = retailcrm.New("https://demo.url", "09jIJ")
|
||||
//
|
||||
// data, status, err := client.OrderIntegrationDeliveryCancel("externalId", false, "1001C")
|
||||
//
|
||||
// if err != nil {
|
||||
// if apiErr, ok := retailcrm.AsAPIError(err); ok {
|
||||
// log.Fatalf("http status: %d, %s", status, apiErr.String())
|
||||
// }
|
||||
//
|
||||
// log.Fatalf("http status: %d, error: %s", status, err)
|
||||
// }
|
||||
//
|
||||
// if data.Success == true {
|
||||
// log.Printf("%v", res.Success)
|
||||
// }
|
||||
func (c *Client) OrderIntegrationDeliveryCancel(by string, force bool, id string) (SuccessfulResponse, int, error) {
|
||||
var result SuccessfulResponse
|
||||
|
||||
p := url.Values{
|
||||
"by": {checkBy(by)},
|
||||
"force": {fmt.Sprintf("%t", force)},
|
||||
}
|
||||
|
||||
resp, status, err := c.PostRequest(fmt.Sprintf("/orders/%s/delivery/cancel?%s", id, p.Encode()), strings.NewReader(""))
|
||||
|
||||
if err != nil {
|
||||
return result, status, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(resp, &result)
|
||||
|
||||
if err != nil {
|
||||
return result, status, err
|
||||
}
|
||||
|
||||
return result, status, nil
|
||||
}
|
||||
|
||||
// CreateProductsGroup adds a product group
|
||||
//
|
||||
// For more information see https://docs.retailcrm.ru/Developers/API/APIVersions/APIv5#post--api-v5-store-product-groups-create
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var client = retailcrm.New("https://demo.url", "09jIJ")
|
||||
//
|
||||
// group := ProductGroup{
|
||||
// ParentID: 125,
|
||||
// Name: "Фрукты",
|
||||
// Site: "main",
|
||||
// Active: true,
|
||||
// ExternalID: "abc22",
|
||||
// }
|
||||
//
|
||||
// data, status, err := client.CreateProductsGroup(group)
|
||||
//
|
||||
// if err != nil {
|
||||
// if apiErr, ok := retailcrm.AsAPIError(err); ok {
|
||||
// log.Fatalf("http status: %d, %s", status, apiErr.String())
|
||||
// }
|
||||
//
|
||||
// log.Fatalf("http status: %d, error: %s", status, err)
|
||||
// }
|
||||
//
|
||||
// if data.Success == true {
|
||||
// log.Printf("%v", res.ID)
|
||||
// }
|
||||
func (c *Client) CreateProductsGroup(group ProductGroup) (ActionProductsGroupResponse, int, error) {
|
||||
var result ActionProductsGroupResponse
|
||||
|
||||
groupJSON, _ := json.Marshal(group)
|
||||
|
||||
p := url.Values{
|
||||
"productGroup": {string(groupJSON)},
|
||||
}
|
||||
|
||||
resp, status, err := c.PostRequest("/store/product-groups/create", p)
|
||||
|
||||
if err != nil {
|
||||
return result, status, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(resp, &result)
|
||||
|
||||
if err != nil {
|
||||
return result, status, err
|
||||
}
|
||||
|
||||
return result, status, nil
|
||||
}
|
||||
|
||||
// EditProductsGroup edits a product group
|
||||
//
|
||||
// For more information see https://docs.retailcrm.ru/Developers/API/APIVersions/APIv5#post--api-v5-store-product-groups-externalId-edit
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var client = retailcrm.New("https://demo.url", "09jIJ")
|
||||
//
|
||||
// group := ProductGroup{
|
||||
// Name: "Овощи",
|
||||
// Active: true,
|
||||
// ExternalID: "abc22",
|
||||
// }
|
||||
//
|
||||
// data, status, err := client.EditProductsGroup("id", "125", "main", group)
|
||||
//
|
||||
// if err != nil {
|
||||
// if apiErr, ok := retailcrm.AsAPIError(err); ok {
|
||||
// log.Fatalf("http status: %d, %s", status, apiErr.String())
|
||||
// }
|
||||
//
|
||||
// log.Fatalf("http status: %d, error: %s", status, err)
|
||||
// }
|
||||
//
|
||||
// if data.Success == true {
|
||||
// log.Printf("%v", res.ID)
|
||||
// }
|
||||
func (c *Client) EditProductsGroup(by, id, site string, group ProductGroup) (ActionProductsGroupResponse, int, error) {
|
||||
var result ActionProductsGroupResponse
|
||||
|
||||
groupJSON, _ := json.Marshal(group)
|
||||
|
||||
p := url.Values{
|
||||
"by": {checkBy(by)},
|
||||
"site": {site},
|
||||
"productGroup": {string(groupJSON)},
|
||||
}
|
||||
|
||||
resp, status, err := c.PostRequest(fmt.Sprintf("/store/product-groups/%s/edit", id), p)
|
||||
|
||||
if err != nil {
|
||||
return result, status, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(resp, &result)
|
||||
|
||||
if err != nil {
|
||||
return result, status, err
|
||||
}
|
||||
|
||||
return result, status, nil
|
||||
}
|
||||
|
||||
// GetOrderPlate receives a print form file for the order
|
||||
//
|
||||
// # Body of response is already closed
|
||||
//
|
||||
// For more information see https://help.retailcrm.ru/api_v5_ru.html#get--api-v5-orders-externalId-plates-plateId-print
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var client = retailcrm.New("https://demo.url", "09jIJ")
|
||||
//
|
||||
// data, status, err := client.GetOrderPlate("id", "107", "main", 1)
|
||||
//
|
||||
// if err != nil {
|
||||
// if apiErr, ok := retailcrm.AsAPIError(err); ok {
|
||||
// log.Fatalf("http status: %d, %s", status, apiErr.String())
|
||||
// }
|
||||
//
|
||||
// log.Fatalf("http status: %d, error: %s", status, err)
|
||||
// }
|
||||
//
|
||||
// if data != nil {
|
||||
// fileData, err := io.ReadAll(data)
|
||||
// if err != nil {
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// log.Printf("%s", fileData)
|
||||
// }
|
||||
func (c *Client) GetOrderPlate(by, orderID, site string, plateID int) (io.ReadCloser, int, error) {
|
||||
p := url.Values{
|
||||
"by": {checkBy(by)},
|
||||
"site": {site},
|
||||
}
|
||||
|
||||
requestURL := fmt.Sprintf("%s/api/v5/orders/%s/plates/%d/print?%s", c.URL, orderID, plateID, p.Encode())
|
||||
req, err := http.NewRequest("GET", requestURL, nil)
|
||||
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
req.Header.Set("X-API-KEY", c.Key)
|
||||
|
||||
if c.Debug {
|
||||
c.writeLog("API Request: %s %s", requestURL, c.Key)
|
||||
}
|
||||
|
||||
resp, err := c.httpClient.Do(req)
|
||||
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
if resp.StatusCode >= http.StatusInternalServerError {
|
||||
return nil, resp.StatusCode, CreateGenericAPIError(
|
||||
fmt.Sprintf("HTTP request error. Status code: %d.", resp.StatusCode))
|
||||
}
|
||||
|
||||
if resp.StatusCode >= http.StatusBadRequest && resp.StatusCode < http.StatusInternalServerError {
|
||||
res, err := buildRawResponse(resp)
|
||||
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
return nil, resp.StatusCode, CreateAPIError(res)
|
||||
}
|
||||
|
||||
reader := resp.Body
|
||||
err = reader.Close()
|
||||
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
return reader, resp.StatusCode, nil
|
||||
}
|
||||
|
947
client_test.go
947
client_test.go
File diff suppressed because it is too large
Load Diff
34
filters.go
34
filters.go
@ -439,3 +439,37 @@ 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:"minOrderSum,omitempty"`
|
||||
MaxOrderSum string `url:"maxOrderSum,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"`
|
||||
}
|
||||
|
31
request.go
31
request.go
@ -246,6 +246,37 @@ type AccountBonusOperationsRequest struct {
|
||||
Page int `url:"page,omitempty"`
|
||||
}
|
||||
|
||||
type LoyaltyBonusCreditRequest struct {
|
||||
Amount float64 `url:"amount"`
|
||||
ActivationDate string `url:"activationDate,omitempty"`
|
||||
ExpiredDate string `url:"expiredDate,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:"limit,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"`
|
||||
}
|
||||
|
||||
// SystemURL returns system URL from the connection request without trailing slash.
|
||||
func (r ConnectRequest) SystemURL() string {
|
||||
if r.URL == "" {
|
||||
|
87
response.go
87
response.go
@ -5,6 +5,17 @@ type SuccessfulResponse struct {
|
||||
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.
|
||||
type CreateResponse struct {
|
||||
Success bool `json:"success"`
|
||||
@ -112,6 +123,7 @@ type CorporateCustomerChangeResponse CustomerChangeResponse
|
||||
type CustomersUploadResponse struct {
|
||||
Success bool `json:"success"`
|
||||
UploadedCustomers []IdentifiersPair `json:"uploadedCustomers,omitempty"`
|
||||
FailedCustomers []ExternalID `json:"failedCustomers,omitempty"`
|
||||
}
|
||||
|
||||
// CorporateCustomersUploadResponse type.
|
||||
@ -156,6 +168,7 @@ type OrdersStatusesResponse struct {
|
||||
type OrdersUploadResponse struct {
|
||||
Success bool `json:"success"`
|
||||
UploadedOrders []IdentifiersPair `json:"uploadedOrders,omitempty"`
|
||||
FailedOrders []ExternalID `json:"failedOrders,omitempty"`
|
||||
}
|
||||
|
||||
// OrdersHistoryResponse type.
|
||||
@ -370,6 +383,23 @@ type ProductsResponse struct {
|
||||
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.
|
||||
type ProductsPropertiesResponse struct {
|
||||
Success bool `json:"success"`
|
||||
@ -420,6 +450,7 @@ type ResponseInfo struct {
|
||||
MgTransportInfo MgInfo `json:"mgTransport,omitempty"`
|
||||
MgBotInfo MgInfo `json:"mgBot,omitempty"`
|
||||
BillingInfo *BillingInfo `json:"billingInfo,omitempty"`
|
||||
DeliveryTypeInfo DeliveryTypeInfo `json:"deliveryType,omitempty"`
|
||||
}
|
||||
|
||||
type BillingInfo struct {
|
||||
@ -564,3 +595,59 @@ type AccountBonusOperationsResponse struct {
|
||||
Pagination *Pagination `json:"pagination,omitempty"`
|
||||
BonusOperations []BonusOperation `json:"bonusOperations,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"`
|
||||
}
|
||||
|
426
testutils.go
Normal file
426
testutils.go
Normal file
@ -0,0 +1,426 @@
|
||||
//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: []string{"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: []string{"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: []string{"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": []
|
||||
}
|
||||
}`
|
||||
}
|
||||
|
||||
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"
|
||||
}
|
||||
}`
|
||||
}
|
217
types.go
217
types.go
@ -328,6 +328,8 @@ type Order struct {
|
||||
Items []OrderItem `json:"items,omitempty"`
|
||||
CustomFields StringMap `json:"customFields,omitempty"`
|
||||
Payments OrderPayments `json:"payments,omitempty"`
|
||||
ApplyRound *bool `json:"applyRound,omitempty"`
|
||||
PrivilegeType string `json:"privilegeType,omitempty"`
|
||||
}
|
||||
|
||||
// OrdersStatus type.
|
||||
@ -703,6 +705,21 @@ type WorkTime struct {
|
||||
LunchEndTime string `json:"lunch_end_time"`
|
||||
}
|
||||
|
||||
type SerializedBaseLoyaltyAccount struct {
|
||||
PhoneNumber string `json:"phoneNumber,omitempty"`
|
||||
CardNumber string `json:"cardNumber,omitempty"`
|
||||
CustomFields []string `json:"customFields,omitempty"`
|
||||
}
|
||||
|
||||
type SerializedCreateLoyaltyAccount struct {
|
||||
SerializedBaseLoyaltyAccount
|
||||
Customer SerializedEntityCustomer `json:"customer"`
|
||||
}
|
||||
|
||||
type SerializedEditLoyaltyAccount struct {
|
||||
SerializedBaseLoyaltyAccount
|
||||
}
|
||||
|
||||
// Settings type. Contains retailCRM configuration.
|
||||
type Settings struct {
|
||||
DefaultCurrency SettingsNode `json:"default_currency"`
|
||||
@ -768,7 +785,13 @@ type DeliveryType struct {
|
||||
VatRate string `json:"vatRate,omitempty"`
|
||||
DefaultForCrm bool `json:"defaultForCrm,omitempty"`
|
||||
DeliveryServices []string `json:"deliveryServices,omitempty"`
|
||||
PaymentTypes []string `json:"paymentTypes,omitempty"`
|
||||
PaymentTypes []string `json:"paymentTypes,omitempty"` // Deprecated, use DeliveryPaymentTypes
|
||||
DeliveryPaymentTypes []DeliveryPaymentType `json:"deliveryPaymentTypes,omitempty"`
|
||||
}
|
||||
|
||||
type DeliveryPaymentType struct {
|
||||
Code string `json:"code"`
|
||||
Cod bool `json:"cod,omitempty"`
|
||||
}
|
||||
|
||||
// LegalEntity type.
|
||||
@ -793,6 +816,11 @@ type LegalEntity struct {
|
||||
BankAccount string `json:"bankAccount,omitempty"`
|
||||
}
|
||||
|
||||
type SerializedEntityCustomer struct {
|
||||
ID int `json:"id,omitempty"`
|
||||
ExternalID int `json:"externalId,omitempty"`
|
||||
}
|
||||
|
||||
// OrderMethod type.
|
||||
type OrderMethod struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
@ -898,6 +926,9 @@ type Site struct {
|
||||
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"`
|
||||
}
|
||||
|
||||
// Store type.
|
||||
@ -922,29 +953,60 @@ type ProductGroup struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Site string `json:"site,omitempty"`
|
||||
Active bool `json:"active,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
ExternalID string `json:"externalId,omitempty"`
|
||||
ParentExternalID string `json:"parentExternalId,omitempty"`
|
||||
}
|
||||
|
||||
// Product type.
|
||||
type Product struct {
|
||||
ID int `json:"id,omitempty"`
|
||||
MaxPrice float32 `json:"maxPrice,omitempty"`
|
||||
MinPrice float32 `json:"minPrice,omitempty"`
|
||||
// BaseProduct type.
|
||||
type BaseProduct struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
URL string `json:"url,omitempty"`
|
||||
Article string `json:"article,omitempty"`
|
||||
ExternalID string `json:"externalId,omitempty"`
|
||||
Manufacturer string `json:"manufacturer,omitempty"`
|
||||
ImageURL string `json:"imageUrl,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Popular bool `json:"popular,omitempty"`
|
||||
Stock bool `json:"stock,omitempty"`
|
||||
Novelty bool `json:"novelty,omitempty"`
|
||||
Recommended bool `json:"recommended,omitempty"`
|
||||
Active bool `json:"active,omitempty"`
|
||||
Markable bool `json:"markable,omitempty"`
|
||||
}
|
||||
|
||||
// Product type.
|
||||
type Product struct {
|
||||
BaseProduct
|
||||
ID int `json:"id,omitempty"`
|
||||
MaxPrice float32 `json:"maxPrice,omitempty"`
|
||||
MinPrice float32 `json:"minPrice,omitempty"`
|
||||
ImageURL string `json:"imageUrl,omitempty"`
|
||||
Quantity float32 `json:"quantity,omitempty"`
|
||||
Offers []Offer `json:"offers,omitempty"`
|
||||
Groups []ProductGroup `json:"groups,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.
|
||||
@ -1025,6 +1087,8 @@ type DeliveryStatus struct {
|
||||
Code string `json:"code,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
IsEditable bool `json:"isEditable,omitempty"`
|
||||
IsError bool `json:"isError,omitempty"`
|
||||
IsPreprocessing bool `json:"isPreprocessing,omitempty"`
|
||||
}
|
||||
|
||||
// Plate type.
|
||||
@ -1230,3 +1294,140 @@ type OperationLoyalty struct {
|
||||
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 []string `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"`
|
||||
}
|
||||
|
||||
// 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"`
|
||||
}
|
||||
|
||||
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"`
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user