mirror of
https://github.com/retailcrm/api-client-go.git
synced 2024-11-24 13:56: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:
|
steps:
|
||||||
- name: Check out code into the Go module directory
|
- name: Check out code into the Go module directory
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: Set up latest Go 1.x version
|
- name: Set up Go 1.17
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: '^1'
|
go-version: '1.17'
|
||||||
- name: Get dependencies
|
- name: Get dependencies
|
||||||
run: |
|
run: |
|
||||||
go mod tidy
|
go mod tidy
|
||||||
cp .env.dist .env
|
cp .env.dist .env
|
||||||
- name: Lint code with golangci-lint
|
- name: Lint code with golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v2
|
uses: golangci/golangci-lint-action@v3
|
||||||
with:
|
with:
|
||||||
version: v1.39
|
version: v1.45.2
|
||||||
only-new-issues: true
|
only-new-issues: true
|
||||||
skip-go-installation: true
|
|
||||||
skip-pkg-cache: true
|
skip-pkg-cache: true
|
||||||
tests:
|
tests:
|
||||||
name: Tests
|
name: Tests
|
||||||
|
@ -32,7 +32,7 @@ linters:
|
|||||||
- gocyclo
|
- gocyclo
|
||||||
- godot
|
- godot
|
||||||
- goimports
|
- goimports
|
||||||
- golint
|
- revive
|
||||||
- gomnd
|
- gomnd
|
||||||
- gosec
|
- gosec
|
||||||
- ifshort
|
- ifshort
|
||||||
|
@ -2171,13 +2171,16 @@ func (c *Client) IntegrationModuleEdit(integrationModule IntegrationModule) (
|
|||||||
// if data.Success == true {
|
// if data.Success == true {
|
||||||
// fmt.Printf("%v\n", data.APIKey)
|
// 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
|
var resp UpdateScopesResponse
|
||||||
updateJSON, _ := json.Marshal(&request)
|
updateJSON, _ := json.Marshal(&request)
|
||||||
|
|
||||||
|
p := url.Values{
|
||||||
|
"requires": {string(updateJSON)},
|
||||||
|
}
|
||||||
|
|
||||||
data, status, err := c.PostRequest(
|
data, status, err := c.PostRequest(
|
||||||
fmt.Sprintf("/integration-modules/%s/update-scopes", code),
|
fmt.Sprintf("/integration-modules/%s/update-scopes", code), p)
|
||||||
bytes.NewBuffer(updateJSON))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return resp, status, err
|
return resp, status, err
|
||||||
}
|
}
|
||||||
|
@ -6572,13 +6572,14 @@ func TestClient_UpdateScopes(t *testing.T) {
|
|||||||
|
|
||||||
defer gock.Off()
|
defer gock.Off()
|
||||||
|
|
||||||
request := UpdateScopesRequest{Requires: ScopesRequired{Scopes: []string{"scope1", "scope2"}}}
|
request := ScopesRequired{Scopes: []string{"scope1", "scope2"}}
|
||||||
|
|
||||||
jr, _ := json.Marshal(&request)
|
jr, _ := json.Marshal(&request)
|
||||||
|
|
||||||
gock.New(crmURL).
|
gock.New(crmURL).
|
||||||
Post(fmt.Sprintf("/integration-modules/%s/update-scopes", code)).
|
Post(fmt.Sprintf("/integration-modules/%s/update-scopes", code)).
|
||||||
BodyString(string(jr[:])).
|
BodyString((url.Values{
|
||||||
|
"requires": {string(jr)},
|
||||||
|
}).Encode()).
|
||||||
Reply(200).
|
Reply(200).
|
||||||
BodyString(`{"success": true, "apiKey": "newApiKey"}`)
|
BodyString(`{"success": true, "apiKey": "newApiKey"}`)
|
||||||
|
|
||||||
@ -6603,13 +6604,14 @@ func TestClient_UpdateScopes_Fail(t *testing.T) {
|
|||||||
|
|
||||||
defer gock.Off()
|
defer gock.Off()
|
||||||
|
|
||||||
request := UpdateScopesRequest{Requires: ScopesRequired{Scopes: []string{"scope1", "scope2"}}}
|
request := ScopesRequired{Scopes: []string{"scope1", "scope2"}}
|
||||||
|
|
||||||
jr, _ := json.Marshal(&request)
|
jr, _ := json.Marshal(&request)
|
||||||
|
|
||||||
gock.New(crmURL).
|
gock.New(crmURL).
|
||||||
Post(fmt.Sprintf("/integration-modules/%s/update-scopes", code)).
|
Post(fmt.Sprintf("/integration-modules/%s/update-scopes", code)).
|
||||||
BodyString(string(jr[:])).
|
BodyString((url.Values{
|
||||||
|
"requires": {string(jr)},
|
||||||
|
}).Encode()).
|
||||||
Reply(400).
|
Reply(400).
|
||||||
BodyString(`{"success": false, "errorMsg": "Not enabled simple connection"}`)
|
BodyString(`{"success": false, "errorMsg": "Not enabled simple connection"}`)
|
||||||
|
|
||||||
|
5
types.go
5
types.go
@ -976,11 +976,6 @@ type IntegrationModule struct {
|
|||||||
Integrations *Integrations `json:"integrations,omitempty"`
|
Integrations *Integrations `json:"integrations,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateScopesRequest type.
|
|
||||||
type UpdateScopesRequest struct {
|
|
||||||
Requires ScopesRequired `json:"requires"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ScopesRequired struct {
|
type ScopesRequired struct {
|
||||||
Scopes []string
|
Scopes []string
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user