Remove errs package, change logic for error processing (#48)

This commit is contained in:
RenCurs 2021-04-26 12:09:21 +03:00 committed by GitHub
parent 03fc70d679
commit baddbe95b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 1519 additions and 2332 deletions

View File

@ -1,75 +0,0 @@
package errs
import (
"encoding/json"
"fmt"
"strconv"
)
// Error returns the string representation of the error and satisfies the error interface.
func (f *Failure) Error() string {
if f != nil && f.runtimeErr != nil {
return f.runtimeErr.Error()
}
return ""
}
// ApiError returns formatted string representation of the API error
func (f *Failure) ApiError() string {
if f != nil && f.apiErr != "" {
return fmt.Sprintf("%+v", f.apiErr)
}
return ""
}
// ApiErrors returns array of formatted strings that represents API errors
func (f *Failure) ApiErrors() map[string]string {
if len(f.apiErrs) > 0 {
return f.apiErrs
}
return nil
}
// SetRuntimeError set runtime error value
func (f *Failure) SetRuntimeError(e error) {
f.runtimeErr = e
}
// SetApiError set api error value
func (f *Failure) SetApiError(e string) {
f.apiErr = e
}
// SetApiErrors set api errors value
func (f *Failure) SetApiErrors(e map[string]string) {
f.apiErrs = e
}
// ErrorsHandler returns map
func ErrorsHandler(errs interface{}) map[string]string {
m := make(map[string]string)
switch errs.(type) {
case map[string]interface{}:
for idx, val := range errs.(map[string]interface{}) {
m[idx] = val.(string)
}
case []interface{}:
for idx, val := range errs.([]interface{}) {
m[strconv.Itoa(idx)] = val.(string)
}
}
return m
}
// ErrorResponse method
func ErrorResponse(data []byte) (FailureResponse, error) {
var resp FailureResponse
err := json.Unmarshal(data, &resp)
return resp, err
}

View File

@ -1,50 +0,0 @@
package errs
import (
"reflect"
"testing"
)
func TestFailure_ApiErrorsSlice(t *testing.T) {
var err = Failure{}
b := []byte(`{"success": false, "errorMsg": "Failed to activate module", "errors": ["Your account has insufficient funds to activate integration module"]}`)
expected := map[string]string{
"0": "Your account has insufficient funds to activate integration module",
}
resp, e := ErrorResponse(b)
err.SetRuntimeError(e)
err.SetApiError(resp.ErrorMsg)
if resp.Errors != nil {
err.SetApiErrors(ErrorsHandler(resp.Errors))
}
eq := reflect.DeepEqual(expected, err.ApiErrors())
if eq != true {
t.Errorf("%+v", eq)
}
}
func TestFailure_ApiErrorsMap(t *testing.T) {
var err = Failure{}
b := []byte(`{"success": false, "errorMsg": "Failed to activate module", "errors": {"id": "ID must be an integer"}}`)
expected := map[string]string{
"id": "ID must be an integer",
}
resp, e := ErrorResponse(b)
err.SetRuntimeError(e)
err.SetApiError(resp.ErrorMsg)
if resp.Errors != nil {
err.SetApiErrors(ErrorsHandler(resp.Errors))
}
eq := reflect.DeepEqual(expected, err.ApiErrors())
if eq != true {
t.Errorf("%+v", eq)
}
}

View File

@ -1,8 +0,0 @@
package errs
// Error implements generic error interface
type Error interface {
error
ApiError() string
ApiErrors() map[string]string
}

View File

@ -1,14 +0,0 @@
package errs
// Failure struct implode runtime & api errors
type Failure struct {
runtimeErr error
apiErr string
apiErrs map[string]string
}
// FailureResponse convert json error response into object
type FailureResponse struct {
ErrorMsg string `json:"errorMsg,omitempty"`
Errors interface{} `json:"errors,omitempty"`
}

1
go.mod
View File

@ -5,5 +5,6 @@ go 1.13
require (
github.com/google/go-querystring v1.1.0
github.com/joho/godotenv v1.3.0
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543
gopkg.in/h2non/gock.v1 v1.0.16
)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

32
v5/error.go Normal file
View File

@ -0,0 +1,32 @@
package v5
import "encoding/json"
// APIErrorsList struct.
type APIErrorsList map[string]string
// APIError struct.
type APIError struct {
SuccessfulResponse
ErrorMsg string `json:"errorMsg,omitempty"`
Errors APIErrorsList `json:"errors,omitempty"`
}
func (e *APIError) Error() string {
return e.ErrorMsg
}
func NewAPIError(dataResponse []byte) error {
a := &APIError{}
if len(dataResponse) > 0 && dataResponse[0] == '<' {
a.ErrorMsg = "Account does not exist."
return a
}
if err := json.Unmarshal(dataResponse, a); err != nil {
return err
}
return a
}

54
v5/error_test.go Normal file
View File

@ -0,0 +1,54 @@
package v5
import (
"reflect"
"testing"
"golang.org/x/xerrors"
)
func TestFailure_ApiErrorsSlice(t *testing.T) {
b := []byte(`{"success": false,
"errorMsg": "Failed to activate module",
"errors": [
"Your account has insufficient funds to activate integration module",
"Test error"
]}`)
expected := APIErrorsList{
"0": "Your account has insufficient funds to activate integration module",
"1": "Test error",
}
var expEr *APIError
e := NewAPIError(b)
if xerrors.As(e, &expEr) {
if eq := reflect.DeepEqual(expEr.Errors, expected); eq != true {
t.Errorf("%+v", eq)
}
} else {
t.Errorf("Error must be type of APIError: %v", e)
}
}
func TestFailure_ApiErrorsMap(t *testing.T) {
b := []byte(`{"success": false,
"errorMsg": "Failed to activate module",
"errors": {"id": "ID must be an integer", "test": "Test error"}}`,
)
expected := APIErrorsList{
"id": "ID must be an integer",
"test": "Test error",
}
var expEr *APIError
e := NewAPIError(b)
if xerrors.As(e, &expEr) {
if eq := reflect.DeepEqual(expEr.Errors, expected); eq != true {
t.Errorf("%+v", eq)
}
} else {
t.Errorf("Error must be type of APIError: %v", e)
}
}

View File

@ -1,6 +1,6 @@
package v5
// CustomersFilter type
// CustomersFilter type.
type CustomersFilter struct {
Ids []string `url:"ids,omitempty,brackets"`
ExternalIds []string `url:"externalIds,omitempty,brackets"`
@ -57,7 +57,7 @@ type CustomersFilter struct {
CustomFields map[string]string `url:"customFields,omitempty,brackets"`
}
// CorporateCustomersFilter type
// CorporateCustomersFilter type.
type CorporateCustomersFilter struct {
ContragentName string `url:"contragentName,omitempty"`
ContragentInn string `url:"contragentInn,omitempty"`
@ -99,7 +99,7 @@ type CorporateCustomersFilter struct {
CustomFields map[string]string `url:"customFields,omitempty,brackets"`
}
// CorporateCustomersNotesFilter type
// CorporateCustomersNotesFilter type.
type CorporateCustomersNotesFilter struct {
Ids []string `url:"ids,omitempty,brackets"`
CustomerIds []string `url:"ids,omitempty,brackets"`
@ -110,7 +110,7 @@ type CorporateCustomersNotesFilter struct {
CreatedAtTo string `url:"createdAtTo,omitempty"`
}
// CorporateCustomerAddressesFilter type
// CorporateCustomerAddressesFilter type.
type CorporateCustomerAddressesFilter struct {
Ids []string `url:"ids,omitempty,brackets"`
Name string `url:"name,omitempty"`
@ -118,13 +118,13 @@ type CorporateCustomerAddressesFilter struct {
Region string `url:"region,omitempty"`
}
// IdentifiersPairFilter type
// IdentifiersPairFilter type.
type IdentifiersPairFilter struct {
Ids []string `url:"ids,omitempty,brackets"`
ExternalIds []string `url:"externalIds,omitempty,brackets"`
}
// CustomersHistoryFilter type
// CustomersHistoryFilter type.
type CustomersHistoryFilter struct {
CustomerID int `url:"customerId,omitempty"`
SinceID int `url:"sinceId,omitempty"`
@ -133,7 +133,7 @@ type CustomersHistoryFilter struct {
EndDate string `url:"endDate,omitempty"`
}
// CorporateCustomersHistoryFilter type
// CorporateCustomersHistoryFilter type.
type CorporateCustomersHistoryFilter struct {
CustomerID int `url:"customerId,omitempty"`
SinceID int `url:"sinceId,omitempty"`
@ -143,7 +143,7 @@ type CorporateCustomersHistoryFilter struct {
EndDate string `url:"endDate,omitempty"`
}
// OrdersFilter type
// OrdersFilter type.
type OrdersFilter struct {
Ids []int `url:"ids,omitempty,brackets"`
ExternalIds []string `url:"externalIds,omitempty,brackets"`
@ -234,7 +234,7 @@ type OrdersFilter struct {
CustomFields map[string]string `url:"customFields,omitempty,brackets"`
}
// OrdersHistoryFilter type
// OrdersHistoryFilter type.
type OrdersHistoryFilter struct {
OrderID int `url:"orderId,omitempty"`
SinceID int `url:"sinceId,omitempty"`
@ -243,7 +243,7 @@ type OrdersHistoryFilter struct {
EndDate string `url:"endDate,omitempty"`
}
// UsersFilter type
// UsersFilter type.
type UsersFilter struct {
Email string `url:"email,omitempty"`
Status string `url:"status,omitempty"`
@ -256,7 +256,7 @@ type UsersFilter struct {
Groups []string `url:"groups,omitempty,brackets"`
}
// TasksFilter type
// TasksFilter type.
type TasksFilter struct {
OrderNumber string `url:"orderNumber,omitempty"`
Status string `url:"status,omitempty"`
@ -268,7 +268,7 @@ type TasksFilter struct {
Performers []int `url:"performers,omitempty,brackets"`
}
// NotesFilter type
// NotesFilter type.
type NotesFilter struct {
Ids []int `url:"ids,omitempty,brackets"`
CustomerIds []int `url:"customerIds,omitempty,brackets"`
@ -279,7 +279,7 @@ type NotesFilter struct {
CreatedAtTo string `url:"createdAtTo,omitempty"`
}
// SegmentsFilter type
// SegmentsFilter type.
type SegmentsFilter struct {
Ids []int `url:"ids,omitempty,brackets"`
Active int `url:"active,omitempty"`
@ -291,7 +291,7 @@ type SegmentsFilter struct {
DateTo string `url:"dateTo,omitempty"`
}
// PacksFilter type
// PacksFilter type.
type PacksFilter struct {
Ids []int `url:"ids,omitempty,brackets"`
Stores []string `url:"stores,omitempty"`
@ -306,7 +306,7 @@ type PacksFilter struct {
DeliveryNoteNumber string `url:"deliveryNoteNumber,omitempty"`
}
// InventoriesFilter type
// InventoriesFilter type.
type InventoriesFilter struct {
Ids []int `url:"ids,omitempty,brackets"`
ProductExternalID string `url:"productExternalId,omitempty"`
@ -319,7 +319,7 @@ type InventoriesFilter struct {
Sites []string `url:"sites,omitempty,brackets"`
}
// ProductsGroupsFilter type
// ProductsGroupsFilter type.
type ProductsGroupsFilter struct {
Ids []int `url:"ids,omitempty,brackets"`
Sites []string `url:"sites,omitempty,brackets"`
@ -327,7 +327,7 @@ type ProductsGroupsFilter struct {
ParentGroupID string `url:"parentGroupId,omitempty"`
}
// ProductsFilter type
// ProductsFilter type.
type ProductsFilter struct {
Ids []int `url:"ids,omitempty,brackets"`
OfferIds []int `url:"offerIds,omitempty,brackets"`
@ -355,14 +355,14 @@ type ProductsFilter struct {
Properties map[string]string `url:"properties,omitempty,brackets"`
}
// ProductsPropertiesFilter type
// ProductsPropertiesFilter type.
type ProductsPropertiesFilter struct {
Code string `url:"code,omitempty"`
Name string `url:"name,omitempty"`
Sites []string `url:"sites,omitempty,brackets"`
}
// ShipmentFilter type
// ShipmentFilter type.
type ShipmentFilter struct {
Ids []int `url:"ids,omitempty,brackets"`
ExternalID string `url:"externalId,omitempty"`
@ -375,7 +375,7 @@ type ShipmentFilter struct {
Statuses []string `url:"statuses,omitempty,brackets"`
}
// CostsFilter type
// CostsFilter type.
type CostsFilter struct {
MinSumm string `url:"minSumm,omitempty"`
MaxSumm string `url:"maxSumm,omitempty"`
@ -395,7 +395,7 @@ type CostsFilter struct {
OrderExternalIds []string `url:"orderIds,omitempty,brackets"`
}
// FilesFilter type
// FilesFilter type.
type FilesFilter struct {
Ids []int `url:"ids,omitempty,brackets"`
OrderIds []int `url:"orderIds,omitempty,brackets"`
@ -412,7 +412,7 @@ type FilesFilter struct {
Sites []string `url:"sites,omitempty,brackets"`
}
// CustomFieldsFilter type
// CustomFieldsFilter type.
type CustomFieldsFilter struct {
Name string `url:"name,omitempty"`
Code string `url:"code,omitempty"`
@ -422,7 +422,7 @@ type CustomFieldsFilter struct {
DisplayArea string `url:"displayArea,omitempty"`
}
// CustomDictionariesFilter type
// CustomDictionariesFilter type.
type CustomDictionariesFilter struct {
Name string `url:"name,omitempty"`
Code string `url:"code,omitempty"`

View File

@ -1,7 +1,35 @@
package v5
import "encoding/json"
import (
"encoding/json"
"fmt"
"strconv"
)
func (t Tag) MarshalJSON() ([]byte, error) {
return json.Marshal(t.Name)
}
func (a *APIErrorsList) UnmarshalJSON(data []byte) error {
var i interface{}
var m map[string]string
if err := json.Unmarshal(data, &i); err != nil {
return err
}
switch e := i.(type) {
case map[string]interface{}:
m = make(map[string]string, len(e))
for idx, val := range e {
m[idx] = fmt.Sprint(val)
}
case []interface{}:
m = make(map[string]string, len(e))
for idx, val := range e {
m[strconv.Itoa(idx)] = fmt.Sprint(val)
}
}
*a = m
return nil
}

View File

@ -1,33 +1,33 @@
package v5
// CustomerRequest type
// CustomerRequest type.
type CustomerRequest struct {
By string `url:"by,omitempty"`
Site string `url:"site,omitempty"`
}
// CustomersRequest type
// CustomersRequest type.
type CustomersRequest struct {
Filter CustomersFilter `url:"filter,omitempty"`
Limit int `url:"limit,omitempty"`
Page int `url:"page,omitempty"`
}
// CorporateCustomersRequest type
// CorporateCustomersRequest type.
type CorporateCustomersRequest struct {
Filter CorporateCustomersFilter `url:"filter,omitempty"`
Limit int `url:"limit,omitempty"`
Page int `url:"page,omitempty"`
}
// CorporateCustomersNotesRequest type
// CorporateCustomersNotesRequest type.
type CorporateCustomersNotesRequest struct {
Filter CorporateCustomersNotesFilter `url:"filter,omitempty"`
Limit int `url:"limit,omitempty"`
Page int `url:"page,omitempty"`
}
// CorporateCustomerAddressesRequest type
// CorporateCustomerAddressesRequest type.
type CorporateCustomerAddressesRequest struct {
Filter CorporateCustomerAddressesFilter `url:"filter,omitempty"`
By string `url:"by,omitempty"`
@ -36,7 +36,7 @@ type CorporateCustomerAddressesRequest struct {
Page int `url:"page,omitempty"`
}
// IdentifiersPairRequest type
// IdentifiersPairRequest type.
type IdentifiersPairRequest struct {
Filter IdentifiersPairFilter `url:"filter,omitempty"`
By string `url:"by,omitempty"`
@ -45,135 +45,135 @@ type IdentifiersPairRequest struct {
Page int `url:"page,omitempty"`
}
// CustomersUploadRequest type
// CustomersUploadRequest type.
type CustomersUploadRequest struct {
Customers []Customer `url:"customers,omitempty,brackets"`
Site string `url:"site,omitempty"`
}
// CustomersHistoryRequest type
// CustomersHistoryRequest type.
type CustomersHistoryRequest struct {
Filter CustomersHistoryFilter `url:"filter,omitempty"`
Limit int `url:"limit,omitempty"`
Page int `url:"page,omitempty"`
}
// CorporateCustomersHistoryRequest type
// CorporateCustomersHistoryRequest type.
type CorporateCustomersHistoryRequest struct {
Filter CorporateCustomersHistoryFilter `url:"filter,omitempty"`
Limit int `url:"limit,omitempty"`
Page int `url:"page,omitempty"`
}
// OrderRequest type
// OrderRequest type.
type OrderRequest struct {
By string `url:"by,omitempty"`
Site string `url:"site,omitempty"`
}
// OrdersRequest type
// OrdersRequest type.
type OrdersRequest struct {
Filter OrdersFilter `url:"filter,omitempty"`
Limit int `url:"limit,omitempty"`
Page int `url:"page,omitempty"`
}
// OrdersStatusesRequest type
// OrdersStatusesRequest type.
type OrdersStatusesRequest struct {
IDs []int `url:"ids,omitempty,brackets"`
ExternalIDs []string `url:"externalIds,omitempty,brackets"`
}
// OrdersUploadRequest type
// OrdersUploadRequest type.
type OrdersUploadRequest struct {
Orders []Order `url:"orders,omitempty,brackets"`
Site string `url:"site,omitempty"`
}
// OrdersHistoryRequest type
// OrdersHistoryRequest type.
type OrdersHistoryRequest struct {
Filter OrdersHistoryFilter `url:"filter,omitempty"`
Limit int `url:"limit,omitempty"`
Page int `url:"page,omitempty"`
}
// PacksRequest type
// PacksRequest type.
type PacksRequest struct {
Filter PacksFilter `url:"filter,omitempty"`
Limit int `url:"limit,omitempty"`
Page int `url:"page,omitempty"`
}
// PacksHistoryRequest type
// PacksHistoryRequest type.
type PacksHistoryRequest struct {
Filter OrdersHistoryFilter `url:"filter,omitempty"`
Limit int `url:"limit,omitempty"`
Page int `url:"page,omitempty"`
}
// UsersRequest type
// UsersRequest type.
type UsersRequest struct {
Filter UsersFilter `url:"filter,omitempty"`
Limit int `url:"limit,omitempty"`
Page int `url:"page,omitempty"`
}
// UserGroupsRequest type
// UserGroupsRequest type.
type UserGroupsRequest struct {
Limit int `url:"limit,omitempty"`
Page int `url:"page,omitempty"`
}
// TasksRequest type
// TasksRequest type.
type TasksRequest struct {
Filter TasksFilter `url:"filter,omitempty"`
Limit int `url:"limit,omitempty"`
Page int `url:"page,omitempty"`
}
// NotesRequest type
// NotesRequest type.
type NotesRequest struct {
Filter NotesFilter `url:"filter,omitempty"`
Limit int `url:"limit,omitempty"`
Page int `url:"page,omitempty"`
}
// SegmentsRequest type
// SegmentsRequest type.
type SegmentsRequest struct {
Filter SegmentsFilter `url:"filter,omitempty"`
Limit int `url:"limit,omitempty"`
Page int `url:"page,omitempty"`
}
// InventoriesRequest type
// InventoriesRequest type.
type InventoriesRequest struct {
Filter InventoriesFilter `url:"filter,omitempty"`
Limit int `url:"limit,omitempty"`
Page int `url:"page,omitempty"`
}
// ProductsGroupsRequest type
// ProductsGroupsRequest type.
type ProductsGroupsRequest struct {
Filter ProductsGroupsFilter `url:"filter,omitempty"`
Limit int `url:"limit,omitempty"`
Page int `url:"page,omitempty"`
}
// ProductsRequest type
// ProductsRequest type.
type ProductsRequest struct {
Filter ProductsFilter `url:"filter,omitempty"`
Limit int `url:"limit,omitempty"`
Page int `url:"page,omitempty"`
}
// ProductsPropertiesRequest type
// ProductsPropertiesRequest type.
type ProductsPropertiesRequest struct {
Filter ProductsPropertiesFilter `url:"filter,omitempty"`
Limit int `url:"limit,omitempty"`
Page int `url:"page,omitempty"`
}
// DeliveryTrackingRequest type
// DeliveryTrackingRequest type.
type DeliveryTrackingRequest struct {
DeliveryID string `json:"deliveryId,omitempty"`
TrackNumber string `json:"trackNumber,omitempty"`
@ -181,35 +181,35 @@ type DeliveryTrackingRequest struct {
ExtraData map[string]string `json:"extraData,omitempty,brackets"`
}
// DeliveryShipmentsRequest type
// DeliveryShipmentsRequest type.
type DeliveryShipmentsRequest struct {
Filter ShipmentFilter `url:"filter,omitempty"`
Limit int `url:"limit,omitempty"`
Page int `url:"page,omitempty"`
}
// CostsRequest type
// CostsRequest type.
type CostsRequest struct {
Filter CostsFilter `url:"filter,omitempty"`
Limit int `url:"limit,omitempty"`
Page int `url:"page,omitempty"`
}
// FilesRequest type
// FilesRequest type.
type FilesRequest struct {
Filter FilesFilter `url:"filter,omitempty"`
Limit int `url:"limit,omitempty"`
Page int `url:"page,omitempty"`
}
// CustomFieldsRequest type
// CustomFieldsRequest type.
type CustomFieldsRequest struct {
Filter CustomFieldsFilter `url:"filter,omitempty"`
Limit int `url:"limit,omitempty"`
Page int `url:"page,omitempty"`
}
// CustomDictionariesRequest type
// CustomDictionariesRequest type.
type CustomDictionariesRequest struct {
Filter CustomDictionariesFilter `url:"filter,omitempty"`
Limit int `url:"limit,omitempty"`

View File

@ -1,495 +1,495 @@
package v5
// SuccessfulResponse type
// SuccessfulResponse type.
type SuccessfulResponse struct {
Success bool `json:"success,omitempty"`
}
// CreateResponse type
// CreateResponse type.
type CreateResponse struct {
Success bool `json:"success"`
ID int `json:"id,omitempty"`
}
// OrderCreateResponse type
// OrderCreateResponse type.
type OrderCreateResponse struct {
CreateResponse
Order Order `json:"order,omitempty"`
}
// OperationResponse type
// OperationResponse type.
type OperationResponse struct {
Success bool `json:"success"`
Errors map[string]string `json:"errors,omitempty,brackets"`
Errors map[string]string `json:"errors,omitempty"`
}
// VersionResponse return available API versions
// VersionResponse return available API versions.
type VersionResponse struct {
Success bool `json:"success,omitempty"`
Versions []string `json:"versions,brackets,omitempty"`
Versions []string `json:"versions,omitempty"`
}
// CredentialResponse return available API methods
// CredentialResponse return available API methods.
type CredentialResponse struct {
Success bool `json:"success,omitempty"`
Credentials []string `json:"credentials,brackets,omitempty"`
Credentials []string `json:"credentials,omitempty"`
SiteAccess string `json:"siteAccess,omitempty"`
SitesAvailable []string `json:"sitesAvailable,brackets,omitempty"`
SitesAvailable []string `json:"sitesAvailable,omitempty"`
}
// CustomerResponse type
// CustomerResponse type.
type CustomerResponse struct {
Success bool `json:"success"`
Customer *Customer `json:"customer,omitempty,brackets"`
Customer *Customer `json:"customer,omitempty"`
}
// CorporateCustomerResponse type
// CorporateCustomerResponse type.
type CorporateCustomerResponse struct {
Success bool `json:"success"`
CorporateCustomer *CorporateCustomer `json:"customerCorporate,omitempty,brackets"`
CorporateCustomer *CorporateCustomer `json:"customerCorporate,omitempty"`
}
// CustomersResponse type
// CustomersResponse type.
type CustomersResponse struct {
Success bool `json:"success"`
Pagination *Pagination `json:"pagination,omitempty"`
Customers []Customer `json:"customers,omitempty,brackets"`
Customers []Customer `json:"customers,omitempty"`
}
// CorporateCustomersResponse type
// CorporateCustomersResponse type.
type CorporateCustomersResponse struct {
Success bool `json:"success"`
Pagination *Pagination `json:"pagination,omitempty"`
CustomersCorporate []CorporateCustomer `json:"customersCorporate,omitempty,brackets"`
CustomersCorporate []CorporateCustomer `json:"customersCorporate,omitempty"`
}
// CorporateCustomersNotesResponse type
// CorporateCustomersNotesResponse type.
type CorporateCustomersNotesResponse struct {
Success bool `json:"success"`
Pagination *Pagination `json:"pagination,omitempty"`
Notes []Note `json:"notes,omitempty,brackets"`
Notes []Note `json:"notes,omitempty"`
}
// CorporateCustomersAddressesResponse type
// CorporateCustomersAddressesResponse type.
type CorporateCustomersAddressesResponse struct {
Success bool `json:"success"`
Addresses []CorporateCustomerAddress `json:"addresses"`
}
// CorporateCustomerCompaniesResponse type
// CorporateCustomerCompaniesResponse type.
type CorporateCustomerCompaniesResponse struct {
Success bool `json:"success"`
Companies []Company `json:"companies"`
}
// CorporateCustomerContactsResponse type
// CorporateCustomerContactsResponse type.
type CorporateCustomerContactsResponse struct {
Success bool `json:"success"`
Contacts []CorporateCustomerContact `json:"contacts"`
}
// CustomerChangeResponse type
// CustomerChangeResponse type.
type CustomerChangeResponse struct {
Success bool `json:"success"`
ID int `json:"id,omitempty"`
State string `json:"state,omitempty"`
}
// CorporateCustomerChangeResponse type
// CorporateCustomerChangeResponse type.
type CorporateCustomerChangeResponse CustomerChangeResponse
// CustomersUploadResponse type
// CustomersUploadResponse type.
type CustomersUploadResponse struct {
Success bool `json:"success"`
UploadedCustomers []IdentifiersPair `json:"uploadedCustomers,omitempty,brackets"`
UploadedCustomers []IdentifiersPair `json:"uploadedCustomers,omitempty"`
}
// CorporateCustomersUploadResponse type
// CorporateCustomersUploadResponse type.
type CorporateCustomersUploadResponse CustomersUploadResponse
// CustomersHistoryResponse type
// CustomersHistoryResponse type.
type CustomersHistoryResponse struct {
Success bool `json:"success,omitempty"`
GeneratedAt string `json:"generatedAt,omitempty"`
History []CustomerHistoryRecord `json:"history,omitempty,brackets"`
History []CustomerHistoryRecord `json:"history,omitempty"`
Pagination *Pagination `json:"pagination,omitempty"`
}
// CorporateCustomersHistoryResponse type
// CorporateCustomersHistoryResponse type.
type CorporateCustomersHistoryResponse struct {
Success bool `json:"success,omitempty"`
GeneratedAt string `json:"generatedAt,omitempty"`
History []CorporateCustomerHistoryRecord `json:"history,omitempty,brackets"`
History []CorporateCustomerHistoryRecord `json:"history,omitempty"`
Pagination *Pagination `json:"pagination,omitempty"`
}
// OrderResponse type
// OrderResponse type.
type OrderResponse struct {
Success bool `json:"success"`
Order *Order `json:"order,omitempty,brackets"`
Order *Order `json:"order,omitempty"`
}
// OrdersResponse type
// OrdersResponse type.
type OrdersResponse struct {
Success bool `json:"success"`
Pagination *Pagination `json:"pagination,omitempty"`
Orders []Order `json:"orders,omitempty,brackets"`
Orders []Order `json:"orders,omitempty"`
}
// OrdersStatusesResponse type
// OrdersStatusesResponse type.
type OrdersStatusesResponse struct {
Success bool `json:"success"`
Orders []OrdersStatus `json:"orders"`
}
// OrdersUploadResponse type
// OrdersUploadResponse type.
type OrdersUploadResponse struct {
Success bool `json:"success"`
UploadedOrders []IdentifiersPair `json:"uploadedOrders,omitempty,brackets"`
UploadedOrders []IdentifiersPair `json:"uploadedOrders,omitempty"`
}
// OrdersHistoryResponse type
// OrdersHistoryResponse type.
type OrdersHistoryResponse struct {
Success bool `json:"success,omitempty"`
GeneratedAt string `json:"generatedAt,omitempty"`
History []OrdersHistoryRecord `json:"history,omitempty,brackets"`
History []OrdersHistoryRecord `json:"history,omitempty"`
Pagination *Pagination `json:"pagination,omitempty"`
}
// PackResponse type
// PackResponse type.
type PackResponse struct {
Success bool `json:"success"`
Pack *Pack `json:"pack,omitempty,brackets"`
Pack *Pack `json:"pack,omitempty"`
}
// PacksResponse type
// PacksResponse type.
type PacksResponse struct {
Success bool `json:"success"`
Pagination *Pagination `json:"pagination,omitempty"`
Packs []Pack `json:"packs,omitempty,brackets"`
Packs []Pack `json:"packs,omitempty"`
}
// PacksHistoryResponse type
// PacksHistoryResponse type.
type PacksHistoryResponse struct {
Success bool `json:"success,omitempty"`
GeneratedAt string `json:"generatedAt,omitempty"`
History []PacksHistoryRecord `json:"history,omitempty,brackets"`
History []PacksHistoryRecord `json:"history,omitempty"`
Pagination *Pagination `json:"pagination,omitempty"`
}
// UserResponse type
// UserResponse type.
type UserResponse struct {
Success bool `json:"success"`
User *User `json:"user,omitempty,brackets"`
User *User `json:"user,omitempty"`
}
// UsersResponse type
// UsersResponse type.
type UsersResponse struct {
Success bool `json:"success"`
Pagination *Pagination `json:"pagination,omitempty"`
Users []User `json:"users,omitempty,brackets"`
Users []User `json:"users,omitempty"`
}
// UserGroupsResponse type
// UserGroupsResponse type.
type UserGroupsResponse struct {
Success bool `json:"success"`
Pagination *Pagination `json:"pagination,omitempty"`
Groups []UserGroup `json:"groups,omitempty,brackets"`
Groups []UserGroup `json:"groups,omitempty"`
}
// TaskResponse type
// TaskResponse type.
type TaskResponse struct {
Success bool `json:"success"`
Task *Task `json:"task,omitempty,brackets"`
Task *Task `json:"task,omitempty"`
}
// TasksResponse type
// TasksResponse type.
type TasksResponse struct {
Success bool `json:"success"`
Pagination *Pagination `json:"pagination,omitempty"`
Tasks []Task `json:"tasks,omitempty,brackets"`
Tasks []Task `json:"tasks,omitempty"`
}
// NotesResponse type
// NotesResponse type.
type NotesResponse struct {
Success bool `json:"success"`
Pagination *Pagination `json:"pagination,omitempty"`
Notes []Note `json:"notes,omitempty,brackets"`
Notes []Note `json:"notes,omitempty"`
}
// SegmentsResponse type
// SegmentsResponse type.
type SegmentsResponse struct {
Success bool `json:"success"`
Pagination *Pagination `json:"pagination,omitempty"`
Segments []Segment `json:"segments,omitempty,brackets"`
Segments []Segment `json:"segments,omitempty"`
}
// SettingsResponse type
// SettingsResponse type.
type SettingsResponse struct {
Success bool `json:"success"`
Settings Settings `json:"settings,omitempty,brackets"`
Settings Settings `json:"settings,omitempty"`
}
// CountriesResponse type
// CountriesResponse type.
type CountriesResponse struct {
Success bool `json:"success"`
CountriesIso []string `json:"countriesIso,omitempty,brackets"`
CountriesIso []string `json:"countriesIso,omitempty"`
}
// CostGroupsResponse type
// CostGroupsResponse type.
type CostGroupsResponse struct {
Success bool `json:"success"`
CostGroups []CostGroup `json:"costGroups,omitempty,brackets"`
CostGroups []CostGroup `json:"costGroups,omitempty"`
}
// CostItemsResponse type
// CostItemsResponse type.
type CostItemsResponse struct {
Success bool `json:"success"`
CostItems []CostItem `json:"costItems,omitempty,brackets"`
CostItems []CostItem `json:"costItems,omitempty"`
}
// CouriersResponse type
// CouriersResponse type.
type CouriersResponse struct {
Success bool `json:"success"`
Couriers []Courier `json:"couriers,omitempty,brackets"`
Couriers []Courier `json:"couriers,omitempty"`
}
// DeliveryServiceResponse type
// DeliveryServiceResponse type.
type DeliveryServiceResponse struct {
Success bool `json:"success"`
DeliveryServices map[string]DeliveryService `json:"deliveryServices,omitempty,brackets"`
DeliveryServices map[string]DeliveryService `json:"deliveryServices,omitempty"`
}
// DeliveryTypesResponse type
// DeliveryTypesResponse type.
type DeliveryTypesResponse struct {
Success bool `json:"success"`
DeliveryTypes map[string]DeliveryType `json:"deliveryTypes,omitempty,brackets"`
DeliveryTypes map[string]DeliveryType `json:"deliveryTypes,omitempty"`
}
// LegalEntitiesResponse type
// LegalEntitiesResponse type.
type LegalEntitiesResponse struct {
Success bool `json:"success"`
LegalEntities []LegalEntity `json:"legalEntities,omitempty,brackets"`
LegalEntities []LegalEntity `json:"legalEntities,omitempty"`
}
// OrderMethodsResponse type
// OrderMethodsResponse type.
type OrderMethodsResponse struct {
Success bool `json:"success"`
OrderMethods map[string]OrderMethod `json:"orderMethods,omitempty,brackets"`
OrderMethods map[string]OrderMethod `json:"orderMethods,omitempty"`
}
// OrderTypesResponse type
// OrderTypesResponse type.
type OrderTypesResponse struct {
Success bool `json:"success"`
OrderTypes map[string]OrderType `json:"orderTypes,omitempty,brackets"`
OrderTypes map[string]OrderType `json:"orderTypes,omitempty"`
}
// PaymentStatusesResponse type
// PaymentStatusesResponse type.
type PaymentStatusesResponse struct {
Success bool `json:"success"`
PaymentStatuses map[string]PaymentStatus `json:"paymentStatuses,omitempty,brackets"`
PaymentStatuses map[string]PaymentStatus `json:"paymentStatuses,omitempty"`
}
// PaymentTypesResponse type
// PaymentTypesResponse type.
type PaymentTypesResponse struct {
Success bool `json:"success"`
PaymentTypes map[string]PaymentType `json:"paymentTypes,omitempty,brackets"`
PaymentTypes map[string]PaymentType `json:"paymentTypes,omitempty"`
}
// PriceTypesResponse type
// PriceTypesResponse type.
type PriceTypesResponse struct {
Success bool `json:"success"`
PriceTypes []PriceType `json:"priceTypes,omitempty,brackets"`
PriceTypes []PriceType `json:"priceTypes,omitempty"`
}
// ProductStatusesResponse type
// ProductStatusesResponse type.
type ProductStatusesResponse struct {
Success bool `json:"success"`
ProductStatuses map[string]ProductStatus `json:"productStatuses,omitempty,brackets"`
ProductStatuses map[string]ProductStatus `json:"productStatuses,omitempty"`
}
// StatusesResponse type
// StatusesResponse type.
type StatusesResponse struct {
Success bool `json:"success"`
Statuses map[string]Status `json:"statuses,omitempty,brackets"`
Statuses map[string]Status `json:"statuses,omitempty"`
}
// StatusGroupsResponse type
// StatusGroupsResponse type.
type StatusGroupsResponse struct {
Success bool `json:"success"`
StatusGroups map[string]StatusGroup `json:"statusGroups,omitempty,brackets"`
StatusGroups map[string]StatusGroup `json:"statusGroups,omitempty"`
}
// SitesResponse type
// SitesResponse type.
type SitesResponse struct {
Success bool `json:"success"`
Sites map[string]Site `json:"sites,omitempty,brackets"`
Sites map[string]Site `json:"sites,omitempty"`
}
// StoresResponse type
// StoresResponse type.
type StoresResponse struct {
Success bool `json:"success"`
Stores []Store `json:"stores,omitempty,brackets"`
Stores []Store `json:"stores,omitempty"`
}
// InventoriesResponse type
// InventoriesResponse type.
type InventoriesResponse struct {
Success bool `json:"success"`
Pagination *Pagination `json:"pagination,omitempty"`
Offers []Offer `json:"offers,omitempty"`
}
// StoreUploadResponse type
// StoreUploadResponse type.
type StoreUploadResponse struct {
Success bool `json:"success"`
ProcessedOffersCount int `json:"processedOffersCount,omitempty"`
NotFoundOffers []Offer `json:"notFoundOffers,omitempty"`
}
// ProductsGroupsResponse type
// ProductsGroupsResponse type.
type ProductsGroupsResponse struct {
Success bool `json:"success"`
Pagination *Pagination `json:"pagination,omitempty"`
ProductGroup []ProductGroup `json:"productGroup,omitempty,brackets"`
ProductGroup []ProductGroup `json:"productGroup,omitempty"`
}
// ProductsResponse type
// ProductsResponse type.
type ProductsResponse struct {
Success bool `json:"success"`
Pagination *Pagination `json:"pagination,omitempty"`
Products []Product `json:"products,omitempty,brackets"`
Products []Product `json:"products,omitempty"`
}
// ProductsPropertiesResponse type
// ProductsPropertiesResponse type.
type ProductsPropertiesResponse struct {
Success bool `json:"success"`
Pagination *Pagination `json:"pagination,omitempty"`
Properties []Property `json:"properties,omitempty,brackets"`
Properties []Property `json:"properties,omitempty"`
}
// DeliveryShipmentsResponse type
// DeliveryShipmentsResponse type.
type DeliveryShipmentsResponse struct {
Success bool `json:"success"`
Pagination *Pagination `json:"pagination,omitempty"`
DeliveryShipments []DeliveryShipment `json:"deliveryShipments,omitempty,brackets"`
DeliveryShipments []DeliveryShipment `json:"deliveryShipments,omitempty"`
}
// DeliveryShipmentResponse type
// DeliveryShipmentResponse type.
type DeliveryShipmentResponse struct {
Success bool `json:"success"`
DeliveryShipment *DeliveryShipment `json:"deliveryShipment,omitempty,brackets"`
DeliveryShipment *DeliveryShipment `json:"deliveryShipment,omitempty"`
}
// DeliveryShipmentUpdateResponse type
// DeliveryShipmentUpdateResponse type.
type DeliveryShipmentUpdateResponse struct {
Success bool `json:"success"`
ID int `json:"id,omitempty"`
Status string `json:"status,omitempty"`
}
// IntegrationModuleResponse type
// IntegrationModuleResponse type.
type IntegrationModuleResponse struct {
Success bool `json:"success"`
IntegrationModule *IntegrationModule `json:"integrationModule,omitempty"`
}
// IntegrationModuleEditResponse type
// IntegrationModuleEditResponse type.
type IntegrationModuleEditResponse struct {
Success bool `json:"success"`
Info ResponseInfo `json:"info,omitempty,brackets"`
Info ResponseInfo `json:"info,omitempty"`
}
// ResponseInfo type
// ResponseInfo type.
type ResponseInfo struct {
MgTransportInfo MgInfo `json:"mgTransport,omitempty,brackets"`
MgBotInfo MgInfo `json:"mgBot,omitempty,brackets"`
MgTransportInfo MgInfo `json:"mgTransport,omitempty"`
MgBotInfo MgInfo `json:"mgBot,omitempty"`
}
// MgInfo type
// MgInfo type.
type MgInfo struct {
EndpointUrl string `json:"endpointUrl"`
Token string `json:"token"`
}
// CostsResponse type
// CostsResponse type.
type CostsResponse struct {
Success bool `json:"success"`
Pagination *Pagination `json:"pagination,omitempty"`
Costs []Cost `json:"costs,omitempty,brackets"`
Costs []Cost `json:"costs,omitempty"`
}
// CostsUploadResponse type
// CostsUploadResponse type.
type CostsUploadResponse struct {
Success bool `json:"success"`
UploadedCosts []int `json:"uploadedCosts,omitempty,brackets"`
UploadedCosts []int `json:"uploadedCosts,omitempty"`
}
// CostsDeleteResponse type
// CostsDeleteResponse type.
type CostsDeleteResponse struct {
Success bool `json:"success"`
Count int `json:"count,omitempty,brackets"`
NotRemovedIds []int `json:"notRemovedIds,omitempty,brackets"`
Count int `json:"count,omitempty"`
NotRemovedIds []int `json:"notRemovedIds,omitempty"`
}
// CostResponse type
// CostResponse type.
type CostResponse struct {
Success bool `json:"success"`
Cost *Cost `json:"cost,omitempty,brackets"`
Cost *Cost `json:"cost,omitempty"`
}
// FilesResponse type
// FilesResponse type.
type FilesResponse struct {
Success bool `json:"success"`
Pagination *Pagination `json:"pagination,omitempty"`
Files []File `json:"files,omitempty"`
}
// FileUpload response
// FileUpload response.
type FileUploadResponse struct {
Success bool `json:"success"`
File *File `json:"file,omitempty"`
}
// FileResponse type
// FileResponse type.
type FileResponse struct {
Success bool `json:"success"`
File *File `json:"file,omitempty"`
}
// CustomFieldsResponse type
// CustomFieldsResponse type.
type CustomFieldsResponse struct {
Success bool `json:"success"`
Pagination *Pagination `json:"pagination,omitempty"`
CustomFields []CustomFields `json:"customFields,omitempty,brackets"`
CustomFields []CustomFields `json:"customFields,omitempty"`
}
// CustomDictionariesResponse type
// CustomDictionariesResponse type.
type CustomDictionariesResponse struct {
Success bool `json:"success"`
Pagination *Pagination `json:"pagination,omitempty"`
CustomDictionaries *[]CustomDictionary `json:"customDictionaries,omitempty,brackets"`
CustomDictionaries *[]CustomDictionary `json:"customDictionaries,omitempty"`
}
// CustomResponse type
// CustomResponse type.
type CustomResponse struct {
Success bool `json:"success"`
Code string `json:"code,omitempty"`
}
// CustomDictionaryResponse type
// CustomDictionaryResponse type.
type CustomDictionaryResponse struct {
Success bool `json:"success"`
CustomDictionary *CustomDictionary `json:"CustomDictionary,omitempty,brackets"`
CustomDictionary *CustomDictionary `json:"CustomDictionary,omitempty"`
}
// CustomFieldResponse type
// CustomFieldResponse type.
type CustomFieldResponse struct {
Success bool `json:"success"`
CustomField CustomFields `json:"customField,omitempty,brackets"`
CustomField CustomFields `json:"customField,omitempty"`
}
// UnitsResponse type
// UnitsResponse type.
type UnitsResponse struct {
Success bool `json:"success"`
Units *[]Unit `json:"units,omitempty,brackets"`
Units *[]Unit `json:"units,omitempty"`
}

View File

@ -7,13 +7,13 @@ import (
"strings"
)
// ByID is "id" constant to use as `by` property in methods
// ByID is "id" constant to use as `by` property in methods.
const ByID = "id"
// ByExternalId is "externalId" constant to use as `by` property in methods
// ByExternalId is "externalId" constant to use as `by` property in methods.
const ByExternalID = "externalId"
// Client type
// Client type.
type Client struct {
URL string
Key string
@ -21,7 +21,7 @@ type Client struct {
httpClient *http.Client
}
// Pagination type
// Pagination type.
type Pagination struct {
Limit int `json:"limit,omitempty"`
TotalCount int `json:"totalCount,omitempty"`
@ -29,7 +29,7 @@ type Pagination struct {
TotalPageCount int `json:"totalPageCount,omitempty"`
}
// Address type
// Address type.
type Address struct {
Index string `json:"index,omitempty"`
CountryIso string `json:"countryIso,omitempty"`
@ -51,7 +51,7 @@ type Address struct {
Text string `json:"text,omitempty"`
}
// GeoHierarchyRow type
// GeoHierarchyRow type.
type GeoHierarchyRow struct {
Country string `json:"country,omitempty"`
Region string `json:"region,omitempty"`
@ -60,7 +60,7 @@ type GeoHierarchyRow struct {
CityID int `json:"cityId,omitempty"`
}
// Source type
// Source type.
type Source struct {
Source string `json:"source,omitempty"`
Medium string `json:"medium,omitempty"`
@ -69,7 +69,7 @@ type Source struct {
Content string `json:"content,omitempty"`
}
// Contragent type
// Contragent type.
type Contragent struct {
ContragentType string `json:"contragentType,omitempty"`
LegalName string `json:"legalName,omitempty"`
@ -88,26 +88,26 @@ type Contragent struct {
BankAccount string `json:"bankAccount,omitempty"`
}
// APIKey type
// APIKey type.
type APIKey struct {
Current bool `json:"current,omitempty"`
}
// Property type
// Property type.
type Property struct {
Code string `json:"code,omitempty"`
Name string `json:"name,omitempty"`
Value string `json:"value,omitempty"`
Sites []string `json:"Sites,omitempty,brackets"`
Sites []string `json:"Sites,omitempty"`
}
// IdentifiersPair type
// IdentifiersPair type.
type IdentifiersPair struct {
ID int `json:"id,omitempty"`
ExternalID string `json:"externalId,omitempty"`
}
// DeliveryTime type
// DeliveryTime type.
type DeliveryTime struct {
From string `json:"from,omitempty"`
To string `json:"to,omitempty"`
@ -118,7 +118,7 @@ type DeliveryTime struct {
Customer related types
*/
// Customer type
// Customer type.
type Customer struct {
ID int `json:"id,omitempty"`
ExternalID string `json:"externalId,omitempty"`
@ -127,7 +127,7 @@ type Customer struct {
Patronymic string `json:"patronymic,omitempty"`
Sex string `json:"sex,omitempty"`
Email string `json:"email,omitempty"`
Phones []Phone `json:"phones,brackets,omitempty"`
Phones []Phone `json:"phones,omitempty"`
Address *Address `json:"address,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
Birthday string `json:"birthday,omitempty"`
@ -153,11 +153,11 @@ type Customer struct {
BrowserID string `json:"browserId,omitempty"`
MgCustomerID string `json:"mgCustomerId,omitempty"`
PhotoURL string `json:"photoUrl,omitempty"`
CustomFields map[string]string `json:"customFields,omitempty,brackets"`
Tags []Tag `json:"tags,brackets,omitempty"`
CustomFields map[string]string `json:"customFields,omitempty"`
Tags []Tag `json:"tags,omitempty"`
}
// CorporateCustomer type
// CorporateCustomer type.
type CorporateCustomer struct {
ID int `json:"id,omitempty"`
ExternalID string `json:"externalId,omitempty"`
@ -165,7 +165,7 @@ type CorporateCustomer struct {
CreatedAt string `json:"createdAt,omitempty"`
Vip bool `json:"vip,omitempty"`
Bad bool `json:"bad,omitempty"`
CustomFields map[string]string `json:"customFields,omitempty,brackets"`
CustomFields map[string]string `json:"customFields,omitempty"`
PersonalDiscount float32 `json:"personalDiscount,omitempty"`
DiscountCardNumber string `json:"discountCardNumber,omitempty"`
ManagerID int `json:"managerId,omitempty"`
@ -226,22 +226,22 @@ type Company struct {
CreatedAt string `json:"createdAt,omitempty"`
Contragent *Contragent `json:"contragent,omitempty"`
Address *IdentifiersPair `json:"address,omitempty"`
CustomFields map[string]string `json:"customFields,omitempty,brackets"`
CustomFields map[string]string `json:"customFields,omitempty"`
}
// CorporateCustomerNote type
// CorporateCustomerNote type.
type CorporateCustomerNote struct {
ManagerID int `json:"managerId,omitempty"`
Text string `json:"text,omitempty"`
Customer *IdentifiersPair `json:"customer,omitempty"`
}
// Phone type
// Phone type.
type Phone struct {
Number string `json:"number,omitempty"`
}
// CustomerHistoryRecord type
// CustomerHistoryRecord type.
type CustomerHistoryRecord struct {
ID int `json:"id,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
@ -249,12 +249,12 @@ type CustomerHistoryRecord struct {
Deleted bool `json:"deleted,omitempty"`
Source string `json:"source,omitempty"`
Field string `json:"field,omitempty"`
User *User `json:"user,omitempty,brackets"`
APIKey *APIKey `json:"apiKey,omitempty,brackets"`
Customer *Customer `json:"customer,omitempty,brackets"`
User *User `json:"user,omitempty"`
APIKey *APIKey `json:"apiKey,omitempty"`
Customer *Customer `json:"customer,omitempty"`
}
// CorporateCustomerHistoryRecord type
// CorporateCustomerHistoryRecord type.
type CorporateCustomerHistoryRecord struct {
ID int `json:"id,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
@ -262,16 +262,16 @@ type CorporateCustomerHistoryRecord struct {
Deleted bool `json:"deleted,omitempty"`
Source string `json:"source,omitempty"`
Field string `json:"field,omitempty"`
User *User `json:"user,omitempty,brackets"`
APIKey *APIKey `json:"apiKey,omitempty,brackets"`
CorporateCustomer *CorporateCustomer `json:"corporateCustomer,omitempty,brackets"`
User *User `json:"user,omitempty"`
APIKey *APIKey `json:"apiKey,omitempty"`
CorporateCustomer *CorporateCustomer `json:"corporateCustomer,omitempty"`
}
/**
Order related types
*/
// Order type
// Order type.
type Order struct {
ID int `json:"id,omitempty"`
ExternalID string `json:"externalId,omitempty"`
@ -319,12 +319,12 @@ type Order struct {
Customer *Customer `json:"customer,omitempty"`
Delivery *OrderDelivery `json:"delivery,omitempty"`
Marketplace *OrderMarketplace `json:"marketplace,omitempty"`
Items []OrderItem `json:"items,omitempty,brackets"`
CustomFields map[string]string `json:"customFields,omitempty,brackets"`
Payments map[string]OrderPayment `json:"payments,omitempty,brackets"`
Items []OrderItem `json:"items,omitempty"`
CustomFields map[string]string `json:"customFields,omitempty"`
Payments map[string]OrderPayment `json:"payments,omitempty"`
}
// OrdersStatus type
// OrdersStatus type.
type OrdersStatus struct {
ID int `json:"id"`
ExternalID string `json:"externalId,omitempty"`
@ -332,7 +332,7 @@ type OrdersStatus struct {
Group string `json:"group"`
}
// OrderDelivery type
// OrderDelivery type.
type OrderDelivery struct {
Code string `json:"code,omitempty"`
IntegrationCode string `json:"integrationCode,omitempty"`
@ -346,21 +346,21 @@ type OrderDelivery struct {
Data *OrderDeliveryData `json:"data,omitempty"`
}
// OrderDeliveryTime type
// OrderDeliveryTime type.
type OrderDeliveryTime struct {
From string `json:"from,omitempty"`
To string `json:"to,omitempty"`
Custom string `json:"custom,omitempty"`
}
// OrderDeliveryService type
// OrderDeliveryService type.
type OrderDeliveryService struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
Active bool `json:"active,omitempty"`
}
// OrderDeliveryDataBasic type
// OrderDeliveryDataBasic type.
type OrderDeliveryDataBasic struct {
TrackNumber string `json:"trackNumber,omitempty"`
Status string `json:"status,omitempty"`
@ -368,13 +368,13 @@ type OrderDeliveryDataBasic struct {
PayerType string `json:"payerType,omitempty"`
}
// OrderDeliveryData type
// OrderDeliveryData type.
type OrderDeliveryData struct {
OrderDeliveryDataBasic
AdditionalFields map[string]interface{}
}
// UnmarshalJSON method
// UnmarshalJSON method.
func (v *OrderDeliveryData) UnmarshalJSON(b []byte) error {
var additionalData map[string]interface{}
json.Unmarshal(b, &additionalData)
@ -396,7 +396,7 @@ func (v *OrderDeliveryData) UnmarshalJSON(b []byte) error {
return nil
}
// MarshalJSON method
// MarshalJSON method.
func (v OrderDeliveryData) MarshalJSON() ([]byte, error) {
result := map[string]interface{}{}
data, _ := json.Marshal(v.OrderDeliveryDataBasic)
@ -409,13 +409,13 @@ func (v OrderDeliveryData) MarshalJSON() ([]byte, error) {
return json.Marshal(result)
}
// OrderMarketplace type
// OrderMarketplace type.
type OrderMarketplace struct {
Code string `json:"code,omitempty"`
OrderID string `json:"orderId,omitempty"`
}
// OrderPayment type
// OrderPayment type.
type OrderPayment struct {
ID int `json:"id,omitempty"`
ExternalID string `json:"externalId,omitempty"`
@ -426,7 +426,7 @@ type OrderPayment struct {
Comment string `json:"comment,omitempty"`
}
// OrderItem type
// OrderItem type.
type OrderItem struct {
ID int `json:"id,omitempty"`
InitialPrice float32 `json:"initialPrice,omitempty"`
@ -442,11 +442,11 @@ type OrderItem struct {
Comment string `json:"comment,omitempty"`
IsCanceled bool `json:"isCanceled,omitempty"`
Offer Offer `json:"offer,omitempty"`
Properties map[string]Property `json:"properties,omitempty,brackets"`
Properties map[string]Property `json:"properties,omitempty"`
PriceType *PriceType `json:"priceType,omitempty"`
}
// OrdersHistoryRecord type
// OrdersHistoryRecord type.
type OrdersHistoryRecord struct {
ID int `json:"id,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
@ -454,12 +454,12 @@ type OrdersHistoryRecord struct {
Deleted bool `json:"deleted,omitempty"`
Source string `json:"source,omitempty"`
Field string `json:"field,omitempty"`
User *User `json:"user,omitempty,brackets"`
APIKey *APIKey `json:"apiKey,omitempty,brackets"`
Order *Order `json:"order,omitempty,brackets"`
User *User `json:"user,omitempty"`
APIKey *APIKey `json:"apiKey,omitempty"`
Order *Order `json:"order,omitempty"`
}
// Pack type
// Pack type.
type Pack struct {
ID int `json:"id,omitempty"`
PurchasePrice float32 `json:"purchasePrice,omitempty"`
@ -473,14 +473,14 @@ type Pack struct {
Unit *Unit `json:"unit,omitempty"`
}
// PackItem type
// PackItem type.
type PackItem struct {
ID int `json:"id,omitempty"`
Order *Order `json:"order,omitempty"`
Offer *Offer `json:"offer,omitempty"`
}
// PacksHistoryRecord type
// PacksHistoryRecord type.
type PacksHistoryRecord struct {
ID int `json:"id,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
@ -488,11 +488,11 @@ type PacksHistoryRecord struct {
Deleted bool `json:"deleted,omitempty"`
Source string `json:"source,omitempty"`
Field string `json:"field,omitempty"`
User *User `json:"user,omitempty,brackets"`
Pack *Pack `json:"pack,omitempty,brackets"`
User *User `json:"user,omitempty"`
Pack *Pack `json:"pack,omitempty"`
}
// Offer type
// Offer type.
type Offer struct {
ID int `json:"id,omitempty"`
ExternalID string `json:"externalId,omitempty"`
@ -507,21 +507,21 @@ type Offer struct {
Width float32 `json:"width,omitempty"`
Length float32 `json:"length,omitempty"`
Weight float32 `json:"weight,omitempty"`
Stores []Inventory `json:"stores,omitempty,brackets"`
Properties map[string]string `json:"properties,omitempty,brackets"`
Prices []OfferPrice `json:"prices,omitempty,brackets"`
Images []string `json:"images,omitempty,brackets"`
Unit *Unit `json:"unit,omitempty,brackets"`
Stores []Inventory `json:"stores,omitempty"`
Properties map[string]string `json:"properties,omitempty"`
Prices []OfferPrice `json:"prices,omitempty"`
Images []string `json:"images,omitempty"`
Unit *Unit `json:"unit,omitempty"`
}
// Inventory type
// Inventory type.
type Inventory struct {
PurchasePrice float32 `json:"purchasePrice,omitempty"`
Quantity float32 `json:"quantity,omitempty"`
Store string `json:"store,omitempty"`
}
// InventoryUpload type
// InventoryUpload type.
type InventoryUpload struct {
ID int `json:"id,omitempty"`
ExternalID string `json:"externalId,omitempty"`
@ -529,21 +529,21 @@ type InventoryUpload struct {
Stores []InventoryUploadStore `json:"stores,omitempty"`
}
// InventoryUploadStore type
// InventoryUploadStore type.
type InventoryUploadStore struct {
PurchasePrice float32 `json:"purchasePrice,omitempty"`
Available float32 `json:"available,omitempty"`
Code string `json:"code,omitempty"`
}
// OfferPrice type
// OfferPrice type.
type OfferPrice struct {
Price float32 `json:"price,omitempty"`
Ordering int `json:"ordering,omitempty"`
PriceType string `json:"priceType,omitempty"`
}
// OfferPriceUpload type
// OfferPriceUpload type.
type OfferPriceUpload struct {
ID int `json:"id,omitempty"`
ExternalID string `json:"externalId,omitempty"`
@ -552,13 +552,13 @@ type OfferPriceUpload struct {
Prices []PriceUpload `json:"prices,omitempty"`
}
// PriceUpload type
// PriceUpload type.
type PriceUpload struct {
Code string `json:"code,omitempty"`
Price float32 `json:"price,omitempty"`
}
// Unit type
// Unit type.
type Unit struct {
Code string `json:"code"`
Name string `json:"name"`
@ -571,7 +571,7 @@ type Unit struct {
User related types
*/
// User type
// User type.
type User struct {
ID int `json:"id,omitempty"`
FirstName string `json:"firstName,omitempty"`
@ -585,30 +585,30 @@ type User struct {
Email string `json:"email,omitempty"`
Phone string `json:"phone,omitempty"`
Status string `json:"status,omitempty"`
Groups []UserGroup `json:"groups,omitempty,brackets"`
Groups []UserGroup `json:"groups,omitempty"`
MgUserId uint64 `json:"mgUserId,omitempty"`
}
// UserGroup type
// UserGroup type.
type UserGroup struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
SignatureTemplate string `json:"signatureTemplate,omitempty"`
IsManager bool `json:"isManager,omitempty"`
IsDeliveryMen bool `json:"isDeliveryMen,omitempty"`
DeliveryTypes []string `json:"deliveryTypes,omitempty,brackets"`
BreakdownOrderTypes []string `json:"breakdownOrderTypes,omitempty,brackets"`
BreakdownSites []string `json:"breakdownSites,omitempty,brackets"`
BreakdownOrderMethods []string `json:"breakdownOrderMethods,omitempty,brackets"`
GrantedOrderTypes []string `json:"grantedOrderTypes,omitempty,brackets"`
GrantedSites []string `json:"grantedSites,omitempty,brackets"`
DeliveryTypes []string `json:"deliveryTypes,omitempty"`
BreakdownOrderTypes []string `json:"breakdownOrderTypes,omitempty"`
BreakdownSites []string `json:"breakdownSites,omitempty"`
BreakdownOrderMethods []string `json:"breakdownOrderMethods,omitempty"`
GrantedOrderTypes []string `json:"grantedOrderTypes,omitempty"`
GrantedSites []string `json:"grantedSites,omitempty"`
}
/**
Task related types
*/
// Task type
// Task type.
type Task struct {
ID int `json:"id,omitempty"`
PerformerID int `json:"performerId,omitempty"`
@ -629,7 +629,7 @@ type Task struct {
Notes related types
*/
// Note type
// Note type.
type Note struct {
ID int `json:"id,omitempty"`
ManagerID int `json:"managerId,omitempty"`
@ -642,7 +642,7 @@ type Note struct {
Payments related types
*/
// Payment type
// Payment type.
type Payment struct {
ID int `json:"id,omitempty"`
ExternalID string `json:"externalId,omitempty"`
@ -658,7 +658,7 @@ type Payment struct {
Segment related types
*/
// Segment type
// Segment type.
type Segment struct {
ID int `json:"id,omitempty"`
Code string `json:"code,omitempty"`
@ -690,7 +690,7 @@ type Settings struct {
Reference related types
*/
// CostGroup type
// CostGroup type.
type CostGroup struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
@ -699,7 +699,7 @@ type CostGroup struct {
Ordering int `json:"ordering,omitempty"`
}
// CostItem type
// CostItem type.
type CostItem struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
@ -712,7 +712,7 @@ type CostItem struct {
Source *Source `json:"source,omitempty"`
}
// Courier type
// Courier type.
type Courier struct {
ID int `json:"id,omitempty"`
FirstName string `json:"firstName,omitempty"`
@ -724,14 +724,14 @@ type Courier struct {
Phone *Phone `json:"phone,omitempty"`
}
// DeliveryService type
// DeliveryService type.
type DeliveryService struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
Active bool `json:"active,omitempty"`
}
// DeliveryType type
// DeliveryType type.
type DeliveryType struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
@ -746,7 +746,7 @@ type DeliveryType struct {
PaymentTypes []string `json:"paymentTypes,omitempty"`
}
// LegalEntity type
// LegalEntity type.
type LegalEntity struct {
Code string `json:"code,omitempty"`
VatRate string `json:"vatRate,omitempty"`
@ -768,7 +768,7 @@ type LegalEntity struct {
BankAccount string `json:"bankAccount,omitempty"`
}
// OrderMethod type
// OrderMethod type.
type OrderMethod struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
@ -777,7 +777,7 @@ type OrderMethod struct {
DefaultForAPI bool `json:"defaultForApi,omitempty"`
}
// OrderType type
// OrderType type.
type OrderType struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
@ -786,7 +786,7 @@ type OrderType struct {
DefaultForAPI bool `json:"defaultForApi,omitempty"`
}
// PaymentStatus type
// PaymentStatus type.
type PaymentStatus struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
@ -796,10 +796,10 @@ type PaymentStatus struct {
PaymentComplete bool `json:"paymentComplete,omitempty"`
Description string `json:"description,omitempty"`
Ordering int `json:"ordering,omitempty"`
PaymentTypes []string `json:"paymentTypes,omitempty,brackets"`
PaymentTypes []string `json:"paymentTypes,omitempty"`
}
// PaymentType type
// PaymentType type.
type PaymentType struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
@ -807,11 +807,11 @@ type PaymentType struct {
DefaultForCRM bool `json:"defaultForCrm,omitempty"`
DefaultForAPI bool `json:"defaultForApi,omitempty"`
Description string `json:"description,omitempty"`
DeliveryTypes []string `json:"deliveryTypes,omitempty,brackets"`
PaymentStatuses []string `json:"PaymentStatuses,omitempty,brackets"`
DeliveryTypes []string `json:"deliveryTypes,omitempty"`
PaymentStatuses []string `json:"PaymentStatuses,omitempty"`
}
// PriceType type
// PriceType type.
type PriceType struct {
ID int `json:"id,omitempty"`
Code string `json:"code,omitempty"`
@ -821,11 +821,11 @@ type PriceType struct {
Description string `json:"description,omitempty"`
FilterExpression string `json:"filterExpression,omitempty"`
Ordering int `json:"ordering,omitempty"`
Groups []string `json:"groups,omitempty,brackets"`
Geo []GeoHierarchyRow `json:"geo,omitempty,brackets"`
Groups []string `json:"groups,omitempty"`
Geo []GeoHierarchyRow `json:"geo,omitempty"`
}
// ProductStatus type
// ProductStatus type.
type ProductStatus struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
@ -837,7 +837,7 @@ type ProductStatus struct {
OrderStatusForProductStatus string `json:"orderStatusForProductStatus,omitempty"`
}
// Status type
// Status type.
type Status struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
@ -846,17 +846,17 @@ type Status struct {
Group string `json:"group,omitempty"`
}
// StatusGroup type
// StatusGroup type.
type StatusGroup struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
Active bool `json:"active,omitempty"`
Ordering int `json:"ordering,omitempty"`
Process bool `json:"process,omitempty"`
Statuses []string `json:"statuses,omitempty,brackets"`
Statuses []string `json:"statuses,omitempty"`
}
// Site type
// Site type.
type Site struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
@ -873,7 +873,7 @@ type Site struct {
Contragent *LegalEntity `json:"contragent,omitempty"`
}
// Store type
// Store type.
type Store struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
@ -888,7 +888,7 @@ type Store struct {
Address *Address `json:"address,omitempty"`
}
// ProductGroup type
// ProductGroup type.
type ProductGroup struct {
ID int `json:"id,omitempty"`
ParentID int `json:"parentId,omitempty"`
@ -897,7 +897,7 @@ type ProductGroup struct {
Active bool `json:"active,omitempty"`
}
// Product type
// Product type.
type Product struct {
ID int `json:"id,omitempty"`
MaxPrice float32 `json:"maxPrice,omitempty"`
@ -915,19 +915,19 @@ type Product struct {
Recommended bool `json:"recommended,omitempty"`
Active bool `json:"active,omitempty"`
Quantity float32 `json:"quantity,omitempty"`
Offers []Offer `json:"offers,omitempty,brackets"`
Groups []ProductGroup `json:"groups,omitempty,brackets"`
Properties map[string]string `json:"properties,omitempty,brackets"`
Offers []Offer `json:"offers,omitempty"`
Groups []ProductGroup `json:"groups,omitempty"`
Properties map[string]string `json:"properties,omitempty"`
}
// DeliveryHistoryRecord type
// DeliveryHistoryRecord type.
type DeliveryHistoryRecord struct {
Code string `json:"code,omitempty"`
UpdatedAt string `json:"updatedAt,omitempty"`
Comment string `json:"comment,omitempty"`
}
// DeliveryShipment type
// DeliveryShipment type.
type DeliveryShipment struct {
IntegrationCode string `json:"integrationCode,omitempty"`
ID int `json:"id,omitempty"`
@ -940,11 +940,11 @@ type DeliveryShipment struct {
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"`
Orders []Order `json:"orders,omitempty"`
ExtraData map[string]string `json:"extraData,omitempty"`
}
// IntegrationModule type
// IntegrationModule type.
type IntegrationModule struct {
Code string `json:"code,omitempty"`
IntegrationCode string `json:"integrationCode,omitempty"`
@ -961,7 +961,7 @@ type IntegrationModule struct {
Integrations *Integrations `json:"integrations,omitempty"`
}
// Integrations type
// Integrations type.
type Integrations struct {
Telephony *Telephony `json:"telephony,omitempty"`
Delivery *Delivery `json:"delivery,omitempty"`
@ -970,11 +970,11 @@ type Integrations struct {
MgBot *MgBot `json:"mgBot,omitempty"`
}
// Delivery type
// Delivery type.
type Delivery struct {
Description string `json:"description,omitempty"`
Actions map[string]string `json:"actions,omitempty,brackets"`
PayerType []string `json:"payerType,omitempty,brackets"`
Actions map[string]string `json:"actions,omitempty"`
PayerType []string `json:"payerType,omitempty"`
PlatePrintLimit int `json:"platePrintLimit,omitempty"`
RateDeliveryCost bool `json:"rateDeliveryCost,omitempty"`
AllowPackages bool `json:"allowPackages,omitempty"`
@ -989,20 +989,20 @@ type Delivery struct {
ShipmentDataFieldList []DeliveryDataField `json:"shipmentDataFieldList,omitempty"`
}
// DeliveryStatus type
// DeliveryStatus type.
type DeliveryStatus struct {
Code string `json:"code,omitempty"`
Name string `json:"name,omitempty"`
IsEditable bool `json:"isEditable,omitempty"`
}
// Plate type
// Plate type.
type Plate struct {
Code string `json:"code,omitempty"`
Label string `json:"label,omitempty"`
}
// DeliveryDataField type
// DeliveryDataField type.
type DeliveryDataField struct {
Code string `json:"code,omitempty"`
Label string `json:"label,omitempty"`
@ -1015,7 +1015,7 @@ type DeliveryDataField struct {
Editable bool `json:"editable,omitempty"`
}
// Telephony type
// Telephony type.
type Telephony struct {
MakeCallURL string `json:"makeCallUrl,omitempty"`
AllowEdit bool `json:"allowEdit,omitempty"`
@ -1023,47 +1023,47 @@ type Telephony struct {
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"`
AdditionalCodes []AdditionalCode `json:"additionalCodes,omitempty"`
ExternalPhones []ExternalPhone `json:"externalPhones,omitempty"`
}
// AdditionalCode type
// AdditionalCode type.
type AdditionalCode struct {
Code string `json:"code,omitempty"`
UserID string `json:"userId,omitempty"`
}
// ExternalPhone type
// ExternalPhone type.
type ExternalPhone struct {
SiteCode string `json:"siteCode,omitempty"`
ExternalPhone string `json:"externalPhone,omitempty"`
}
// Warehouse type
// Warehouse type.
type Warehouse struct {
Actions []Action `json:"actions,omitempty,brackets"`
Actions []Action `json:"actions,omitempty"`
}
// Action type
// Action type.
type Action struct {
Code string `json:"code,omitempty"`
URL string `json:"url,omitempty"`
CallPoints []string `json:"callPoints,omitempty"`
}
// MgTransport type
// MgTransport type.
type MgTransport struct {
WebhookUrl string `json:"webhookUrl,omitempty"`
}
// MgBot type
// MgBot type.
type MgBot struct{}
/**
Cost related types
*/
// CostRecord type
// CostRecord type.
type CostRecord struct {
Source *Source `json:"source,omitempty"`
Comment string `json:"comment,omitempty"`
@ -1073,10 +1073,10 @@ type CostRecord struct {
CostItem string `json:"costItem,omitempty"`
UserId int `json:"userId,omitempty"`
Order *Order `json:"order,omitempty"`
Sites []string `json:"sites,omitempty,brackets"`
Sites []string `json:"sites,omitempty"`
}
// Cost type
// Cost type.
type Cost struct {
Source *Source `json:"source,omitempty"`
ID int `json:"id,omitempty"`
@ -1089,10 +1089,10 @@ type Cost struct {
CreatedBy string `json:"createdBy,omitempty"`
Order *Order `json:"order,omitempty"`
UserId int `json:"userId,omitempty"`
Sites []string `json:"sites,omitempty,brackets"`
Sites []string `json:"sites,omitempty"`
}
// File type
// File type.
type File struct {
ID int `json:"id,omitempty"`
Filename string `json:"filename,omitempty"`
@ -1102,13 +1102,13 @@ type File struct {
Attachment []Attachment `json:"attachment,omitempty"`
}
// Attachment type
// Attachment type.
type Attachment struct {
Customer *Customer `json:"customer,omitempty"`
Order *Order `json:"order,omitempty"`
}
// CustomFields type
// CustomFields type.
type CustomFields struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
@ -1129,27 +1129,27 @@ type CustomFields struct {
CustomDictionaries related types
*/
// CustomDictionary type
// CustomDictionary type.
type CustomDictionary struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
Elements []Element `json:"elements,omitempty,brackets"`
Elements []Element `json:"elements,omitempty"`
}
// Element type
// Element type.
type Element struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
Ordering int `json:"ordering,omitempty"`
}
// Activity struct
// Activity struct.
type Activity struct {
Active bool `json:"active"`
Freeze bool `json:"freeze"`
}
// Tag struct
// Tag struct.
type Tag struct {
Name string `json:"name,omitempty"`
Color string `json:"color,omitempty"`