* #132 Added some comments for API client * #132 fixed godoc formatting * #138 fixed go formatting
Этот коммит содержится в:
коммит произвёл
George Goldberg
родитель
be8be3a6dc
Коммит
60393f1cad
@@ -3069,7 +3069,7 @@ func TestRegisterTermsOfServiceAction(t *testing.T) {
|
|||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
Client := th.Client
|
Client := th.Client
|
||||||
|
|
||||||
success, resp := Client.RegisteTermsOfServiceAction(th.BasicUser.Id, "st_1", true)
|
success, resp := Client.RegisterTermsOfServiceAction(th.BasicUser.Id, "st_1", true)
|
||||||
CheckErrorMessage(t, resp, "store.sql_terms_of_service_store.get.no_rows.app_error")
|
CheckErrorMessage(t, resp, "store.sql_terms_of_service_store.get.no_rows.app_error")
|
||||||
|
|
||||||
termsOfService, err := th.App.CreateTermsOfService("terms of service", th.BasicUser.Id)
|
termsOfService, err := th.App.CreateTermsOfService("terms of service", th.BasicUser.Id)
|
||||||
@@ -3077,7 +3077,7 @@ func TestRegisterTermsOfServiceAction(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
success, resp = Client.RegisteTermsOfServiceAction(th.BasicUser.Id, termsOfService.Id, true)
|
success, resp = Client.RegisterTermsOfServiceAction(th.BasicUser.Id, termsOfService.Id, true)
|
||||||
CheckNoError(t, resp)
|
CheckNoError(t, resp)
|
||||||
|
|
||||||
assert.True(t, *success)
|
assert.True(t, *success)
|
||||||
@@ -3100,7 +3100,7 @@ func TestGetUserTermsOfService(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
success, resp := Client.RegisteTermsOfServiceAction(th.BasicUser.Id, termsOfService.Id, true)
|
success, resp := Client.RegisterTermsOfServiceAction(th.BasicUser.Id, termsOfService.Id, true)
|
||||||
CheckNoError(t, resp)
|
CheckNoError(t, resp)
|
||||||
assert.True(t, *success)
|
assert.True(t, *success)
|
||||||
|
|
||||||
|
|||||||
@@ -3919,7 +3919,8 @@ func (c *Client4) GetRedirectLocation(urlParam, etag string) (string, *Response)
|
|||||||
return MapFromJson(r.Body)["location"], BuildResponse(r)
|
return MapFromJson(r.Body)["location"], BuildResponse(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client4) RegisteTermsOfServiceAction(userId, termsOfServiceId string, accepted bool) (*bool, *Response) {
|
// RegisterTermsOfServiceAction saves action performed by a user against a specific terms of service.
|
||||||
|
func (c *Client4) RegisterTermsOfServiceAction(userId, termsOfServiceId string, accepted bool) (*bool, *Response) {
|
||||||
url := c.GetUserTermsOfServiceRoute(userId)
|
url := c.GetUserTermsOfServiceRoute(userId)
|
||||||
data := map[string]interface{}{"termsOfServiceId": termsOfServiceId, "accepted": accepted}
|
data := map[string]interface{}{"termsOfServiceId": termsOfServiceId, "accepted": accepted}
|
||||||
r, err := c.DoApiPost(url, StringInterfaceToJson(data))
|
r, err := c.DoApiPost(url, StringInterfaceToJson(data))
|
||||||
@@ -3930,6 +3931,7 @@ func (c *Client4) RegisteTermsOfServiceAction(userId, termsOfServiceId string, a
|
|||||||
return NewBool(CheckStatusOK(r)), BuildResponse(r)
|
return NewBool(CheckStatusOK(r)), BuildResponse(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetTermsOfService fetches the latest terms of service
|
||||||
func (c *Client4) GetTermsOfService(etag string) (*TermsOfService, *Response) {
|
func (c *Client4) GetTermsOfService(etag string) (*TermsOfService, *Response) {
|
||||||
url := c.GetTermsOfServiceRoute()
|
url := c.GetTermsOfServiceRoute()
|
||||||
r, err := c.DoApiGet(url, etag)
|
r, err := c.DoApiGet(url, etag)
|
||||||
@@ -3940,6 +3942,7 @@ func (c *Client4) GetTermsOfService(etag string) (*TermsOfService, *Response) {
|
|||||||
return TermsOfServiceFromJson(r.Body), BuildResponse(r)
|
return TermsOfServiceFromJson(r.Body), BuildResponse(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetUserTermsOfService fetches user's latest terms of service action if the latest action was for acceptance.
|
||||||
func (c *Client4) GetUserTermsOfService(userId, etag string) (*UserTermsOfService, *Response) {
|
func (c *Client4) GetUserTermsOfService(userId, etag string) (*UserTermsOfService, *Response) {
|
||||||
url := c.GetUserTermsOfServiceRoute(userId)
|
url := c.GetUserTermsOfServiceRoute(userId)
|
||||||
r, err := c.DoApiGet(url, etag)
|
r, err := c.DoApiGet(url, etag)
|
||||||
@@ -3950,6 +3953,7 @@ func (c *Client4) GetUserTermsOfService(userId, etag string) (*UserTermsOfServic
|
|||||||
return UserTermsOfServiceFromJson(r.Body), BuildResponse(r)
|
return UserTermsOfServiceFromJson(r.Body), BuildResponse(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CreateTermsOfService creates new terms of service.
|
||||||
func (c *Client4) CreateTermsOfService(text, userId string) (*TermsOfService, *Response) {
|
func (c *Client4) CreateTermsOfService(text, userId string) (*TermsOfService, *Response) {
|
||||||
url := c.GetTermsOfServiceRoute()
|
url := c.GetTermsOfServiceRoute()
|
||||||
data := map[string]interface{}{"text": text}
|
data := map[string]interface{}{"text": text}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user