mirror of
https://github.com/retailcrm/api-client-go.git
synced 2025-04-14 22:40:57 +00:00
users & tasks methods
This commit is contained in:
parent
a40fecf774
commit
d6be0230e8
9 changed files with 533 additions and 39 deletions
148
v5/client.go
148
v5/client.go
|
@ -342,3 +342,151 @@ func (c *Client) OrdersHistory(parameters OrdersHistoryRequest) (*CustomersHisto
|
|||
|
||||
return &resp, status, err
|
||||
}
|
||||
|
||||
// User get method
|
||||
func (c *Client) User(id int) (*UserResponse, int, error) {
|
||||
var resp UserResponse
|
||||
|
||||
data, status, err := c.GetRequest(fmt.Sprintf("%s/users/%d", versionedPrefix, id))
|
||||
if err != nil {
|
||||
return &resp, status, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(data, &resp)
|
||||
|
||||
return &resp, status, err
|
||||
}
|
||||
|
||||
// Users list method
|
||||
func (c *Client) Users(parameters UsersRequest) (*UsersResponse, int, error) {
|
||||
var resp UsersResponse
|
||||
|
||||
params, _ := query.Values(parameters)
|
||||
|
||||
data, status, err := c.GetRequest(fmt.Sprintf("%s/users?%s", versionedPrefix, params.Encode()))
|
||||
if err != nil {
|
||||
return &resp, status, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(data, &resp)
|
||||
|
||||
return &resp, status, err
|
||||
}
|
||||
|
||||
// UserGroups list method
|
||||
func (c *Client) UserGroups(parameters UserGroupsRequest) (*UserGroupsResponse, int, error) {
|
||||
var resp UserGroupsResponse
|
||||
|
||||
data, status, err := c.GetRequest(fmt.Sprintf("%s/user-groups", versionedPrefix))
|
||||
if err != nil {
|
||||
return &resp, status, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(data, &resp)
|
||||
|
||||
return &resp, status, err
|
||||
}
|
||||
|
||||
// UserStatus update method
|
||||
func (c *Client) UserStatus(id int, status string) (*SucessfulResponse, int, error) {
|
||||
var resp SucessfulResponse
|
||||
|
||||
p := url.Values{
|
||||
"status": {string(status)},
|
||||
}
|
||||
|
||||
data, st, err := c.PostRequest(fmt.Sprintf("%s/users/%d/status", versionedPrefix, id), p)
|
||||
if err != nil {
|
||||
return &resp, st, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(data, &resp)
|
||||
|
||||
return &resp, st, err
|
||||
}
|
||||
|
||||
// Task get method
|
||||
func (c *Client) Task(id int) (*TaskResponse, int, error) {
|
||||
var resp TaskResponse
|
||||
|
||||
data, status, err := c.GetRequest(fmt.Sprintf("%s/tasks/%d", versionedPrefix, id))
|
||||
if err != nil {
|
||||
return &resp, status, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(data, &resp)
|
||||
|
||||
return &resp, status, err
|
||||
}
|
||||
|
||||
// Tasks list method
|
||||
func (c *Client) Tasks(parameters TasksRequest) (*TasksResponse, int, error) {
|
||||
var resp TasksResponse
|
||||
|
||||
params, _ := query.Values(parameters)
|
||||
|
||||
data, status, err := c.GetRequest(fmt.Sprintf("%s/tasks?%s", versionedPrefix, params.Encode()))
|
||||
if err != nil {
|
||||
return &resp, status, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(data, &resp)
|
||||
|
||||
return &resp, status, err
|
||||
}
|
||||
|
||||
// TaskCreate method
|
||||
func (c *Client) TaskCreate(task Task, site ...string) (*TaskChangeResponse, int, error) {
|
||||
var resp TaskChangeResponse
|
||||
taskJson, _ := json.Marshal(&task)
|
||||
|
||||
p := url.Values{
|
||||
"task": {string(taskJson[:])},
|
||||
}
|
||||
|
||||
if len(site) > 0 {
|
||||
s := site[0]
|
||||
|
||||
if s != "" {
|
||||
p.Add("site", s)
|
||||
}
|
||||
}
|
||||
|
||||
data, status, err := c.PostRequest(fmt.Sprintf("%s/tasks/create", versionedPrefix), p)
|
||||
if err != nil {
|
||||
return &resp, status, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(data, &resp)
|
||||
|
||||
return &resp, status, err
|
||||
}
|
||||
|
||||
// TaskEdit method
|
||||
func (c *Client) TaskEdit(task Task, site ...string) (*SucessfulResponse, int, error) {
|
||||
var resp SucessfulResponse
|
||||
var uid = strconv.Itoa(task.Id)
|
||||
|
||||
taskJson, _ := json.Marshal(&task)
|
||||
|
||||
p := url.Values{
|
||||
"task": {string(taskJson[:])},
|
||||
}
|
||||
|
||||
if len(site) > 0 {
|
||||
s := site[0]
|
||||
|
||||
if s != "" {
|
||||
p.Add("site", s)
|
||||
}
|
||||
}
|
||||
|
||||
data, status, err := c.PostRequest(fmt.Sprintf("%s/tasks/%s/edit", versionedPrefix, uid), p)
|
||||
if err != nil {
|
||||
return &resp, status, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(data, &resp)
|
||||
|
||||
return &resp, status, err
|
||||
}
|
||||
|
|
|
@ -164,3 +164,28 @@ type OrdersHistoryFilter struct {
|
|||
StartDate string `url:"startDate,omitempty"`
|
||||
EndDate string `url:"endDate,omitempty"`
|
||||
}
|
||||
|
||||
// UsersFilter type
|
||||
type UsersFilter struct {
|
||||
Email string `url:"email,omitempty"`
|
||||
Status string `url:"status,omitempty"`
|
||||
Online int `url:"online,omitempty"`
|
||||
Active int `url:"active,omitempty"`
|
||||
IsManager int `url:"isManager,omitempty"`
|
||||
IsAdmin int `url:"isAdmin,omitempty"`
|
||||
CreatedAtFrom string `url:"createdAtFrom,omitempty"`
|
||||
CreatedAtTo string `url:"createdAtTo,omitempty"`
|
||||
Groups []string `url:"groups,omitempty"`
|
||||
}
|
||||
|
||||
// TasksFilter type
|
||||
type TasksFilter struct {
|
||||
OrderNumber string `url:"orderNumber,omitempty"`
|
||||
Status string `url:"status,omitempty"`
|
||||
Customer string `url:"customer,omitempty"`
|
||||
Text string `url:"text,omitempty"`
|
||||
DateFrom string `url:"dateFrom,omitempty"`
|
||||
DateTo string `url:"dateTo,omitempty"`
|
||||
Creators []int `url:"creators,omitempty"`
|
||||
Performers []int `url:"performers,omitempty"`
|
||||
}
|
||||
|
|
|
@ -51,3 +51,23 @@ type OrdersHistoryRequest struct {
|
|||
Limit int `url:"limit,omitempty"`
|
||||
Page int `url:"page,omitempty"`
|
||||
}
|
||||
|
||||
// UsersRequest type
|
||||
type UsersRequest struct {
|
||||
Filter UsersFilter `url:"filter,omitempty"`
|
||||
Limit int `url:"limit,omitempty"`
|
||||
Page int `url:"page,omitempty"`
|
||||
}
|
||||
|
||||
// UserGroupsRequest type
|
||||
type UserGroupsRequest struct {
|
||||
Limit int `url:"limit,omitempty"`
|
||||
Page int `url:"page,omitempty"`
|
||||
}
|
||||
|
||||
// TasksRequest type
|
||||
type TasksRequest struct {
|
||||
Filter TasksFilter `url:"filter,omitempty"`
|
||||
Limit int `url:"limit,omitempty"`
|
||||
Page int `url:"page,omitempty"`
|
||||
}
|
||||
|
|
|
@ -89,3 +89,42 @@ type OrdersHistoryResponse struct {
|
|||
History []OrdersHistoryRecord `json:"history,omitempty,brackets"`
|
||||
Pagination *Pagination `json:"pagination,omitempty"`
|
||||
}
|
||||
|
||||
// UserResponse type
|
||||
type UserResponse struct {
|
||||
Success bool `json:"success"`
|
||||
User *User `json:"user,omitempty,brackets"`
|
||||
}
|
||||
|
||||
// UsersResponse type
|
||||
type UsersResponse struct {
|
||||
Success bool `json:"success"`
|
||||
Pagination *Pagination `json:"pagination,omitempty"`
|
||||
Users []User `json:"users,omitempty,brackets"`
|
||||
}
|
||||
|
||||
// UserGroupsResponse type
|
||||
type UserGroupsResponse struct {
|
||||
Success bool `json:"success"`
|
||||
Pagination *Pagination `json:"pagination,omitempty"`
|
||||
Groups []UserGroup `json:"groups,omitempty,brackets"`
|
||||
}
|
||||
|
||||
// TaskResponse type
|
||||
type TaskResponse struct {
|
||||
Success bool `json:"success"`
|
||||
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"`
|
||||
Pagination *Pagination `json:"pagination,omitempty"`
|
||||
Tasks []Task `json:"tasks,omitempty,brackets"`
|
||||
}
|
||||
|
|
136
v5/types.go
136
v5/types.go
|
@ -78,40 +78,44 @@ type Property struct {
|
|||
Value string `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
/**
|
||||
Customer related types
|
||||
*/
|
||||
|
||||
// Customer type
|
||||
type Customer struct {
|
||||
Id int `json:"id,omitempty"`
|
||||
ExternalId string `json:"externalId,omitempty"`
|
||||
FirstName string `json:"firstName,omitempty"`
|
||||
LastName string `json:"lastName,omitempty"`
|
||||
Patronymic string `json:"patronymic,omitempty"`
|
||||
Sex string `json:"sex,omitempty"`
|
||||
Email string `json:"email,omitempty"`
|
||||
Phones []CustomerPhone `json:"phones,brackets,omitempty"`
|
||||
Address *Address `json:"address,omitempty"`
|
||||
CreatedAt string `json:"createdAt,omitempty"`
|
||||
Birthday string `json:"birthday,omitempty"`
|
||||
ManagerId int `json:"managerId,omitempty"`
|
||||
Vip bool `json:"vip,omitempty"`
|
||||
Bad bool `json:"bad,omitempty"`
|
||||
Site string `json:"site,omitempty"`
|
||||
Source *Source `json:"source,omitempty"`
|
||||
Contragent *Contragent `json:"contragent,omitempty"`
|
||||
PersonalDiscount float32 `json:"personalDiscount,omitempty"`
|
||||
CumulativeDiscount float32 `json:"cumulativeDiscount,omitempty"`
|
||||
DiscountCardNumber string `json:"discountCardNumber,omitempty"`
|
||||
EmailMarketingUnsubscribedAt string `json:"emailMarketingUnsubscribedAt,omitempty"`
|
||||
AvgMarginSumm float32 `json:"avgMarginSumm,omitempty"`
|
||||
MarginSumm float32 `json:"marginSumm,omitempty"`
|
||||
TotalSumm float32 `json:"totalSumm,omitempty"`
|
||||
AverageSumm float32 `json:"averageSumm,omitempty"`
|
||||
OrdersCount int `json:"ordersCount,omitempty"`
|
||||
CostSumm float32 `json:"costSumm,omitempty"`
|
||||
MaturationTime int `json:"maturationTime,omitempty"`
|
||||
FirstClientId string `json:"firstClientId,omitempty"`
|
||||
LastClientId string `json:"lastClientId,omitempty"`
|
||||
BrowserId string `json:"browserId,omitempty"`
|
||||
CustomFields []map[string]string `json:"customFields,omitempty,brackets"`
|
||||
Id int `json:"id,omitempty"`
|
||||
ExternalId string `json:"externalId,omitempty"`
|
||||
FirstName string `json:"firstName,omitempty"`
|
||||
LastName string `json:"lastName,omitempty"`
|
||||
Patronymic string `json:"patronymic,omitempty"`
|
||||
Sex string `json:"sex,omitempty"`
|
||||
Email string `json:"email,omitempty"`
|
||||
Phones []CustomerPhone `json:"phones,brackets,omitempty"`
|
||||
Address *Address `json:"address,omitempty"`
|
||||
CreatedAt string `json:"createdAt,omitempty"`
|
||||
Birthday string `json:"birthday,omitempty"`
|
||||
ManagerId int `json:"managerId,omitempty"`
|
||||
Vip bool `json:"vip,omitempty"`
|
||||
Bad bool `json:"bad,omitempty"`
|
||||
Site string `json:"site,omitempty"`
|
||||
Source *Source `json:"source,omitempty"`
|
||||
Contragent *Contragent `json:"contragent,omitempty"`
|
||||
PersonalDiscount float32 `json:"personalDiscount,omitempty"`
|
||||
CumulativeDiscount float32 `json:"cumulativeDiscount,omitempty"`
|
||||
DiscountCardNumber string `json:"discountCardNumber,omitempty"`
|
||||
EmailMarketingUnsubscribedAt string `json:"emailMarketingUnsubscribedAt,omitempty"`
|
||||
AvgMarginSumm float32 `json:"avgMarginSumm,omitempty"`
|
||||
MarginSumm float32 `json:"marginSumm,omitempty"`
|
||||
TotalSumm float32 `json:"totalSumm,omitempty"`
|
||||
AverageSumm float32 `json:"averageSumm,omitempty"`
|
||||
OrdersCount int `json:"ordersCount,omitempty"`
|
||||
CostSumm float32 `json:"costSumm,omitempty"`
|
||||
MaturationTime int `json:"maturationTime,omitempty"`
|
||||
FirstClientId string `json:"firstClientId,omitempty"`
|
||||
LastClientId string `json:"lastClientId,omitempty"`
|
||||
BrowserId string `json:"browserId,omitempty"`
|
||||
//CustomFields []map[string]string `json:"customFields,omitempty,brackets"`
|
||||
}
|
||||
|
||||
// CustomerPhone type
|
||||
|
@ -138,6 +142,10 @@ type CustomerHistoryRecord struct {
|
|||
Customer *Customer `json:"customer,omitempty,brackets"`
|
||||
}
|
||||
|
||||
/**
|
||||
Order related types
|
||||
*/
|
||||
|
||||
// Order type
|
||||
type Order struct {
|
||||
Id int `json:"id,omitempty"`
|
||||
|
@ -270,6 +278,7 @@ type OrdersHistoryRecord struct {
|
|||
Order *Order `json:"order,omitempty,brackets"`
|
||||
}
|
||||
|
||||
// Offer type
|
||||
type Offer struct {
|
||||
Id int `json:"id,omitempty"`
|
||||
ExternalId string `json:"externalId,omitempty"`
|
||||
|
@ -277,13 +286,47 @@ type Offer struct {
|
|||
VatRate string `json:"vatRate,omitempty"`
|
||||
}
|
||||
|
||||
/**
|
||||
User related types
|
||||
*/
|
||||
|
||||
// User type
|
||||
type User struct {
|
||||
Id int `json:"id,omitempty"`
|
||||
FirstName string `json:"firstName,omitempty"`
|
||||
LastName string `json:"lastName,omitempty"`
|
||||
Patronymic string `json:"patronymic,omitempty"`
|
||||
Id int `json:"id,omitempty"`
|
||||
FirstName string `json:"firstName,omitempty"`
|
||||
LastName string `json:"lastName,omitempty"`
|
||||
Patronymic string `json:"patronymic,omitempty"`
|
||||
CreatedAt string `json:"createdAt,omitempty"`
|
||||
Active bool `json:"active,omitempty"`
|
||||
Online bool `json:"online,omitempty"`
|
||||
IsAdmin bool `json:"isAdmin,omitempty"`
|
||||
IsManager bool `json:"isManager,omitempty"`
|
||||
Email string `json:"email,omitempty"`
|
||||
Phone string `json:"phone,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
Groups []UserGroup `json:"groups,omitempty,brackets"`
|
||||
}
|
||||
|
||||
// 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"`
|
||||
}
|
||||
|
||||
/**
|
||||
Reference related types
|
||||
*/
|
||||
|
||||
// PriceType type
|
||||
type PriceType struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Code string `json:"code,omitempty"`
|
||||
|
@ -292,3 +335,24 @@ type PriceType struct {
|
|||
Active bool `json:"active,omitempty"`
|
||||
Ordering int `json:"ordering,omitempty"`
|
||||
}
|
||||
|
||||
/**
|
||||
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"`
|
||||
}
|
||||
|
|
|
@ -185,7 +185,7 @@ func TestClient_CustomersHistory(t *testing.T) {
|
|||
c := client()
|
||||
f := v5.CustomersHistoryRequest{
|
||||
Filter: v5.CustomersHistoryFilter{
|
||||
SinceId: 100,
|
||||
SinceId: 20,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ func TestClient_OrdersOrders(t *testing.T) {
|
|||
func TestClient_OrdersOrder(t *testing.T) {
|
||||
c := client()
|
||||
|
||||
data, status, err := c.Order("upload-b-1480333204", "externalId", "")
|
||||
data, status, err := c.Order("asdf1510920687", "externalId", "")
|
||||
if err != nil {
|
||||
t.Errorf("%s", err)
|
||||
t.Fail()
|
||||
|
@ -57,7 +57,7 @@ func TestClient_OrdersHistory(t *testing.T) {
|
|||
c := client()
|
||||
f := v5.OrdersHistoryRequest{
|
||||
Filter: v5.OrdersHistoryFilter{
|
||||
SinceId: 100,
|
||||
SinceId: 20,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
101
v5_tests/tasks_test.go
Normal file
101
v5_tests/tasks_test.go
Normal file
|
@ -0,0 +1,101 @@
|
|||
package v5_tests
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/retailcrm/api-client-go/v5"
|
||||
)
|
||||
|
||||
func TestClient_TasksTask(t *testing.T) {
|
||||
c := client()
|
||||
|
||||
data, st, err := c.Task(88)
|
||||
if err != nil {
|
||||
t.Errorf("%s", err)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
if st != http.StatusOK {
|
||||
t.Errorf("%s", err)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
if data.Success != true {
|
||||
t.Errorf("%s", err)
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestClient_TasksTasks(t *testing.T) {
|
||||
c := client()
|
||||
f := v5.TasksRequest{
|
||||
Filter: v5.TasksFilter{
|
||||
Creators: []int{6},
|
||||
},
|
||||
Page: 1,
|
||||
}
|
||||
|
||||
data, status, err := c.Tasks(f)
|
||||
if err != nil {
|
||||
t.Errorf("%s", err)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
if status != http.StatusOK {
|
||||
t.Errorf("%s", err)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
if data.Success != true {
|
||||
t.Errorf("%s", err)
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestClient_TaskChange(t *testing.T) {
|
||||
c := client()
|
||||
|
||||
random1 := RandomString(15)
|
||||
random2 := RandomString(20)
|
||||
|
||||
f := v5.Task{
|
||||
Text: random1,
|
||||
PerformerId: 6,
|
||||
}
|
||||
|
||||
cr, sc, err := c.TaskCreate(f)
|
||||
if err != nil {
|
||||
t.Errorf("%s", err)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
if sc != http.StatusCreated {
|
||||
t.Errorf("%s", err)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
if cr.Success != true {
|
||||
t.Errorf("%s", err)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
f.Id = cr.Id
|
||||
f.Commentary = random2
|
||||
|
||||
data, status, err := c.TaskEdit(f)
|
||||
if err != nil {
|
||||
t.Errorf("%s", err)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
if status != http.StatusOK {
|
||||
t.Errorf("%s", err)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
if data.Success != true {
|
||||
t.Errorf("%s", err)
|
||||
t.Fail()
|
||||
}
|
||||
}
|
97
v5_tests/users_test.go
Normal file
97
v5_tests/users_test.go
Normal file
|
@ -0,0 +1,97 @@
|
|||
package v5_tests
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/retailcrm/api-client-go/v5"
|
||||
)
|
||||
|
||||
func TestClient_UsersUsers(t *testing.T) {
|
||||
c := client()
|
||||
f := v5.UsersRequest{
|
||||
Filter: v5.UsersFilter{
|
||||
Active: 1,
|
||||
},
|
||||
Page: 1,
|
||||
}
|
||||
|
||||
data, status, err := c.Users(f)
|
||||
if err != nil {
|
||||
t.Errorf("%s", err)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
if status >= http.StatusBadRequest {
|
||||
t.Errorf("%s", err)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
if data.Success != true {
|
||||
t.Errorf("%s", err)
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestClient_UsersUser(t *testing.T) {
|
||||
c := client()
|
||||
|
||||
data, st, err := c.User(6)
|
||||
if err != nil {
|
||||
t.Errorf("%s", err)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
if st != http.StatusOK {
|
||||
t.Errorf("%s", err)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
if data.Success != true {
|
||||
t.Errorf("%s", err)
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestClient_UsersGroups(t *testing.T) {
|
||||
c := client()
|
||||
f := v5.UserGroupsRequest{
|
||||
Page: 1,
|
||||
}
|
||||
|
||||
data, status, err := c.UserGroups(f)
|
||||
if err != nil {
|
||||
t.Errorf("%s", err)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
if status >= http.StatusBadRequest {
|
||||
t.Errorf("%s", err)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
if data.Success != true {
|
||||
t.Errorf("%s", err)
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestClient_UsersUpdate(t *testing.T) {
|
||||
c := client()
|
||||
|
||||
data, st, err := c.UserStatus(6, "busy")
|
||||
if err != nil {
|
||||
t.Errorf("%s", err)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
if st != http.StatusOK {
|
||||
t.Errorf("%s", err)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
if data.Success != true {
|
||||
t.Errorf("%s", err)
|
||||
t.Fail()
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue