mirror of
https://github.com/retailcrm/api-client-go.git
synced 2025-04-18 16:31:02 +00:00
Compare commits
6 commits
Author | SHA1 | Date | |
---|---|---|---|
39568f3db6 | |||
|
3c2715bc36 | ||
c62a02aa1f | |||
|
871459c8b7 | ||
d0b0dd59d6 | |||
|
cc83657f32 |
7 changed files with 510 additions and 0 deletions
168
client.go
168
client.go
|
@ -1957,6 +1957,174 @@ func (c *Client) CorporateCustomerEdit(customer CorporateCustomer, by string, si
|
||||||
return resp, status, nil
|
return resp, status, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ClearCart clears the current customer's shopping cart
|
||||||
|
//
|
||||||
|
// For more information see https://docs.retailcrm.ru/Developers/API/APIVersions/APIv5#post--api-v5-customer-interaction-site-cart-clear
|
||||||
|
//
|
||||||
|
// Example:
|
||||||
|
//
|
||||||
|
// var client = retailcrm.New("https://demo.url", "09jIJ")
|
||||||
|
//
|
||||||
|
// data, status, err := client.ClearCart("site_id", retailcrm.SiteFilter{SiteBy: "id"},
|
||||||
|
// retailcrm.ClearCartRequest{
|
||||||
|
// ClearedAt: time.Now().String(),
|
||||||
|
// Customer: retailcrm.CartCustomer{
|
||||||
|
// ID: 1,
|
||||||
|
// ExternalID: "ext_id",
|
||||||
|
// Site: "site",
|
||||||
|
// BrowserID: "browser_id",
|
||||||
|
// GaClientID: "ga_client_id",
|
||||||
|
// },
|
||||||
|
// Order: retailcrm.ClearCartOrder{
|
||||||
|
// ID: 1,
|
||||||
|
// ExternalID: "ext_id",
|
||||||
|
// Number: "abc123",
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// )
|
||||||
|
//
|
||||||
|
// 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)
|
||||||
|
// }
|
||||||
|
func (c *Client) ClearCart(site string, filter SiteFilter, req ClearCartRequest) (
|
||||||
|
SuccessfulResponse, int, error,
|
||||||
|
) {
|
||||||
|
var resp SuccessfulResponse
|
||||||
|
|
||||||
|
updateJSON, err := json.Marshal(&req)
|
||||||
|
if err != nil {
|
||||||
|
return SuccessfulResponse{}, 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
p := url.Values{
|
||||||
|
"cart": {string(updateJSON)},
|
||||||
|
}
|
||||||
|
|
||||||
|
params, _ := query.Values(filter)
|
||||||
|
|
||||||
|
data, status, err := c.PostRequest(fmt.Sprintf("/customer-interaction/%s/cart/clear?%s", site, params.Encode()), p)
|
||||||
|
if err != nil {
|
||||||
|
return resp, status, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal(data, &resp)
|
||||||
|
if err != nil {
|
||||||
|
return resp, status, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp, status, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetCart creates or overwrites shopping cart data
|
||||||
|
//
|
||||||
|
// For more information see https://docs.retailcrm.ru/Developers/API/APIVersions/APIv5#post--api-v5-customer-interaction-site-cart-set
|
||||||
|
//
|
||||||
|
// Example:
|
||||||
|
//
|
||||||
|
// var client = retailcrm.New("https://demo.url", "09jIJ")
|
||||||
|
//
|
||||||
|
// data, status, err := client.SetCart("site_id", retailcrm.SiteFilter{SiteBy: "id"},
|
||||||
|
// retailcrm.SetCartRequest{
|
||||||
|
// ExternalID: "ext_id",
|
||||||
|
// DroppedAt: time.Now().String(),
|
||||||
|
// Link: "link",
|
||||||
|
// Customer: retailcrm.CartCustomer{
|
||||||
|
// ID: 1,
|
||||||
|
// ExternalID: "ext_id",
|
||||||
|
// Site: "site",
|
||||||
|
// BrowserID: "browser_id",
|
||||||
|
// GaClientID: "ga_client_id",
|
||||||
|
// },
|
||||||
|
// Items: []retailcrm.SetCartItem{
|
||||||
|
// {
|
||||||
|
// Quantity: 1,
|
||||||
|
// Price: 1.0,
|
||||||
|
// Offer: retailcrm.SetCartOffer{
|
||||||
|
// ID: 1,
|
||||||
|
// ExternalID: "ext_id",
|
||||||
|
// XMLID: "xml_id",
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// )
|
||||||
|
//
|
||||||
|
// 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)
|
||||||
|
// }
|
||||||
|
func (c *Client) SetCart(site string, filter SiteFilter, req SetCartRequest) (
|
||||||
|
SuccessfulResponse, int, error,
|
||||||
|
) {
|
||||||
|
var resp SuccessfulResponse
|
||||||
|
|
||||||
|
updateJSON, err := json.Marshal(&req)
|
||||||
|
if err != nil {
|
||||||
|
return SuccessfulResponse{}, 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
p := url.Values{
|
||||||
|
"cart": {string(updateJSON)},
|
||||||
|
}
|
||||||
|
|
||||||
|
params, _ := query.Values(filter)
|
||||||
|
|
||||||
|
data, status, err := c.PostRequest(fmt.Sprintf("/customer-interaction/%s/cart/set?%s", site, params.Encode()), p)
|
||||||
|
if err != nil {
|
||||||
|
return resp, status, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal(data, &resp)
|
||||||
|
if err != nil {
|
||||||
|
return resp, status, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp, status, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetCart returns the current customer's shopping cart
|
||||||
|
//
|
||||||
|
// For more information see https://docs.retailcrm.ru/Developers/API/APIVersions/APIv5#get--api-v5-customer-interaction-site-cart-customerId
|
||||||
|
//
|
||||||
|
// Example:
|
||||||
|
//
|
||||||
|
// var client = retailcrm.New("https://demo.url", "09jIJ")
|
||||||
|
//
|
||||||
|
// data, status, err := client.GetCart("site_id","customer_id",
|
||||||
|
// retailcrm.GetCartFilter{ SiteBy: "code", By: "externalId"})
|
||||||
|
//
|
||||||
|
// 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)
|
||||||
|
// }
|
||||||
|
func (c *Client) GetCart(site, customer string, filter GetCartFilter) (CartResponse, int, error) {
|
||||||
|
var resp CartResponse
|
||||||
|
|
||||||
|
params, _ := query.Values(filter)
|
||||||
|
|
||||||
|
data, status, err := c.GetRequest(fmt.Sprintf("/customer-interaction/%s/cart/%s?%s", site, customer, params.Encode()))
|
||||||
|
if err != nil {
|
||||||
|
return resp, status, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal(data, &resp)
|
||||||
|
if err != nil {
|
||||||
|
return resp, status, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp, status, nil
|
||||||
|
}
|
||||||
|
|
||||||
// DeliveryTracking updates tracking data
|
// DeliveryTracking updates tracking data
|
||||||
//
|
//
|
||||||
// For more information see http://www.simla.com/docs/Developers/API/APIVersions/APIv5#post--api-v5-delivery-generic-subcode-tracking
|
// For more information see http://www.simla.com/docs/Developers/API/APIVersions/APIv5#post--api-v5-delivery-generic-subcode-tracking
|
||||||
|
|
233
client_test.go
233
client_test.go
|
@ -1,9 +1,13 @@
|
||||||
package retailcrm
|
package retailcrm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/retailcrm/api-client-go/v2/constant"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
@ -1877,6 +1881,235 @@ func TestClient_CorporateCustomerEdit(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestClient_ClearCart(t *testing.T) {
|
||||||
|
c := client()
|
||||||
|
|
||||||
|
tm := "2025-04-14 15:50:00"
|
||||||
|
clearedAt, err := time.Parse("2006-01-02 15:04:05", tm)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
site := "site_id"
|
||||||
|
filter := SiteFilter{SiteBy: "id"}
|
||||||
|
request := ClearCartRequest{
|
||||||
|
ClearedAt: clearedAt.UTC().Format(constant.DateTimeWithZoneFormat),
|
||||||
|
Customer: CartCustomer{
|
||||||
|
ID: 1,
|
||||||
|
ExternalID: "ext_id",
|
||||||
|
Site: "site",
|
||||||
|
GaClientID: "ga_client_id",
|
||||||
|
},
|
||||||
|
Order: ClearCartOrder{
|
||||||
|
ID: 1,
|
||||||
|
ExternalID: "ext_id",
|
||||||
|
Number: "abc123",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
expectedJSON := `{
|
||||||
|
"clearedAt": "2025-04-14 15:50:00+00:00",
|
||||||
|
"customer": {
|
||||||
|
"id": 1,
|
||||||
|
"externalId": "ext_id",
|
||||||
|
"site": "site",
|
||||||
|
"gaClientId": "ga_client_id"
|
||||||
|
},
|
||||||
|
"order": {
|
||||||
|
"id": 1,
|
||||||
|
"externalId": "ext_id",
|
||||||
|
"number": "abc123"
|
||||||
|
}
|
||||||
|
}`
|
||||||
|
|
||||||
|
defer gock.Off()
|
||||||
|
gock.New(crmURL).
|
||||||
|
Post(fmt.Sprintf("/customer-interaction/%s/cart/clear", site)).
|
||||||
|
AddMatcher(func(request *http.Request, _ *gock.Request) (bool, error) {
|
||||||
|
body, err := io.ReadAll(request.Body)
|
||||||
|
require.NoError(t, err)
|
||||||
|
request.Body = io.NopCloser(bytes.NewBuffer(body))
|
||||||
|
|
||||||
|
val, err := url.ParseQuery(string(body))
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
val.Get("cart")
|
||||||
|
|
||||||
|
if !assert.JSONEq(t, expectedJSON, val.Get("cart")) {
|
||||||
|
return false, errors.New("unequal values")
|
||||||
|
}
|
||||||
|
|
||||||
|
return true, nil
|
||||||
|
}).
|
||||||
|
MatchParam("siteBy", filter.SiteBy).
|
||||||
|
Reply(200).
|
||||||
|
BodyString(`{"success":true}`)
|
||||||
|
|
||||||
|
data, status, err := c.ClearCart(site, filter, request)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("%v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if status >= http.StatusBadRequest {
|
||||||
|
t.Errorf("(%d) %v", status, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if data.Success != true {
|
||||||
|
t.Errorf("%v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestClient_SetCart(t *testing.T) {
|
||||||
|
c := client()
|
||||||
|
|
||||||
|
site := "site_id"
|
||||||
|
filter := SiteFilter{SiteBy: "id"}
|
||||||
|
request := SetCartRequest{
|
||||||
|
ExternalID: "ext_id",
|
||||||
|
DroppedAt: time.Now().UTC().Format(constant.DateTimeWithZoneFormat),
|
||||||
|
Link: "link",
|
||||||
|
Customer: CartCustomer{
|
||||||
|
ID: 1,
|
||||||
|
ExternalID: "ext_id",
|
||||||
|
Site: "site",
|
||||||
|
BrowserID: "browser_id",
|
||||||
|
GaClientID: "ga_client_id",
|
||||||
|
},
|
||||||
|
Items: []SetCartItem{
|
||||||
|
{
|
||||||
|
Quantity: 1,
|
||||||
|
Price: 1.0,
|
||||||
|
Offer: SetCartOffer{
|
||||||
|
ID: 1,
|
||||||
|
ExternalID: "ext_id",
|
||||||
|
XMLID: "xml_id",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
defer gock.Off()
|
||||||
|
gock.New(crmURL).
|
||||||
|
Post(fmt.Sprintf("/customer-interaction/%s/cart/set", site)).
|
||||||
|
AddMatcher(func(req *http.Request, _ *gock.Request) (bool, error) {
|
||||||
|
body, err := io.ReadAll(req.Body)
|
||||||
|
require.NoError(t, err)
|
||||||
|
req.Body = io.NopCloser(bytes.NewBuffer(body))
|
||||||
|
|
||||||
|
val, err := url.ParseQuery(string(body))
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
cartJSON := val.Get("cart")
|
||||||
|
var cart SetCartRequest
|
||||||
|
require.NoError(t, json.Unmarshal([]byte(cartJSON), &cart))
|
||||||
|
|
||||||
|
equal := assert.Equal(t, "ext_id", cart.ExternalID) &&
|
||||||
|
assert.NotEmpty(t, cart.DroppedAt) &&
|
||||||
|
assert.Equal(t, 1, cart.Customer.ID) &&
|
||||||
|
assert.Equal(t, "ext_id", cart.Customer.ExternalID) &&
|
||||||
|
assert.Equal(t, "site", cart.Customer.Site) &&
|
||||||
|
assert.Equal(t, "ga_client_id", cart.Customer.GaClientID) &&
|
||||||
|
assert.Equal(t, float64(1), cart.Items[0].Quantity) &&
|
||||||
|
assert.Equal(t, float64(1), cart.Items[0].Price) &&
|
||||||
|
assert.Equal(t, 1, cart.Items[0].Offer.ID) &&
|
||||||
|
assert.Equal(t, "ext_id", cart.Items[0].Offer.ExternalID) &&
|
||||||
|
assert.Equal(t, "xml_id", cart.Items[0].Offer.XMLID)
|
||||||
|
|
||||||
|
if !equal {
|
||||||
|
return false, errors.New("unequal values")
|
||||||
|
}
|
||||||
|
|
||||||
|
return true, nil
|
||||||
|
}).
|
||||||
|
MatchParam("siteBy", filter.SiteBy).
|
||||||
|
Reply(200).
|
||||||
|
BodyString(`{"success":true}`)
|
||||||
|
|
||||||
|
data, status, err := c.SetCart(site, filter, request)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("%v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if status >= http.StatusBadRequest {
|
||||||
|
t.Errorf("(%d) %v", status, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if data.Success != true {
|
||||||
|
t.Errorf("%v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestClient_GetCart(t *testing.T) {
|
||||||
|
c := client()
|
||||||
|
|
||||||
|
site := "site_id"
|
||||||
|
customer := "customer_id"
|
||||||
|
filter := GetCartFilter{
|
||||||
|
SiteBy: "code",
|
||||||
|
By: "externalId",
|
||||||
|
}
|
||||||
|
|
||||||
|
expCart := Cart{
|
||||||
|
Currency: "currency",
|
||||||
|
ExternalID: "ext_id",
|
||||||
|
DroppedAt: "2025-04-14 14:32:14+03:00",
|
||||||
|
ClearedAt: "2025-04-14 14:52:14+03:00",
|
||||||
|
Link: "link",
|
||||||
|
Items: []CartItem{
|
||||||
|
{
|
||||||
|
ID: 1,
|
||||||
|
Quantity: 2,
|
||||||
|
Price: 3.0,
|
||||||
|
Offer: CartOffer{
|
||||||
|
DisplayName: "name",
|
||||||
|
ID: 1,
|
||||||
|
ExternalID: "ext_id",
|
||||||
|
XMLID: "xml_id",
|
||||||
|
Name: "name",
|
||||||
|
Article: "article",
|
||||||
|
VatRate: "vat_rate",
|
||||||
|
Properties: StringMap{
|
||||||
|
"a": "b",
|
||||||
|
"c": "d",
|
||||||
|
},
|
||||||
|
Barcode: "barcode",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
cartResp := CartResponse{
|
||||||
|
SuccessfulResponse: SuccessfulResponse{Success: true},
|
||||||
|
Cart: expCart,
|
||||||
|
}
|
||||||
|
|
||||||
|
defer gock.Off()
|
||||||
|
gock.New(crmURL).
|
||||||
|
Get(fmt.Sprintf("/customer-interaction/%s/cart/%s", site, customer)).
|
||||||
|
MatchParams(map[string]string{
|
||||||
|
"siteBy": filter.SiteBy,
|
||||||
|
"by": filter.By,
|
||||||
|
}).
|
||||||
|
Reply(200).
|
||||||
|
JSON(cartResp)
|
||||||
|
|
||||||
|
data, status, err := c.GetCart(site, customer, filter)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("%v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if status >= http.StatusBadRequest {
|
||||||
|
t.Errorf("(%d) %v", status, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if data.Success != true {
|
||||||
|
t.Errorf("%v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !reflect.DeepEqual(expCart, data.Cart) {
|
||||||
|
t.Errorf("%v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func TestClient_NotesNotes(t *testing.T) {
|
func TestClient_NotesNotes(t *testing.T) {
|
||||||
c := client()
|
c := client()
|
||||||
|
|
||||||
|
|
3
constant/date.go
Normal file
3
constant/date.go
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
package constant
|
||||||
|
|
||||||
|
const DateTimeWithZoneFormat = "2006-01-02 15:04:05-07:00"
|
15
filters.go
15
filters.go
|
@ -480,3 +480,18 @@ type OffersFilter struct {
|
||||||
Ids []int `url:"ids,omitempty,brackets"`
|
Ids []int `url:"ids,omitempty,brackets"`
|
||||||
Active *int `url:"active,omitempty"`
|
Active *int `url:"active,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SiteFilter struct {
|
||||||
|
// SiteBy contains information about what is betrayed site id or site code.
|
||||||
|
// id|code, default is code.
|
||||||
|
SiteBy string `url:"siteBy,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetCartFilter struct {
|
||||||
|
// SiteBy contains information about what is betrayed site id or site code.
|
||||||
|
// id|code, default is code.
|
||||||
|
SiteBy string `url:"siteBy,omitempty"`
|
||||||
|
// By contains information about what is betrayed: customer id or customer externalId.
|
||||||
|
// id|externalId, default is externalId.
|
||||||
|
By string `url:"by,omitempty"`
|
||||||
|
}
|
||||||
|
|
16
request.go
16
request.go
|
@ -194,6 +194,22 @@ type DeliveryShipmentsRequest struct {
|
||||||
Page int `url:"page,omitempty"`
|
Page int `url:"page,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ClearCartRequest type.
|
||||||
|
type ClearCartRequest struct {
|
||||||
|
ClearedAt string `json:"clearedAt,omitempty"`
|
||||||
|
Customer CartCustomer `json:"customer,omitempty"`
|
||||||
|
Order ClearCartOrder `json:"order,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetCartRequest type.
|
||||||
|
type SetCartRequest struct {
|
||||||
|
ExternalID string `json:"externalId,omitempty"`
|
||||||
|
DroppedAt string `json:"droppedAt,omitempty"`
|
||||||
|
Link string `json:"link,omitempty"`
|
||||||
|
Customer CartCustomer `json:"customer,omitempty"`
|
||||||
|
Items []SetCartItem `json:"items,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// CostsRequest type.
|
// CostsRequest type.
|
||||||
type CostsRequest struct {
|
type CostsRequest struct {
|
||||||
Filter CostsFilter `url:"filter,omitempty"`
|
Filter CostsFilter `url:"filter,omitempty"`
|
||||||
|
|
|
@ -407,6 +407,12 @@ type ProductsPropertiesResponse struct {
|
||||||
Properties []Property `json:"properties,omitempty"`
|
Properties []Property `json:"properties,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CartResponse type.
|
||||||
|
type CartResponse struct {
|
||||||
|
SuccessfulResponse
|
||||||
|
Cart Cart `json:"cart"`
|
||||||
|
}
|
||||||
|
|
||||||
// DeliveryShipmentsResponse type.
|
// DeliveryShipmentsResponse type.
|
||||||
type DeliveryShipmentsResponse struct {
|
type DeliveryShipmentsResponse struct {
|
||||||
Success bool `json:"success"`
|
Success bool `json:"success"`
|
||||||
|
|
69
types.go
69
types.go
|
@ -247,6 +247,15 @@ type CorporateCustomerContactCustomer struct {
|
||||||
Site string `json:"site,omitempty"`
|
Site string `json:"site,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CartCustomer type.
|
||||||
|
type CartCustomer struct {
|
||||||
|
ID int `json:"id,omitempty"`
|
||||||
|
ExternalID string `json:"externalId,omitempty"`
|
||||||
|
Site string `json:"site,omitempty"`
|
||||||
|
BrowserID string `json:"browserId,omitempty"`
|
||||||
|
GaClientID string `json:"gaClientId,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
type Company struct {
|
type Company struct {
|
||||||
ID int `json:"id,omitempty"`
|
ID int `json:"id,omitempty"`
|
||||||
IsMain bool `json:"isMain,omitempty"`
|
IsMain bool `json:"isMain,omitempty"`
|
||||||
|
@ -399,6 +408,13 @@ type SerializedOrderLink struct {
|
||||||
Orders []LinkedOrder `json:"orders,omitempty"`
|
Orders []LinkedOrder `json:"orders,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ClearCartOrder type.
|
||||||
|
type ClearCartOrder struct {
|
||||||
|
ID int `json:"id,omitempty"`
|
||||||
|
ExternalID string `json:"externalId,omitempty"`
|
||||||
|
Number string `json:"number,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// ClientID type.
|
// ClientID type.
|
||||||
type ClientID struct {
|
type ClientID struct {
|
||||||
Value string `json:"value"`
|
Value string `json:"value"`
|
||||||
|
@ -469,6 +485,59 @@ type OrderDeliveryData struct {
|
||||||
AdditionalFields map[string]interface{}
|
AdditionalFields map[string]interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetCartItem type.
|
||||||
|
type SetCartItem struct {
|
||||||
|
Quantity float64 `json:"quantity,omitempty"`
|
||||||
|
Price float64 `json:"price,omitempty"`
|
||||||
|
Offer SetCartOffer `json:"offer,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetCartOffer type.
|
||||||
|
type SetCartOffer struct {
|
||||||
|
ID int `json:"id,omitempty"`
|
||||||
|
ExternalID string `json:"externalId,omitempty"`
|
||||||
|
XMLID string `json:"xmlId,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cart type.
|
||||||
|
type Cart struct {
|
||||||
|
Currency string `json:"currency,omitempty"`
|
||||||
|
ExternalID string `json:"externalId,omitempty"`
|
||||||
|
DroppedAt string `json:"droppedAt,omitempty"`
|
||||||
|
ClearedAt string `json:"clearedAt,omitempty"`
|
||||||
|
Link string `json:"link,omitempty"`
|
||||||
|
Items []CartItem `json:"items,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CartItem type.
|
||||||
|
type CartItem struct {
|
||||||
|
ID int `json:"id,omitempty"`
|
||||||
|
Quantity float64 `json:"quantity,omitempty"`
|
||||||
|
Price float64 `json:"price,omitempty"`
|
||||||
|
Offer CartOffer `json:"offer,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CartOffer type.
|
||||||
|
type CartOffer struct {
|
||||||
|
DisplayName string `json:"displayName,omitempty"`
|
||||||
|
ID int `json:"id,omitempty"`
|
||||||
|
ExternalID string `json:"externalId,omitempty"`
|
||||||
|
XMLID string `json:"xmlId,omitempty"`
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
Article string `json:"article,omitempty"`
|
||||||
|
VatRate string `json:"vatRate,omitempty"`
|
||||||
|
Properties StringMap `json:"properties,omitempty"`
|
||||||
|
Unit CartUnit `json:"unit,omitempty"`
|
||||||
|
Barcode string `json:"barcode,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CartUnit type.
|
||||||
|
type CartUnit struct {
|
||||||
|
Code string `json:"code"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Sym string `json:"sym"`
|
||||||
|
}
|
||||||
|
|
||||||
// UnmarshalJSON method.
|
// UnmarshalJSON method.
|
||||||
func (v *OrderDeliveryData) UnmarshalJSON(b []byte) error {
|
func (v *OrderDeliveryData) UnmarshalJSON(b []byte) error {
|
||||||
var additionalData map[string]interface{}
|
var additionalData map[string]interface{}
|
||||||
|
|
Loading…
Add table
Reference in a new issue