mirror of
https://github.com/retailcrm/api-client-go.git
synced 2024-11-22 04:46:03 +03:00
Add/edit methods
add `/api/v5/store/products/batch/create`, `/api/v5/store/products/batch/edit` add fields `isError` and `isPreprocessing` for statuses of integration delivery add field `deliveryType` for response of creating integration module with inegration delivery add `/api/v5/loyalty/account/create`, `/api/v5/loyalty/account/{id}`, `/api/v5/loyalty/account/{id}/edit` add `/api/v5/loyalty/account/{id}/activate`, `/api/v5/loyalty/account/{id}/bonus/credit` add `/api/v5/loyalty/account/{id}/bonus/{status}/details`
This commit is contained in:
parent
2f6ab28d85
commit
921d4c1295
344
client.go
344
client.go
@ -1846,7 +1846,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,
|
||||
) {
|
||||
@ -5644,6 +5643,40 @@ 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
|
||||
|
||||
@ -5666,6 +5699,38 @@ func (c *Client) ProductsBatchEdit(products []ProductEdit) (ProductsBatchEditRes
|
||||
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
|
||||
|
||||
@ -5688,3 +5753,280 @@ func (c *Client) ProductsBatchCreate(products []ProductCreate) (ProductsBatchEdi
|
||||
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
|
||||
}
|
||||
|
444
client_test.go
444
client_test.go
@ -3,6 +3,7 @@ package retailcrm
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/google/go-querystring/query"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"math/rand"
|
||||
@ -21,6 +22,8 @@ import (
|
||||
gock "gopkg.in/h2non/gock.v1"
|
||||
)
|
||||
|
||||
const prefix = "/api/v5"
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
err := godotenv.Load(".env")
|
||||
if err != nil {
|
||||
@ -5124,6 +5127,26 @@ func TestClient_IntegrationModule(t *testing.T) {
|
||||
BaseURL: fmt.Sprintf("http://example.com/%s", name),
|
||||
ClientID: RandomString(10),
|
||||
Logo: "https://cdn.worldvectorlogo.com/logos/github-icon.svg",
|
||||
Integrations: &Integrations{
|
||||
Delivery: &Delivery{
|
||||
StatusList: []DeliveryStatus{
|
||||
{
|
||||
Code: "st1",
|
||||
Name: "st1",
|
||||
IsEditable: true,
|
||||
IsError: true,
|
||||
IsPreprocessing: false,
|
||||
},
|
||||
{
|
||||
Code: "st2",
|
||||
Name: "st2",
|
||||
IsEditable: false,
|
||||
IsError: false,
|
||||
IsPreprocessing: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
jsonData := fmt.Sprintf(
|
||||
@ -5140,7 +5163,24 @@ func TestClient_IntegrationModule(t *testing.T) {
|
||||
MatchType("url").
|
||||
BodyString(pr.Encode()).
|
||||
Reply(201).
|
||||
BodyString(`{"success": true}`)
|
||||
BodyString(`{
|
||||
"success": true,
|
||||
"info": {
|
||||
"deliveryType": {
|
||||
"id": 38,
|
||||
"code": "sdek-v-2-podkliuchenie-1"
|
||||
},
|
||||
"billingInfo": {
|
||||
"price": 0,
|
||||
"currency": {
|
||||
"name": "Рубль",
|
||||
"shortName": "руб.",
|
||||
"code": "RUB"
|
||||
},
|
||||
"billingType": "fixed"
|
||||
}
|
||||
}
|
||||
}`)
|
||||
|
||||
m, status, err := c.IntegrationModuleEdit(integrationModule)
|
||||
if err != nil {
|
||||
@ -6803,25 +6843,144 @@ func TestClient_AccountBonusOperations_Fail(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Проверить реально запросы
|
||||
func TestClient_ProductsBatchCreate(t *testing.T) {
|
||||
defer gock.Off()
|
||||
|
||||
products := getProductsCreate()
|
||||
productsJSON, err := json.Marshal(getProductsCreate())
|
||||
productsJSON, err := json.Marshal(products)
|
||||
assert.NoError(t, err)
|
||||
|
||||
p := url.Values{"products": {string(productsJSON)}}
|
||||
|
||||
gock.New(crmURL).
|
||||
Post("/store/products/batch/create").
|
||||
Post(prefix + "/store/products/batch/create").
|
||||
BodyString(p.Encode()).
|
||||
Reply(http.StatusOK).
|
||||
JSON(getProductsCreateResponse())
|
||||
|
||||
resp, status, err := client().ProductsBatchCreate(products)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("%v", err)
|
||||
}
|
||||
|
||||
if !statuses[status] {
|
||||
t.Errorf("%v", err)
|
||||
}
|
||||
|
||||
if resp.Success != true || resp.ProcessedProductsCount == 0 {
|
||||
t.Errorf("%v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClient_ProductsBatchCreateFail(t *testing.T) {
|
||||
defer gock.Off()
|
||||
|
||||
products := getProductsCreate()
|
||||
productsJSON, err := json.Marshal(products)
|
||||
assert.NoError(t, err)
|
||||
|
||||
p := url.Values{"products": {string(productsJSON)}}
|
||||
|
||||
gock.New(crmURL).
|
||||
Post(prefix + "/store/products/batch/create").
|
||||
BodyString(p.Encode()).
|
||||
Reply(http.StatusBadRequest).
|
||||
JSON(`{"success":false,"errorMsg":"Something went wrong"}`)
|
||||
|
||||
resp, status, err := client().ProductsBatchCreate(products)
|
||||
|
||||
if err == nil {
|
||||
t.Error("Expected error")
|
||||
}
|
||||
|
||||
if status < http.StatusBadRequest {
|
||||
t.Errorf("%v", err)
|
||||
}
|
||||
|
||||
if resp.Success != false {
|
||||
t.Error(successFail)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClient_ProductsBatchEdit(t *testing.T) {
|
||||
defer gock.Off()
|
||||
|
||||
products := getProductsEdit()
|
||||
productsJSON, err := json.Marshal(products)
|
||||
assert.NoError(t, err)
|
||||
|
||||
p := url.Values{"products": {string(productsJSON)}}
|
||||
|
||||
gock.New(crmURL).
|
||||
Post(prefix + "/store/products/batch/edit").
|
||||
BodyString(p.Encode()).
|
||||
Reply(http.StatusOK).
|
||||
JSON(getProductsEditResponse())
|
||||
|
||||
resp, status, err := client().ProductsBatchEdit(products)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("%v", err)
|
||||
}
|
||||
|
||||
if !statuses[status] {
|
||||
t.Errorf("%v", err)
|
||||
}
|
||||
|
||||
if resp.Success != true || resp.ProcessedProductsCount == 0 {
|
||||
t.Errorf("%v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClient_ProductsBatchEditFail(t *testing.T) {
|
||||
defer gock.Off()
|
||||
|
||||
products := getProductsEdit()
|
||||
productsJSON, err := json.Marshal(products)
|
||||
assert.NoError(t, err)
|
||||
|
||||
p := url.Values{"products": {string(productsJSON)}}
|
||||
|
||||
gock.New(crmURL).
|
||||
Post(prefix + "/store/products/batch/edit").
|
||||
BodyString(p.Encode()).
|
||||
Reply(http.StatusInternalServerError).
|
||||
JSON(`{"success":false,"errorMsg":"Something went wrong"}`)
|
||||
|
||||
resp, status, err := client().ProductsBatchEdit(products)
|
||||
|
||||
if err == nil {
|
||||
t.Error("Expected error")
|
||||
}
|
||||
|
||||
if status != http.StatusInternalServerError {
|
||||
t.Errorf("%v", err)
|
||||
}
|
||||
|
||||
if resp.Success != false {
|
||||
t.Error(successFail)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClient_LoyaltyAccountCreate(t *testing.T) {
|
||||
defer gock.Off()
|
||||
|
||||
acc := getLoyaltyAccountCreate()
|
||||
accJSON, _ := json.Marshal(acc)
|
||||
p := url.Values{
|
||||
"site": {"second"},
|
||||
"loyaltyAccount": {string(accJSON)},
|
||||
}
|
||||
|
||||
gock.New(crmURL).
|
||||
Post(prefix + "/loyalty/account/create").
|
||||
BodyString(p.Encode()).
|
||||
Reply(http.StatusOK).
|
||||
JSON(getLoyaltyAccountCreateResponse())
|
||||
|
||||
resp, status, err := client().LoyaltyAccountCreate("second", acc)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("%v", err)
|
||||
}
|
||||
@ -6834,3 +6993,280 @@ func TestClient_ProductsBatchCreate(t *testing.T) {
|
||||
t.Errorf("%v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClient_LoyaltyAccountCreateFail(t *testing.T) {
|
||||
defer gock.Off()
|
||||
|
||||
acc := getLoyaltyAccountCreate()
|
||||
accJSON, _ := json.Marshal(acc)
|
||||
p := url.Values{
|
||||
"site": {"second"},
|
||||
"loyaltyAccount": {string(accJSON)},
|
||||
}
|
||||
|
||||
gock.New(crmURL).
|
||||
Post("/loyalty/account/create").
|
||||
BodyString(p.Encode()).
|
||||
Reply(http.StatusInternalServerError).
|
||||
JSON(`{"success":false,"errorMsg":"Something went wrong"}`)
|
||||
|
||||
resp, status, err := client().LoyaltyAccountCreate("second", acc)
|
||||
|
||||
if err == nil {
|
||||
t.Error("Expected error")
|
||||
}
|
||||
|
||||
if status != http.StatusInternalServerError {
|
||||
t.Errorf("%v", err)
|
||||
}
|
||||
|
||||
if resp.Success != false {
|
||||
t.Error(successFail)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClient_LoyaltyAccountEdit(t *testing.T) {
|
||||
defer gock.Off()
|
||||
|
||||
acc := getLoyaltyAccountCreate()
|
||||
acc.PhoneNumber = "89142221020"
|
||||
req := SerializedEditLoyaltyAccount{acc.SerializedBaseLoyaltyAccount}
|
||||
reqJSON, _ := json.Marshal(req)
|
||||
p := url.Values{
|
||||
"loyaltyAccount": {string(reqJSON)},
|
||||
}
|
||||
|
||||
gock.New(crmURL).
|
||||
Post(fmt.Sprintf("/loyalty/account/%d/edit", 13)).
|
||||
BodyString(p.Encode()).
|
||||
Reply(http.StatusOK).
|
||||
JSON(getLoyaltyAccountEditResponse())
|
||||
|
||||
res, status, err := client().LoyaltyAccountEdit(13, req)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("%v", err)
|
||||
}
|
||||
|
||||
if !statuses[status] {
|
||||
t.Errorf("%v", err)
|
||||
}
|
||||
|
||||
if res.Success != true {
|
||||
t.Errorf("%v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClient_LoyaltyAccountEditFail(t *testing.T) {
|
||||
defer gock.Off()
|
||||
|
||||
acc := getLoyaltyAccountCreate()
|
||||
acc.PhoneNumber = "89142221020"
|
||||
req := SerializedEditLoyaltyAccount{acc.SerializedBaseLoyaltyAccount}
|
||||
reqJSON, _ := json.Marshal(req)
|
||||
p := url.Values{
|
||||
"loyaltyAccount": {string(reqJSON)},
|
||||
}
|
||||
|
||||
gock.New(crmURL).
|
||||
Post(fmt.Sprintf("/loyalty/account/%d/edit", 13)).
|
||||
BodyString(p.Encode()).
|
||||
Reply(http.StatusInternalServerError).
|
||||
JSON(`{"success":false,"errorMsg":"Something went wrong"}`)
|
||||
|
||||
res, status, err := client().LoyaltyAccountEdit(13, req)
|
||||
|
||||
if err == nil {
|
||||
t.Error("Expected error")
|
||||
}
|
||||
|
||||
if status != http.StatusInternalServerError {
|
||||
t.Errorf("%v", err)
|
||||
}
|
||||
|
||||
if res.Success != false {
|
||||
t.Error(successFail)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClient_LoyaltyAccount(t *testing.T) {
|
||||
defer gock.Off()
|
||||
|
||||
gock.New(crmURL).
|
||||
Get(prefix + fmt.Sprintf("/loyalty/account/%d", 13)).
|
||||
Reply(http.StatusOK).
|
||||
JSON(getLoyaltyAccountResponse())
|
||||
|
||||
res, status, err := client().LoyaltyAccount(13)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("%v", err)
|
||||
}
|
||||
|
||||
if !statuses[status] {
|
||||
t.Errorf("%v", err)
|
||||
}
|
||||
|
||||
if res.Success != true {
|
||||
t.Errorf("%v", err)
|
||||
}
|
||||
|
||||
assert.NotEmpty(t, res.LoyaltyAccount.ID)
|
||||
assert.NotEmpty(t, res.LoyaltyAccount.Loyalty)
|
||||
assert.NotEmpty(t, res.LoyaltyAccount.Customer)
|
||||
assert.NotEmpty(t, res.LoyaltyAccount.PhoneNumber)
|
||||
assert.NotEmpty(t, res.LoyaltyAccount.NextLevelSum)
|
||||
assert.NotEmpty(t, res.LoyaltyAccount.LoyaltyLevel)
|
||||
assert.NotEmpty(t, res.LoyaltyAccount.CreatedAt)
|
||||
assert.NotEmpty(t, res.LoyaltyAccount.ActivatedAt)
|
||||
assert.NotEmpty(t, res.LoyaltyAccount.Status)
|
||||
}
|
||||
|
||||
func TestClient_LoyaltyAccountActivate(t *testing.T) {
|
||||
defer gock.Off()
|
||||
|
||||
var resp LoyaltyAccountActivateResponse
|
||||
err := json.Unmarshal([]byte(getLoyaltyAccountResponse()), &resp)
|
||||
assert.NoError(t, err)
|
||||
resp.Verification = SmsVerification{
|
||||
CreatedAt: "2022-11-24 12:39:37",
|
||||
ExpiredAt: "2022-11-24 12:39:37",
|
||||
VerifiedAt: "2022-11-24 13:39:37",
|
||||
CheckID: "test",
|
||||
ActionType: "test",
|
||||
}
|
||||
gock.New(crmURL).
|
||||
Post(prefix + fmt.Sprintf("/loyalty/account/%d/activate", 13)).
|
||||
Body(strings.NewReader("")).
|
||||
Reply(http.StatusOK).
|
||||
JSON(resp)
|
||||
|
||||
res, status, err := client().LoyaltyAccountActivate(13)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("%v", err)
|
||||
}
|
||||
|
||||
if !statuses[status] {
|
||||
t.Errorf("%v", err)
|
||||
}
|
||||
|
||||
if res.Success != true {
|
||||
t.Errorf("%v", err)
|
||||
}
|
||||
|
||||
assert.NotEmpty(t, res.LoyaltyAccount.ID)
|
||||
assert.NotEmpty(t, res.LoyaltyAccount.Loyalty)
|
||||
assert.NotEmpty(t, res.LoyaltyAccount.Customer)
|
||||
assert.NotEmpty(t, res.LoyaltyAccount.PhoneNumber)
|
||||
assert.NotEmpty(t, res.LoyaltyAccount.NextLevelSum)
|
||||
assert.NotEmpty(t, res.LoyaltyAccount.LoyaltyLevel)
|
||||
assert.NotEmpty(t, res.LoyaltyAccount.CreatedAt)
|
||||
assert.NotEmpty(t, res.LoyaltyAccount.ActivatedAt)
|
||||
assert.NotEmpty(t, res.LoyaltyAccount.Status)
|
||||
assert.NotEmpty(t, res.Verification)
|
||||
}
|
||||
|
||||
func TestClient_LoyaltyBonusCredit(t *testing.T) {
|
||||
defer gock.Off()
|
||||
|
||||
req := LoyaltyBonusCreditRequest{
|
||||
Amount: 120,
|
||||
ExpiredDate: "2023-11-24 12:39:37",
|
||||
Comment: "Test",
|
||||
}
|
||||
body, err := query.Values(req)
|
||||
assert.NoError(t, err)
|
||||
|
||||
gock.New(crmURL).
|
||||
Post(prefix + fmt.Sprintf("/loyalty/account/%d/bonus/credit", 13)).
|
||||
BodyString(body.Encode()).
|
||||
Reply(http.StatusOK).
|
||||
JSON(`{
|
||||
"success":true,
|
||||
"loyaltyBonus": {
|
||||
"amount":120,
|
||||
"expiredDate":"2023-11-24 12:39:37"
|
||||
}
|
||||
}`)
|
||||
|
||||
res, status, err := client().LoyaltyBonusCredit(13, req)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("%v", err)
|
||||
}
|
||||
|
||||
if !statuses[status] {
|
||||
t.Errorf("%v", err)
|
||||
}
|
||||
|
||||
if res.Success != true {
|
||||
t.Errorf("%v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClient_LoyaltyBonusCreditFail(t *testing.T) {
|
||||
defer gock.Off()
|
||||
|
||||
req := LoyaltyBonusCreditRequest{
|
||||
Amount: 120,
|
||||
ExpiredDate: "2023-11-24 12:39:37",
|
||||
Comment: "Test",
|
||||
}
|
||||
body, err := query.Values(req)
|
||||
assert.NoError(t, err)
|
||||
|
||||
gock.New(crmURL).
|
||||
Post(prefix + fmt.Sprintf("/loyalty/account/%d/bonus/credit", 13)).
|
||||
BodyString(body.Encode()).
|
||||
Reply(http.StatusInternalServerError).
|
||||
JSON(`{"success":false,"errorMsg":"Something went wrong"}`)
|
||||
|
||||
res, status, err := client().LoyaltyBonusCredit(13, req)
|
||||
|
||||
if err == nil {
|
||||
t.Error("Expected error")
|
||||
}
|
||||
|
||||
if status != http.StatusInternalServerError {
|
||||
t.Errorf("%v", err)
|
||||
}
|
||||
|
||||
if res.Success != false {
|
||||
t.Error(successFail)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClient_LoyaltyBonusStatusDetails(t *testing.T) {
|
||||
defer gock.Off()
|
||||
|
||||
req := LoyaltyBonusStatusDetailsRequest{
|
||||
Limit: 20,
|
||||
Page: 3,
|
||||
}
|
||||
|
||||
gock.New(crmURL).
|
||||
Get(prefix+fmt.Sprintf("/loyalty/account/%d/bonus/%s/details", 13, "waiting_activation")).
|
||||
MatchParam("limit", strconv.Itoa(20)).
|
||||
MatchParam("page", strconv.Itoa(3)).
|
||||
Reply(http.StatusOK).
|
||||
JSON(getBonusDetailsResponse())
|
||||
|
||||
res, status, err := client().LoyaltyBonusStatusDetails(13, "waiting_activation", req)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("%v", err)
|
||||
}
|
||||
|
||||
if !statuses[status] {
|
||||
t.Errorf("%v", err)
|
||||
}
|
||||
|
||||
if res.Success != true {
|
||||
t.Errorf("%v", err)
|
||||
}
|
||||
|
||||
assert.NotEmpty(t, res.Pagination.TotalCount)
|
||||
assert.NotEmpty(t, res.Bonuses)
|
||||
assert.NotEmpty(t, res.Statistic.TotalAmount)
|
||||
}
|
||||
|
13
request.go
13
request.go
@ -246,6 +246,19 @@ 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"`
|
||||
}
|
||||
|
||||
// SystemURL returns system URL from the connection request without trailing slash.
|
||||
func (r ConnectRequest) SystemURL() string {
|
||||
if r.URL == "" {
|
||||
|
48
response.go
48
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"`
|
||||
@ -376,13 +387,13 @@ type ProductEditNotFoundResponse struct {
|
||||
}
|
||||
|
||||
type ProductsBatchEditResponse struct {
|
||||
Success bool `json:"success"`
|
||||
SuccessfulResponse
|
||||
ProcessedProductsCount int `json:"processedProductsCount,omitempty"`
|
||||
NotFoundProducts []ProductEditNotFoundResponse `json:"notFoundProducts,omitempty"`
|
||||
}
|
||||
|
||||
type ProductsBatchCreateResponse struct {
|
||||
Success bool `json:"success"`
|
||||
SuccessfulResponse
|
||||
ProcessedProductsCount int `json:"processedProductsCount,omitempty"`
|
||||
AddedProducts []int `json:"addedProducts,omitempty"`
|
||||
}
|
||||
@ -437,6 +448,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 {
|
||||
@ -581,3 +593,35 @@ 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"`
|
||||
}
|
||||
|
||||
type LoyaltyBonusStatisticResponse struct {
|
||||
TotalAmount float64 `json:"totalAmount"`
|
||||
}
|
||||
|
||||
type BonusDetail struct {
|
||||
Date string `json:"date"`
|
||||
Amount float64 `json:"amount"`
|
||||
}
|
||||
|
136
testutils.go
136
testutils.go
@ -6,7 +6,7 @@ package retailcrm
|
||||
func getProductsCreate() []ProductCreate {
|
||||
products := []ProductCreate{
|
||||
{
|
||||
CatalogID: 123,
|
||||
CatalogID: 3,
|
||||
BaseProduct: BaseProduct{
|
||||
Name: "Product 1",
|
||||
URL: "https://example.com/p/1",
|
||||
@ -19,12 +19,12 @@ func getProductsCreate() []ProductCreate {
|
||||
Novelty: true,
|
||||
Recommended: true,
|
||||
Active: true,
|
||||
Groups: []ProductGroup{{ID: 333}},
|
||||
Markable: true,
|
||||
},
|
||||
Groups: []ProductEditGroupInput{{ID: 19}},
|
||||
},
|
||||
{
|
||||
CatalogID: 123,
|
||||
CatalogID: 3,
|
||||
BaseProduct: BaseProduct{
|
||||
Name: "Product 2",
|
||||
URL: "https://example.com/p/2",
|
||||
@ -37,9 +37,9 @@ func getProductsCreate() []ProductCreate {
|
||||
Novelty: true,
|
||||
Recommended: true,
|
||||
Active: true,
|
||||
Groups: []ProductGroup{{ID: 444}},
|
||||
Markable: true,
|
||||
},
|
||||
Groups: []ProductEditGroupInput{{ID: 19}},
|
||||
},
|
||||
}
|
||||
|
||||
@ -48,8 +48,134 @@ func getProductsCreate() []ProductCreate {
|
||||
|
||||
func getProductsCreateResponse() ProductsBatchCreateResponse {
|
||||
return ProductsBatchCreateResponse{
|
||||
Success: true,
|
||||
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
|
||||
}
|
||||
]
|
||||
}`
|
||||
}
|
||||
|
103
types.go
103
types.go
@ -703,6 +703,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"`
|
||||
@ -793,6 +808,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"`
|
||||
@ -937,7 +957,6 @@ type BaseProduct struct {
|
||||
Novelty bool `json:"novelty,omitempty"`
|
||||
Recommended bool `json:"recommended,omitempty"`
|
||||
Active bool `json:"active,omitempty"`
|
||||
Groups []ProductGroup `json:"groups,omitempty"`
|
||||
Markable bool `json:"markable,omitempty"`
|
||||
}
|
||||
|
||||
@ -951,6 +970,20 @@ type Product struct {
|
||||
Quantity float32 `json:"quantity,omitempty"`
|
||||
Offers []Offer `json:"offers,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.
|
||||
@ -959,12 +992,7 @@ type ProductEdit struct {
|
||||
ID int `json:"id,omitempty"`
|
||||
CatalogID int `json:"catalogId,omitempty"`
|
||||
Site string `json:"site,omitempty"`
|
||||
}
|
||||
|
||||
// ProductCreate type.
|
||||
type ProductCreate struct {
|
||||
BaseProduct
|
||||
CatalogID int `json:"catalogId,omitempty"`
|
||||
Groups []ProductEditGroupInput `json:"groups,omitempty"`
|
||||
}
|
||||
|
||||
// DeliveryHistoryRecord type.
|
||||
@ -1045,6 +1073,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.
|
||||
@ -1250,3 +1280,62 @@ 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"`
|
||||
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"`
|
||||
}
|
||||
|
||||
// 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 float64 `json:"amount"`
|
||||
ActivationDate string `json:"activationDate"`
|
||||
ExpiredDate string `json:"expiredDate,omitempty"`
|
||||
}
|
||||
|
||||
type LoyaltyBonusApiFilterType struct {
|
||||
Date string `url:"date,omitempty"`
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user