mirror of
https://github.com/retailcrm/api-client-go.git
synced 2025-04-04 05:33:32 +03:00
Delivery, Shipments & Integration modules
This commit is contained in:
parent
116f6d5c5b
commit
66224524e3
5 changed files with 320 additions and 0 deletions
124
v5/client.go
124
v5/client.go
|
@ -1550,3 +1550,127 @@ func (c *Client) ProductsProperties(parameters ProductsPropertiesRequest) (*Prod
|
|||
|
||||
return &resp, status, err
|
||||
}
|
||||
|
||||
// DeliveryTracking method
|
||||
func (c *Client) DeliveryTracking(parameters DeliveryTrackingRequest, subcode string) (*SucessfulResponse, int, ErrorResponse) {
|
||||
var resp SucessfulResponse
|
||||
|
||||
updateJson, _ := json.Marshal(¶meters)
|
||||
|
||||
p := url.Values{
|
||||
"statusUpdate": {string(updateJson[:])},
|
||||
}
|
||||
|
||||
data, status, err := c.PostRequest(fmt.Sprintf("%s/delivery/generic/%s/tracking", versionedPrefix, subcode), p)
|
||||
if err.ErrorMsg != "" {
|
||||
return &resp, status, err
|
||||
}
|
||||
|
||||
json.Unmarshal(data, &resp)
|
||||
|
||||
return &resp, status, err
|
||||
}
|
||||
|
||||
// DeliveryShipments method
|
||||
func (c *Client) DeliveryShipments(parameters DeliveryShipmentsRequest) (*DeliveryShipmentsResponse, int, ErrorResponse) {
|
||||
var resp DeliveryShipmentsResponse
|
||||
|
||||
params, _ := query.Values(parameters)
|
||||
|
||||
data, status, err := c.GetRequest(fmt.Sprintf("%s/delivery/shipments?%s", versionedPrefix, params.Encode()))
|
||||
if err.ErrorMsg != "" {
|
||||
return &resp, status, err
|
||||
}
|
||||
|
||||
json.Unmarshal(data, &resp)
|
||||
|
||||
return &resp, status, err
|
||||
}
|
||||
|
||||
// DeliveryShipments method
|
||||
func (c *Client) DeliveryShipment(id int) (*DeliveryShipmentResponse, int, ErrorResponse) {
|
||||
var resp DeliveryShipmentResponse
|
||||
|
||||
data, status, err := c.GetRequest(fmt.Sprintf("%s/delivery/shipments/%s", versionedPrefix, id))
|
||||
if err.ErrorMsg != "" {
|
||||
return &resp, status, err
|
||||
}
|
||||
|
||||
json.Unmarshal(data, &resp)
|
||||
|
||||
return &resp, status, err
|
||||
}
|
||||
|
||||
// DeliveryShipmentEdit method
|
||||
func (c *Client) DeliveryShipmentEdit(shipment DeliveryShipment, site ...string) (*DeliveryShipmentUpdateResponse, int, ErrorResponse) {
|
||||
var resp DeliveryShipmentUpdateResponse
|
||||
updateJson, _ := json.Marshal(&shipment)
|
||||
|
||||
p := url.Values{
|
||||
"deliveryShipment": {string(updateJson[:])},
|
||||
}
|
||||
|
||||
fillSite(&p, site)
|
||||
|
||||
data, status, err := c.PostRequest(fmt.Sprintf("%s/delivery/shipments/%s/edit", versionedPrefix, strconv.Itoa(shipment.Id)), p)
|
||||
if err.ErrorMsg != "" {
|
||||
return &resp, status, err
|
||||
}
|
||||
|
||||
json.Unmarshal(data, &resp)
|
||||
|
||||
return &resp, status, err
|
||||
}
|
||||
|
||||
// DeliveryShipmentCreate method
|
||||
func (c *Client) DeliveryShipmentCreate(shipment DeliveryShipment, deliveryType string, site ...string) (*DeliveryShipmentUpdateResponse, int, ErrorResponse) {
|
||||
var resp DeliveryShipmentUpdateResponse
|
||||
updateJson, _ := json.Marshal(&shipment)
|
||||
|
||||
p := url.Values{
|
||||
"deliveryType": {string(deliveryType)},
|
||||
"deliveryShipment": {string(updateJson[:])},
|
||||
}
|
||||
|
||||
fillSite(&p, site)
|
||||
|
||||
data, status, err := c.PostRequest(fmt.Sprintf("%s/delivery/shipments/create", versionedPrefix), p)
|
||||
if err.ErrorMsg != "" {
|
||||
return &resp, status, err
|
||||
}
|
||||
|
||||
json.Unmarshal(data, &resp)
|
||||
|
||||
return &resp, status, err
|
||||
}
|
||||
|
||||
// IntegrationModule method
|
||||
func (c *Client) IntegrationModule(code string) (*IntegrationModuleResponse, int, ErrorResponse) {
|
||||
var resp IntegrationModuleResponse
|
||||
|
||||
data, status, err := c.GetRequest(fmt.Sprintf("%s/integration-modules/%s", versionedPrefix, code))
|
||||
if err.ErrorMsg != "" {
|
||||
return &resp, status, err
|
||||
}
|
||||
|
||||
json.Unmarshal(data, &resp)
|
||||
|
||||
return &resp, status, err
|
||||
}
|
||||
|
||||
// IntegrationModuleEdit method
|
||||
func (c *Client) IntegrationModuleEdit(integrationModule IntegrationModule) (*IntegrationModuleEditResponse, int, ErrorResponse) {
|
||||
var resp IntegrationModuleEditResponse
|
||||
updateJson, _ := json.Marshal(&integrationModule)
|
||||
|
||||
p := url.Values{"integrationModule": {string(updateJson[:])}}
|
||||
|
||||
data, status, err := c.PostRequest(fmt.Sprintf("%s/integration-modules/%s/edit", versionedPrefix, integrationModule.Code), p)
|
||||
if err.ErrorMsg != "" {
|
||||
return &resp, status, err
|
||||
}
|
||||
|
||||
json.Unmarshal(data, &resp)
|
||||
|
||||
return &resp, status, err
|
||||
}
|
||||
|
|
|
@ -283,3 +283,16 @@ type ProductsPropertiesFilter struct {
|
|||
Name string `url:"name,omitempty"`
|
||||
Sites []string `url:"sites,omitempty,brackets"`
|
||||
}
|
||||
|
||||
// ShipmentFilter type
|
||||
type ShipmentFilter struct {
|
||||
Ids []int `url:"ids,omitempty,brackets"`
|
||||
ExternalId string `url:"externalId,omitempty"`
|
||||
OrderNumber string `url:"orderNumber,omitempty"`
|
||||
DateFrom string `url:"dateFrom,omitempty"`
|
||||
DateTo string `url:"dateTo,omitempty"`
|
||||
Stores []string `url:"stores,omitempty,brackets"`
|
||||
Managers []string `url:"managers,omitempty,brackets"`
|
||||
DeliveryTypes []string `url:"deliveryTypes,omitempty,brackets"`
|
||||
Statuses []string `url:"statuses,omitempty,brackets"`
|
||||
}
|
||||
|
|
|
@ -127,3 +127,18 @@ type ProductsPropertiesRequest struct {
|
|||
Limit int `url:"limit,omitempty"`
|
||||
Page int `url:"page,omitempty"`
|
||||
}
|
||||
|
||||
// DeliveryTrackingRequest type
|
||||
type DeliveryTrackingRequest struct {
|
||||
DeliveryId string `url:"deliveryId,omitempty"`
|
||||
TrackNumber string `url:"trackNumber,omitempty"`
|
||||
History []DeliveryHistoryRecord `url:"history,omitempty,brackets"`
|
||||
ExtraData map[string]string `url:"extraData,omitempty,brackets"`
|
||||
}
|
||||
|
||||
// DeliveryShipmentsRequest type
|
||||
type DeliveryShipmentsRequest struct {
|
||||
Filter ShipmentFilter `url:"filter,omitempty"`
|
||||
Limit int `url:"limit,omitempty"`
|
||||
Page int `url:"page,omitempty"`
|
||||
}
|
||||
|
|
|
@ -312,3 +312,35 @@ type ProductsPropertiesResponse struct {
|
|||
Pagination *Pagination `json:"pagination,omitempty"`
|
||||
Properties []Property `json:"properties,omitempty,brackets"`
|
||||
}
|
||||
|
||||
// DeliveryShipmentsResponse type
|
||||
type DeliveryShipmentsResponse struct {
|
||||
Success bool `json:"success"`
|
||||
Pagination *Pagination `json:"pagination,omitempty"`
|
||||
DeliveryShipments []DeliveryShipment `json:"deliveryShipments,omitempty,brackets"`
|
||||
}
|
||||
|
||||
// DeliveryShipmentResponse type
|
||||
type DeliveryShipmentResponse struct {
|
||||
Success bool `json:"success"`
|
||||
DeliveryShipment *DeliveryShipment `json:"deliveryShipment,omitempty,brackets"`
|
||||
}
|
||||
|
||||
// DeliveryShipmentUpdateResponse type
|
||||
type DeliveryShipmentUpdateResponse struct {
|
||||
Success bool `json:"success"`
|
||||
Id int `json:"id,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// IntegrationModuleResponse type
|
||||
type IntegrationModuleResponse struct {
|
||||
Success bool `json:"success"`
|
||||
IntegrationModule *IntegrationModule `json:"integrationModule,omitempty"`
|
||||
}
|
||||
|
||||
// IntegrationModuleEditResponse type
|
||||
type IntegrationModuleEditResponse struct {
|
||||
Success bool `json:"success"`
|
||||
Info map[string]string `json:"info,omitempty,brackets"`
|
||||
}
|
||||
|
|
136
v5/types.go
136
v5/types.go
|
@ -96,6 +96,13 @@ type IdentifiersPair struct {
|
|||
ExternalId string `json:"externalId,omitempty"`
|
||||
}
|
||||
|
||||
// DeliveryTime type
|
||||
type DeliveryTime struct {
|
||||
From string `json:"from,omitempty"`
|
||||
To string `json:"to,omitempty"`
|
||||
Custom string `json:"custom,omitempty"`
|
||||
}
|
||||
|
||||
/**
|
||||
Customer related types
|
||||
*/
|
||||
|
@ -728,3 +735,132 @@ type Product struct {
|
|||
Groups []ProductGroup `json:"groups,omitempty,brackets"`
|
||||
Properties map[string]string `json:"properties,omitempty,brackets"`
|
||||
}
|
||||
|
||||
// DeliveryHistoryRecord type
|
||||
type DeliveryHistoryRecord struct {
|
||||
Code string `json:"code,omitempty"`
|
||||
UpdatedAt string `json:"updatedAt,omitempty"`
|
||||
Comment string `json:"comment,omitempty"`
|
||||
}
|
||||
|
||||
// DeliveryShipment type
|
||||
type DeliveryShipment struct {
|
||||
IntegrationCode string `json:"integrationCode,omitempty"`
|
||||
Id int `json:"id,omitempty"`
|
||||
ExternalId string `json:"externalId,omitempty"`
|
||||
DeliveryType string `json:"deliveryType,omitempty"`
|
||||
Store string `json:"store,omitempty"`
|
||||
ManagerId int `json:"managerId,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
Date string `json:"date,omitempty"`
|
||||
Time *DeliveryTime `json:"time,omitempty"`
|
||||
LunchTime string `json:"lunchTime,omitempty"`
|
||||
Comment string `json:"comment,omitempty"`
|
||||
Orders []Order `json:"orders,omitempty,brackets"`
|
||||
ExtraData map[string]string `json:"extraData,omitempty,brackets"`
|
||||
}
|
||||
|
||||
// IntegrationModule type
|
||||
type IntegrationModule struct {
|
||||
Code string `json:"code,omitempty"`
|
||||
IntegrationCode string `json:"integrationCode,omitempty"`
|
||||
Active bool `json:"active,omitempty"`
|
||||
Freeze bool `json:"freeze,omitempty"`
|
||||
Native bool `json:"native,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Logo string `json:"logo,omitempty"`
|
||||
ClientId string `json:"clientId,omitempty"`
|
||||
BaseUrl string `json:"baseUrl,omitempty"`
|
||||
AccountUrl string `json:"accountUrl,omitempty"`
|
||||
AvailableCountries []string `json:"availableCountries,omitempty"`
|
||||
Actions []string `json:"actions,omitempty"`
|
||||
Integrations *Integrations `json:"integrations,omitempty"`
|
||||
}
|
||||
|
||||
// Integrations type
|
||||
type Integrations struct {
|
||||
Telephony *Telephony `json:"telephony,omitempty"`
|
||||
Delivery *Delivery `json:"delivery,omitempty"`
|
||||
Store *Warehouse `json:"store,omitempty"`
|
||||
}
|
||||
|
||||
// Delivery type
|
||||
type Delivery struct {
|
||||
Description string `json:"description,omitempty"`
|
||||
Actions []Action `json:"actions,omitempty,brackets"`
|
||||
PayerType []string `json:"payerType,omitempty,brackets"`
|
||||
PlatePrintLimit int `json:"platePrintLimit,omitempty"`
|
||||
RateDeliveryCost bool `json:"rateDeliveryCost,omitempty"`
|
||||
AllowPackages bool `json:"allowPackages,omitempty"`
|
||||
CodAvailable bool `json:"codAvailable,omitempty"`
|
||||
SelfShipmentAvailable bool `json:"selfShipmentAvailable,omitempty"`
|
||||
AllowTrackNumber bool `json:"allowTrackNumber,omitempty"`
|
||||
AvailableCountries []string `json:"availableCountries,omitempty"`
|
||||
RequiredFields []string `json:"requiredFields,omitempty"`
|
||||
StatusList []DeliveryStatus `json:"statusList,omitempty"`
|
||||
PlateList []Plate `json:"plateList,omitempty"`
|
||||
DeliveryDataFieldList []DeliveryDataField `json:"deliveryDataFieldList,omitempty"`
|
||||
ShipmentDataFieldList []DeliveryDataField `json:"shipmentDataFieldList,omitempty"`
|
||||
}
|
||||
|
||||
// DeliveryStatus type
|
||||
type DeliveryStatus struct {
|
||||
Code string `json:"code,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
IsEditable bool `json:"isEditable,omitempty"`
|
||||
}
|
||||
|
||||
// Plate type
|
||||
type Plate struct {
|
||||
Code string `json:"code,omitempty"`
|
||||
Label string `json:"label,omitempty"`
|
||||
}
|
||||
|
||||
// DeliveryDataField type
|
||||
type DeliveryDataField struct {
|
||||
Code string `json:"code,omitempty"`
|
||||
Label string `json:"label,omitempty"`
|
||||
Hint string `json:"hint,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
AutocompleteUrl string `json:"autocompleteUrl,omitempty"`
|
||||
Multiple bool `json:"multiple,omitempty"`
|
||||
Required bool `json:"required,omitempty"`
|
||||
AffectsCost bool `json:"affectsCost,omitempty"`
|
||||
Editable bool `json:"editable,omitempty"`
|
||||
}
|
||||
|
||||
// Telephony type
|
||||
type Telephony struct {
|
||||
MakeCallUrl string `json:"makeCallUrl,omitempty"`
|
||||
AllowEdit bool `json:"allowEdit,omitempty"`
|
||||
InputEventSupported bool `json:"inputEventSupported,omitempty"`
|
||||
OutputEventSupported bool `json:"outputEventSupported,omitempty"`
|
||||
HangupEventSupported bool `json:"hangupEventSupported,omitempty"`
|
||||
ChangeUserStatusUrl string `json:"changeUserStatusUrl,omitempty"`
|
||||
AdditionalCodes []AdditionalCode `json:"additionalCodes,omitempty,brackets"`
|
||||
ExternalPhones []ExternalPhone `json:"externalPhones,omitempty,brackets"`
|
||||
}
|
||||
|
||||
// AdditionalCode type
|
||||
type AdditionalCode struct {
|
||||
Code string `json:"code,omitempty"`
|
||||
UserId string `json:"userId,omitempty"`
|
||||
}
|
||||
|
||||
// ExternalPhone type
|
||||
type ExternalPhone struct {
|
||||
SiteCode string `json:"siteCode,omitempty"`
|
||||
ExternalPhone string `json:"externalPhone,omitempty"`
|
||||
}
|
||||
|
||||
// Warehouse type
|
||||
type Warehouse struct {
|
||||
Actions []Action `json:"actions,omitempty,brackets"`
|
||||
}
|
||||
|
||||
// Action type
|
||||
type Action struct {
|
||||
Code string `json:"code,omitempty"`
|
||||
Url string `json:"url,omitempty"`
|
||||
CallPoints []string `json:"callPoints,omitempty"`
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue