mirror of
https://github.com/retailcrm/api-client-go.git
synced 2024-11-25 14:26:04 +03:00
Merge pull request #11 from DmitryZagorulko/master
add methods, documentation and tests
This commit is contained in:
commit
11a57e2e68
@ -5,4 +5,5 @@ go:
|
|||||||
- '1.10'
|
- '1.10'
|
||||||
before_install:
|
before_install:
|
||||||
- go get -v github.com/google/go-querystring/query
|
- go get -v github.com/google/go-querystring/query
|
||||||
|
- go get -v github.com/h2non/gock
|
||||||
script: go test -v ./...
|
script: go test -v ./...
|
||||||
|
36
README.md
36
README.md
@ -52,17 +52,41 @@ func main() {
|
|||||||
{
|
{
|
||||||
XMLID: "pTKIKAeghYzX21HTdzFCe1",
|
XMLID: "pTKIKAeghYzX21HTdzFCe1",
|
||||||
Stores: []InventoryUploadStore{
|
Stores: []InventoryUploadStore{
|
||||||
{Code: "test-store-v5", Available: 10, PurchasePrice: 1500},
|
{
|
||||||
{Code: "test-store-v4", Available: 20, PurchasePrice: 1530},
|
Code: "test-store-v5",
|
||||||
{Code: "test-store", Available: 30, PurchasePrice: 1510},
|
Available: 10,
|
||||||
|
PurchasePrice: 1500,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Code: "test-store-v4",
|
||||||
|
Available: 20,
|
||||||
|
PurchasePrice: 1530,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Code: "test-store",
|
||||||
|
Available: 30,
|
||||||
|
PurchasePrice: 1510,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
XMLID: "JQIvcrCtiSpOV3AAfMiQB3",
|
XMLID: "JQIvcrCtiSpOV3AAfMiQB3",
|
||||||
Stores: []InventoryUploadStore{
|
Stores: []InventoryUploadStore{
|
||||||
{Code: "test-store-v5", Available: 45, PurchasePrice: 1500},
|
{
|
||||||
{Code: "test-store-v4", Available: 32, PurchasePrice: 1530},
|
Code: "test-store-v5",
|
||||||
{Code: "test-store", Available: 46, PurchasePrice: 1510},
|
Available: 45,
|
||||||
|
PurchasePrice: 1500,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Code: "test-store-v4",
|
||||||
|
Available: 32,
|
||||||
|
PurchasePrice: 1530,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Code: "test-store",
|
||||||
|
Available: 46,
|
||||||
|
PurchasePrice: 1510,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -16,14 +16,8 @@ func (f *Failure) ApiError() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ApiErrors returns array of formatted strings that represents API errors
|
// ApiErrors returns array of formatted strings that represents API errors
|
||||||
func (f *Failure) ApiErrors() []string {
|
func (f *Failure) ApiErrors() map[string]string {
|
||||||
var errors []string
|
return f.ApiErrs
|
||||||
|
|
||||||
for i := 0; i < len(f.ApiErrs); i++ {
|
|
||||||
errors = append(errors, fmt.Sprintf("%v", f.ApiErrs[i]))
|
|
||||||
}
|
|
||||||
|
|
||||||
return errors
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrorResponse method
|
// ErrorResponse method
|
||||||
|
@ -4,5 +4,5 @@ package errs
|
|||||||
type Error interface {
|
type Error interface {
|
||||||
error
|
error
|
||||||
ApiError() string
|
ApiError() string
|
||||||
ApiErrors() []string
|
ApiErrors() map[string]string
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,11 @@ package errs
|
|||||||
type Failure struct {
|
type Failure struct {
|
||||||
RuntimeErr error
|
RuntimeErr error
|
||||||
ApiErr string
|
ApiErr string
|
||||||
ApiErrs []string
|
ApiErrs map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
// FailureResponse convert json error response into object
|
// FailureResponse convert json error response into object
|
||||||
type FailureResponse struct {
|
type FailureResponse struct {
|
||||||
ErrorMsg string `json:"errorMsg,omitempty"`
|
ErrorMsg string `json:"errorMsg,omitempty"`
|
||||||
Errors []string `json:"errors,omitempty"`
|
Errors map[string]string `json:"errors,omitempty"`
|
||||||
}
|
}
|
||||||
|
2221
v5/client.go
2221
v5/client.go
File diff suppressed because it is too large
Load Diff
3688
v5/client_test.go
3688
v5/client_test.go
File diff suppressed because it is too large
Load Diff
@ -296,3 +296,39 @@ type ShipmentFilter struct {
|
|||||||
DeliveryTypes []string `url:"deliveryTypes,omitempty,brackets"`
|
DeliveryTypes []string `url:"deliveryTypes,omitempty,brackets"`
|
||||||
Statuses []string `url:"statuses,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"`
|
||||||
|
}
|
||||||
|
@ -88,7 +88,7 @@ type TasksRequest struct {
|
|||||||
|
|
||||||
// NotesRequest type
|
// NotesRequest type
|
||||||
type NotesRequest struct {
|
type NotesRequest struct {
|
||||||
Filter TasksFilter `url:"filter,omitempty"`
|
Filter NotesFilter `url:"filter,omitempty"`
|
||||||
Limit int `url:"limit,omitempty"`
|
Limit int `url:"limit,omitempty"`
|
||||||
Page int `url:"page,omitempty"`
|
Page int `url:"page,omitempty"`
|
||||||
}
|
}
|
||||||
@ -142,3 +142,24 @@ type DeliveryShipmentsRequest struct {
|
|||||||
Limit int `url:"limit,omitempty"`
|
Limit int `url:"limit,omitempty"`
|
||||||
Page int `url:"page,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"`
|
||||||
|
}
|
||||||
|
@ -328,3 +328,61 @@ type IntegrationModuleEditResponse struct {
|
|||||||
Success bool `json:"success"`
|
Success bool `json:"success"`
|
||||||
Info map[string]string `json:"info,omitempty,brackets"`
|
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"`
|
||||||
|
}
|
||||||
|
68
v5/types.go
68
v5/types.go
@ -864,3 +864,71 @@ type Action struct {
|
|||||||
URL string `json:"url,omitempty"`
|
URL string `json:"url,omitempty"`
|
||||||
CallPoints []string `json:"callPoints,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"`
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user