mirror of
https://github.com/retailcrm/api-client-go.git
synced 2024-11-28 07:46:04 +03:00
Сorrect implementation for update-scopes method
* correct implementation for update-scopes method * update CI
This commit is contained in:
parent
1309825638
commit
735103b9bd
9
.github/workflows/ci.yml
vendored
9
.github/workflows/ci.yml
vendored
@ -20,20 +20,19 @@ jobs:
|
||||
steps:
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v2
|
||||
- name: Set up latest Go 1.x version
|
||||
- name: Set up Go 1.17
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: '^1'
|
||||
go-version: '1.17'
|
||||
- name: Get dependencies
|
||||
run: |
|
||||
go mod tidy
|
||||
cp .env.dist .env
|
||||
- name: Lint code with golangci-lint
|
||||
uses: golangci/golangci-lint-action@v2
|
||||
uses: golangci/golangci-lint-action@v3
|
||||
with:
|
||||
version: v1.39
|
||||
version: v1.45.2
|
||||
only-new-issues: true
|
||||
skip-go-installation: true
|
||||
skip-pkg-cache: true
|
||||
tests:
|
||||
name: Tests
|
||||
|
@ -32,7 +32,7 @@ linters:
|
||||
- gocyclo
|
||||
- godot
|
||||
- goimports
|
||||
- golint
|
||||
- revive
|
||||
- gomnd
|
||||
- gosec
|
||||
- ifshort
|
||||
|
@ -2171,13 +2171,16 @@ func (c *Client) IntegrationModuleEdit(integrationModule IntegrationModule) (
|
||||
// if data.Success == true {
|
||||
// fmt.Printf("%v\n", data.APIKey)
|
||||
// }
|
||||
func (c *Client) UpdateScopes(code string, request UpdateScopesRequest) (UpdateScopesResponse, int, error) {
|
||||
func (c *Client) UpdateScopes(code string, request ScopesRequired) (UpdateScopesResponse, int, error) {
|
||||
var resp UpdateScopesResponse
|
||||
updateJSON, _ := json.Marshal(&request)
|
||||
|
||||
p := url.Values{
|
||||
"requires": {string(updateJSON)},
|
||||
}
|
||||
|
||||
data, status, err := c.PostRequest(
|
||||
fmt.Sprintf("/integration-modules/%s/update-scopes", code),
|
||||
bytes.NewBuffer(updateJSON))
|
||||
fmt.Sprintf("/integration-modules/%s/update-scopes", code), p)
|
||||
if err != nil {
|
||||
return resp, status, err
|
||||
}
|
||||
|
@ -6572,13 +6572,14 @@ func TestClient_UpdateScopes(t *testing.T) {
|
||||
|
||||
defer gock.Off()
|
||||
|
||||
request := UpdateScopesRequest{Requires: ScopesRequired{Scopes: []string{"scope1", "scope2"}}}
|
||||
|
||||
request := ScopesRequired{Scopes: []string{"scope1", "scope2"}}
|
||||
jr, _ := json.Marshal(&request)
|
||||
|
||||
gock.New(crmURL).
|
||||
Post(fmt.Sprintf("/integration-modules/%s/update-scopes", code)).
|
||||
BodyString(string(jr[:])).
|
||||
BodyString((url.Values{
|
||||
"requires": {string(jr)},
|
||||
}).Encode()).
|
||||
Reply(200).
|
||||
BodyString(`{"success": true, "apiKey": "newApiKey"}`)
|
||||
|
||||
@ -6603,13 +6604,14 @@ func TestClient_UpdateScopes_Fail(t *testing.T) {
|
||||
|
||||
defer gock.Off()
|
||||
|
||||
request := UpdateScopesRequest{Requires: ScopesRequired{Scopes: []string{"scope1", "scope2"}}}
|
||||
|
||||
request := ScopesRequired{Scopes: []string{"scope1", "scope2"}}
|
||||
jr, _ := json.Marshal(&request)
|
||||
|
||||
gock.New(crmURL).
|
||||
Post(fmt.Sprintf("/integration-modules/%s/update-scopes", code)).
|
||||
BodyString(string(jr[:])).
|
||||
BodyString((url.Values{
|
||||
"requires": {string(jr)},
|
||||
}).Encode()).
|
||||
Reply(400).
|
||||
BodyString(`{"success": false, "errorMsg": "Not enabled simple connection"}`)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user