diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3b026dc..7c36b28 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.golangci.yml b/.golangci.yml index c9b3570..c73d891 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -32,7 +32,7 @@ linters: - gocyclo - godot - goimports - - golint + - revive - gomnd - gosec - ifshort diff --git a/client.go b/client.go index 1e92466..2c17d63 100644 --- a/client.go +++ b/client.go @@ -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 } diff --git a/client_test.go b/client_test.go index 5d545e3..ffb0424 100644 --- a/client_test.go +++ b/client_test.go @@ -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"}`) diff --git a/types.go b/types.go index 928a5af..d4ab827 100644 --- a/types.go +++ b/types.go @@ -976,11 +976,6 @@ type IntegrationModule struct { Integrations *Integrations `json:"integrations,omitempty"` } -// UpdateScopesRequest type. -type UpdateScopesRequest struct { - Requires ScopesRequired `json:"requires"` -} - type ScopesRequired struct { Scopes []string }