add methods for costs, customFields, customDictionaries

This commit is contained in:
DmitryZagorulko 2018-04-11 13:39:43 +03:00
parent 93bb2f5e26
commit a2fdb06219
6 changed files with 1214 additions and 0 deletions

View File

@ -2062,3 +2062,638 @@ func (c *Client) StaticticsUpdate() (SuccessfulResponse, int, errs.Failure) {
return resp, status, err
}
// Getting of the cost list, adequate for the given filter
//
// Example:
//
// var client = v5.New("https://demo.url", "09jIJ")
//
// data, status, err := client.Costs(CostsRequest{
// Filter: CostsFilter{
// Ids: []string{"1","2","3"},
// MinSumm: "1000"
// },
// })
//
// if err.ErrorMsg != "" {
// fmt.Printf("%v", err.ErrorMsg)
// }
//
// if status >= http.StatusBadRequest {
// fmt.Printf("%v", err.ErrorMsg)
// }
//
// for _, value := range data.Costs {
// fmt.Printf("%v\n", value.Summ)
// }
func (c *Client) Costs(costs CostsRequest) (CostsResponse, int, ErrorResponse) {
var resp CostsResponse
params, _ := query.Values(costs)
data, status, err := c.GetRequest(fmt.Sprintf("/costs?%s", params.Encode()))
if err.ErrorMsg != "" {
return resp, status, err
}
json.Unmarshal(data, &resp)
return resp, status, err
}
// Creation of the cost
//
// Example:
//
// var client = v5.New("https://demo.url", "09jIJ")
//
// data, status, err := client.CostCreate(
// v5.CostRecord{
// DateFrom: "2012-12-12",
// DateTo: "2012-12-12",
// Summ: 12,
// CostItem: "calculation-of-costs",
// Order: Order{
// Number: "1"
// },
// Sites: []string{"store"},
// },
// "store"
// )
//
// if err.ErrorMsg != "" {
// fmt.Printf("%v", err.ErrorMsg)
// }
//
// if status >= http.StatusBadRequest {
// fmt.Printf("%v", err.ErrorMsg)
// }
//
// If data.Success == true {
// fmt.Printf("%v", data.ID)
// }
func (c *Client) CostCreate(cost CostRecord, site ...string) (CreateResponse, int, ErrorResponse) {
var resp CreateResponse
costJSON, _ := json.Marshal(&cost)
p := url.Values{
"cost": {string(costJSON[:])},
}
fillSite(&p, site)
data, status, err := c.PostRequest("/costs/create", p)
if err.ErrorMsg != "" {
return resp, status, err
}
json.Unmarshal(data, &resp)
return resp, status, err
}
// Method allows to remove batch up to 50 costs.
//
// Example:
//
// var client = v5.New("https://demo.url", "09jIJ")
//
// data, status, err := client.client.CostsDelete([]int{1, 2, 3, 48, 49, 50})
//
// if err.ErrorMsg != "" {
// fmt.Printf("%v", err.ErrorMsg)
// }
//
// if status >= http.StatusBadRequest {
// fmt.Printf("%v", err.ErrorMsg)
// }
//
// If data.Success == true {
// fmt.Printf("Not removed costs: %v", data.NotRemovedIds)
// }
func (c *Client) CostsDelete(ids []int) (CostsDeleteResponse, int, ErrorResponse) {
var resp CostsDeleteResponse
costJSON, _ := json.Marshal(&ids)
p := url.Values{
"ids": {string(costJSON[:])},
}
data, status, err := c.PostRequest("/costs/delete", p)
if err.ErrorMsg != "" {
return resp, status, err
}
json.Unmarshal(data, &resp)
return resp, status, err
}
// Method allows to upload as packet up to 50 costs.
//
// Example:
//
// var client = v5.New("https://demo.url", "09jIJ")
//
// data, status, err := client.CostCreate([]v5.CostRecord{
// {
// DateFrom: "2012-12-12",
// DateTo: "2012-12-12",
// Summ: 12,
// CostItem: "calculation-of-costs",
// Order: Order{
// Number: "1"
// },
// Sites: []string{"store"},
// },
// {
// DateFrom: "2012-12-13",
// DateTo: "2012-12-13",
// Summ: 13,
// CostItem: "seo",
// }
// })
//
// if err.ErrorMsg != "" {
// fmt.Printf("%v", err.ErrorMsg)
// }
//
// if status >= http.StatusBadRequest {
// fmt.Printf("%v", err.ErrorMsg)
// }
//
// If data.Success == true {
// fmt.Printf("Uploaded costs: %v", data.UploadedCosts)
// }
func (c *Client) CostsUpload(cost []CostRecord) (CostsUploadResponse, int, ErrorResponse) {
var resp CostsUploadResponse
costJSON, _ := json.Marshal(&cost)
p := url.Values{
"costs": {string(costJSON[:])},
}
data, status, err := c.PostRequest("/costs/upload", p)
if err.ErrorMsg != "" {
return resp, status, err
}
json.Unmarshal(data, &resp)
return resp, status, err
}
// Getting of cost information
//
// Example:
//
// var client = v5.New("https://demo.url", "09jIJ")
//
// data, status, err := client.Cost(1)
//
// if err.ErrorMsg != "" {
// fmt.Printf("%v", err.ErrorMsg)
// }
//
// if status >= http.StatusBadRequest {
// fmt.Printf("%v", err.ErrorMsg)
// }
//
// If data.Success == true {
// fmt.Printf("%v", data.Cost)
// }
func (c *Client) Cost(id int) (CostResponse, int, ErrorResponse) {
var resp CostResponse
data, status, err := c.GetRequest(fmt.Sprintf("/costs/%d", id))
if err.ErrorMsg != "" {
return resp, status, err
}
json.Unmarshal(data, &resp)
return resp, status, err
}
// Cost removing
//
// Example:
//
// var client = v5.New("https://demo.url", "09jIJ")
//
// data, status, err := client.CostDelete(1)
//
// if err.ErrorMsg != "" {
// fmt.Printf("%v", err.ErrorMsg)
// }
//
// if status >= http.StatusBadRequest {
// fmt.Printf("%v", err.ErrorMsg)
// }
func (c *Client) CostDelete(id int) (SuccessfulResponse, int, ErrorResponse) {
var resp SuccessfulResponse
costJSON, _ := json.Marshal(&id)
p := url.Values{
"costs": {string(costJSON[:])},
}
data, status, err := c.PostRequest(fmt.Sprintf("/costs/%d/delete", id), p)
if err.ErrorMsg != "" {
return resp, status, err
}
json.Unmarshal(data, &resp)
return resp, status, err
}
// Cost editing
//
// Example:
//
// var client = v5.New("https://demo.url", "09jIJ")
//
// data, status, err := client.CostEdit(1, v5.Cost{
// DateFrom: "2012-12-12",
// DateTo: "2018-12-13",
// Summ: 321,
// CostItem: "seo",
// })
//
// if err.ErrorMsg != "" {
// fmt.Printf("%v", err.ErrorMsg)
// }
//
// if status >= http.StatusBadRequest {
// fmt.Printf("%v", err.ErrorMsg)
// }
//
// If data.Success == true {
// fmt.Printf("%v", data.Id)
// }
func (c *Client) CostEdit(id int, cost CostRecord, site ...string) (CreateResponse, int, ErrorResponse) {
var resp CreateResponse
costJSON, _ := json.Marshal(&cost)
p := url.Values{
"cost": {string(costJSON[:])},
}
fillSite(&p, site)
data, status, err := c.PostRequest(fmt.Sprintf("/costs/%d/edit", id), p)
if err.ErrorMsg != "" {
return resp, status, err
}
json.Unmarshal(data, &resp)
return resp, status, err
}
// Getting the list of custom fields
//
// Example:
//
// var client = v5.New("https://demo.url", "09jIJ")
//
// data, status, err := client.CustomFields(v5.CustomFieldsRequest{
// Type: "string",
// Entity: "customer",
// })
//
// if err.ErrorMsg != "" {
// fmt.Printf("%v", err.ErrorMsg)
// }
//
// if status >= http.StatusBadRequest {
// fmt.Printf("%v", err.ErrorMsg)
// }
//
// for _, value := range data.CustomFields {
// fmt.Printf("%v\n", value)
// }
func (c *Client) CustomFields(customFields CustomFieldsRequest) (CustomFieldsResponse, int, ErrorResponse) {
var resp CustomFieldsResponse
params, _ := query.Values(customFields)
data, status, err := c.GetRequest(fmt.Sprintf("/custom-fields?%s", params.Encode()))
if err.ErrorMsg != "" {
return resp, status, err
}
json.Unmarshal(data, &resp)
return resp, status, err
}
// Getting the list of custom directory
//
// Example:
//
// var client = v5.New("https://demo.url", "09jIJ")
//
// data, status, err := client.CustomDictionaries(v5.CustomDictionariesRequest{
// Filter: v5.CustomDictionariesFilter{
// Name: "Dictionary-1",
// },
// })
//
// if err.ErrorMsg != "" {
// fmt.Printf("%v", err.ErrorMsg)
// }
//
// if status >= http.StatusBadRequest {
// fmt.Printf("%v", err.ErrorMsg)
// }
//
// for _, value := range data.CustomDictionaries {
// fmt.Printf("%v\n", value.Elements)
// }
func (c *Client) CustomDictionaries(customDictionaries CustomDictionariesRequest) (CustomDictionariesResponse, int, ErrorResponse) {
var resp CustomDictionariesResponse
params, _ := query.Values(customDictionaries)
data, status, err := c.GetRequest(fmt.Sprintf("/custom-fields/dictionaries?%s", params.Encode()))
if err.ErrorMsg != "" {
return resp, status, err
}
json.Unmarshal(data, &resp)
return resp, status, err
}
// Directory fields creation
//
// Example:
//
// var client = v5.New("https://demo.url", "09jIJ")
//
// data, status, err := client.CustomDictionariesCreate(v5.CustomDictionary{
// Name: "Courier profiles",
// Code: "courier-profiles",
// Elements: []Element{
// {
// Name: "Name",
// Code: "name",
// },
// {
// Name: "Lastname",
// Code: "lastname",
// }
// },
// })
//
// if err.ErrorMsg != "" {
// fmt.Printf("%v", err.ErrorMsg)
// }
//
// if status >= http.StatusBadRequest {
// fmt.Printf("%v", err.ErrorMsg)
// }
//
// If data.Success == true {
// fmt.Printf("%v", data.Code)
// }
func (c *Client) CustomDictionariesCreate(customDictionary CustomDictionary) (CustomResponse, int, ErrorResponse) {
var resp CustomResponse
costJSON, _ := json.Marshal(&customDictionary)
p := url.Values{
"customDictionary": {string(costJSON[:])},
}
data, status, err := c.PostRequest("/custom-fields/dictionaries/create", p)
if err.ErrorMsg != "" {
return resp, status, err
}
json.Unmarshal(data, &resp)
return resp, status, err
}
// Getting information on directory
//
// Example:
//
// var client = v5.New("https://demo.url", "09jIJ")
//
// data, status, err := client.CustomDictionary("courier-profiles")
//
// if err.ErrorMsg != "" {
// fmt.Printf("%v", err.ErrorMsg)
// }
//
// if status >= http.StatusBadRequest {
// fmt.Printf("%v", err.ErrorMsg)
// }
//
// If data.Success == true {
// fmt.Printf("%v", data.CustomDictionary.Name)
// }
func (c *Client) CustomDictionary(code string) (CustomDictionaryResponse, int, ErrorResponse) {
var resp CustomDictionaryResponse
data, status, err := c.GetRequest(fmt.Sprintf("/custom-fields/dictionaries/%s", code))
if err.ErrorMsg != "" {
return resp, status, err
}
json.Unmarshal(data, &resp)
return resp, status, err
}
// Directory fields editing
//
// Example:
//
// var client = v5.New("https://demo.url", "09jIJ")
//
// data, status, err := client.CustomDictionaryEdit(v5.CustomDictionary{
// Name: "Courier profiles",
// Code: "courier-profiles",
// Elements: []Element{
// {
// Name: "Name",
// Code: "name",
// },
// {
// Name: "Lastname",
// Code: "lastname",
// }
// },
// })
//
// if err.ErrorMsg != "" {
// fmt.Printf("%v", err.ErrorMsg)
// }
//
// if status >= http.StatusBadRequest {
// fmt.Printf("%v", err.ErrorMsg)
// }
//
// If data.Success == true {
// fmt.Printf("%v", data.Code)
// }
func (c *Client) CustomDictionaryEdit(customDictionary CustomDictionary) (CustomResponse, int, ErrorResponse) {
var resp CustomResponse
costJSON, _ := json.Marshal(&customDictionary)
p := url.Values{
"customDictionary": {string(costJSON[:])},
}
data, status, err := c.PostRequest(fmt.Sprintf("/custom-fields/dictionaries/%s/edit", customDictionary.Code), p)
if err.ErrorMsg != "" {
return resp, status, err
}
json.Unmarshal(data, &resp)
return resp, status, err
}
// Custom fields creation
//
// Example:
//
// var client = v5.New("https://demo.url", "09jIJ")
//
// data, status, err := client.CustomFieldsCreate(v5.CustomFieldsEditRequest{
// CustomField: v5.CustomFields{
// Name: "First order",
// Code: "first-order",
// Type: "bool",
// Entity: "order",
// DisplayArea: "customer",
// },
// })
//
// if err.ErrorMsg != "" {
// fmt.Printf("%v", err.ErrorMsg)
// }
//
// if status >= http.StatusBadRequest {
// fmt.Printf("%v", err.ErrorMsg)
// }
//
// If data.Success == true {
// fmt.Printf("%v", data.Code)
// }
func (c *Client) CustomFieldsCreate(customFields CustomFieldsEditRequest) (CustomResponse, int, ErrorResponse) {
var resp CustomResponse
costJSON, _ := json.Marshal(&customFields)
p := url.Values{
"customField": {string(costJSON[:])},
}
data, status, err := c.PostRequest(fmt.Sprintf("/custom-fields/%s/create", customFields.CustomField.Entity), p)
if err.ErrorMsg != "" {
return resp, status, err
}
json.Unmarshal(data, &resp)
return resp, status, err
}
// Getting information on custom fields
//
// Example:
//
// var client = v5.New("https://demo.url", "09jIJ")
//
// data, status, err := client.CustomField("order", "first-order")
//
// if err.ErrorMsg != "" {
// fmt.Printf("%v", err.ErrorMsg)
// }
//
// if status >= http.StatusBadRequest {
// fmt.Printf("%v", err.ErrorMsg)
// }
//
// If data.Success == true {
// fmt.Printf("%v", data.CustomField)
// }
func (c *Client) CustomField(entity, code string) (CustomFieldResponse, int, ErrorResponse) {
var resp CustomFieldResponse
data, status, err := c.GetRequest(fmt.Sprintf("/custom-fields/%s/%s", entity, code))
if err.ErrorMsg != "" {
return resp, status, err
}
json.Unmarshal(data, &resp)
return resp, status, err
}
// CustomFieldEdit list method
//
// Example:
//
// var client = v5.New("https://demo.url", "09jIJ")
//
// data, status, err := client.CustomFieldEdit("order", v5.CustomFieldsEditRequest{
// CustomField: v5.CustomFields{
// Name: "First customer order",
// Code: "first-order",
// },
// })
//
// if err.ErrorMsg != "" {
// fmt.Printf("%v", err.ErrorMsg)
// }
//
// if status >= http.StatusBadRequest {
// fmt.Printf("%v", err.ErrorMsg)
// }
//
// If data.Success == true {
// fmt.Printf("%v", data.Code)
// }
func (c *Client) CustomFieldEdit(entity string, customFields CustomFieldsEditRequest) (CustomResponse, int, ErrorResponse) {
var resp CustomResponse
costJSON, _ := json.Marshal(&customFields)
p := url.Values{
"customField": {string(costJSON[:])},
}
data, status, err := c.PostRequest(fmt.Sprintf("/custom-fields/%s/%s/edit", entity, customFields.CustomField.Code), p)
if err.ErrorMsg != "" {
return resp, status, err
}
json.Unmarshal(data, &resp)
return resp, status, err
}

View File

@ -14,6 +14,8 @@ import (
var r *rand.Rand // Rand for this package.
var user, _ = strconv.Atoi(os.Getenv("RETAILCRM_USER"))
var statuses = map[int]bool{http.StatusOK: true, http.StatusCreated: true}
var id int
var ids []int
func init() {
r = rand.New(rand.NewSource(time.Now().UnixNano()))
@ -1850,3 +1852,391 @@ func TestClient_DeliveryShipments(t *testing.T) {
t.Errorf("%v", err.ApiError())
}
}
func TestClient_CostCreate(t *testing.T) {
c := client()
data, status, err := c.CostCreate(CostRecord{
DateFrom: "2018-04-02",
DateTo: "2018-04-02",
Summ: 124,
CostItem: "seo",
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
id = data.ID
}
func TestClient_Costs(t *testing.T) {
c := client()
data, status, err := c.Costs(CostsRequest{
Filter: CostsFilter{
Ids: []string{strconv.Itoa(id)},
},
Limit: 20,
Page: 1,
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_Cost(t *testing.T) {
c := client()
data, status, err := c.Cost(id)
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_CostEdit(t *testing.T) {
c := client()
data, status, err := c.CostEdit(id, CostRecord{
DateFrom: "2018-04-09",
DateTo: "2018-04-09",
Summ: 421,
CostItem: "seo",
Order: nil,
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_CostDelete(t *testing.T) {
c := client()
data, status, err := c.CostDelete(id)
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_CostsUpload(t *testing.T) {
c := client()
data, status, err := c.CostsUpload([]CostRecord{
{
Source: nil,
DateFrom: "2018-04-02",
DateTo: "2018-04-02",
Summ: 124,
CostItem: "seo",
Order: nil,
},
{
Source: nil,
DateFrom: "2018-04-03",
DateTo: "2018-04-03",
Summ: 125,
CostItem: "seo",
Order: nil,
Sites: []string{"catalog-test"},
},
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
ids = data.UploadedCosts
}
func TestClient_CostsDelete(t *testing.T) {
c := client()
data, status, err := c.CostsDelete(ids)
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_CustomFields(t *testing.T) {
c := client()
data, status, err := c.CustomFields(CustomFieldsRequest{})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_CustomDictionaries(t *testing.T) {
c := client()
data, status, err := c.CustomDictionaries(CustomDictionariesRequest{
Filter: CustomDictionariesFilter{
Name: "test",
},
Limit: 10,
Page: 1,
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_CustomDictionary(t *testing.T) {
c := client()
data, status, err := c.CustomDictionary("test2")
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_CustomDictionariesCreate(t *testing.T) {
c := client()
data, status, err := c.CustomDictionariesCreate(CustomDictionary{
Name: "test2",
Code: "test2",
Elements: []Element{
{
Name: "test",
Code: "test",
},
},
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_CustomDictionaryEdit(t *testing.T) {
c := client()
data, status, err := c.CustomDictionaryEdit(CustomDictionary{
Name: "test223",
Code: "test2",
Elements: []Element{
{
Name: "test3",
Code: "test3",
},
},
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_CustomFieldsCreate(t *testing.T) {
c := client()
data, status, err := c.CustomFieldsCreate(CustomFieldsEditRequest{
CustomField: CustomFields{
Name: "test4",
Code: "test4",
Type: "text",
Entity: "order",
DisplayArea: "customer",
},
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_CustomField(t *testing.T) {
c := client()
data, status, err := c.CustomField("customer", "testtest")
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
func TestClient_CustomFieldEdit(t *testing.T) {
c := client()
data, status, err := c.CustomFieldEdit("customer", CustomFieldsEditRequest{
CustomField: CustomFields{
Name: "testtesttest",
},
})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status != http.StatusOK {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}

View File

@ -296,3 +296,39 @@ type ShipmentFilter struct {
DeliveryTypes []string `url:"deliveryTypes,omitempty,brackets"`
Statuses []string `url:"statuses,omitempty,brackets"`
}
// CostsFilter type
type CostsFilter struct {
MinSumm string `url:"minSumm,omitempty"`
MaxSumm string `url:"maxSumm,omitempty"`
OrderNumber string `url:"orderNumber,omitempty"`
Comment string `url:"orderNumber,omitempty"`
Ids []string `url:"ids,omitempty,brackets"`
Sites []string `url:"sites,omitempty,brackets"`
CreatedBy []string `url:"createdBy,omitempty,brackets"`
CostGroups []string `url:"costGroups,omitempty,brackets"`
CostItems []string `url:"costItems,omitempty,brackets"`
Users []string `url:"users,omitempty,brackets"`
DateFrom string `url:"dateFrom,omitempty"`
DateTo string `url:"dateTo,omitempty"`
CreatedAtFrom string `url:"createdAtFrom,omitempty"`
CreatedAtTo string `url:"createdAtTo,omitempty"`
OrderIds []string `url:"orderIds,omitempty,brackets"`
OrderExternalIds []string `url:"orderIds,omitempty,brackets"`
}
// CustomFieldsFilter type
type CustomFieldsFilter struct {
Name string `url:"name,omitempty"`
Code string `url:"code,omitempty"`
Type string `url:"type,omitempty"`
Entity string `url:"entity,omitempty"`
ViewMode string `url:"viewMode,omitempty"`
DisplayArea string `url:"displayArea,omitempty"`
}
// CustomDictionariesFilter type
type CustomDictionariesFilter struct {
Name string `url:"name,omitempty"`
Code string `url:"code,omitempty"`
}

View File

@ -142,3 +142,30 @@ type DeliveryShipmentsRequest struct {
Limit int `url:"limit,omitempty"`
Page int `url:"page,omitempty"`
}
// CostsRequest type
type CostsRequest struct {
Filter CostsFilter `url:"filter,omitempty"`
Limit int `url:"limit,omitempty"`
Page int `url:"page,omitempty"`
}
// CustomFieldsRequest type
type CustomFieldsRequest struct {
Filter CustomFieldsFilter `url:"filter,omitempty"`
Limit int `url:"limit,omitempty"`
Page int `url:"page,omitempty"`
}
// CustomeDictionariesRequest type
type CustomDictionariesRequest struct {
Filter CustomDictionariesFilter `url:"filter,omitempty"`
Limit int `url:"limit,omitempty"`
Page int `url:"page,omitempty"`
}
// CustomFieldsEditRequest type
type CustomFieldsEditRequest struct {
CustomField CustomFields `url:"customField,omitempty"`
Entity string `url:"entity,omitempty"`
}

View File

@ -328,3 +328,61 @@ type IntegrationModuleEditResponse struct {
Success bool `json:"success"`
Info map[string]string `json:"info,omitempty,brackets"`
}
// CostsResponse type
type CostsResponse struct {
Success bool `json:"success"`
Pagination *Pagination `json:"pagination,omitempty"`
Costs []Cost `json:"costs,omitempty,brackets"`
}
// CostsUploadResponse type
type CostsUploadResponse struct {
Success bool `json:"success"`
UploadedCosts []int `json:"uploadedCosts,omitempty,brackets"`
}
// CostsDeleteResponse type
type CostsDeleteResponse struct {
Success bool `json:"success"`
Count int `json:"count,omitempty,brackets"`
NotRemovedIds []int `json:"notRemovedIds,omitempty,brackets"`
}
// CostResponse type
type CostResponse struct {
Success bool `json:"success"`
Cost *Cost `json:"cost,omitempty,brackets"`
}
// CustomFieldsResponse type
type CustomFieldsResponse struct {
Success bool `json:"success"`
Pagination *Pagination `json:"pagination,omitempty"`
CustomFields []CustomFields `json:"customFields,omitempty,brackets"`
}
// CustomDictionariesResponse type
type CustomDictionariesResponse struct {
Success bool `json:"success"`
Pagination *Pagination `json:"pagination,omitempty"`
CustomDictionaries *[]CustomDictionary `json:"customDictionaries,omitempty,brackets"`
}
// CustomDictionariesResponse type
type CustomResponse struct {
Success bool `json:"success"`
Code string `json:"code,omitempty"`
}
// CustomDictionaryResponse type
type CustomDictionaryResponse struct {
Success bool `json:"success"`
CustomDictionary *CustomDictionary `json:"CustomDictionary,omitempty,brackets"`
}
// CustomFieldResponse type
type CustomFieldResponse struct {
Success bool `json:"success"`
CustomField CustomFields `json:"customField,omitempty,brackets"`
}

View File

@ -864,3 +864,71 @@ type Action struct {
URL string `json:"url,omitempty"`
CallPoints []string `json:"callPoints,omitempty"`
}
/**
Cost related types
*/
// CostRecord type
type CostRecord struct {
Source *Source `json:"source,omitempty"`
Comment string `json:"comment,omitempty"`
DateFrom string `json:"dateFrom,omitempty"`
DateTo string `json:"dateTo,omitempty"`
Summ float32 `json:"summ,omitempty"`
CostItem string `json:"costItem,omitempty"`
UserId int `json:"userId,omitempty"`
Order *Order `json:"order,omitempty"`
Sites []string `json:"sites,omitempty,brackets"`
}
// Cost type
type Cost struct {
Source *Source `json:"source,omitempty"`
ID int `json:"id,omitempty"`
DateFrom string `json:"dateFrom,omitempty"`
DateTo string `json:"dateTo,omitempty"`
Summ float32 `json:"summ,omitempty"`
CostItem string `json:"costItem,omitempty"`
Comment string `json:"comment,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
CreatedBy string `json:"createdBy,omitempty"`
Order *Order `json:"order,omitempty"`
UserId int `json:"userId,omitempty"`
Sites []string `json:"sites,omitempty,brackets"`
}
// CustomFields type
type CustomFields struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
Required bool `json:"required,omitempty"`
InFilter bool `json:"inFilter,omitempty"`
InList bool `json:"inList,omitempty"`
InGroupActions bool `json:"inGroupActions,omitempty"`
Type string `json:"type,omitempty"`
Entity string `json:"entity,omitempty"`
Default string `json:"default,omitempty"`
Ordering int `json:"ordering,omitempty"`
DisplayArea string `json:"displayArea,omitempty"`
ViewMode string `json:"viewMode,omitempty"`
Dictionary string `json:"dictionary,omitempty"`
}
/**
CustomeDictionaries related types
*/
// customDictionary type
type CustomDictionary struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
Elements []Element `json:"elements,omitempty,brackets"`
}
// Dictionary Element type
type Element struct {
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
Ordering int `json:"ordering,omitempty"`
}