diff --git a/v5/client.go b/v5/client.go index aef42e1..ab17d56 100644 --- a/v5/client.go +++ b/v5/client.go @@ -542,8 +542,8 @@ func (c *Client) Tasks(parameters TasksRequest) (*TasksResponse, int, error) { } // TaskCreate method -func (c *Client) TaskCreate(task Task, site ...string) (*TaskChangeResponse, int, error) { - var resp TaskChangeResponse +func (c *Client) TaskCreate(task Task, site ...string) (*CreateResponse, int, error) { + var resp CreateResponse taskJson, _ := json.Marshal(&task) p := url.Values{ diff --git a/v5/response.go b/v5/response.go index f125ba5..f01a333 100644 --- a/v5/response.go +++ b/v5/response.go @@ -128,12 +128,6 @@ type TaskResponse struct { Task *Task `json:"task,omitempty,brackets"` } -// TaskChangeResponse type -type TaskChangeResponse struct { - Success bool `json:"success"` - Id int `json:"id,omitempty"` -} - // TasksResponse type type TasksResponse struct { Success bool `json:"success"` diff --git a/v5/types.go b/v5/types.go index 3a9ef1a..673e1aa 100644 --- a/v5/types.go +++ b/v5/types.go @@ -100,7 +100,7 @@ type Customer struct { Sex string `json:"sex,omitempty"` Email string `json:"email,omitempty"` Phones []CustomerPhone `json:"phones,brackets,omitempty"` - Address Address `json:"address,omitempty"` + Address *Address `json:"address,omitempty"` CreatedAt string `json:"createdAt,omitempty"` Birthday string `json:"birthday,omitempty"` ManagerId int `json:"managerId,omitempty"` @@ -133,15 +133,15 @@ type CustomerPhone struct { // CustomerHistoryRecord type type CustomerHistoryRecord struct { - Id int `json:"id,omitempty"` - CreatedAt string `json:"createdAt,omitempty"` - Created bool `json:"created,omitempty"` - 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"` + Id int `json:"id,omitempty"` + CreatedAt string `json:"createdAt,omitempty"` + Created bool `json:"created,omitempty"` + 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"` } /** @@ -191,11 +191,11 @@ type Order struct { ClientId string `json:"clientId,omitempty"` Shipped bool `json:"shipped,omitempty"` UploadedToExternalStoreSystem bool `json:"uploadedToExternalStoreSystem,omitempty"` - Source Source `json:"source,omitempty"` - Contragent Contragent `json:"contragent,omitempty"` - Customer Customer `json:"customer,omitempty"` - Delivery OrderDelivery `json:"delivery,omitempty"` - Marketplace OrderMarketplace `json:"marketplace,omitempty"` + Source *Source `json:"source,omitempty"` + Contragent *Contragent `json:"contragent,omitempty"` + 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 []OrderPayment `json:"payments,omitempty,brackets"` @@ -203,16 +203,16 @@ type Order struct { // OrderDelivery type type OrderDelivery struct { - Code string `json:"code,omitempty"` - IntegrationCode string `json:"integrationCode,omitempty"` - Cost float32 `json:"cost,omitempty"` - NetCost float32 `json:"netCost,omitempty"` - VatRate string `json:"vatRate,omitempty"` - Date string `json:"date,omitempty"` - Time OrderDeliveryTime `json:"time,omitempty"` - Address Address `json:"address,omitempty"` - Service OrderDeliveryService `json:"service,omitempty"` - Data OrderDeliveryData `json:"data,omitempty"` + Code string `json:"code,omitempty"` + IntegrationCode string `json:"integrationCode,omitempty"` + Cost float32 `json:"cost,omitempty"` + NetCost float32 `json:"netCost,omitempty"` + VatRate string `json:"vatRate,omitempty"` + Date string `json:"date,omitempty"` + Time *OrderDeliveryTime `json:"time,omitempty"` + Address *Address `json:"address,omitempty"` + Service *OrderDeliveryService `json:"service,omitempty"` + Data *OrderDeliveryData `json:"data,omitempty"` } // OrderDeliveryTime type @@ -256,35 +256,35 @@ type OrderPayment struct { // OrderItem type type OrderItem struct { - Id int `json:"id,omitempty"` - InitialPrice float32 `json:"initialPrice,omitempty"` - PurchasePrice float32 `json:"purchasePrice,omitempty"` - DiscountTotal float32 `json:"discountTotal,omitempty"` - DiscountManualAmount float32 `json:"discountManualAmount,omitempty"` - DiscountManualPercent float32 `json:"discountManualPercent,omitempty"` - ProductName string `json:"productName,omitempty"` - VatRate string `json:"vatRate,omitempty"` - CreatedAt string `json:"createdAt,omitempty"` - Quantity float32 `json:"quantity,omitempty"` - Status string `json:"status,omitempty"` - Comment string `json:"comment,omitempty"` - IsCanceled bool `json:"isCanceled,omitempty"` - Offer Offer `json:"offer,omitempty"` - Properties []Property `json:"properties,omitempty,brackets"` - PriceType PriceType `json:"priceType,omitempty"` + Id int `json:"id,omitempty"` + InitialPrice float32 `json:"initialPrice,omitempty"` + PurchasePrice float32 `json:"purchasePrice,omitempty"` + DiscountTotal float32 `json:"discountTotal,omitempty"` + DiscountManualAmount float32 `json:"discountManualAmount,omitempty"` + DiscountManualPercent float32 `json:"discountManualPercent,omitempty"` + ProductName string `json:"productName,omitempty"` + VatRate string `json:"vatRate,omitempty"` + CreatedAt string `json:"createdAt,omitempty"` + Quantity float32 `json:"quantity,omitempty"` + Status string `json:"status,omitempty"` + Comment string `json:"comment,omitempty"` + IsCanceled bool `json:"isCanceled,omitempty"` + Offer *Offer `json:"offer,omitempty"` + Properties []*Property `json:"properties,omitempty,brackets"` + PriceType *PriceType `json:"priceType,omitempty"` } // OrdersHistoryRecord type type OrdersHistoryRecord struct { - Id int `json:"id,omitempty"` - CreatedAt string `json:"createdAt,omitempty"` - Created bool `json:"created,omitempty"` - 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"` + Id int `json:"id,omitempty"` + CreatedAt string `json:"createdAt,omitempty"` + Created bool `json:"created,omitempty"` + 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"` } // Offer type @@ -351,19 +351,19 @@ Task related types // Task type type Task struct { - Id int `json:"id,omitempty"` - PerformerId int `json:"performerId,omitempty"` - Text string `json:"text,omitempty"` - Commentary string `json:"commentary,omitempty"` - Datetime string `json:"datetime,omitempty"` - Complete bool `json:"complete,omitempty"` - CreatedAt string `json:"createdAt,omitempty"` - Creator int `json:"creator,omitempty"` - Performer int `json:"performer,omitempty"` - Phone string `json:"phone,omitempty"` - PhoneSite string `json:"phoneSite,omitempty"` - Customer Customer `json:"customer,omitempty"` - Order Order `json:"order,omitempty"` + Id int `json:"id,omitempty"` + PerformerId int `json:"performerId,omitempty"` + Text string `json:"text,omitempty"` + Commentary string `json:"commentary,omitempty"` + Datetime string `json:"datetime,omitempty"` + Complete bool `json:"complete,omitempty"` + CreatedAt string `json:"createdAt,omitempty"` + Creator int `json:"creator,omitempty"` + Performer int `json:"performer,omitempty"` + Phone string `json:"phone,omitempty"` + PhoneSite string `json:"phoneSite,omitempty"` + Customer *Customer `json:"customer,omitempty"` + Order *Order `json:"order,omitempty"` } /* @@ -372,9 +372,9 @@ type Task struct { // Note type type Note struct { - Id int `json:"id,omitempty"` - ManagerId int `json:"managerId,omitempty"` - Text string `json:"text,omitempty"` - CreatedAt string `json:"createdAt,omitempty"` - Customer Customer `json:"customer,omitempty"` + Id int `json:"id,omitempty"` + ManagerId int `json:"managerId,omitempty"` + Text string `json:"text,omitempty"` + CreatedAt string `json:"createdAt,omitempty"` + Customer *Customer `json:"customer,omitempty"` } diff --git a/v5_tests/notes_test.go b/v5_tests/notes_test.go index 9b6bcb9..a4f946e 100644 --- a/v5_tests/notes_test.go +++ b/v5_tests/notes_test.go @@ -61,7 +61,7 @@ func TestClient_NotesCreateDelete(t *testing.T) { f := v5.Note{ Text: "some text", ManagerId: GetUser(), - Customer: v5.Customer{ + Customer: &v5.Customer{ Id: createCustomerResponse.Id, }, } diff --git a/v5_tests/tasks_test.go b/v5_tests/tasks_test.go index 69a761a..d635a97 100644 --- a/v5_tests/tasks_test.go +++ b/v5_tests/tasks_test.go @@ -37,11 +37,8 @@ func TestClient_TasksTasks(t *testing.T) { func TestClient_TaskChange(t *testing.T) { c := client() - random1 := RandomString(15) - random2 := RandomString(20) - f := v5.Task{ - Text: random1, + Text: RandomString(15), PerformerId: GetUser(), } @@ -62,7 +59,7 @@ func TestClient_TaskChange(t *testing.T) { } f.Id = cr.Id - f.Commentary = random2 + f.Commentary = RandomString(20) gt, sg, err := c.Task(f.Id) if err != nil {