Сorrect implementation for update-scopes method

* correct implementation for update-scopes method
* update CI
This commit is contained in:
Pavel 2022-04-12 15:37:15 +03:00 committed by GitHub
parent 1309825638
commit 735103b9bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 20 deletions

View File

@ -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

View File

@ -32,7 +32,7 @@ linters:
- gocyclo
- godot
- goimports
- golint
- revive
- gomnd
- gosec
- ifshort

View File

@ -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
}

View File

@ -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"}`)

View File

@ -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
}