diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 1d1f22f3..00bc9619 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,4 +1,5 @@ name: Lint + on: push: branches: @@ -6,35 +7,32 @@ on: - feature/* pull_request: branches: [ main ] + permissions: contents: read # Optional: allow read access to pull request. Use with `only-new-issues` option. # pull-requests: read + jobs: golangci: + name: GolangCI-Lint strategy: max-parallel: 6 matrix: go: [1.22, 1.23] os: [ubuntu-latest, macos-latest, windows-latest] - name: lint runs-on: ${{ matrix.os }} steps: - - uses: actions/setup-go@v5 + - name: Setup Go + uses: actions/setup-go@v5 with: go-version: ${{ matrix.go }} - - uses: actions/checkout@v4 + + - name: Checkout code + uses: actions/checkout@v4 + - name: golangci-lint uses: golangci/golangci-lint-action@v6 with: - # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. - # version: v1.51.2 - # Optional: working directory, useful for monorepos - # working-directory: somedir - - # Optional: golangci-lint command line arguments. - # args: --issues-exit-code=0 + version: latest args: --timeout=10m - - # Optional: show only new issues if it's a pull request. The default value is `false`. - # only-new-issues: true \ No newline at end of file diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 00000000..8cb106be --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,24 @@ +run: + concurrency: 4 + timeout: 20m + tests: false + # This gives us the ability to efficiently skip whole files by using "//go:build !codeanalysis" at the top of a file. + build-tags: + - codeanalysis + +linters: + enable: + - revive + +linters-settings: + revive: + rules: + - name: unused-parameter + disabled: true # forces all unused to be "_" which leads to confusion + +issues: + max-issues-per-linter: 0 + max-same-issues: 0 + +severity: + default-severity: critical diff --git a/admin/api_client_impl.go b/admin/api_client_impl.go index 5da16aa9..fb48e7bb 100644 --- a/admin/api_client_impl.go +++ b/admin/api_client_impl.go @@ -5,19 +5,20 @@ import ( "context" "encoding/json" "fmt" - "github.com/ctreminiom/go-atlassian/admin/internal" - model "github.com/ctreminiom/go-atlassian/pkg/infra/models" - "github.com/ctreminiom/go-atlassian/service/common" "io" "net/http" "net/url" + + "github.com/ctreminiom/go-atlassian/admin/internal" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" + "github.com/ctreminiom/go-atlassian/service/common" ) -const defaultApiEndpoint = "https://api.atlassian.com/" +const defaultAPIEndpoint = "https://api.atlassian.com/" // New creates a new instance of Client. -// It takes a common.HttpClient as input and returns a pointer to Client and an error. -func New(httpClient common.HttpClient) (*Client, error) { +// It takes a common.HTTPClient as input and returns a pointer to Client and an error. +func New(httpClient common.HTTPClient) (*Client, error) { // If no HTTP client is provided, use the default HTTP client. if httpClient == nil { @@ -25,7 +26,7 @@ func New(httpClient common.HttpClient) (*Client, error) { } // Parse the default API endpoint URL. - u, err := url.Parse(defaultApiEndpoint) + u, err := url.Parse(defaultAPIEndpoint) if err != nil { return nil, err } @@ -61,7 +62,7 @@ func New(httpClient common.HttpClient) (*Client, error) { // Client represents a client for interacting with the Atlassian Administration API. type Client struct { // HTTP is the HTTP client used for making requests. - HTTP common.HttpClient + HTTP common.HTTPClient // Site is the base URL for the API. Site *url.URL // Auth is the authentication service. @@ -76,7 +77,7 @@ type Client struct { // NewRequest creates a new HTTP request with the given context, method, URL string, content type, and body. // It returns an HTTP request and an error. -func (c *Client) NewRequest(ctx context.Context, method, urlStr, type_ string, body interface{}) (*http.Request, error) { +func (c *Client) NewRequest(ctx context.Context, method, urlStr, contentType string, body interface{}) (*http.Request, error) { // Parse the relative URL. rel, err := url.Parse(urlStr) @@ -103,12 +104,12 @@ func (c *Client) NewRequest(ctx context.Context, method, urlStr, type_ string, b req.Header.Set("Accept", "application/json") // Set the Content-Type header if a body is provided. - if body != nil && type_ == "" { + if body != nil && contentType == "" { req.Header.Set("Content-Type", "application/json") } - if body != nil && type_ != "" { - req.Header.Set("Content-Type", type_) + if body != nil && contentType != "" { + req.Header.Set("Content-Type", contentType) } // Add the Authorization header if a bearer token is available. diff --git a/admin/api_client_impl_test.go b/admin/api_client_impl_test.go index 98bd2eaf..1b161ce6 100644 --- a/admin/api_client_impl_test.go +++ b/admin/api_client_impl_test.go @@ -3,16 +3,18 @@ package admin import ( "bytes" "context" - "github.com/ctreminiom/go-atlassian/admin/internal" - model "github.com/ctreminiom/go-atlassian/pkg/infra/models" - "github.com/ctreminiom/go-atlassian/service/common" - "github.com/ctreminiom/go-atlassian/service/mocks" - "github.com/stretchr/testify/assert" "io" "net/http" "net/url" "strings" "testing" + + "github.com/stretchr/testify/assert" + + "github.com/ctreminiom/go-atlassian/admin/internal" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" + "github.com/ctreminiom/go-atlassian/service/common" + "github.com/ctreminiom/go-atlassian/service/mocks" ) func TestClient_Call(t *testing.T) { @@ -63,7 +65,7 @@ func TestClient_Call(t *testing.T) { } type fields struct { - HTTP common.HttpClient + HTTP common.HTTPClient Site *url.URL Auth common.Authentication } @@ -85,7 +87,7 @@ func TestClient_Call(t *testing.T) { name: "when the parameters are correct", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(expectedResponse, nil) @@ -109,7 +111,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is a bad request", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(badRequestResponse, nil) @@ -134,7 +136,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is an internal service error", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(internalServerResponse, nil) @@ -159,7 +161,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is a not found", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(notFoundResponse, nil) @@ -184,7 +186,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is unauthorized", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(unauthorizedResponse, nil) @@ -262,17 +264,17 @@ func TestClient_NewRequest(t *testing.T) { requestMocked.Header.Set("Content-Type", "application/json") type fields struct { - HTTP common.HttpClient + HTTP common.HTTPClient Auth common.Authentication Site *url.URL } type args struct { - ctx context.Context - method string - urlStr string - type_ string - body interface{} + ctx context.Context + method string + urlStr string + contentType string + body interface{} } testCases := []struct { @@ -290,11 +292,11 @@ func TestClient_NewRequest(t *testing.T) { Site: siteAsURL, }, args: args{ - ctx: context.Background(), - method: http.MethodGet, - urlStr: "rest/2/issue/attachment", - type_: "", - body: bytes.NewReader([]byte("Hello World")), + ctx: context.Background(), + method: http.MethodGet, + urlStr: "rest/2/issue/attachment", + contentType: "", + body: bytes.NewReader([]byte("Hello World")), }, want: requestMocked, wantErr: false, @@ -348,7 +350,7 @@ func TestClient_NewRequest(t *testing.T) { testCase.args.ctx, testCase.args.method, testCase.args.urlStr, - testCase.args.type_, + testCase.args.contentType, testCase.args.body, ) @@ -371,7 +373,7 @@ func TestClient_NewRequest(t *testing.T) { func TestClient_processResponse(t *testing.T) { - expectedJsonResponse := ` + expectedJSONResponse := ` { "id": 4, "self": "https://ctreminiom.atlassian.net/rest/agile/1.0/board/4", @@ -381,7 +383,7 @@ func TestClient_processResponse(t *testing.T) { expectedResponse := &http.Response{ StatusCode: http.StatusOK, - Body: io.NopCloser(strings.NewReader(expectedJsonResponse)), + Body: io.NopCloser(strings.NewReader(expectedJSONResponse)), Request: &http.Request{ Method: http.MethodGet, URL: &url.URL{}, @@ -389,7 +391,7 @@ func TestClient_processResponse(t *testing.T) { } type fields struct { - HTTP common.HttpClient + HTTP common.HTTPClient Site *url.URL Authentication common.Authentication } @@ -417,7 +419,7 @@ func TestClient_processResponse(t *testing.T) { Response: expectedResponse, Code: http.StatusOK, Method: http.MethodGet, - Bytes: *bytes.NewBufferString(expectedJsonResponse), + Bytes: *bytes.NewBufferString(expectedJSONResponse), }, wantErr: false, }, @@ -462,7 +464,7 @@ func TestNew(t *testing.T) { mockClient.Auth.SetUserAgent("aaa") type args struct { - httpClient common.HttpClient + httpClient common.HTTPClient site string } diff --git a/admin/internal/organization_directory_impl.go b/admin/internal/organization_directory_impl.go index 6443445b..5a60da9b 100644 --- a/admin/internal/organization_directory_impl.go +++ b/admin/internal/organization_directory_impl.go @@ -3,10 +3,11 @@ package internal import ( "context" "fmt" + "net/http" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" "github.com/ctreminiom/go-atlassian/service" "github.com/ctreminiom/go-atlassian/service/admin" - "net/http" ) // NewOrganizationDirectoryService creates a new instance of OrganizationDirectoryService. @@ -31,7 +32,7 @@ type OrganizationDirectoryService struct { // // The added_to_org date field is available only to customers using the new user management experience. // -// GET /admin/v1/orgs/{orgId}/directory/users/{accountId}/last-active-dates +// GET /admin/v1/orgs/{orgId}/directory/users/{accountID}/last-active-dates // // https://docs.go-atlassian.io/atlassian-admin-cloud/organization/directory#users-last-active-dates func (o *OrganizationDirectoryService) Activity(ctx context.Context, organizationID, accountID string) (*model.UserProductAccessScheme, *model.ResponseScheme, error) { diff --git a/assets/api_client_impl.go b/assets/api_client_impl.go index ed30d3e8..3ce4cf46 100644 --- a/assets/api_client_impl.go +++ b/assets/api_client_impl.go @@ -4,19 +4,20 @@ import ( "bytes" "context" "encoding/json" - "github.com/ctreminiom/go-atlassian/assets/internal" - model "github.com/ctreminiom/go-atlassian/pkg/infra/models" - "github.com/ctreminiom/go-atlassian/service/common" "io" "net/http" "net/url" + + "github.com/ctreminiom/go-atlassian/assets/internal" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" + "github.com/ctreminiom/go-atlassian/service/common" ) const DefaultAssetsSite = "https://api.atlassian.com/" // New creates a new instance of Client. -// It takes a common.HttpClient and a site URL as inputs and returns a pointer to Client and an error. -func New(httpClient common.HttpClient, site string) (*Client, error) { +// It takes a common.HTTPClient and a site URL as inputs and returns a pointer to Client and an error. +func New(httpClient common.HTTPClient, site string) (*Client, error) { // If no HTTP client is provided, use the default HTTP client. if httpClient == nil { @@ -57,7 +58,7 @@ func New(httpClient common.HttpClient, site string) (*Client, error) { // Client represents a client for interacting with the Atlassian Assets API. type Client struct { // HTTP is the HTTP client used for making requests. - HTTP common.HttpClient + HTTP common.HTTPClient // Site is the base URL for the API. Site *url.URL // Auth is the authentication service. @@ -78,7 +79,7 @@ type Client struct { // NewRequest creates a new HTTP request with the given context, method, URL string, content type, and body. // It returns an HTTP request and an error. -func (c *Client) NewRequest(ctx context.Context, method, urlStr, type_ string, body interface{}) (*http.Request, error) { +func (c *Client) NewRequest(ctx context.Context, method, urlStr, contentType string, body interface{}) (*http.Request, error) { // Parse the relative URL. rel, err := url.Parse(urlStr) @@ -105,12 +106,12 @@ func (c *Client) NewRequest(ctx context.Context, method, urlStr, type_ string, b req.Header.Set("Accept", "application/json") // Set the Content-Type header if a body is provided. - if body != nil && type_ == "" { + if body != nil && contentType == "" { req.Header.Set("Content-Type", "application/json") } - if body != nil && type_ != "" { - req.Header.Set("Content-Type", type_) + if body != nil && contentType != "" { + req.Header.Set("Content-Type", contentType) } // Add the Basic Authentication header if available. diff --git a/assets/api_client_impl_test.go b/assets/api_client_impl_test.go index 2e5770fd..3ade18bb 100644 --- a/assets/api_client_impl_test.go +++ b/assets/api_client_impl_test.go @@ -3,16 +3,18 @@ package assets import ( "bytes" "context" - "github.com/ctreminiom/go-atlassian/assets/internal" - model "github.com/ctreminiom/go-atlassian/pkg/infra/models" - "github.com/ctreminiom/go-atlassian/service/common" - "github.com/ctreminiom/go-atlassian/service/mocks" - "github.com/stretchr/testify/assert" "io" "net/http" "net/url" "strings" "testing" + + "github.com/stretchr/testify/assert" + + "github.com/ctreminiom/go-atlassian/assets/internal" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" + "github.com/ctreminiom/go-atlassian/service/common" + "github.com/ctreminiom/go-atlassian/service/mocks" ) func TestClient_Call(t *testing.T) { @@ -63,7 +65,7 @@ func TestClient_Call(t *testing.T) { } type fields struct { - HTTP common.HttpClient + HTTP common.HTTPClient Site *url.URL Auth common.Authentication } @@ -85,7 +87,7 @@ func TestClient_Call(t *testing.T) { name: "when the parameters are correct", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(expectedResponse, nil) @@ -109,7 +111,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is a bad request", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(badRequestResponse, nil) @@ -134,7 +136,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is an internal service error", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(internalServerResponse, nil) @@ -159,7 +161,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is a not found", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(notFoundResponse, nil) @@ -184,7 +186,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is unauthorized", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(unauthorizedResponse, nil) @@ -261,17 +263,17 @@ func TestClient_NewRequest(t *testing.T) { requestMocked.Header.Set("Content-Type", "application/json") type fields struct { - HTTP common.HttpClient + HTTP common.HTTPClient Auth common.Authentication Site *url.URL } type args struct { - ctx context.Context - method string - urlStr string - type_ string - body interface{} + ctx context.Context + method string + urlStr string + contentType string + body interface{} } testCases := []struct { @@ -289,11 +291,11 @@ func TestClient_NewRequest(t *testing.T) { Site: siteAsURL, }, args: args{ - ctx: context.Background(), - method: http.MethodGet, - urlStr: "rest/2/issue/attachment", - type_: "", - body: bytes.NewReader([]byte("Hello World")), + ctx: context.Background(), + method: http.MethodGet, + urlStr: "rest/2/issue/attachment", + contentType: "", + body: bytes.NewReader([]byte("Hello World")), }, want: requestMocked, wantErr: false, @@ -347,7 +349,7 @@ func TestClient_NewRequest(t *testing.T) { testCase.args.ctx, testCase.args.method, testCase.args.urlStr, - testCase.args.type_, + testCase.args.contentType, testCase.args.body, ) @@ -369,7 +371,7 @@ func TestClient_NewRequest(t *testing.T) { func TestClient_processResponse(t *testing.T) { - expectedJsonResponse := ` + expectedJSONResponse := ` { "id": 4, "self": "https://ctreminiom.atlassian.net/rest/agile/1.0/board/4", @@ -379,7 +381,7 @@ func TestClient_processResponse(t *testing.T) { expectedResponse := &http.Response{ StatusCode: http.StatusOK, - Body: io.NopCloser(strings.NewReader(expectedJsonResponse)), + Body: io.NopCloser(strings.NewReader(expectedJSONResponse)), Request: &http.Request{ Method: http.MethodGet, URL: &url.URL{}, @@ -387,7 +389,7 @@ func TestClient_processResponse(t *testing.T) { } type fields struct { - HTTP common.HttpClient + HTTP common.HTTPClient Site *url.URL Authentication common.Authentication } @@ -415,7 +417,7 @@ func TestClient_processResponse(t *testing.T) { Response: expectedResponse, Code: http.StatusOK, Method: http.MethodGet, - Bytes: *bytes.NewBufferString(expectedJsonResponse), + Bytes: *bytes.NewBufferString(expectedJSONResponse), }, wantErr: false, }, @@ -468,7 +470,7 @@ func TestNew(t *testing.T) { mockClientWithOutClient.Auth.SetUserAgent("aaa") type args struct { - httpClient common.HttpClient + httpClient common.HTTPClient site string } diff --git a/bitbucket/api_client_impl.go b/bitbucket/api_client_impl.go index 09895cf7..91f03f79 100644 --- a/bitbucket/api_client_impl.go +++ b/bitbucket/api_client_impl.go @@ -19,7 +19,7 @@ import ( const DefaultBitbucketSite = "https://api.bitbucket.org" // New creates a new Bitbucket API client. -func New(httpClient common.HttpClient, site string) (*Client, error) { +func New(httpClient common.HTTPClient, site string) (*Client, error) { if httpClient == nil { httpClient = http.DefaultClient @@ -55,7 +55,7 @@ func New(httpClient common.HttpClient, site string) (*Client, error) { // Client is a Bitbucket API client. type Client struct { - HTTP common.HttpClient + HTTP common.HTTPClient Site *url.URL Auth common.Authentication Workspace *internal.WorkspaceService diff --git a/bitbucket/api_client_impl_test.go b/bitbucket/api_client_impl_test.go index aafac9e1..c8bd4c3d 100644 --- a/bitbucket/api_client_impl_test.go +++ b/bitbucket/api_client_impl_test.go @@ -66,7 +66,7 @@ func TestClient_Call(t *testing.T) { } type fields struct { - HTTP common.HttpClient + HTTP common.HTTPClient Site *url.URL Auth common.Authentication } @@ -88,7 +88,7 @@ func TestClient_Call(t *testing.T) { name: "when the parameters are correct", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(expectedResponse, nil) @@ -112,7 +112,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is a bad request", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(badRequestResponse, nil) @@ -137,7 +137,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is an internal service error", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(internalServerResponse, nil) @@ -162,7 +162,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is a not found", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(notFoundResponse, nil) @@ -187,7 +187,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is unauthorized", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(unauthorizedResponse, nil) @@ -265,17 +265,17 @@ func TestClient_NewRequest(t *testing.T) { requestMocked.Header.Set("Content-Type", "application/json") type fields struct { - HTTP common.HttpClient + HTTP common.HTTPClient Auth common.Authentication Site *url.URL } type args struct { - ctx context.Context - method string - urlStr string - typ string - body interface{} + ctx context.Context + method string + urlStr string + contentType string + body interface{} } testCases := []struct { @@ -293,11 +293,11 @@ func TestClient_NewRequest(t *testing.T) { Site: siteAsURL, }, args: args{ - ctx: context.Background(), - method: http.MethodGet, - urlStr: "rest/2/issue/attachment", - typ: "", - body: bytes.NewReader([]byte("Hello World")), + ctx: context.Background(), + method: http.MethodGet, + urlStr: "rest/2/issue/attachment", + contentType: "", + body: bytes.NewReader([]byte("Hello World")), }, want: requestMocked, wantErr: false, @@ -328,11 +328,11 @@ func TestClient_NewRequest(t *testing.T) { Site: siteAsURL, }, args: args{ - ctx: context.Background(), - method: http.MethodGet, - urlStr: "rest/2/issue/attachment", - typ: "type_sample", - body: bytes.NewReader([]byte("Hello World")), + ctx: context.Background(), + method: http.MethodGet, + urlStr: "rest/2/issue/attachment", + contentType: "type_sample", + body: bytes.NewReader([]byte("Hello World")), }, want: requestMocked, wantErr: false, @@ -369,7 +369,7 @@ func TestClient_NewRequest(t *testing.T) { testCase.args.ctx, testCase.args.method, testCase.args.urlStr, - testCase.args.typ, + testCase.args.contentType, testCase.args.body, ) @@ -409,7 +409,7 @@ func TestClient_processResponse(t *testing.T) { } type fields struct { - HTTP common.HttpClient + HTTP common.HTTPClient Site *url.URL Authentication common.Authentication } @@ -484,7 +484,7 @@ func TestNew(t *testing.T) { invalidURLClientMocked, _ := New(nil, " https://zhidao.baidu.com/special/view?id=sd&preview=1") type args struct { - httpClient common.HttpClient + httpClient common.HTTPClient site string } diff --git a/confluence/api_client_impl.go b/confluence/api_client_impl.go index b05afbd1..6c4f5104 100644 --- a/confluence/api_client_impl.go +++ b/confluence/api_client_impl.go @@ -5,16 +5,17 @@ import ( "context" "encoding/json" "fmt" - "github.com/ctreminiom/go-atlassian/confluence/internal" - "github.com/ctreminiom/go-atlassian/pkg/infra/models" - "github.com/ctreminiom/go-atlassian/service/common" "io" "net/http" "net/url" "strings" + + "github.com/ctreminiom/go-atlassian/confluence/internal" + "github.com/ctreminiom/go-atlassian/pkg/infra/models" + "github.com/ctreminiom/go-atlassian/service/common" ) -func New(httpClient common.HttpClient, site string) (*Client, error) { +func New(httpClient common.HTTPClient, site string) (*Client, error) { if httpClient == nil { httpClient = http.DefaultClient @@ -64,7 +65,7 @@ func New(httpClient common.HttpClient, site string) (*Client, error) { } type Client struct { - HTTP common.HttpClient + HTTP common.HTTPClient Site *url.URL Auth common.Authentication Content *internal.ContentService @@ -75,7 +76,7 @@ type Client struct { Analytics *internal.AnalyticsService } -func (c *Client) NewRequest(ctx context.Context, method, urlStr, type_ string, body interface{}) (*http.Request, error) { +func (c *Client) NewRequest(ctx context.Context, method, urlStr, contentType string, body interface{}) (*http.Request, error) { rel, err := url.Parse(urlStr) if err != nil { @@ -108,9 +109,9 @@ func (c *Client) NewRequest(ctx context.Context, method, urlStr, type_ string, b req.Header.Set("Content-Type", "application/json") } - if type_ != "" { - // When the type_ is provided, it means the request needs to be created to handle files - req.Header.Set("Content-Type", type_) + if contentType != "" { + // When the contentType is provided, it means the request needs to be created to handle files + req.Header.Set("Content-Type", contentType) req.Header.Set("X-Atlassian-Token", "no-check") } diff --git a/confluence/api_client_impl_test.go b/confluence/api_client_impl_test.go index a137e0ae..805ccce9 100644 --- a/confluence/api_client_impl_test.go +++ b/confluence/api_client_impl_test.go @@ -4,16 +4,18 @@ import ( "bytes" "context" "errors" - "github.com/ctreminiom/go-atlassian/confluence/internal" - model "github.com/ctreminiom/go-atlassian/pkg/infra/models" - "github.com/ctreminiom/go-atlassian/service/common" - "github.com/ctreminiom/go-atlassian/service/mocks" - "github.com/stretchr/testify/assert" "io" "net/http" "net/url" "strings" "testing" + + "github.com/stretchr/testify/assert" + + "github.com/ctreminiom/go-atlassian/confluence/internal" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" + "github.com/ctreminiom/go-atlassian/service/common" + "github.com/ctreminiom/go-atlassian/service/mocks" ) func TestClient_Call(t *testing.T) { @@ -64,7 +66,7 @@ func TestClient_Call(t *testing.T) { } type fields struct { - HTTP common.HttpClient + HTTP common.HTTPClient Site *url.URL Auth common.Authentication } @@ -86,7 +88,7 @@ func TestClient_Call(t *testing.T) { name: "when the parameters are correct", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(expectedResponse, nil) @@ -110,7 +112,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is a bad request", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(badRequestResponse, nil) @@ -135,7 +137,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is an internal service error", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(internalServerResponse, nil) @@ -160,7 +162,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is a not found", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(notFoundResponse, nil) @@ -185,7 +187,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is unauthorized", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(unauthorizedResponse, nil) @@ -263,17 +265,17 @@ func TestClient_NewRequest(t *testing.T) { requestMocked.Header.Set("Content-Type", "application/json") type fields struct { - HTTP common.HttpClient + HTTP common.HTTPClient Auth common.Authentication Site *url.URL } type args struct { - ctx context.Context - method string - urlStr string - type_ string - body interface{} + ctx context.Context + method string + urlStr string + contentType string + body interface{} } testCases := []struct { @@ -291,11 +293,11 @@ func TestClient_NewRequest(t *testing.T) { Site: siteAsURL, }, args: args{ - ctx: context.Background(), - method: http.MethodGet, - urlStr: "rest/2/issue/attachment", - type_: "", - body: bytes.NewReader([]byte("Hello World")), + ctx: context.Background(), + method: http.MethodGet, + urlStr: "rest/2/issue/attachment", + contentType: "", + body: bytes.NewReader([]byte("Hello World")), }, want: requestMocked, wantErr: false, @@ -326,11 +328,11 @@ func TestClient_NewRequest(t *testing.T) { Site: siteAsURL, }, args: args{ - ctx: context.Background(), - method: http.MethodGet, - urlStr: "rest/2/issue/attachment", - type_: "type_sample", - body: bytes.NewReader([]byte("Hello World")), + ctx: context.Background(), + method: http.MethodGet, + urlStr: "rest/2/issue/attachment", + contentType: "type_sample", + body: bytes.NewReader([]byte("Hello World")), }, want: requestMocked, wantErr: false, @@ -367,7 +369,7 @@ func TestClient_NewRequest(t *testing.T) { testCase.args.ctx, testCase.args.method, testCase.args.urlStr, - testCase.args.type_, + testCase.args.contentType, testCase.args.body, ) @@ -389,7 +391,7 @@ func TestClient_NewRequest(t *testing.T) { func TestClient_processResponse(t *testing.T) { - expectedJsonResponse := ` + expectedJSONResponse := ` { "id": 4, "self": "https://ctreminiom.atlassian.net/rest/agile/1.0/board/4", @@ -399,7 +401,7 @@ func TestClient_processResponse(t *testing.T) { expectedResponse := &http.Response{ StatusCode: http.StatusOK, - Body: io.NopCloser(strings.NewReader(expectedJsonResponse)), + Body: io.NopCloser(strings.NewReader(expectedJSONResponse)), Request: &http.Request{ Method: http.MethodGet, URL: &url.URL{}, @@ -407,7 +409,7 @@ func TestClient_processResponse(t *testing.T) { } type fields struct { - HTTP common.HttpClient + HTTP common.HTTPClient Site *url.URL Authentication common.Authentication } @@ -435,7 +437,7 @@ func TestClient_processResponse(t *testing.T) { Response: expectedResponse, Code: http.StatusOK, Method: http.MethodGet, - Bytes: *bytes.NewBufferString(expectedJsonResponse), + Bytes: *bytes.NewBufferString(expectedJSONResponse), }, wantErr: false, }, @@ -484,7 +486,7 @@ func TestNew(t *testing.T) { noURLClientMocked, _ := New(nil, "") type args struct { - httpClient common.HttpClient + httpClient common.HTTPClient site string } diff --git a/confluence/internal/attachment_impl.go b/confluence/internal/attachment_impl.go index 92c3021d..9240b1db 100644 --- a/confluence/internal/attachment_impl.go +++ b/confluence/internal/attachment_impl.go @@ -3,13 +3,14 @@ package internal import ( "context" "fmt" - model "github.com/ctreminiom/go-atlassian/pkg/infra/models" - "github.com/ctreminiom/go-atlassian/service" - "github.com/ctreminiom/go-atlassian/service/confluence" "net/http" "net/url" "strconv" "strings" + + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" + "github.com/ctreminiom/go-atlassian/service" + "github.com/ctreminiom/go-atlassian/service/confluence" ) // NewAttachmentService creates a new instance of AttachmentService. @@ -156,9 +157,9 @@ func (i *internalAttachmentImpl) Gets(ctx context.Context, entityID int, entityT // Checking if the entity type provided is supported by the library var isSupported bool - for _, type_ := range model.ValidEntityValues { + for _, typ := range model.ValidEntityValues { - if entityType == type_ { + if entityType == typ { isSupported = true break } diff --git a/confluence/internal/custom_content_impl.go b/confluence/internal/custom_content_impl.go index c6dace57..9375ba98 100644 --- a/confluence/internal/custom_content_impl.go +++ b/confluence/internal/custom_content_impl.go @@ -3,13 +3,14 @@ package internal import ( "context" "fmt" - model "github.com/ctreminiom/go-atlassian/pkg/infra/models" - "github.com/ctreminiom/go-atlassian/service" - "github.com/ctreminiom/go-atlassian/service/confluence" "net/http" "net/url" "strconv" "strings" + + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" + "github.com/ctreminiom/go-atlassian/service" + "github.com/ctreminiom/go-atlassian/service/confluence" ) // NewCustomContentService creates a new instance of CustomContentService. @@ -31,8 +32,8 @@ type CustomContentService struct { // GET /wiki/api/v2/custom-content // // https://docs.go-atlassian.io/confluence-cloud/v2/custom-content#get-custom-content-by-type -func (c *CustomContentService) Gets(ctx context.Context, type_ string, options *model.CustomContentOptionsScheme, cursor string, limit int) (*model.CustomContentPageScheme, *model.ResponseScheme, error) { - return c.internalClient.Gets(ctx, type_, options, cursor, limit) +func (c *CustomContentService) Gets(ctx context.Context, typ string, options *model.CustomContentOptionsScheme, cursor string, limit int) (*model.CustomContentPageScheme, *model.ResponseScheme, error) { + return c.internalClient.Gets(ctx, typ, options, cursor, limit) } // Create creates a new custom content in the given space, page, blogpost or other custom content. @@ -79,9 +80,9 @@ type internalCustomContentServiceImpl struct { c service.Connector } -func (i *internalCustomContentServiceImpl) Gets(ctx context.Context, type_ string, options *model.CustomContentOptionsScheme, cursor string, limit int) (*model.CustomContentPageScheme, *model.ResponseScheme, error) { +func (i *internalCustomContentServiceImpl) Gets(ctx context.Context, typ string, options *model.CustomContentOptionsScheme, cursor string, limit int) (*model.CustomContentPageScheme, *model.ResponseScheme, error) { - if type_ == "" { + if typ == "" { return nil, nil, model.ErrNoCustomContentType } diff --git a/confluence/internal/custom_content_impl_test.go b/confluence/internal/custom_content_impl_test.go index 0cd14623..6b928298 100644 --- a/confluence/internal/custom_content_impl_test.go +++ b/confluence/internal/custom_content_impl_test.go @@ -3,12 +3,14 @@ package internal import ( "context" "errors" + "net/http" + "testing" + + "github.com/stretchr/testify/assert" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" "github.com/ctreminiom/go-atlassian/service" "github.com/ctreminiom/go-atlassian/service/mocks" - "github.com/stretchr/testify/assert" - "net/http" - "testing" ) func Test_internalCustomContentServiceImpl_Gets(t *testing.T) { @@ -19,7 +21,7 @@ func Test_internalCustomContentServiceImpl_Gets(t *testing.T) { type args struct { ctx context.Context - type_ string + typ string options *model.CustomContentOptionsScheme cursor string limit int @@ -36,8 +38,8 @@ func Test_internalCustomContentServiceImpl_Gets(t *testing.T) { { name: "when the parameters are correct", args: args{ - ctx: context.Background(), - type_: "custom_content_type_id", + ctx: context.Background(), + typ: "custom_content_type_id", options: &model.CustomContentOptionsScheme{ IDs: []int{101, 102}, SpaceIDs: []int{10001, 10002}, @@ -71,8 +73,8 @@ func Test_internalCustomContentServiceImpl_Gets(t *testing.T) { { name: "when the http request cannot be created", args: args{ - ctx: context.Background(), - type_: "custom_content_type_id", + ctx: context.Background(), + typ: "custom_content_type_id", options: &model.CustomContentOptionsScheme{ IDs: []int{101, 102}, SpaceIDs: []int{10001, 10002}, @@ -120,7 +122,7 @@ func Test_internalCustomContentServiceImpl_Gets(t *testing.T) { gotResult, gotResponse, err := newService.Gets( testCase.args.ctx, - testCase.args.type_, + testCase.args.typ, testCase.args.options, testCase.args.cursor, testCase.args.limit, diff --git a/confluence/v2/api_client_impl.go b/confluence/v2/api_client_impl.go index 5876512a..38866e82 100644 --- a/confluence/v2/api_client_impl.go +++ b/confluence/v2/api_client_impl.go @@ -5,16 +5,17 @@ import ( "context" "encoding/json" "fmt" - "github.com/ctreminiom/go-atlassian/confluence/internal" - "github.com/ctreminiom/go-atlassian/pkg/infra/models" - "github.com/ctreminiom/go-atlassian/service/common" "io" "net/http" "net/url" "strings" + + "github.com/ctreminiom/go-atlassian/confluence/internal" + "github.com/ctreminiom/go-atlassian/pkg/infra/models" + "github.com/ctreminiom/go-atlassian/service/common" ) -func New(httpClient common.HttpClient, site string) (*Client, error) { +func New(httpClient common.HTTPClient, site string) (*Client, error) { if httpClient == nil { httpClient = http.DefaultClient @@ -48,7 +49,7 @@ func New(httpClient common.HttpClient, site string) (*Client, error) { } type Client struct { - HTTP common.HttpClient + HTTP common.HTTPClient Site *url.URL Auth common.Authentication Page *internal.PageService @@ -57,7 +58,7 @@ type Client struct { CustomContent *internal.CustomContentService } -func (c *Client) NewRequest(ctx context.Context, method, urlStr, type_ string, body interface{}) (*http.Request, error) { +func (c *Client) NewRequest(ctx context.Context, method, urlStr, contentType string, body interface{}) (*http.Request, error) { rel, err := url.Parse(urlStr) if err != nil { @@ -90,9 +91,9 @@ func (c *Client) NewRequest(ctx context.Context, method, urlStr, type_ string, b req.Header.Set("Content-Type", "application/json") } - if type_ != "" { - // When the type_ is provided, it means the request needs to be created to handle files - req.Header.Set("Content-Type", type_) + if contentType != "" { + // When the contentType is provided, it means the request needs to be created to handle files + req.Header.Set("Content-Type", contentType) req.Header.Set("X-Atlassian-Token", "no-check") } diff --git a/confluence/v2/api_client_impl_test.go b/confluence/v2/api_client_impl_test.go index a137e0ae..805ccce9 100644 --- a/confluence/v2/api_client_impl_test.go +++ b/confluence/v2/api_client_impl_test.go @@ -4,16 +4,18 @@ import ( "bytes" "context" "errors" - "github.com/ctreminiom/go-atlassian/confluence/internal" - model "github.com/ctreminiom/go-atlassian/pkg/infra/models" - "github.com/ctreminiom/go-atlassian/service/common" - "github.com/ctreminiom/go-atlassian/service/mocks" - "github.com/stretchr/testify/assert" "io" "net/http" "net/url" "strings" "testing" + + "github.com/stretchr/testify/assert" + + "github.com/ctreminiom/go-atlassian/confluence/internal" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" + "github.com/ctreminiom/go-atlassian/service/common" + "github.com/ctreminiom/go-atlassian/service/mocks" ) func TestClient_Call(t *testing.T) { @@ -64,7 +66,7 @@ func TestClient_Call(t *testing.T) { } type fields struct { - HTTP common.HttpClient + HTTP common.HTTPClient Site *url.URL Auth common.Authentication } @@ -86,7 +88,7 @@ func TestClient_Call(t *testing.T) { name: "when the parameters are correct", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(expectedResponse, nil) @@ -110,7 +112,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is a bad request", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(badRequestResponse, nil) @@ -135,7 +137,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is an internal service error", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(internalServerResponse, nil) @@ -160,7 +162,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is a not found", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(notFoundResponse, nil) @@ -185,7 +187,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is unauthorized", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(unauthorizedResponse, nil) @@ -263,17 +265,17 @@ func TestClient_NewRequest(t *testing.T) { requestMocked.Header.Set("Content-Type", "application/json") type fields struct { - HTTP common.HttpClient + HTTP common.HTTPClient Auth common.Authentication Site *url.URL } type args struct { - ctx context.Context - method string - urlStr string - type_ string - body interface{} + ctx context.Context + method string + urlStr string + contentType string + body interface{} } testCases := []struct { @@ -291,11 +293,11 @@ func TestClient_NewRequest(t *testing.T) { Site: siteAsURL, }, args: args{ - ctx: context.Background(), - method: http.MethodGet, - urlStr: "rest/2/issue/attachment", - type_: "", - body: bytes.NewReader([]byte("Hello World")), + ctx: context.Background(), + method: http.MethodGet, + urlStr: "rest/2/issue/attachment", + contentType: "", + body: bytes.NewReader([]byte("Hello World")), }, want: requestMocked, wantErr: false, @@ -326,11 +328,11 @@ func TestClient_NewRequest(t *testing.T) { Site: siteAsURL, }, args: args{ - ctx: context.Background(), - method: http.MethodGet, - urlStr: "rest/2/issue/attachment", - type_: "type_sample", - body: bytes.NewReader([]byte("Hello World")), + ctx: context.Background(), + method: http.MethodGet, + urlStr: "rest/2/issue/attachment", + contentType: "type_sample", + body: bytes.NewReader([]byte("Hello World")), }, want: requestMocked, wantErr: false, @@ -367,7 +369,7 @@ func TestClient_NewRequest(t *testing.T) { testCase.args.ctx, testCase.args.method, testCase.args.urlStr, - testCase.args.type_, + testCase.args.contentType, testCase.args.body, ) @@ -389,7 +391,7 @@ func TestClient_NewRequest(t *testing.T) { func TestClient_processResponse(t *testing.T) { - expectedJsonResponse := ` + expectedJSONResponse := ` { "id": 4, "self": "https://ctreminiom.atlassian.net/rest/agile/1.0/board/4", @@ -399,7 +401,7 @@ func TestClient_processResponse(t *testing.T) { expectedResponse := &http.Response{ StatusCode: http.StatusOK, - Body: io.NopCloser(strings.NewReader(expectedJsonResponse)), + Body: io.NopCloser(strings.NewReader(expectedJSONResponse)), Request: &http.Request{ Method: http.MethodGet, URL: &url.URL{}, @@ -407,7 +409,7 @@ func TestClient_processResponse(t *testing.T) { } type fields struct { - HTTP common.HttpClient + HTTP common.HTTPClient Site *url.URL Authentication common.Authentication } @@ -435,7 +437,7 @@ func TestClient_processResponse(t *testing.T) { Response: expectedResponse, Code: http.StatusOK, Method: http.MethodGet, - Bytes: *bytes.NewBufferString(expectedJsonResponse), + Bytes: *bytes.NewBufferString(expectedJSONResponse), }, wantErr: false, }, @@ -484,7 +486,7 @@ func TestNew(t *testing.T) { noURLClientMocked, _ := New(nil, "") type args struct { - httpClient common.HttpClient + httpClient common.HTTPClient site string } diff --git a/jira/agile/api_client_impl.go b/jira/agile/api_client_impl.go index 875d166a..aaedf099 100644 --- a/jira/agile/api_client_impl.go +++ b/jira/agile/api_client_impl.go @@ -5,16 +5,17 @@ import ( "context" "encoding/json" "fmt" - "github.com/ctreminiom/go-atlassian/jira/agile/internal" - model "github.com/ctreminiom/go-atlassian/pkg/infra/models" - "github.com/ctreminiom/go-atlassian/service/common" "io" "net/http" "net/url" "strings" + + "github.com/ctreminiom/go-atlassian/jira/agile/internal" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" + "github.com/ctreminiom/go-atlassian/service/common" ) -func New(httpClient common.HttpClient, site string) (*Client, error) { +func New(httpClient common.HTTPClient, site string) (*Client, error) { if httpClient == nil { httpClient = http.DefaultClient @@ -48,7 +49,7 @@ func New(httpClient common.HttpClient, site string) (*Client, error) { } type Client struct { - HTTP common.HttpClient + HTTP common.HTTPClient Site *url.URL Auth common.Authentication Board *internal.BoardService @@ -57,7 +58,7 @@ type Client struct { Sprint *internal.SprintService } -func (c *Client) NewRequest(ctx context.Context, method, urlStr, type_ string, body interface{}) (*http.Request, error) { +func (c *Client) NewRequest(ctx context.Context, method, urlStr, contentType string, body interface{}) (*http.Request, error) { rel, err := url.Parse(urlStr) if err != nil { @@ -79,12 +80,12 @@ func (c *Client) NewRequest(ctx context.Context, method, urlStr, type_ string, b } req.Header.Set("Accept", "application/json") - if body != nil && type_ == "" { + if body != nil && contentType == "" { req.Header.Set("Content-Type", "application/json") } - if body != nil && type_ != "" { - req.Header.Set("Content-Type", type_) + if body != nil && contentType != "" { + req.Header.Set("Content-Type", contentType) } if c.Auth.HasBasicAuth() { diff --git a/jira/agile/api_client_impl_test.go b/jira/agile/api_client_impl_test.go index 7e74c1c1..2daf1e7d 100644 --- a/jira/agile/api_client_impl_test.go +++ b/jira/agile/api_client_impl_test.go @@ -4,16 +4,18 @@ import ( "bytes" "context" "errors" - "github.com/ctreminiom/go-atlassian/jira/agile/internal" - model "github.com/ctreminiom/go-atlassian/pkg/infra/models" - "github.com/ctreminiom/go-atlassian/service/common" - "github.com/ctreminiom/go-atlassian/service/mocks" - "github.com/stretchr/testify/assert" "io" "net/http" "net/url" "strings" "testing" + + "github.com/stretchr/testify/assert" + + "github.com/ctreminiom/go-atlassian/jira/agile/internal" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" + "github.com/ctreminiom/go-atlassian/service/common" + "github.com/ctreminiom/go-atlassian/service/mocks" ) func TestClient_Call(t *testing.T) { @@ -64,7 +66,7 @@ func TestClient_Call(t *testing.T) { } type fields struct { - HTTP common.HttpClient + HTTP common.HTTPClient Site *url.URL Auth common.Authentication Board *internal.BoardService @@ -90,7 +92,7 @@ func TestClient_Call(t *testing.T) { name: "when the parameters are correct", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(expectedResponse, nil) @@ -114,7 +116,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is a bad request", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(badRequestResponse, nil) @@ -139,7 +141,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is an internal service error", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(internalServerResponse, nil) @@ -164,7 +166,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is a not found", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(notFoundResponse, nil) @@ -189,7 +191,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is unauthorized", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(unauthorizedResponse, nil) @@ -270,17 +272,17 @@ func TestClient_NewRequest(t *testing.T) { requestMocked.Header.Set("Content-Type", "application/json") type fields struct { - HTTP common.HttpClient + HTTP common.HTTPClient Auth common.Authentication Site *url.URL } type args struct { - ctx context.Context - method string - urlStr string - type_ string - body interface{} + ctx context.Context + method string + urlStr string + contentType string + body interface{} } testCases := []struct { @@ -298,11 +300,11 @@ func TestClient_NewRequest(t *testing.T) { Site: siteAsURL, }, args: args{ - ctx: context.Background(), - method: http.MethodGet, - urlStr: "rest/2/issue/attachment", - type_: "", - body: bytes.NewReader([]byte("Hello World")), + ctx: context.Background(), + method: http.MethodGet, + urlStr: "rest/2/issue/attachment", + contentType: "", + body: bytes.NewReader([]byte("Hello World")), }, want: requestMocked, wantErr: false, @@ -356,7 +358,7 @@ func TestClient_NewRequest(t *testing.T) { testCase.args.ctx, testCase.args.method, testCase.args.urlStr, - testCase.args.type_, + testCase.args.contentType, testCase.args.body, ) @@ -378,7 +380,7 @@ func TestClient_NewRequest(t *testing.T) { func TestClient_processResponse(t *testing.T) { - expectedJsonResponse := ` + expectedJSONResponse := ` { "id": 4, "self": "https://ctreminiom.atlassian.net/rest/agile/1.0/board/4", @@ -388,7 +390,7 @@ func TestClient_processResponse(t *testing.T) { expectedResponse := &http.Response{ StatusCode: http.StatusOK, - Body: io.NopCloser(strings.NewReader(expectedJsonResponse)), + Body: io.NopCloser(strings.NewReader(expectedJSONResponse)), Request: &http.Request{ Method: http.MethodGet, URL: &url.URL{}, @@ -396,7 +398,7 @@ func TestClient_processResponse(t *testing.T) { } type fields struct { - HTTP common.HttpClient + HTTP common.HTTPClient Site *url.URL Authentication common.Authentication Board *internal.BoardService @@ -427,7 +429,7 @@ func TestClient_processResponse(t *testing.T) { Response: expectedResponse, Code: http.StatusOK, Method: http.MethodGet, - Bytes: *bytes.NewBufferString(expectedJsonResponse), + Bytes: *bytes.NewBufferString(expectedJSONResponse), }, wantErr: false, }, @@ -479,7 +481,7 @@ func TestNew(t *testing.T) { noURLClientMocked, _ := New(nil, "") type args struct { - httpClient common.HttpClient + httpClient common.HTTPClient site string } diff --git a/jira/agile/internal/board_backlog_impl_test.go b/jira/agile/internal/board_backlog_impl_test.go index f7c171cb..8fa79b3a 100644 --- a/jira/agile/internal/board_backlog_impl_test.go +++ b/jira/agile/internal/board_backlog_impl_test.go @@ -3,12 +3,14 @@ package internal import ( "context" "errors" + "net/http" + "testing" + + "github.com/stretchr/testify/assert" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" "github.com/ctreminiom/go-atlassian/service" "github.com/ctreminiom/go-atlassian/service/mocks" - "github.com/stretchr/testify/assert" - "net/http" - "testing" ) func Test_internalBoardBacklogImpl_Move(t *testing.T) { @@ -148,7 +150,7 @@ func Test_internalBoardBacklogImpl_MoveTo(t *testing.T) { Issues: []string{"PR-1", "10001", "PR-3"}, RankBeforeIssue: "PR-4", RankAfterIssue: "", - RankCustomFieldId: 10521, + RankCustomFieldID: 10521, } type fields struct { diff --git a/jira/internal/announcement_banner_impl.go b/jira/internal/announcement_banner_impl.go index 396b563b..45efb4e7 100644 --- a/jira/internal/announcement_banner_impl.go +++ b/jira/internal/announcement_banner_impl.go @@ -3,10 +3,11 @@ package internal import ( "context" "fmt" + "net/http" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" "github.com/ctreminiom/go-atlassian/service" "github.com/ctreminiom/go-atlassian/service/jira" - "net/http" ) // NewAnnouncementBannerService creates a new instance of AnnouncementBannerService. diff --git a/jira/internal/comment_impl_rich_text.go b/jira/internal/comment_impl_rich_text.go index 37cb91c4..e3594646 100644 --- a/jira/internal/comment_impl_rich_text.go +++ b/jira/internal/comment_impl_rich_text.go @@ -21,11 +21,11 @@ type CommentRichTextService struct { // Delete deletes a comment. // -// DELETE /rest/api/{2-3}/issue/{issueKeyOrID}/comment/{id} +// DELETE /rest/api/{2-3}/issue/{issueKeyOrID}/comment/{commentID} // // https://docs.go-atlassian.io/jira-software-cloud/issues/comments#delete-comment -func (c *CommentRichTextService) Delete(ctx context.Context, issueKeyOrID, commentId string) (*model.ResponseScheme, error) { - return c.internalClient.Delete(ctx, issueKeyOrID, commentId) +func (c *CommentRichTextService) Delete(ctx context.Context, issueKeyOrID, commentID string) (*model.ResponseScheme, error) { + return c.internalClient.Delete(ctx, issueKeyOrID, commentID) } // Gets returns all comments for an issue. @@ -39,11 +39,11 @@ func (c *CommentRichTextService) Gets(ctx context.Context, issueKeyOrID, orderBy // Get returns a comment. // -// GET /rest/api/{2-3}/issue/{issueKeyOrID}/comment/{id} +// GET /rest/api/{2-3}/issue/{issueKeyOrID}/comment/{commentID} // // TODO: The documentation needs to be created, raise a ticket here: https://github.com/ctreminiom/go-atlassian/issues -func (c *CommentRichTextService) Get(ctx context.Context, issueKeyOrID, commentId string) (*model.IssueCommentSchemeV2, *model.ResponseScheme, error) { - return c.internalClient.Get(ctx, issueKeyOrID, commentId) +func (c *CommentRichTextService) Get(ctx context.Context, issueKeyOrID, commentID string) (*model.IssueCommentSchemeV2, *model.ResponseScheme, error) { + return c.internalClient.Get(ctx, issueKeyOrID, commentID) } // Add adds a comment to an issue. diff --git a/jira/internal/comment_impl_rich_text_test.go b/jira/internal/comment_impl_rich_text_test.go index 78fb6102..ee190640 100644 --- a/jira/internal/comment_impl_rich_text_test.go +++ b/jira/internal/comment_impl_rich_text_test.go @@ -159,7 +159,7 @@ func Test_internalRichTextCommentImpl_Get(t *testing.T) { type args struct { ctx context.Context - issueKeyOrID, commentId string + issueKeyOrID, commentID string } testCases := []struct { @@ -176,7 +176,7 @@ func Test_internalRichTextCommentImpl_Get(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "DUMMY-1", - commentId: "10001", + commentID: "10001", }, on: func(fields *fields) { @@ -230,7 +230,7 @@ func Test_internalRichTextCommentImpl_Get(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "DUMMY-1", - commentId: "10001", + commentID: "10001", }, on: func(fields *fields) { @@ -262,7 +262,7 @@ func Test_internalRichTextCommentImpl_Get(t *testing.T) { _, commentService, err := NewCommentService(testCase.fields.c, testCase.fields.version) assert.NoError(t, err) - gotResult, gotResponse, err := commentService.Get(testCase.args.ctx, testCase.args.issueKeyOrID, testCase.args.commentId) + gotResult, gotResponse, err := commentService.Get(testCase.args.ctx, testCase.args.issueKeyOrID, testCase.args.commentID) if testCase.wantErr { @@ -292,7 +292,7 @@ func Test_internalRichTextCommentImpl_Delete(t *testing.T) { type args struct { ctx context.Context - issueKeyOrID, commentId string + issueKeyOrID, commentID string } testCases := []struct { @@ -309,7 +309,7 @@ func Test_internalRichTextCommentImpl_Delete(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "DUMMY-1", - commentId: "10001", + commentID: "10001", }, on: func(fields *fields) { @@ -363,7 +363,7 @@ func Test_internalRichTextCommentImpl_Delete(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "DUMMY-1", - commentId: "10001", + commentID: "10001", }, on: func(fields *fields) { @@ -395,7 +395,7 @@ func Test_internalRichTextCommentImpl_Delete(t *testing.T) { _, commentService, err := NewCommentService(testCase.fields.c, testCase.fields.version) assert.NoError(t, err) - gotResponse, err := commentService.Delete(testCase.args.ctx, testCase.args.issueKeyOrID, testCase.args.commentId) + gotResponse, err := commentService.Delete(testCase.args.ctx, testCase.args.issueKeyOrID, testCase.args.commentID) if testCase.wantErr { diff --git a/jira/internal/field_configuration_scheme.go b/jira/internal/field_configuration_scheme.go index 9c8c209b..cb515ee1 100644 --- a/jira/internal/field_configuration_scheme.go +++ b/jira/internal/field_configuration_scheme.go @@ -61,8 +61,8 @@ func (i *IssueFieldConfigSchemeService) Create(ctx context.Context, name, descri // GET /rest/api/{2-3}/fieldconfigurationscheme/mapping // // https://docs.go-atlassian.io/jira-software-cloud/issues/fields/configuration/schemes#get-field-configuration-scheme-mapping -func (i *IssueFieldConfigSchemeService) Mapping(ctx context.Context, fieldConfigIds []int, startAt, maxResults int) (*model.FieldConfigurationIssueTypeItemPageScheme, *model.ResponseScheme, error) { - return i.internalClient.Mapping(ctx, fieldConfigIds, startAt, maxResults) +func (i *IssueFieldConfigSchemeService) Mapping(ctx context.Context, fieldConfigIDs []int, startAt, maxResults int) (*model.FieldConfigurationIssueTypeItemPageScheme, *model.ResponseScheme, error) { + return i.internalClient.Mapping(ctx, fieldConfigIDs, startAt, maxResults) } // Project returns a paginated list of field configuration schemes and, for each scheme, a list of the projects that use it. @@ -74,8 +74,8 @@ func (i *IssueFieldConfigSchemeService) Mapping(ctx context.Context, fieldConfig // GET /rest/api/{2-3}/fieldconfigurationscheme/project // // https://docs.go-atlassian.io/jira-software-cloud/issues/fields/configuration/schemes#get-field-configuration-schemes-by-project -func (i *IssueFieldConfigSchemeService) Project(ctx context.Context, projectIds []int, startAt, maxResults int) (*model.FieldConfigurationSchemeProjectPageScheme, *model.ResponseScheme, error) { - return i.internalClient.Project(ctx, projectIds, startAt, maxResults) +func (i *IssueFieldConfigSchemeService) Project(ctx context.Context, projectIDs []int, startAt, maxResults int) (*model.FieldConfigurationSchemeProjectPageScheme, *model.ResponseScheme, error) { + return i.internalClient.Project(ctx, projectIDs, startAt, maxResults) } // Assign assigns a field configuration scheme to a project. If the field configuration scheme ID is null, @@ -220,13 +220,13 @@ func (i *internalIssueFieldConfigSchemeServiceImpl) Mapping(ctx context.Context, return page, response, nil } -func (i *internalIssueFieldConfigSchemeServiceImpl) Project(ctx context.Context, projectIds []int, startAt, maxResults int) (*model.FieldConfigurationSchemeProjectPageScheme, *model.ResponseScheme, error) { +func (i *internalIssueFieldConfigSchemeServiceImpl) Project(ctx context.Context, projectIDs []int, startAt, maxResults int) (*model.FieldConfigurationSchemeProjectPageScheme, *model.ResponseScheme, error) { params := url.Values{} params.Add("startAt", strconv.Itoa(startAt)) params.Add("maxResults", strconv.Itoa(maxResults)) - for _, projectID := range projectIds { + for _, projectID := range projectIDs { params.Add("projectId", strconv.Itoa(projectID)) } diff --git a/jira/internal/field_configuration_scheme_test.go b/jira/internal/field_configuration_scheme_test.go index d4c024fa..1db1ba9b 100644 --- a/jira/internal/field_configuration_scheme_test.go +++ b/jira/internal/field_configuration_scheme_test.go @@ -343,7 +343,7 @@ func Test_internalIssueFieldConfigSchemeServiceImpl_Mapping(t *testing.T) { type args struct { ctx context.Context - fieldConfigIds []int + fieldConfigIDs []int startAt, maxResults int } @@ -360,7 +360,7 @@ func Test_internalIssueFieldConfigSchemeServiceImpl_Mapping(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - fieldConfigIds: []int{10001}, + fieldConfigIDs: []int{10001}, startAt: 50, maxResults: 50, }, @@ -392,7 +392,7 @@ func Test_internalIssueFieldConfigSchemeServiceImpl_Mapping(t *testing.T) { fields: fields{version: "2"}, args: args{ ctx: context.Background(), - fieldConfigIds: []int{10001}, + fieldConfigIDs: []int{10001}, startAt: 50, maxResults: 50, }, @@ -424,7 +424,7 @@ func Test_internalIssueFieldConfigSchemeServiceImpl_Mapping(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - fieldConfigIds: []int{10001}, + fieldConfigIDs: []int{10001}, startAt: 50, maxResults: 50, }, @@ -457,7 +457,7 @@ func Test_internalIssueFieldConfigSchemeServiceImpl_Mapping(t *testing.T) { fieldConfigService, err := NewIssueFieldConfigurationSchemeService(testCase.fields.c, testCase.fields.version) assert.NoError(t, err) - gotResult, gotResponse, err := fieldConfigService.Mapping(testCase.args.ctx, testCase.args.fieldConfigIds, + gotResult, gotResponse, err := fieldConfigService.Mapping(testCase.args.ctx, testCase.args.fieldConfigIDs, testCase.args.startAt, testCase.args.maxResults) if testCase.wantErr { @@ -488,7 +488,7 @@ func Test_internalIssueFieldConfigSchemeServiceImpl_Project(t *testing.T) { type args struct { ctx context.Context - projectIds []int + projectIDs []int startAt, maxResults int } @@ -505,7 +505,7 @@ func Test_internalIssueFieldConfigSchemeServiceImpl_Project(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - projectIds: []int{10001}, + projectIDs: []int{10001}, startAt: 50, maxResults: 50, }, @@ -537,7 +537,7 @@ func Test_internalIssueFieldConfigSchemeServiceImpl_Project(t *testing.T) { fields: fields{version: "2"}, args: args{ ctx: context.Background(), - projectIds: []int{10001}, + projectIDs: []int{10001}, startAt: 50, maxResults: 50, }, @@ -569,7 +569,7 @@ func Test_internalIssueFieldConfigSchemeServiceImpl_Project(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - projectIds: []int{10001}, + projectIDs: []int{10001}, startAt: 50, maxResults: 50, }, @@ -602,7 +602,7 @@ func Test_internalIssueFieldConfigSchemeServiceImpl_Project(t *testing.T) { fieldConfigService, err := NewIssueFieldConfigurationSchemeService(testCase.fields.c, testCase.fields.version) assert.NoError(t, err) - gotResult, gotResponse, err := fieldConfigService.Project(testCase.args.ctx, testCase.args.projectIds, + gotResult, gotResponse, err := fieldConfigService.Project(testCase.args.ctx, testCase.args.projectIDs, testCase.args.startAt, testCase.args.maxResults) if testCase.wantErr { diff --git a/jira/internal/field_context_impl_test.go b/jira/internal/field_context_impl_test.go index f667ba15..bbb473af 100644 --- a/jira/internal/field_context_impl_test.go +++ b/jira/internal/field_context_impl_test.go @@ -362,7 +362,7 @@ func Test_internalIssueFieldContextServiceImpl_GetDefaultValues(t *testing.T) { type args struct { ctx context.Context fieldID string - contextIds []int + contextIDs []int startAt, maxResults int } @@ -380,7 +380,7 @@ func Test_internalIssueFieldContextServiceImpl_GetDefaultValues(t *testing.T) { args: args{ ctx: context.Background(), fieldID: "custom_field_10002", - contextIds: []int{10001}, + contextIDs: []int{10001}, startAt: 0, maxResults: 50, }, @@ -413,7 +413,7 @@ func Test_internalIssueFieldContextServiceImpl_GetDefaultValues(t *testing.T) { args: args{ ctx: context.Background(), fieldID: "custom_field_10002", - contextIds: []int{10001}, + contextIDs: []int{10001}, startAt: 0, maxResults: 50, }, @@ -457,7 +457,7 @@ func Test_internalIssueFieldContextServiceImpl_GetDefaultValues(t *testing.T) { args: args{ ctx: context.Background(), fieldID: "custom_field_10002", - contextIds: []int{10001}, + contextIDs: []int{10001}, startAt: 0, maxResults: 50, }, @@ -495,7 +495,7 @@ func Test_internalIssueFieldContextServiceImpl_GetDefaultValues(t *testing.T) { fieldConfigService, err := NewIssueFieldContextService(testCase.fields.c, testCase.fields.version, nil) assert.NoError(t, err) - gotResult, gotResponse, err := fieldConfigService.GetDefaultValues(testCase.args.ctx, testCase.args.fieldID, testCase.args.contextIds, + gotResult, gotResponse, err := fieldConfigService.GetDefaultValues(testCase.args.ctx, testCase.args.fieldID, testCase.args.contextIDs, testCase.args.startAt, testCase.args.maxResults) if testCase.wantErr { @@ -687,8 +687,8 @@ func Test_internalIssueFieldContextServiceImpl_IssueTypesContext(t *testing.T) { type args struct { ctx context.Context - fieldId string - contextIds []int + fieldID string + contextIDs []int startAt, maxResults int } @@ -705,8 +705,8 @@ func Test_internalIssueFieldContextServiceImpl_IssueTypesContext(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - fieldId: "custom_field_10002", - contextIds: []int{10001}, + fieldID: "custom_field_10002", + contextIDs: []int{10001}, startAt: 0, maxResults: 50, }, @@ -738,8 +738,8 @@ func Test_internalIssueFieldContextServiceImpl_IssueTypesContext(t *testing.T) { fields: fields{version: "2"}, args: args{ ctx: context.Background(), - fieldId: "custom_field_10002", - contextIds: []int{10001}, + fieldID: "custom_field_10002", + contextIDs: []int{10001}, startAt: 0, maxResults: 50, }, @@ -771,7 +771,7 @@ func Test_internalIssueFieldContextServiceImpl_IssueTypesContext(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - fieldId: "", + fieldID: "", }, wantErr: true, Err: model.ErrNoFieldID, @@ -782,8 +782,8 @@ func Test_internalIssueFieldContextServiceImpl_IssueTypesContext(t *testing.T) { fields: fields{version: "2"}, args: args{ ctx: context.Background(), - fieldId: "custom_field_10002", - contextIds: []int{10001}, + fieldID: "custom_field_10002", + contextIDs: []int{10001}, startAt: 0, maxResults: 50, }, @@ -816,7 +816,7 @@ func Test_internalIssueFieldContextServiceImpl_IssueTypesContext(t *testing.T) { fieldConfigService, err := NewIssueFieldContextService(testCase.fields.c, testCase.fields.version, nil) assert.NoError(t, err) - gotResult, gotResponse, err := fieldConfigService.IssueTypesContext(testCase.args.ctx, testCase.args.fieldId, testCase.args.contextIds, + gotResult, gotResponse, err := fieldConfigService.IssueTypesContext(testCase.args.ctx, testCase.args.fieldID, testCase.args.contextIDs, testCase.args.startAt, testCase.args.maxResults) if testCase.wantErr { @@ -847,8 +847,8 @@ func Test_internalIssueFieldContextServiceImpl_ProjectsContext(t *testing.T) { type args struct { ctx context.Context - fieldId string - contextIds []int + fieldID string + contextIDs []int startAt, maxResults int } @@ -865,8 +865,8 @@ func Test_internalIssueFieldContextServiceImpl_ProjectsContext(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - fieldId: "custom_field_10002", - contextIds: []int{10001}, + fieldID: "custom_field_10002", + contextIDs: []int{10001}, startAt: 0, maxResults: 50, }, @@ -898,8 +898,8 @@ func Test_internalIssueFieldContextServiceImpl_ProjectsContext(t *testing.T) { fields: fields{version: "2"}, args: args{ ctx: context.Background(), - fieldId: "custom_field_10002", - contextIds: []int{10001}, + fieldID: "custom_field_10002", + contextIDs: []int{10001}, startAt: 0, maxResults: 50, }, @@ -931,7 +931,7 @@ func Test_internalIssueFieldContextServiceImpl_ProjectsContext(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - fieldId: "", + fieldID: "", }, wantErr: true, Err: model.ErrNoFieldID, @@ -942,8 +942,8 @@ func Test_internalIssueFieldContextServiceImpl_ProjectsContext(t *testing.T) { fields: fields{version: "2"}, args: args{ ctx: context.Background(), - fieldId: "custom_field_10002", - contextIds: []int{10001}, + fieldID: "custom_field_10002", + contextIDs: []int{10001}, startAt: 0, maxResults: 50, }, @@ -976,7 +976,7 @@ func Test_internalIssueFieldContextServiceImpl_ProjectsContext(t *testing.T) { fieldConfigService, err := NewIssueFieldContextService(testCase.fields.c, testCase.fields.version, nil) assert.NoError(t, err) - gotResult, gotResponse, err := fieldConfigService.ProjectsContext(testCase.args.ctx, testCase.args.fieldId, testCase.args.contextIds, + gotResult, gotResponse, err := fieldConfigService.ProjectsContext(testCase.args.ctx, testCase.args.fieldID, testCase.args.contextIDs, testCase.args.startAt, testCase.args.maxResults) if testCase.wantErr { @@ -1011,8 +1011,8 @@ func Test_internalIssueFieldContextServiceImpl_Update(t *testing.T) { type args struct { ctx context.Context - fieldId string - contextId int + fieldID string + contextID int name, description string } @@ -1029,8 +1029,8 @@ func Test_internalIssueFieldContextServiceImpl_Update(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - fieldId: "custom_field_10002", - contextId: 10001, + fieldID: "custom_field_10002", + contextID: 10001, name: "DUMMY - customfield_10002 Context", description: "new customfield context description", }, @@ -1062,8 +1062,8 @@ func Test_internalIssueFieldContextServiceImpl_Update(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - fieldId: "custom_field_10002", - contextId: 10001, + fieldID: "custom_field_10002", + contextID: 10001, name: "DUMMY - customfield_10002 Context", description: "", }, @@ -1095,8 +1095,8 @@ func Test_internalIssueFieldContextServiceImpl_Update(t *testing.T) { fields: fields{version: "2"}, args: args{ ctx: context.Background(), - fieldId: "custom_field_10002", - contextId: 10001, + fieldID: "custom_field_10002", + contextID: 10001, name: "DUMMY - customfield_10002 Context", description: "new customfield context description", }, @@ -1128,7 +1128,7 @@ func Test_internalIssueFieldContextServiceImpl_Update(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - fieldId: "", + fieldID: "", }, wantErr: true, Err: model.ErrNoFieldID, @@ -1139,8 +1139,8 @@ func Test_internalIssueFieldContextServiceImpl_Update(t *testing.T) { fields: fields{version: "2"}, args: args{ ctx: context.Background(), - fieldId: "custom_field_10002", - contextId: 10001, + fieldID: "custom_field_10002", + contextID: 10001, name: "DUMMY - customfield_10002 Context", description: "new customfield context description", }, @@ -1173,7 +1173,7 @@ func Test_internalIssueFieldContextServiceImpl_Update(t *testing.T) { fieldConfigService, err := NewIssueFieldContextService(testCase.fields.c, testCase.fields.version, nil) assert.NoError(t, err) - gotResponse, err := fieldConfigService.Update(testCase.args.ctx, testCase.args.fieldId, testCase.args.contextId, + gotResponse, err := fieldConfigService.Update(testCase.args.ctx, testCase.args.fieldID, testCase.args.contextID, testCase.args.name, testCase.args.description) if testCase.wantErr { @@ -1203,8 +1203,8 @@ func Test_internalIssueFieldContextServiceImpl_Delete(t *testing.T) { type args struct { ctx context.Context - fieldId string - contextId int + fieldID string + contextID int } testCases := []struct { @@ -1220,8 +1220,8 @@ func Test_internalIssueFieldContextServiceImpl_Delete(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - fieldId: "custom_field_10002", - contextId: 10001, + fieldID: "custom_field_10002", + contextID: 10001, }, on: func(fields *fields) { @@ -1251,8 +1251,8 @@ func Test_internalIssueFieldContextServiceImpl_Delete(t *testing.T) { fields: fields{version: "2"}, args: args{ ctx: context.Background(), - fieldId: "custom_field_10002", - contextId: 10001, + fieldID: "custom_field_10002", + contextID: 10001, }, on: func(fields *fields) { @@ -1282,7 +1282,7 @@ func Test_internalIssueFieldContextServiceImpl_Delete(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - fieldId: "", + fieldID: "", }, wantErr: true, Err: model.ErrNoFieldID, @@ -1293,8 +1293,8 @@ func Test_internalIssueFieldContextServiceImpl_Delete(t *testing.T) { fields: fields{version: "2"}, args: args{ ctx: context.Background(), - fieldId: "custom_field_10002", - contextId: 10001, + fieldID: "custom_field_10002", + contextID: 10001, }, on: func(fields *fields) { @@ -1325,7 +1325,7 @@ func Test_internalIssueFieldContextServiceImpl_Delete(t *testing.T) { fieldConfigService, err := NewIssueFieldContextService(testCase.fields.c, testCase.fields.version, nil) assert.NoError(t, err) - gotResponse, err := fieldConfigService.Delete(testCase.args.ctx, testCase.args.fieldId, testCase.args.contextId) + gotResponse, err := fieldConfigService.Delete(testCase.args.ctx, testCase.args.fieldID, testCase.args.contextID) if testCase.wantErr { @@ -1356,8 +1356,8 @@ func Test_internalIssueFieldContextServiceImpl_AddIssueTypes(t *testing.T) { type args struct { ctx context.Context - fieldId string - contextId int + fieldID string + contextID int issueTypesIds []string } @@ -1374,8 +1374,8 @@ func Test_internalIssueFieldContextServiceImpl_AddIssueTypes(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - fieldId: "custom_field_10002", - contextId: 10001, + fieldID: "custom_field_10002", + contextID: 10001, issueTypesIds: []string{"4", "3"}, }, on: func(fields *fields) { @@ -1406,8 +1406,8 @@ func Test_internalIssueFieldContextServiceImpl_AddIssueTypes(t *testing.T) { fields: fields{version: "2"}, args: args{ ctx: context.Background(), - fieldId: "custom_field_10002", - contextId: 10001, + fieldID: "custom_field_10002", + contextID: 10001, issueTypesIds: []string{"4", "3"}, }, on: func(fields *fields) { @@ -1438,7 +1438,7 @@ func Test_internalIssueFieldContextServiceImpl_AddIssueTypes(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - fieldId: "", + fieldID: "", }, wantErr: true, Err: model.ErrNoFieldID, @@ -1449,8 +1449,8 @@ func Test_internalIssueFieldContextServiceImpl_AddIssueTypes(t *testing.T) { fields: fields{version: "2"}, args: args{ ctx: context.Background(), - fieldId: "custom_field_10002", - contextId: 10001, + fieldID: "custom_field_10002", + contextID: 10001, issueTypesIds: []string{"4", "3"}, }, on: func(fields *fields) { @@ -1482,7 +1482,7 @@ func Test_internalIssueFieldContextServiceImpl_AddIssueTypes(t *testing.T) { fieldConfigService, err := NewIssueFieldContextService(testCase.fields.c, testCase.fields.version, nil) assert.NoError(t, err) - gotResponse, err := fieldConfigService.AddIssueTypes(testCase.args.ctx, testCase.args.fieldId, testCase.args.contextId, + gotResponse, err := fieldConfigService.AddIssueTypes(testCase.args.ctx, testCase.args.fieldID, testCase.args.contextID, testCase.args.issueTypesIds) if testCase.wantErr { @@ -1514,8 +1514,8 @@ func Test_internalIssueFieldContextServiceImpl_RemoveIssueTypes(t *testing.T) { type args struct { ctx context.Context - fieldId string - contextId int + fieldID string + contextID int issueTypesIds []string } @@ -1532,8 +1532,8 @@ func Test_internalIssueFieldContextServiceImpl_RemoveIssueTypes(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - fieldId: "custom_field_10002", - contextId: 10001, + fieldID: "custom_field_10002", + contextID: 10001, issueTypesIds: []string{"4", "3"}, }, on: func(fields *fields) { @@ -1564,8 +1564,8 @@ func Test_internalIssueFieldContextServiceImpl_RemoveIssueTypes(t *testing.T) { fields: fields{version: "2"}, args: args{ ctx: context.Background(), - fieldId: "custom_field_10002", - contextId: 10001, + fieldID: "custom_field_10002", + contextID: 10001, issueTypesIds: []string{"4", "3"}, }, on: func(fields *fields) { @@ -1596,7 +1596,7 @@ func Test_internalIssueFieldContextServiceImpl_RemoveIssueTypes(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - fieldId: "", + fieldID: "", }, wantErr: true, Err: model.ErrNoFieldID, @@ -1607,7 +1607,7 @@ func Test_internalIssueFieldContextServiceImpl_RemoveIssueTypes(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - fieldId: "custom_field_10002", + fieldID: "custom_field_10002", issueTypesIds: nil, }, wantErr: true, @@ -1619,8 +1619,8 @@ func Test_internalIssueFieldContextServiceImpl_RemoveIssueTypes(t *testing.T) { fields: fields{version: "2"}, args: args{ ctx: context.Background(), - fieldId: "custom_field_10002", - contextId: 10001, + fieldID: "custom_field_10002", + contextID: 10001, issueTypesIds: []string{"4", "3"}, }, on: func(fields *fields) { @@ -1652,7 +1652,7 @@ func Test_internalIssueFieldContextServiceImpl_RemoveIssueTypes(t *testing.T) { fieldConfigService, err := NewIssueFieldContextService(testCase.fields.c, testCase.fields.version, nil) assert.NoError(t, err) - gotResponse, err := fieldConfigService.RemoveIssueTypes(testCase.args.ctx, testCase.args.fieldId, testCase.args.contextId, + gotResponse, err := fieldConfigService.RemoveIssueTypes(testCase.args.ctx, testCase.args.fieldID, testCase.args.contextID, testCase.args.issueTypesIds) if testCase.wantErr { @@ -1684,9 +1684,9 @@ func Test_internalIssueFieldContextServiceImpl_Link(t *testing.T) { type args struct { ctx context.Context - fieldId string - contextId int - projectIds []string + fieldID string + contextID int + projectIDs []string } testCases := []struct { @@ -1702,9 +1702,9 @@ func Test_internalIssueFieldContextServiceImpl_Link(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - fieldId: "custom_field_10002", - contextId: 10001, - projectIds: []string{"4", "3"}, + fieldID: "custom_field_10002", + contextID: 10001, + projectIDs: []string{"4", "3"}, }, on: func(fields *fields) { @@ -1734,9 +1734,9 @@ func Test_internalIssueFieldContextServiceImpl_Link(t *testing.T) { fields: fields{version: "2"}, args: args{ ctx: context.Background(), - fieldId: "custom_field_10002", - contextId: 10001, - projectIds: []string{"4", "3"}, + fieldID: "custom_field_10002", + contextID: 10001, + projectIDs: []string{"4", "3"}, }, on: func(fields *fields) { @@ -1766,7 +1766,7 @@ func Test_internalIssueFieldContextServiceImpl_Link(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - fieldId: "", + fieldID: "", }, wantErr: true, Err: model.ErrNoFieldID, @@ -1777,7 +1777,7 @@ func Test_internalIssueFieldContextServiceImpl_Link(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - fieldId: "custom_field_10002", + fieldID: "custom_field_10002", }, wantErr: true, Err: model.ErrNoFieldContextID, @@ -1788,8 +1788,8 @@ func Test_internalIssueFieldContextServiceImpl_Link(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - fieldId: "custom_field_10002", - contextId: 10001, + fieldID: "custom_field_10002", + contextID: 10001, }, wantErr: true, Err: model.ErrNoProjectIDs, @@ -1800,9 +1800,9 @@ func Test_internalIssueFieldContextServiceImpl_Link(t *testing.T) { fields: fields{version: "2"}, args: args{ ctx: context.Background(), - fieldId: "custom_field_10002", - contextId: 10001, - projectIds: []string{"4", "3"}, + fieldID: "custom_field_10002", + contextID: 10001, + projectIDs: []string{"4", "3"}, }, on: func(fields *fields) { @@ -1833,8 +1833,8 @@ func Test_internalIssueFieldContextServiceImpl_Link(t *testing.T) { fieldConfigService, err := NewIssueFieldContextService(testCase.fields.c, testCase.fields.version, nil) assert.NoError(t, err) - gotResponse, err := fieldConfigService.Link(testCase.args.ctx, testCase.args.fieldId, testCase.args.contextId, - testCase.args.projectIds) + gotResponse, err := fieldConfigService.Link(testCase.args.ctx, testCase.args.fieldID, testCase.args.contextID, + testCase.args.projectIDs) if testCase.wantErr { @@ -1865,9 +1865,9 @@ func Test_internalIssueFieldContextServiceImpl_Unlink(t *testing.T) { type args struct { ctx context.Context - fieldId string - contextId int - projectIds []string + fieldID string + contextID int + projectIDs []string } testCases := []struct { @@ -1883,9 +1883,9 @@ func Test_internalIssueFieldContextServiceImpl_Unlink(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - fieldId: "custom_field_10002", - contextId: 10001, - projectIds: []string{"4", "3"}, + fieldID: "custom_field_10002", + contextID: 10001, + projectIDs: []string{"4", "3"}, }, on: func(fields *fields) { @@ -1915,9 +1915,9 @@ func Test_internalIssueFieldContextServiceImpl_Unlink(t *testing.T) { fields: fields{version: "2"}, args: args{ ctx: context.Background(), - fieldId: "custom_field_10002", - contextId: 10001, - projectIds: []string{"4", "3"}, + fieldID: "custom_field_10002", + contextID: 10001, + projectIDs: []string{"4", "3"}, }, on: func(fields *fields) { @@ -1947,7 +1947,7 @@ func Test_internalIssueFieldContextServiceImpl_Unlink(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - fieldId: "", + fieldID: "", }, wantErr: true, Err: model.ErrNoFieldID, @@ -1958,7 +1958,7 @@ func Test_internalIssueFieldContextServiceImpl_Unlink(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - fieldId: "custom_field_10002", + fieldID: "custom_field_10002", }, wantErr: true, Err: model.ErrNoFieldContextID, @@ -1969,8 +1969,8 @@ func Test_internalIssueFieldContextServiceImpl_Unlink(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - fieldId: "custom_field_10002", - contextId: 10001, + fieldID: "custom_field_10002", + contextID: 10001, }, wantErr: true, Err: model.ErrNoProjectIDs, @@ -1981,9 +1981,9 @@ func Test_internalIssueFieldContextServiceImpl_Unlink(t *testing.T) { fields: fields{version: "2"}, args: args{ ctx: context.Background(), - fieldId: "custom_field_10002", - contextId: 10001, - projectIds: []string{"4", "3"}, + fieldID: "custom_field_10002", + contextID: 10001, + projectIDs: []string{"4", "3"}, }, on: func(fields *fields) { @@ -2014,8 +2014,8 @@ func Test_internalIssueFieldContextServiceImpl_Unlink(t *testing.T) { fieldConfigService, err := NewIssueFieldContextService(testCase.fields.c, testCase.fields.version, nil) assert.NoError(t, err) - gotResponse, err := fieldConfigService.UnLink(testCase.args.ctx, testCase.args.fieldId, testCase.args.contextId, - testCase.args.projectIds) + gotResponse, err := fieldConfigService.UnLink(testCase.args.ctx, testCase.args.fieldID, testCase.args.contextID, + testCase.args.projectIDs) if testCase.wantErr { diff --git a/jira/internal/field_context_option_impl.go b/jira/internal/field_context_option_impl.go index bac04642..ea9de1d0 100644 --- a/jira/internal/field_context_option_impl.go +++ b/jira/internal/field_context_option_impl.go @@ -36,11 +36,11 @@ type IssueFieldContextOptionService struct { // // Options are returned first then cascading options, in the order they display in Jira. // -// GET /rest/api/{2-3}/field/{fieldID}/context/{contextId}/option +// GET /rest/api/{2-3}/field/{fieldID}/context/{contextID}/option // // https://docs.go-atlassian.io/jira-software-cloud/issues/fields/context/option#get-custom-field-options -func (i *IssueFieldContextOptionService) Gets(ctx context.Context, fieldID string, contextId int, options *model.FieldOptionContextParams, startAt, maxResults int) (*model.CustomFieldContextOptionPageScheme, *model.ResponseScheme, error) { - return i.internalClient.Gets(ctx, fieldID, contextId, options, startAt, maxResults) +func (i *IssueFieldContextOptionService) Gets(ctx context.Context, fieldID string, contextID int, options *model.FieldOptionContextParams, startAt, maxResults int) (*model.CustomFieldContextOptionPageScheme, *model.ResponseScheme, error) { + return i.internalClient.Gets(ctx, fieldID, contextID, options, startAt, maxResults) } // Create creates options and, where the custom select field is of the type Select List (cascading), cascading options for a custom select field. @@ -49,11 +49,11 @@ func (i *IssueFieldContextOptionService) Gets(ctx context.Context, fieldID strin // // 2. The maximum number of options that can be created per request is 1000 and each field can have a maximum of 10000 options. // -// POST /rest/api/{2-3}/field/{fieldID}/context/{contextId}/option +// POST /rest/api/{2-3}/field/{fieldID}/context/{contextID}/option // // https://docs.go-atlassian.io/jira-software-cloud/issues/fields/context/option#create-custom-field-options -func (i *IssueFieldContextOptionService) Create(ctx context.Context, fieldID string, contextId int, payload *model.FieldContextOptionListScheme) (*model.FieldContextOptionListScheme, *model.ResponseScheme, error) { - return i.internalClient.Create(ctx, fieldID, contextId, payload) +func (i *IssueFieldContextOptionService) Create(ctx context.Context, fieldID string, contextID int, payload *model.FieldContextOptionListScheme) (*model.FieldContextOptionListScheme, *model.ResponseScheme, error) { + return i.internalClient.Create(ctx, fieldID, contextID, payload) } // Update updates the options of a custom field. @@ -62,31 +62,31 @@ func (i *IssueFieldContextOptionService) Create(ctx context.Context, fieldID str // // 2. Options where the values in the request match the current values aren't updated and aren't reported in the response. // -// PUT /rest/api/{2-3}/field/{fieldID}/context/{contextId}/option +// PUT /rest/api/{2-3}/field/{fieldID}/context/{contextID}/option // // https://docs.go-atlassian.io/jira-software-cloud/issues/fields/context/option#update-custom-field-options -func (i *IssueFieldContextOptionService) Update(ctx context.Context, fieldID string, contextId int, payload *model.FieldContextOptionListScheme) (*model.FieldContextOptionListScheme, *model.ResponseScheme, error) { - return i.internalClient.Update(ctx, fieldID, contextId, payload) +func (i *IssueFieldContextOptionService) Update(ctx context.Context, fieldID string, contextID int, payload *model.FieldContextOptionListScheme) (*model.FieldContextOptionListScheme, *model.ResponseScheme, error) { + return i.internalClient.Update(ctx, fieldID, contextID, payload) } // Delete deletes a custom field option. // // 1. Options with cascading options cannot be deleted without deleting the cascading options first. // -// DELETE /rest/api/{2-3}/field/{fieldID}/context/{contextId}/option/{optionId} +// DELETE /rest/api/{2-3}/field/{fieldID}/context/{contextID}/option/{optionID} // // https://docs.go-atlassian.io/jira-software-cloud/issues/fields/context/option#delete-custom-field-options -func (i *IssueFieldContextOptionService) Delete(ctx context.Context, fieldID string, contextId, optionId int) (*model.ResponseScheme, error) { - return i.internalClient.Delete(ctx, fieldID, contextId, optionId) +func (i *IssueFieldContextOptionService) Delete(ctx context.Context, fieldID string, contextID, optionID int) (*model.ResponseScheme, error) { + return i.internalClient.Delete(ctx, fieldID, contextID, optionID) } // Order changes the order of custom field options or cascading options in a context. // -// PUT /rest/api/{2-3}/field/{fieldID}/context/{contextId}/option/move +// PUT /rest/api/{2-3}/field/{fieldID}/context/{contextID}/option/move // // https://docs.go-atlassian.io/jira-software-cloud/issues/fields/context/option#reorder-custom-field-options -func (i *IssueFieldContextOptionService) Order(ctx context.Context, fieldID string, contextId int, payload *model.OrderFieldOptionPayloadScheme) (*model.ResponseScheme, error) { - return i.internalClient.Order(ctx, fieldID, contextId, payload) +func (i *IssueFieldContextOptionService) Order(ctx context.Context, fieldID string, contextID int, payload *model.OrderFieldOptionPayloadScheme) (*model.ResponseScheme, error) { + return i.internalClient.Order(ctx, fieldID, contextID, payload) } type internalIssueFieldContextOptionServiceImpl struct { @@ -94,7 +94,7 @@ type internalIssueFieldContextOptionServiceImpl struct { version string } -func (i *internalIssueFieldContextOptionServiceImpl) Gets(ctx context.Context, fieldID string, contextId int, options *model.FieldOptionContextParams, startAt, maxResults int) (*model.CustomFieldContextOptionPageScheme, *model.ResponseScheme, error) { +func (i *internalIssueFieldContextOptionServiceImpl) Gets(ctx context.Context, fieldID string, contextID int, options *model.FieldOptionContextParams, startAt, maxResults int) (*model.CustomFieldContextOptionPageScheme, *model.ResponseScheme, error) { if fieldID == "" { return nil, nil, model.ErrNoFieldID @@ -112,7 +112,7 @@ func (i *internalIssueFieldContextOptionServiceImpl) Gets(ctx context.Context, f } } - endpoint := fmt.Sprintf("rest/api/%v/field/%v/context/%v/option?%v", i.version, fieldID, contextId, params.Encode()) + endpoint := fmt.Sprintf("rest/api/%v/field/%v/context/%v/option?%v", i.version, fieldID, contextID, params.Encode()) request, err := i.c.NewRequest(ctx, http.MethodGet, endpoint, "", nil) if err != nil { @@ -128,17 +128,17 @@ func (i *internalIssueFieldContextOptionServiceImpl) Gets(ctx context.Context, f return pagination, response, nil } -func (i *internalIssueFieldContextOptionServiceImpl) Create(ctx context.Context, fieldID string, contextId int, payload *model.FieldContextOptionListScheme) (*model.FieldContextOptionListScheme, *model.ResponseScheme, error) { +func (i *internalIssueFieldContextOptionServiceImpl) Create(ctx context.Context, fieldID string, contextID int, payload *model.FieldContextOptionListScheme) (*model.FieldContextOptionListScheme, *model.ResponseScheme, error) { if fieldID == "" { return nil, nil, model.ErrNoFieldID } - if contextId == 0 { + if contextID == 0 { return nil, nil, model.ErrNoFieldContextID } - endpoint := fmt.Sprintf("rest/api/%v/field/%v/context/%v/option", i.version, fieldID, contextId) + endpoint := fmt.Sprintf("rest/api/%v/field/%v/context/%v/option", i.version, fieldID, contextID) request, err := i.c.NewRequest(ctx, http.MethodPost, endpoint, "", payload) if err != nil { @@ -154,17 +154,17 @@ func (i *internalIssueFieldContextOptionServiceImpl) Create(ctx context.Context, return options, response, nil } -func (i *internalIssueFieldContextOptionServiceImpl) Update(ctx context.Context, fieldId string, contextId int, payload *model.FieldContextOptionListScheme) (*model.FieldContextOptionListScheme, *model.ResponseScheme, error) { +func (i *internalIssueFieldContextOptionServiceImpl) Update(ctx context.Context, fieldID string, contextID int, payload *model.FieldContextOptionListScheme) (*model.FieldContextOptionListScheme, *model.ResponseScheme, error) { - if fieldId == "" { + if fieldID == "" { return nil, nil, model.ErrNoFieldID } - if contextId == 0 { + if contextID == 0 { return nil, nil, model.ErrNoFieldContextID } - endpoint := fmt.Sprintf("rest/api/%v/field/%v/context/%v/option", i.version, fieldId, contextId) + endpoint := fmt.Sprintf("rest/api/%v/field/%v/context/%v/option", i.version, fieldID, contextID) request, err := i.c.NewRequest(ctx, http.MethodPut, endpoint, "", payload) if err != nil { @@ -180,21 +180,21 @@ func (i *internalIssueFieldContextOptionServiceImpl) Update(ctx context.Context, return options, response, nil } -func (i *internalIssueFieldContextOptionServiceImpl) Delete(ctx context.Context, fieldId string, contextId, optionId int) (*model.ResponseScheme, error) { +func (i *internalIssueFieldContextOptionServiceImpl) Delete(ctx context.Context, fieldID string, contextID, optionID int) (*model.ResponseScheme, error) { - if fieldId == "" { + if fieldID == "" { return nil, model.ErrNoFieldID } - if contextId == 0 { + if contextID == 0 { return nil, model.ErrNoFieldContextID } - if optionId == 0 { + if optionID == 0 { return nil, model.ErrNoContextOptionID } - endpoint := fmt.Sprintf("rest/api/%v/field/%v/context/%v/option/%v", i.version, fieldId, contextId, optionId) + endpoint := fmt.Sprintf("rest/api/%v/field/%v/context/%v/option/%v", i.version, fieldID, contextID, optionID) request, err := i.c.NewRequest(ctx, http.MethodDelete, endpoint, "", nil) if err != nil { @@ -204,17 +204,17 @@ func (i *internalIssueFieldContextOptionServiceImpl) Delete(ctx context.Context, return i.c.Call(request, nil) } -func (i *internalIssueFieldContextOptionServiceImpl) Order(ctx context.Context, fieldId string, contextId int, payload *model.OrderFieldOptionPayloadScheme) (*model.ResponseScheme, error) { +func (i *internalIssueFieldContextOptionServiceImpl) Order(ctx context.Context, fieldID string, contextID int, payload *model.OrderFieldOptionPayloadScheme) (*model.ResponseScheme, error) { - if fieldId == "" { + if fieldID == "" { return nil, model.ErrNoFieldID } - if contextId == 0 { + if contextID == 0 { return nil, model.ErrNoFieldContextID } - endpoint := fmt.Sprintf("rest/api/%v/field/%v/context/%v/option/move", i.version, fieldId, contextId) + endpoint := fmt.Sprintf("rest/api/%v/field/%v/context/%v/option/move", i.version, fieldID, contextID) request, err := i.c.NewRequest(ctx, http.MethodPut, endpoint, "", payload) if err != nil { diff --git a/jira/internal/field_context_option_impl_test.go b/jira/internal/field_context_option_impl_test.go index 7624622b..e694c8d7 100644 --- a/jira/internal/field_context_option_impl_test.go +++ b/jira/internal/field_context_option_impl_test.go @@ -23,7 +23,7 @@ func Test_internalIssueFieldContextOptionServiceImpl_Gets(t *testing.T) { type args struct { ctx context.Context fieldID string - contextId int + contextID int options *model.FieldOptionContextParams startAt, maxResults int } @@ -42,7 +42,7 @@ func Test_internalIssueFieldContextOptionServiceImpl_Gets(t *testing.T) { args: args{ ctx: context.Background(), fieldID: "custom_field_10002", - contextId: 10001, + contextID: 10001, options: &model.FieldOptionContextParams{ OptionID: 3022, OnlyOptions: false, @@ -79,7 +79,7 @@ func Test_internalIssueFieldContextOptionServiceImpl_Gets(t *testing.T) { args: args{ ctx: context.Background(), fieldID: "custom_field_10002", - contextId: 10001, + contextID: 10001, options: &model.FieldOptionContextParams{ OptionID: 3022, OnlyOptions: false, @@ -116,7 +116,7 @@ func Test_internalIssueFieldContextOptionServiceImpl_Gets(t *testing.T) { args: args{ ctx: context.Background(), fieldID: "", - contextId: 10001, + contextID: 10001, options: &model.FieldOptionContextParams{ OptionID: 3022, OnlyOptions: false, @@ -134,7 +134,7 @@ func Test_internalIssueFieldContextOptionServiceImpl_Gets(t *testing.T) { args: args{ ctx: context.Background(), fieldID: "custom_field_10002", - contextId: 10001, + contextID: 10001, options: &model.FieldOptionContextParams{ OptionID: 3022, OnlyOptions: false, @@ -171,7 +171,7 @@ func Test_internalIssueFieldContextOptionServiceImpl_Gets(t *testing.T) { fieldConfigService, err := NewIssueFieldContextOptionService(testCase.fields.c, testCase.fields.version) assert.NoError(t, err) - gotResult, gotResponse, err := fieldConfigService.Gets(testCase.args.ctx, testCase.args.fieldID, testCase.args.contextId, + gotResult, gotResponse, err := fieldConfigService.Gets(testCase.args.ctx, testCase.args.fieldID, testCase.args.contextID, testCase.args.options, testCase.args.startAt, testCase.args.maxResults) if testCase.wantErr { @@ -218,7 +218,7 @@ func Test_internalIssueFieldContextOptionServiceImpl_Create(t *testing.T) { type args struct { ctx context.Context fieldID string - contextId int + contextID int payload *model.FieldContextOptionListScheme } @@ -236,7 +236,7 @@ func Test_internalIssueFieldContextOptionServiceImpl_Create(t *testing.T) { args: args{ ctx: context.Background(), fieldID: "custom_field_10002", - contextId: 10001, + contextID: 10001, payload: payloadMocked, }, on: func(fields *fields) { @@ -268,7 +268,7 @@ func Test_internalIssueFieldContextOptionServiceImpl_Create(t *testing.T) { args: args{ ctx: context.Background(), fieldID: "custom_field_10002", - contextId: 10001, + contextID: 10001, payload: payloadMocked, }, on: func(fields *fields) { @@ -300,7 +300,7 @@ func Test_internalIssueFieldContextOptionServiceImpl_Create(t *testing.T) { args: args{ ctx: context.Background(), fieldID: "", - contextId: 10001, + contextID: 10001, }, wantErr: true, Err: model.ErrNoFieldID, @@ -312,7 +312,7 @@ func Test_internalIssueFieldContextOptionServiceImpl_Create(t *testing.T) { args: args{ ctx: context.Background(), fieldID: "customfield_1000", - contextId: 0, + contextID: 0, }, wantErr: true, Err: model.ErrNoFieldContextID, @@ -324,7 +324,7 @@ func Test_internalIssueFieldContextOptionServiceImpl_Create(t *testing.T) { args: args{ ctx: context.Background(), fieldID: "custom_field_10002", - contextId: 10001, + contextID: 10001, payload: payloadMocked, }, on: func(fields *fields) { @@ -356,7 +356,7 @@ func Test_internalIssueFieldContextOptionServiceImpl_Create(t *testing.T) { fieldConfigService, err := NewIssueFieldContextOptionService(testCase.fields.c, testCase.fields.version) assert.NoError(t, err) - gotResult, gotResponse, err := fieldConfigService.Create(testCase.args.ctx, testCase.args.fieldID, testCase.args.contextId, + gotResult, gotResponse, err := fieldConfigService.Create(testCase.args.ctx, testCase.args.fieldID, testCase.args.contextID, testCase.args.payload) if testCase.wantErr { @@ -403,7 +403,7 @@ func Test_internalIssueFieldContextOptionServiceImpl_Update(t *testing.T) { type args struct { ctx context.Context fieldID string - contextId int + contextID int payload *model.FieldContextOptionListScheme } @@ -421,7 +421,7 @@ func Test_internalIssueFieldContextOptionServiceImpl_Update(t *testing.T) { args: args{ ctx: context.Background(), fieldID: "custom_field_10002", - contextId: 10001, + contextID: 10001, payload: payloadMocked, }, on: func(fields *fields) { @@ -453,7 +453,7 @@ func Test_internalIssueFieldContextOptionServiceImpl_Update(t *testing.T) { args: args{ ctx: context.Background(), fieldID: "custom_field_10002", - contextId: 10001, + contextID: 10001, payload: payloadMocked, }, on: func(fields *fields) { @@ -485,7 +485,7 @@ func Test_internalIssueFieldContextOptionServiceImpl_Update(t *testing.T) { args: args{ ctx: context.Background(), fieldID: "", - contextId: 10001, + contextID: 10001, }, wantErr: true, Err: model.ErrNoFieldID, @@ -497,7 +497,7 @@ func Test_internalIssueFieldContextOptionServiceImpl_Update(t *testing.T) { args: args{ ctx: context.Background(), fieldID: "customfield_1000", - contextId: 0, + contextID: 0, }, wantErr: true, Err: model.ErrNoFieldContextID, @@ -509,7 +509,7 @@ func Test_internalIssueFieldContextOptionServiceImpl_Update(t *testing.T) { args: args{ ctx: context.Background(), fieldID: "custom_field_10002", - contextId: 10001, + contextID: 10001, payload: payloadMocked, }, on: func(fields *fields) { @@ -541,7 +541,7 @@ func Test_internalIssueFieldContextOptionServiceImpl_Update(t *testing.T) { fieldConfigService, err := NewIssueFieldContextOptionService(testCase.fields.c, testCase.fields.version) assert.NoError(t, err) - gotResult, gotResponse, err := fieldConfigService.Update(testCase.args.ctx, testCase.args.fieldID, testCase.args.contextId, + gotResult, gotResponse, err := fieldConfigService.Update(testCase.args.ctx, testCase.args.fieldID, testCase.args.contextID, testCase.args.payload) if testCase.wantErr { @@ -573,8 +573,8 @@ func Test_internalIssueFieldContextOptionServiceImpl_Delete(t *testing.T) { type args struct { ctx context.Context fieldID string - contextId int - optionId int + contextID int + optionID int } testCases := []struct { @@ -591,8 +591,8 @@ func Test_internalIssueFieldContextOptionServiceImpl_Delete(t *testing.T) { args: args{ ctx: context.Background(), fieldID: "custom_field_10002", - contextId: 10001, - optionId: 1001, + contextID: 10001, + optionID: 1001, }, on: func(fields *fields) { @@ -623,8 +623,8 @@ func Test_internalIssueFieldContextOptionServiceImpl_Delete(t *testing.T) { args: args{ ctx: context.Background(), fieldID: "custom_field_10002", - contextId: 10001, - optionId: 1001, + contextID: 10001, + optionID: 1001, }, on: func(fields *fields) { @@ -655,7 +655,7 @@ func Test_internalIssueFieldContextOptionServiceImpl_Delete(t *testing.T) { args: args{ ctx: context.Background(), fieldID: "", - contextId: 10001, + contextID: 10001, }, wantErr: true, Err: model.ErrNoFieldID, @@ -667,7 +667,7 @@ func Test_internalIssueFieldContextOptionServiceImpl_Delete(t *testing.T) { args: args{ ctx: context.Background(), fieldID: "customfield_1000", - contextId: 0, + contextID: 0, }, wantErr: true, Err: model.ErrNoFieldContextID, @@ -679,8 +679,8 @@ func Test_internalIssueFieldContextOptionServiceImpl_Delete(t *testing.T) { args: args{ ctx: context.Background(), fieldID: "customfield_1000", - contextId: 1000, - optionId: 0, + contextID: 1000, + optionID: 0, }, wantErr: true, @@ -693,8 +693,8 @@ func Test_internalIssueFieldContextOptionServiceImpl_Delete(t *testing.T) { args: args{ ctx: context.Background(), fieldID: "custom_field_10002", - contextId: 10001, - optionId: 1001, + contextID: 10001, + optionID: 1001, }, on: func(fields *fields) { @@ -725,8 +725,8 @@ func Test_internalIssueFieldContextOptionServiceImpl_Delete(t *testing.T) { fieldConfigService, err := NewIssueFieldContextOptionService(testCase.fields.c, testCase.fields.version) assert.NoError(t, err) - gotResponse, err := fieldConfigService.Delete(testCase.args.ctx, testCase.args.fieldID, testCase.args.contextId, - testCase.args.optionId) + gotResponse, err := fieldConfigService.Delete(testCase.args.ctx, testCase.args.fieldID, testCase.args.contextID, + testCase.args.optionID) if testCase.wantErr { @@ -760,8 +760,8 @@ func Test_internalIssueFieldContextOptionServiceImpl_Order(t *testing.T) { type args struct { ctx context.Context - fieldId string - contextId int + fieldID string + contextID int payload *model.OrderFieldOptionPayloadScheme } @@ -778,8 +778,8 @@ func Test_internalIssueFieldContextOptionServiceImpl_Order(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - fieldId: "custom_field_10002", - contextId: 10001, + fieldID: "custom_field_10002", + contextID: 10001, payload: payloadMocked, }, on: func(fields *fields) { @@ -810,8 +810,8 @@ func Test_internalIssueFieldContextOptionServiceImpl_Order(t *testing.T) { fields: fields{version: "2"}, args: args{ ctx: context.Background(), - fieldId: "custom_field_10002", - contextId: 10001, + fieldID: "custom_field_10002", + contextID: 10001, payload: payloadMocked, }, on: func(fields *fields) { @@ -842,8 +842,8 @@ func Test_internalIssueFieldContextOptionServiceImpl_Order(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - fieldId: "", - contextId: 10001, + fieldID: "", + contextID: 10001, }, wantErr: true, Err: model.ErrNoFieldID, @@ -854,8 +854,8 @@ func Test_internalIssueFieldContextOptionServiceImpl_Order(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - fieldId: "customfield_1000", - contextId: 0, + fieldID: "customfield_1000", + contextID: 0, }, wantErr: true, Err: model.ErrNoFieldContextID, @@ -866,8 +866,8 @@ func Test_internalIssueFieldContextOptionServiceImpl_Order(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - fieldId: "custom_field_10002", - contextId: 10001, + fieldID: "custom_field_10002", + contextID: 10001, payload: payloadMocked, }, on: func(fields *fields) { @@ -899,7 +899,7 @@ func Test_internalIssueFieldContextOptionServiceImpl_Order(t *testing.T) { fieldConfigService, err := NewIssueFieldContextOptionService(testCase.fields.c, testCase.fields.version) assert.NoError(t, err) - gotResponse, err := fieldConfigService.Order(testCase.args.ctx, testCase.args.fieldId, testCase.args.contextId, + gotResponse, err := fieldConfigService.Order(testCase.args.ctx, testCase.args.fieldID, testCase.args.contextID, testCase.args.payload) if testCase.wantErr { diff --git a/jira/internal/issue_impl_rich_text_test.go b/jira/internal/issue_impl_rich_text_test.go index 480151a3..dcbf4afc 100644 --- a/jira/internal/issue_impl_rich_text_test.go +++ b/jira/internal/issue_impl_rich_text_test.go @@ -144,7 +144,7 @@ func Test_internalRichTextServiceImpl_Assign(t *testing.T) { type args struct { ctx context.Context - issueKeyOrID, accountId string + issueKeyOrID, accountID string } testCases := []struct { @@ -161,7 +161,7 @@ func Test_internalRichTextServiceImpl_Assign(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "DUMMY-1", - accountId: "account-id-sample", + accountID: "account-id-sample", }, on: func(fields *fields) { @@ -190,7 +190,7 @@ func Test_internalRichTextServiceImpl_Assign(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "", - accountId: "account-id-sample", + accountID: "account-id-sample", }, on: func(fields *fields) { fields.c = mocks.NewConnector(t) @@ -205,7 +205,7 @@ func Test_internalRichTextServiceImpl_Assign(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "DUMMY-1", - accountId: "", + accountID: "", }, on: func(fields *fields) { fields.c = mocks.NewConnector(t) @@ -220,7 +220,7 @@ func Test_internalRichTextServiceImpl_Assign(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "DUMMY-1", - accountId: "account-id-sample", + accountID: "account-id-sample", }, on: func(fields *fields) { @@ -251,7 +251,7 @@ func Test_internalRichTextServiceImpl_Assign(t *testing.T) { issueService, _, err := NewIssueService(testCase.fields.c, testCase.fields.version, nil) assert.NoError(t, err) - gotResponse, err := issueService.Assign(testCase.args.ctx, testCase.args.issueKeyOrID, testCase.args.accountId) + gotResponse, err := issueService.Assign(testCase.args.ctx, testCase.args.issueKeyOrID, testCase.args.accountID) if testCase.wantErr { @@ -1073,7 +1073,7 @@ func Test_internalRichTextServiceImpl_Move(t *testing.T) { type args struct { ctx context.Context - issueKeyOrID, transitionId string + issueKeyOrID, transitionID string options *model.IssueMoveOptionsV2 } @@ -1091,7 +1091,7 @@ func Test_internalRichTextServiceImpl_Move(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "DUMMY-1", - transitionId: "10001", + transitionID: "10001", options: &model.IssueMoveOptionsV2{ Fields: &model.IssueSchemeV2{ Fields: &model.IssueFieldsSchemeV2{ @@ -1131,7 +1131,7 @@ func Test_internalRichTextServiceImpl_Move(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "DUMMY-1", - transitionId: "10001", + transitionID: "10001", options: &model.IssueMoveOptionsV2{ CustomFields: customFieldsMocked, Operations: operationsMocked, @@ -1147,7 +1147,7 @@ func Test_internalRichTextServiceImpl_Move(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "DUMMY-1", - transitionId: "10001", + transitionID: "10001", options: &model.IssueMoveOptionsV2{ Fields: &model.IssueSchemeV2{ Fields: &model.IssueFieldsSchemeV2{ @@ -1187,7 +1187,7 @@ func Test_internalRichTextServiceImpl_Move(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "DUMMY-1", - transitionId: "10001", + transitionID: "10001", options: &model.IssueMoveOptionsV2{ Fields: &model.IssueSchemeV2{ Fields: &model.IssueFieldsSchemeV2{ @@ -1227,7 +1227,7 @@ func Test_internalRichTextServiceImpl_Move(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "DUMMY-1", - transitionId: "10001", + transitionID: "10001", options: nil, }, on: func(fields *fields) { @@ -1257,7 +1257,7 @@ func Test_internalRichTextServiceImpl_Move(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "", - transitionId: "10001", + transitionID: "10001", options: &model.IssueMoveOptionsV2{ Fields: &model.IssueSchemeV2{ Fields: &model.IssueFieldsSchemeV2{ @@ -1283,7 +1283,7 @@ func Test_internalRichTextServiceImpl_Move(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "DUMMY-1", - transitionId: "", + transitionID: "", options: &model.IssueMoveOptionsV2{ Fields: &model.IssueSchemeV2{ Fields: &model.IssueFieldsSchemeV2{ @@ -1309,7 +1309,7 @@ func Test_internalRichTextServiceImpl_Move(t *testing.T) { args: args{ ctx: context.Background(), issueKeyOrID: "DUMMY-1", - transitionId: "10001", + transitionID: "10001", options: &model.IssueMoveOptionsV2{ Fields: &model.IssueSchemeV2{ Fields: &model.IssueFieldsSchemeV2{ @@ -1351,7 +1351,7 @@ func Test_internalRichTextServiceImpl_Move(t *testing.T) { issueService, _, err := NewIssueService(testCase.fields.c, testCase.fields.version, nil) assert.NoError(t, err) - gotResponse, err := issueService.Move(testCase.args.ctx, testCase.args.issueKeyOrID, testCase.args.transitionId, + gotResponse, err := issueService.Move(testCase.args.ctx, testCase.args.issueKeyOrID, testCase.args.transitionID, testCase.args.options) if testCase.wantErr { diff --git a/jira/internal/link_impl.go b/jira/internal/link_impl.go index 5298280f..117d8ac4 100644 --- a/jira/internal/link_impl.go +++ b/jira/internal/link_impl.go @@ -6,7 +6,7 @@ import ( ) // NewLinkService creates new instances of LinkADFService and LinkRichTextService. -func NewLinkService(client service.Connector, version string, type_ *LinkTypeService, remote *RemoteLinkService) (*LinkADFService, *LinkRichTextService, error) { +func NewLinkService(client service.Connector, version string, linkType *LinkTypeService, remote *RemoteLinkService) (*LinkADFService, *LinkRichTextService, error) { if version == "" { return nil, nil, model.ErrNoVersionProvided @@ -17,7 +17,7 @@ func NewLinkService(client service.Connector, version string, type_ *LinkTypeSer c: client, version: version, }, - Type: type_, + Type: linkType, Remote: remote, } @@ -26,7 +26,7 @@ func NewLinkService(client service.Connector, version string, type_ *LinkTypeSer c: client, version: version, }, - Type: type_, + Type: linkType, Remote: remote, } diff --git a/jira/internal/link_impl_rich_text_test.go b/jira/internal/link_impl_rich_text_test.go index 6ac900d7..afbc28a9 100644 --- a/jira/internal/link_impl_rich_text_test.go +++ b/jira/internal/link_impl_rich_text_test.go @@ -22,7 +22,7 @@ func Test_internalLinkRichTextServiceImpl_Get(t *testing.T) { type args struct { ctx context.Context - linkId string + linkID string } testCases := []struct { @@ -38,7 +38,7 @@ func Test_internalLinkRichTextServiceImpl_Get(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - linkId: "10002", + linkID: "10002", }, on: func(fields *fields) { @@ -68,7 +68,7 @@ func Test_internalLinkRichTextServiceImpl_Get(t *testing.T) { fields: fields{version: "2"}, args: args{ ctx: context.Background(), - linkId: "10002", + linkID: "10002", }, on: func(fields *fields) { @@ -98,7 +98,7 @@ func Test_internalLinkRichTextServiceImpl_Get(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - linkId: "10002", + linkID: "10002", }, on: func(fields *fields) { @@ -123,7 +123,7 @@ func Test_internalLinkRichTextServiceImpl_Get(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - linkId: "", + linkID: "", }, wantErr: true, Err: model.ErrNoTypeID, @@ -140,7 +140,7 @@ func Test_internalLinkRichTextServiceImpl_Get(t *testing.T) { _, linkService, err := NewLinkService(testCase.fields.c, testCase.fields.version, nil, nil) assert.NoError(t, err) - gotResult, gotResponse, err := linkService.Get(testCase.args.ctx, testCase.args.linkId) + gotResult, gotResponse, err := linkService.Get(testCase.args.ctx, testCase.args.linkID) if testCase.wantErr { @@ -318,7 +318,7 @@ func Test_internalLinkRichTextServiceImpl_Delete(t *testing.T) { type args struct { ctx context.Context - linkId string + linkID string } testCases := []struct { @@ -334,7 +334,7 @@ func Test_internalLinkRichTextServiceImpl_Delete(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - linkId: "10002", + linkID: "10002", }, on: func(fields *fields) { @@ -364,7 +364,7 @@ func Test_internalLinkRichTextServiceImpl_Delete(t *testing.T) { fields: fields{version: "2"}, args: args{ ctx: context.Background(), - linkId: "10002", + linkID: "10002", }, on: func(fields *fields) { @@ -394,7 +394,7 @@ func Test_internalLinkRichTextServiceImpl_Delete(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - linkId: "10002", + linkID: "10002", }, on: func(fields *fields) { @@ -419,7 +419,7 @@ func Test_internalLinkRichTextServiceImpl_Delete(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - linkId: "", + linkID: "", }, wantErr: true, Err: model.ErrNoTypeID, @@ -436,7 +436,7 @@ func Test_internalLinkRichTextServiceImpl_Delete(t *testing.T) { _, linkService, err := NewLinkService(testCase.fields.c, testCase.fields.version, nil, nil) assert.NoError(t, err) - gotResponse, err := linkService.Delete(testCase.args.ctx, testCase.args.linkId) + gotResponse, err := linkService.Delete(testCase.args.ctx, testCase.args.linkID) if testCase.wantErr { diff --git a/jira/internal/notification_scheme_impl.go b/jira/internal/notification_scheme_impl.go index 56463afc..81055ee0 100644 --- a/jira/internal/notification_scheme_impl.go +++ b/jira/internal/notification_scheme_impl.go @@ -3,13 +3,14 @@ package internal import ( "context" "fmt" - model "github.com/ctreminiom/go-atlassian/pkg/infra/models" - "github.com/ctreminiom/go-atlassian/service" - "github.com/ctreminiom/go-atlassian/service/jira" "net/http" "net/url" "strconv" "strings" + + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" + "github.com/ctreminiom/go-atlassian/service" + "github.com/ctreminiom/go-atlassian/service/jira" ) // NewNotificationSchemeService creates a new instance of NotificationSchemeService. @@ -58,7 +59,7 @@ func (n *NotificationSchemeService) Create(ctx context.Context, payload *model.N // // This is because team-managed projects don't have a concept of a default notification scheme. // -// The mappings are ordered by projectId. +// The mappings are ordered by projectID. // // GET /rest/api/{2-3}/notificationscheme/project func (n *NotificationSchemeService) Projects(ctx context.Context, schemeIDs, projectIDs []string, startAt, maxResults int) (*model.NotificationSchemeProjectPageScheme, *model.ResponseScheme, error) { diff --git a/jira/internal/project_permission_scheme_impl_test.go b/jira/internal/project_permission_scheme_impl_test.go index b5b920c6..5f36b90b 100644 --- a/jira/internal/project_permission_scheme_impl_test.go +++ b/jira/internal/project_permission_scheme_impl_test.go @@ -316,7 +316,7 @@ func Test_internalProjectPermissionSchemeImpl_Assign(t *testing.T) { type args struct { ctx context.Context - projectKeyOrId string + projectKeyOrID string permissionSchemeID int } @@ -333,7 +333,7 @@ func Test_internalProjectPermissionSchemeImpl_Assign(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - projectKeyOrId: "DUMMY", + projectKeyOrID: "DUMMY", permissionSchemeID: 10001, }, on: func(fields *fields) { @@ -363,7 +363,7 @@ func Test_internalProjectPermissionSchemeImpl_Assign(t *testing.T) { fields: fields{version: "2"}, args: args{ ctx: context.Background(), - projectKeyOrId: "DUMMY", + projectKeyOrID: "DUMMY", permissionSchemeID: 10001, }, on: func(fields *fields) { @@ -403,7 +403,7 @@ func Test_internalProjectPermissionSchemeImpl_Assign(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - projectKeyOrId: "DUMMY", + projectKeyOrID: "DUMMY", permissionSchemeID: 10001, }, on: func(fields *fields) { @@ -434,7 +434,7 @@ func Test_internalProjectPermissionSchemeImpl_Assign(t *testing.T) { newService, err := NewProjectPermissionSchemeService(testCase.fields.c, testCase.fields.version) assert.NoError(t, err) - gotResult, gotResponse, err := newService.Assign(testCase.args.ctx, testCase.args.projectKeyOrId, testCase.args.permissionSchemeID) + gotResult, gotResponse, err := newService.Assign(testCase.args.ctx, testCase.args.projectKeyOrID, testCase.args.permissionSchemeID) if testCase.wantErr { diff --git a/jira/internal/project_property_impl_test.go b/jira/internal/project_property_impl_test.go index 670fb9d1..e818307f 100644 --- a/jira/internal/project_property_impl_test.go +++ b/jira/internal/project_property_impl_test.go @@ -488,7 +488,7 @@ func Test_internalProjectPropertyImpl_Set(t *testing.T) { type args struct { ctx context.Context - projectKeyOrId string + projectKeyOrID string propertyKey string payload interface{} } @@ -506,7 +506,7 @@ func Test_internalProjectPropertyImpl_Set(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - projectKeyOrId: "DUMMY", + projectKeyOrID: "DUMMY", propertyKey: "alliance", payload: payloadMocked, }, @@ -537,7 +537,7 @@ func Test_internalProjectPropertyImpl_Set(t *testing.T) { fields: fields{version: "2"}, args: args{ ctx: context.Background(), - projectKeyOrId: "DUMMY", + projectKeyOrID: "DUMMY", propertyKey: "alliance", payload: payloadMocked, }, @@ -578,7 +578,7 @@ func Test_internalProjectPropertyImpl_Set(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - projectKeyOrId: "DUMMY", + projectKeyOrID: "DUMMY", }, wantErr: true, Err: model.ErrNoPropertyKey, @@ -589,7 +589,7 @@ func Test_internalProjectPropertyImpl_Set(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - projectKeyOrId: "DUMMY", + projectKeyOrID: "DUMMY", propertyKey: "alliance", payload: payloadMocked, }, @@ -621,7 +621,7 @@ func Test_internalProjectPropertyImpl_Set(t *testing.T) { newService, err := NewProjectPropertyService(testCase.fields.c, testCase.fields.version) assert.NoError(t, err) - gotResponse, err := newService.Set(testCase.args.ctx, testCase.args.projectKeyOrId, testCase.args.propertyKey, + gotResponse, err := newService.Set(testCase.args.ctx, testCase.args.projectKeyOrID, testCase.args.propertyKey, testCase.args.payload) if testCase.wantErr { diff --git a/jira/internal/project_role_actor_impl.go b/jira/internal/project_role_actor_impl.go index 44667aad..dbec618f 100644 --- a/jira/internal/project_role_actor_impl.go +++ b/jira/internal/project_role_actor_impl.go @@ -35,8 +35,8 @@ type ProjectRoleActorService struct { // POST /rest/api/{2-3}/project/{projectKeyOrID}/role/{roleID} // // https://docs.go-atlassian.io/jira-software-cloud/projects/roles/actors#add-actors-to-project-role -func (p *ProjectRoleActorService) Add(ctx context.Context, projectKeyOrID string, roleID int, accountIds, groups []string) (*model.ProjectRoleScheme, *model.ResponseScheme, error) { - return p.internalClient.Add(ctx, projectKeyOrID, roleID, accountIds, groups) +func (p *ProjectRoleActorService) Add(ctx context.Context, projectKeyOrID string, roleID int, accountIDs, groups []string) (*model.ProjectRoleScheme, *model.ResponseScheme, error) { + return p.internalClient.Add(ctx, projectKeyOrID, roleID, accountIDs, groups) } // Delete deletes actors from a project role for the project. @@ -53,7 +53,7 @@ type internalProjectRoleActorImpl struct { version string } -func (i *internalProjectRoleActorImpl) Add(ctx context.Context, projectKeyOrID string, roleID int, accountIds, groups []string) (*model.ProjectRoleScheme, *model.ResponseScheme, error) { +func (i *internalProjectRoleActorImpl) Add(ctx context.Context, projectKeyOrID string, roleID int, accountIDs, groups []string) (*model.ProjectRoleScheme, *model.ResponseScheme, error) { if projectKeyOrID == "" { return nil, nil, model.ErrNoProjectIDOrKey @@ -65,7 +65,7 @@ func (i *internalProjectRoleActorImpl) Add(ctx context.Context, projectKeyOrID s endpoint := fmt.Sprintf("rest/api/%v/project/%v/role/%v", i.version, projectKeyOrID, roleID) - request, err := i.c.NewRequest(ctx, http.MethodPost, endpoint, "", map[string]interface{}{"group": groups, "user": accountIds}) + request, err := i.c.NewRequest(ctx, http.MethodPost, endpoint, "", map[string]interface{}{"group": groups, "user": accountIDs}) if err != nil { return nil, nil, err } diff --git a/jira/internal/project_role_actor_impl_test.go b/jira/internal/project_role_actor_impl_test.go index d8551a1b..8568c02a 100644 --- a/jira/internal/project_role_actor_impl_test.go +++ b/jira/internal/project_role_actor_impl_test.go @@ -26,7 +26,7 @@ func Test_internalProjectRoleActorImpl_Add(t *testing.T) { ctx context.Context projectKeyOrID string roleID int - accountIds, groups []string + accountIDs, groups []string } testCases := []struct { @@ -44,7 +44,7 @@ func Test_internalProjectRoleActorImpl_Add(t *testing.T) { ctx: context.Background(), projectKeyOrID: "DUMMY", roleID: 10001, - accountIds: []string{"uuid"}, + accountIDs: []string{"uuid"}, groups: []string{"jira-users"}, }, on: func(fields *fields) { @@ -76,7 +76,7 @@ func Test_internalProjectRoleActorImpl_Add(t *testing.T) { ctx: context.Background(), projectKeyOrID: "DUMMY", roleID: 10001, - accountIds: []string{"uuid"}, + accountIDs: []string{"uuid"}, groups: []string{"jira-users"}, }, on: func(fields *fields) { @@ -129,7 +129,7 @@ func Test_internalProjectRoleActorImpl_Add(t *testing.T) { ctx: context.Background(), projectKeyOrID: "DUMMY", roleID: 10001, - accountIds: []string{"uuid"}, + accountIDs: []string{"uuid"}, groups: []string{"jira-users"}, }, on: func(fields *fields) { @@ -161,7 +161,7 @@ func Test_internalProjectRoleActorImpl_Add(t *testing.T) { assert.NoError(t, err) gotResult, gotResponse, err := newService.Add(testCase.args.ctx, testCase.args.projectKeyOrID, testCase.args.roleID, - testCase.args.accountIds, testCase.args.groups) + testCase.args.accountIDs, testCase.args.groups) if testCase.wantErr { diff --git a/jira/internal/screen_tab_field_impl.go b/jira/internal/screen_tab_field_impl.go index 1fe3fa3e..35352853 100644 --- a/jira/internal/screen_tab_field_impl.go +++ b/jira/internal/screen_tab_field_impl.go @@ -151,7 +151,7 @@ func (i *internalScreenTabFieldImpl) Remove(ctx context.Context, screenID, tabID return i.c.Call(request, nil) } -func (i *internalScreenTabFieldImpl) Move(ctx context.Context, screenID, tabID int, fieldId, after, position string) (*model.ResponseScheme, error) { +func (i *internalScreenTabFieldImpl) Move(ctx context.Context, screenID, tabID int, fieldID, after, position string) (*model.ResponseScheme, error) { if screenID == 0 { return nil, model.ErrNoScreenID @@ -161,11 +161,11 @@ func (i *internalScreenTabFieldImpl) Move(ctx context.Context, screenID, tabID i return nil, model.ErrNoScreenTabID } - if fieldId == "" { + if fieldID == "" { return nil, model.ErrNoFieldID } - endpoint := fmt.Sprintf("rest/api/%v/screens/%v/tabs/%v/fields/%v/move", i.version, screenID, tabID, fieldId) + endpoint := fmt.Sprintf("rest/api/%v/screens/%v/tabs/%v/fields/%v/move", i.version, screenID, tabID, fieldID) request, err := i.c.NewRequest(ctx, http.MethodPost, endpoint, "", map[string]interface{}{"after": after, "position": position}) if err != nil { diff --git a/jira/internal/search_impl_adf_test.go b/jira/internal/search_impl_adf_test.go index 6ae0427b..003d46bf 100644 --- a/jira/internal/search_impl_adf_test.go +++ b/jira/internal/search_impl_adf_test.go @@ -3,18 +3,20 @@ package internal import ( "context" "errors" + "net/http" + "testing" + + "github.com/stretchr/testify/assert" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" "github.com/ctreminiom/go-atlassian/service" "github.com/ctreminiom/go-atlassian/service/mocks" - "github.com/stretchr/testify/assert" - "net/http" - "testing" ) func Test_internalSearchADFImpl_Checks(t *testing.T) { payloadMocked := &model.IssueSearchCheckPayloadScheme{ - IssueIds: []int{10001, 1000, 10042}, + IssueIDs: []int{10001, 1000, 10042}, JQLs: []string{ "project = FOO", "issuetype = Bug", diff --git a/jira/internal/search_impl_rich_text_test.go b/jira/internal/search_impl_rich_text_test.go index 3336b2ff..928fe3ff 100644 --- a/jira/internal/search_impl_rich_text_test.go +++ b/jira/internal/search_impl_rich_text_test.go @@ -3,18 +3,20 @@ package internal import ( "context" "errors" + "net/http" + "testing" + + "github.com/stretchr/testify/assert" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" "github.com/ctreminiom/go-atlassian/service" "github.com/ctreminiom/go-atlassian/service/mocks" - "github.com/stretchr/testify/assert" - "net/http" - "testing" ) func Test_internalSearchRichTextImpl_Checks(t *testing.T) { payloadMocked := &model.IssueSearchCheckPayloadScheme{ - IssueIds: []int{10001, 1000, 10042}, + IssueIDs: []int{10001, 1000, 10042}, JQLs: []string{ "project = FOO", "issuetype = Bug", diff --git a/jira/internal/type_scheme_impl_test.go b/jira/internal/type_scheme_impl_test.go index a66e56e6..3f14b7e3 100644 --- a/jira/internal/type_scheme_impl_test.go +++ b/jira/internal/type_scheme_impl_test.go @@ -443,7 +443,7 @@ func Test_internalTypeSchemeImpl_Create(t *testing.T) { payloadMocked := &model.IssueTypeSchemePayloadScheme{ DefaultIssueTypeID: "1000", - IssueTypeIds: []string{"1000", "1001", "1002"}, + IssueTypeIDs: []string{"1000", "1001", "1002"}, Name: "Default Issue Type Scheme", Description: "Issue Type Scheme description", } @@ -584,7 +584,7 @@ func Test_internalTypeSchemeImpl_Update(t *testing.T) { payloadMocked := &model.IssueTypeSchemePayloadScheme{ DefaultIssueTypeID: "1000", - IssueTypeIds: []string{"1000", "1001", "1002"}, + IssueTypeIDs: []string{"1000", "1001", "1002"}, Name: "Default Issue Type Scheme", Description: "Issue Type Scheme description", } diff --git a/jira/internal/type_screen_scheme_impl.go b/jira/internal/type_screen_scheme_impl.go index 63de2e27..5382eef8 100644 --- a/jira/internal/type_screen_scheme_impl.go +++ b/jira/internal/type_screen_scheme_impl.go @@ -68,8 +68,8 @@ func (t *TypeScreenSchemeService) Assign(ctx context.Context, issueTypeScreenSch // GET /rest/api/{2-3}/issuetypescreenscheme/project/{projectID} // // https://docs.go-atlassian.io/jira-software-cloud/issues/types/screen-scheme#assign-issue-type-screen-scheme-to-project -func (t *TypeScreenSchemeService) Projects(ctx context.Context, projectIds []int, startAt, maxResults int) (*model.IssueTypeProjectScreenSchemePageScheme, *model.ResponseScheme, error) { - return t.internalClient.Projects(ctx, projectIds, startAt, maxResults) +func (t *TypeScreenSchemeService) Projects(ctx context.Context, projectIDs []int, startAt, maxResults int) (*model.IssueTypeProjectScreenSchemePageScheme, *model.ResponseScheme, error) { + return t.internalClient.Projects(ctx, projectIDs, startAt, maxResults) } // Mapping returns a paginated list of issue type screen scheme items. @@ -79,8 +79,8 @@ func (t *TypeScreenSchemeService) Projects(ctx context.Context, projectIds []int // GET /rest/api/{2-3}/issuetypescreenscheme/mapping // // https://docs.go-atlassian.io/jira-software-cloud/issues/types/screen-scheme#get-issue-type-screen-scheme-items -func (t *TypeScreenSchemeService) Mapping(ctx context.Context, issueTypeScreenSchemeIds []int, startAt, maxResults int) (*model.IssueTypeScreenSchemeMappingScheme, *model.ResponseScheme, error) { - return t.internalClient.Mapping(ctx, issueTypeScreenSchemeIds, startAt, maxResults) +func (t *TypeScreenSchemeService) Mapping(ctx context.Context, issueTypeScreenSchemeIDs []int, startAt, maxResults int) (*model.IssueTypeScreenSchemeMappingScheme, *model.ResponseScheme, error) { + return t.internalClient.Mapping(ctx, issueTypeScreenSchemeIDs, startAt, maxResults) } // Update updates an issue type screen scheme. @@ -125,8 +125,8 @@ func (t *TypeScreenSchemeService) UpdateDefault(ctx context.Context, issueTypeSc // POST /rest/api/{2-3}/issuetypescreenscheme/{issueTypeScreenSchemeID}/mapping/remove // // https://docs.go-atlassian.io/jira-software-cloud/issues/types/screen-scheme#remove-mappings-from-issue-type-screen-scheme -func (t *TypeScreenSchemeService) Remove(ctx context.Context, issueTypeScreenSchemeID string, issueTypeIds []string) (*model.ResponseScheme, error) { - return t.internalClient.Remove(ctx, issueTypeScreenSchemeID, issueTypeIds) +func (t *TypeScreenSchemeService) Remove(ctx context.Context, issueTypeScreenSchemeID string, issueTypeIDs []string) (*model.ResponseScheme, error) { + return t.internalClient.Remove(ctx, issueTypeScreenSchemeID, issueTypeIDs) } // SchemesByProject returns a paginated list of projects associated with an issue type screen scheme. @@ -227,13 +227,13 @@ func (i *internalTypeScreenSchemeImpl) Assign(ctx context.Context, issueTypeScre return i.c.Call(request, nil) } -func (i *internalTypeScreenSchemeImpl) Projects(ctx context.Context, projectIds []int, startAt, maxResults int) (*model.IssueTypeProjectScreenSchemePageScheme, *model.ResponseScheme, error) { +func (i *internalTypeScreenSchemeImpl) Projects(ctx context.Context, projectIDs []int, startAt, maxResults int) (*model.IssueTypeProjectScreenSchemePageScheme, *model.ResponseScheme, error) { params := url.Values{} params.Add("startAt", strconv.Itoa(startAt)) params.Add("maxResults", strconv.Itoa(maxResults)) - for _, id := range projectIds { + for _, id := range projectIDs { params.Add("projectId", strconv.Itoa(id)) } @@ -253,13 +253,13 @@ func (i *internalTypeScreenSchemeImpl) Projects(ctx context.Context, projectIds return page, response, nil } -func (i *internalTypeScreenSchemeImpl) Mapping(ctx context.Context, issueTypeScreenSchemeIds []int, startAt, maxResults int) (*model.IssueTypeScreenSchemeMappingScheme, *model.ResponseScheme, error) { +func (i *internalTypeScreenSchemeImpl) Mapping(ctx context.Context, issueTypeScreenSchemeIDs []int, startAt, maxResults int) (*model.IssueTypeScreenSchemeMappingScheme, *model.ResponseScheme, error) { params := url.Values{} params.Add("startAt", strconv.Itoa(startAt)) params.Add("maxResults", strconv.Itoa(maxResults)) - for _, id := range issueTypeScreenSchemeIds { + for _, id := range issueTypeScreenSchemeIDs { params.Add("issueTypeScreenSchemeId", strconv.Itoa(id)) } @@ -353,19 +353,19 @@ func (i *internalTypeScreenSchemeImpl) UpdateDefault(ctx context.Context, issueT return i.c.Call(request, nil) } -func (i *internalTypeScreenSchemeImpl) Remove(ctx context.Context, issueTypeScreenSchemeID string, issueTypeIds []string) (*model.ResponseScheme, error) { +func (i *internalTypeScreenSchemeImpl) Remove(ctx context.Context, issueTypeScreenSchemeID string, issueTypeIDs []string) (*model.ResponseScheme, error) { if issueTypeScreenSchemeID == "" { return nil, model.ErrNoIssueTypeScreenSchemeID } - if len(issueTypeIds) == 0 { + if len(issueTypeIDs) == 0 { return nil, model.ErrNoIssueTypes } endpoint := fmt.Sprintf("rest/api/%v/issuetypescreenscheme/%v/mapping/remove", i.version, issueTypeScreenSchemeID) - request, err := i.c.NewRequest(ctx, http.MethodPost, endpoint, "", map[string]interface{}{"issueTypeIds": issueTypeIds}) + request, err := i.c.NewRequest(ctx, http.MethodPost, endpoint, "", map[string]interface{}{"issueTypeIds": issueTypeIDs}) if err != nil { return nil, err } diff --git a/jira/internal/user_search_impl_test.go b/jira/internal/user_search_impl_test.go index 7ab6dc36..9f5c06bc 100644 --- a/jira/internal/user_search_impl_test.go +++ b/jira/internal/user_search_impl_test.go @@ -180,7 +180,7 @@ func Test_internalUserSearchImpl_Do(t *testing.T) { type args struct { ctx context.Context - accountId string + accountID string query string startAt, maxResults int } @@ -198,7 +198,7 @@ func Test_internalUserSearchImpl_Do(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - accountId: "uuid-sample", + accountID: "uuid-sample", query: "charles.smith@example.com", startAt: 100, maxResults: 50, @@ -230,7 +230,7 @@ func Test_internalUserSearchImpl_Do(t *testing.T) { fields: fields{version: "2"}, args: args{ ctx: context.Background(), - accountId: "uuid-sample", + accountID: "uuid-sample", query: "charles.smith@example.com", startAt: 100, maxResults: 50, @@ -262,7 +262,7 @@ func Test_internalUserSearchImpl_Do(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - accountId: "uuid-sample", + accountID: "uuid-sample", query: "charles.smith@example.com", startAt: 100, maxResults: 50, @@ -295,7 +295,7 @@ func Test_internalUserSearchImpl_Do(t *testing.T) { newService, err := NewUserSearchService(testCase.fields.c, testCase.fields.version) assert.NoError(t, err) - gotResult, gotResponse, err := newService.Do(testCase.args.ctx, testCase.args.accountId, testCase.args.query, + gotResult, gotResponse, err := newService.Do(testCase.args.ctx, testCase.args.accountID, testCase.args.query, testCase.args.startAt, testCase.args.maxResults) if testCase.wantErr { diff --git a/jira/internal/workflow_scheme_impl_test.go b/jira/internal/workflow_scheme_impl_test.go index 643ec6e1..8f642784 100644 --- a/jira/internal/workflow_scheme_impl_test.go +++ b/jira/internal/workflow_scheme_impl_test.go @@ -447,7 +447,7 @@ func Test_internalWorkflowSchemeImpl_Associations(t *testing.T) { type args struct { ctx context.Context - projectIds []int + projectIDs []int } testCases := []struct { @@ -463,7 +463,7 @@ func Test_internalWorkflowSchemeImpl_Associations(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - projectIds: []int{1002, 1003}, + projectIDs: []int{1002, 1003}, }, on: func(fields *fields) { @@ -492,7 +492,7 @@ func Test_internalWorkflowSchemeImpl_Associations(t *testing.T) { fields: fields{version: "2"}, args: args{ ctx: context.Background(), - projectIds: []int{1002, 1003}, + projectIDs: []int{1002, 1003}, }, on: func(fields *fields) { @@ -531,7 +531,7 @@ func Test_internalWorkflowSchemeImpl_Associations(t *testing.T) { fields: fields{version: "3"}, args: args{ ctx: context.Background(), - projectIds: []int{1002, 1003}, + projectIDs: []int{1002, 1003}, }, on: func(fields *fields) { @@ -560,7 +560,7 @@ func Test_internalWorkflowSchemeImpl_Associations(t *testing.T) { newService := NewWorkflowSchemeService(testCase.fields.c, testCase.fields.version, nil) - gotResult, gotResponse, err := newService.Associations(testCase.args.ctx, testCase.args.projectIds) + gotResult, gotResponse, err := newService.Associations(testCase.args.ctx, testCase.args.projectIDs) if testCase.wantErr { diff --git a/jira/internal/workflow_status_impl.go b/jira/internal/workflow_status_impl.go index 5c4dd1fb..422355c1 100644 --- a/jira/internal/workflow_status_impl.go +++ b/jira/internal/workflow_status_impl.go @@ -3,13 +3,14 @@ package internal import ( "context" "fmt" - model "github.com/ctreminiom/go-atlassian/pkg/infra/models" - "github.com/ctreminiom/go-atlassian/service" - "github.com/ctreminiom/go-atlassian/service/jira" "net/http" "net/url" "strconv" "strings" + + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" + "github.com/ctreminiom/go-atlassian/service" + "github.com/ctreminiom/go-atlassian/service/jira" ) // NewWorkflowStatusService creates a new instance of WorkflowStatusService. @@ -109,7 +110,7 @@ type internalWorkflowStatusImpl struct { func (i *internalWorkflowStatusImpl) Get(ctx context.Context, idOrName string) (*model.StatusDetailScheme, *model.ResponseScheme, error) { if idOrName == "" { - return nil, nil, model.ErrNoWorkflowStatusNameOrId + return nil, nil, model.ErrNoWorkflowStatusNameOrID } endpoint := fmt.Sprintf("/rest/api/%v/status/%v", i.version, idOrName) diff --git a/jira/internal/worklog_impl_rich_text.go b/jira/internal/worklog_impl_rich_text.go index 01ba12c2..e45013da 100644 --- a/jira/internal/worklog_impl_rich_text.go +++ b/jira/internal/worklog_impl_rich_text.go @@ -38,19 +38,19 @@ type WorklogRichTextService struct { // POST /rest/api/{2-3}/worklog/list // // https://docs.go-atlassian.io/jira-software-cloud/issues/worklogs#get-worklogs -func (w *WorklogRichTextService) Gets(ctx context.Context, worklogIds []int, expand []string) ([]*model.IssueWorklogRichTextScheme, *model.ResponseScheme, error) { - return w.internalClient.Gets(ctx, worklogIds, expand) +func (w *WorklogRichTextService) Gets(ctx context.Context, worklogIDs []int, expand []string) ([]*model.IssueWorklogRichTextScheme, *model.ResponseScheme, error) { + return w.internalClient.Gets(ctx, worklogIDs, expand) } // Get returns a worklog. // // Time tracking must be enabled in Jira, otherwise this operation returns an error. // -// GET /rest/api/{2-3}/issue/{issueKeyOrID}/worklog/{id} +// GET /rest/api/{2-3}/issue/{issueKeyOrID}/worklog/{worklogID} // // https://docs.go-atlassian.io/jira-software-cloud/issues/worklogs#get-worklog -func (w *WorklogRichTextService) Get(ctx context.Context, issueKeyOrID, worklogId string, expand []string) (*model.IssueWorklogRichTextScheme, *model.ResponseScheme, error) { - return w.internalClient.Get(ctx, issueKeyOrID, worklogId, expand) +func (w *WorklogRichTextService) Get(ctx context.Context, issueKeyOrID, worklogID string, expand []string) (*model.IssueWorklogRichTextScheme, *model.ResponseScheme, error) { + return w.internalClient.Get(ctx, issueKeyOrID, worklogID, expand) } // Issue returns worklogs for an issue, starting from the oldest worklog or from the worklog started on or after a date and time. @@ -71,8 +71,8 @@ func (w *WorklogRichTextService) Issue(ctx context.Context, issueKeyOrID string, // DELETE /rest/api/{2-3}/issue/{issueKeyOrID}/worklog/{id} // // https://docs.go-atlassian.io/jira-software-cloud/issues/worklogs#delete-worklog -func (w *WorklogRichTextService) Delete(ctx context.Context, issueKeyOrID, worklogId string, options *model.WorklogOptionsScheme) (*model.ResponseScheme, error) { - return w.internalClient.Delete(ctx, issueKeyOrID, worklogId, options) +func (w *WorklogRichTextService) Delete(ctx context.Context, issueKeyOrID, worklogID string, options *model.WorklogOptionsScheme) (*model.ResponseScheme, error) { + return w.internalClient.Delete(ctx, issueKeyOrID, worklogID, options) } // Deleted returns a list of IDs and delete timestamps for worklogs deleted after a date and time. @@ -122,11 +122,11 @@ func (w *WorklogRichTextService) Add(ctx context.Context, issueKeyOrID string, p // // Time tracking must be enabled in Jira, otherwise this operation returns an error. // -// PUT /rest/api/2/issue/{issueKeyOrID}/worklog/{id} +// PUT /rest/api/2/issue/{issueKeyOrID}/worklog/{worklogID} // // https://docs.go-atlassian.io/jira-software-cloud/issues/worklogs#update-worklog -func (w *WorklogRichTextService) Update(ctx context.Context, issueKeyOrID, worklogId string, payload *model.WorklogRichTextPayloadScheme, options *model.WorklogOptionsScheme) (*model.IssueWorklogRichTextScheme, *model.ResponseScheme, error) { - return w.internalClient.Update(ctx, issueKeyOrID, worklogId, payload, options) +func (w *WorklogRichTextService) Update(ctx context.Context, issueKeyOrID, worklogID string, payload *model.WorklogRichTextPayloadScheme, options *model.WorklogOptionsScheme) (*model.IssueWorklogRichTextScheme, *model.ResponseScheme, error) { + return w.internalClient.Update(ctx, issueKeyOrID, worklogID, payload, options) } type internalWorklogRichTextImpl struct { @@ -134,9 +134,9 @@ type internalWorklogRichTextImpl struct { version string } -func (i *internalWorklogRichTextImpl) Gets(ctx context.Context, worklogIds []int, expand []string) ([]*model.IssueWorklogRichTextScheme, *model.ResponseScheme, error) { +func (i *internalWorklogRichTextImpl) Gets(ctx context.Context, worklogIDs []int, expand []string) ([]*model.IssueWorklogRichTextScheme, *model.ResponseScheme, error) { - if len(worklogIds) == 0 { + if len(worklogIDs) == 0 { return nil, nil, model.ErrNpWorklogs } @@ -152,7 +152,7 @@ func (i *internalWorklogRichTextImpl) Gets(ctx context.Context, worklogIds []int endpoint.WriteString(fmt.Sprintf("?%v", params.Encode())) } - request, err := i.c.NewRequest(ctx, http.MethodPost, endpoint.String(), "", map[string]interface{}{"ids": worklogIds}) + request, err := i.c.NewRequest(ctx, http.MethodPost, endpoint.String(), "", map[string]interface{}{"ids": worklogIDs}) if err != nil { return nil, nil, err } @@ -166,13 +166,13 @@ func (i *internalWorklogRichTextImpl) Gets(ctx context.Context, worklogIds []int return worklogs, response, nil } -func (i *internalWorklogRichTextImpl) Get(ctx context.Context, issueKeyOrID, worklogId string, expand []string) (*model.IssueWorklogRichTextScheme, *model.ResponseScheme, error) { +func (i *internalWorklogRichTextImpl) Get(ctx context.Context, issueKeyOrID, worklogID string, expand []string) (*model.IssueWorklogRichTextScheme, *model.ResponseScheme, error) { if issueKeyOrID == "" { return nil, nil, model.ErrNoIssueKeyOrID } - if worklogId == "" { + if worklogID == "" { return nil, nil, model.ErrNoWorklogID } @@ -182,7 +182,7 @@ func (i *internalWorklogRichTextImpl) Get(ctx context.Context, issueKeyOrID, wor } var endpoint strings.Builder - endpoint.WriteString(fmt.Sprintf("rest/api/%v/issue/%v/worklog/%v", i.version, issueKeyOrID, worklogId)) + endpoint.WriteString(fmt.Sprintf("rest/api/%v/issue/%v/worklog/%v", i.version, issueKeyOrID, worklogID)) if params.Encode() != "" { endpoint.WriteString(fmt.Sprintf("?%v", params.Encode())) @@ -236,18 +236,18 @@ func (i *internalWorklogRichTextImpl) Issue(ctx context.Context, issueKeyOrID st return worklogs, response, nil } -func (i *internalWorklogRichTextImpl) Delete(ctx context.Context, issueKeyOrID, worklogId string, options *model.WorklogOptionsScheme) (*model.ResponseScheme, error) { +func (i *internalWorklogRichTextImpl) Delete(ctx context.Context, issueKeyOrID, worklogID string, options *model.WorklogOptionsScheme) (*model.ResponseScheme, error) { if issueKeyOrID == "" { return nil, model.ErrNoIssueKeyOrID } - if worklogId == "" { + if worklogID == "" { return nil, model.ErrNoWorklogID } var endpoint strings.Builder - endpoint.WriteString(fmt.Sprintf("rest/api/%v/issue/%v/worklog/%v", i.version, issueKeyOrID, worklogId)) + endpoint.WriteString(fmt.Sprintf("rest/api/%v/issue/%v/worklog/%v", i.version, issueKeyOrID, worklogID)) if options != nil { @@ -391,18 +391,18 @@ func (i *internalWorklogRichTextImpl) Add(ctx context.Context, issueKeyOrID stri return worklog, response, nil } -func (i *internalWorklogRichTextImpl) Update(ctx context.Context, issueKeyOrID, worklogId string, payload *model.WorklogRichTextPayloadScheme, options *model.WorklogOptionsScheme) (*model.IssueWorklogRichTextScheme, *model.ResponseScheme, error) { +func (i *internalWorklogRichTextImpl) Update(ctx context.Context, issueKeyOrID, worklogID string, payload *model.WorklogRichTextPayloadScheme, options *model.WorklogOptionsScheme) (*model.IssueWorklogRichTextScheme, *model.ResponseScheme, error) { if issueKeyOrID == "" { return nil, nil, model.ErrNoIssueKeyOrID } - if worklogId == "" { + if worklogID == "" { return nil, nil, model.ErrNoWorklogID } var endpoint strings.Builder - endpoint.WriteString(fmt.Sprintf("rest/api/%v/issue/%v/worklog/%v", i.version, issueKeyOrID, worklogId)) + endpoint.WriteString(fmt.Sprintf("rest/api/%v/issue/%v/worklog/%v", i.version, issueKeyOrID, worklogID)) if options != nil { diff --git a/jira/sm/api_client_impl.go b/jira/sm/api_client_impl.go index 28bb13ad..07bcd366 100644 --- a/jira/sm/api_client_impl.go +++ b/jira/sm/api_client_impl.go @@ -17,7 +17,7 @@ import ( const defaultServiceManagementVersion = "latest" -func New(httpClient common.HttpClient, site string) (*Client, error) { +func New(httpClient common.HTTPClient, site string) (*Client, error) { if httpClient == nil { httpClient = http.DefaultClient @@ -78,7 +78,7 @@ func New(httpClient common.HttpClient, site string) (*Client, error) { } type Client struct { - HTTP common.HttpClient + HTTP common.HTTPClient Site *url.URL Auth common.Authentication Customer *internal.CustomerService @@ -90,7 +90,7 @@ type Client struct { WorkSpace *internal.WorkSpaceService } -func (c *Client) NewRequest(ctx context.Context, method, urlStr, type_ string, body interface{}) (*http.Request, error) { +func (c *Client) NewRequest(ctx context.Context, method, urlStr, contentType string, body interface{}) (*http.Request, error) { rel, err := url.Parse(urlStr) if err != nil { @@ -123,9 +123,9 @@ func (c *Client) NewRequest(ctx context.Context, method, urlStr, type_ string, b req.Header.Set("Content-Type", "application/json") } - if type_ != "" { - // When the type_ is provided, it means the request needs to be created to handle files - req.Header.Set("Content-Type", type_) + if contentType != "" { + // When the contentType is provided, it means the request needs to be created to handle files + req.Header.Set("Content-Type", contentType) req.Header.Set("X-Atlassian-Token", "no-check") } diff --git a/jira/sm/api_client_impl_test.go b/jira/sm/api_client_impl_test.go index 09c8e953..fb03dbf0 100644 --- a/jira/sm/api_client_impl_test.go +++ b/jira/sm/api_client_impl_test.go @@ -66,7 +66,7 @@ func TestClient_Call(t *testing.T) { } type fields struct { - HTTP common.HttpClient + HTTP common.HTTPClient Site *url.URL Auth common.Authentication } @@ -88,7 +88,7 @@ func TestClient_Call(t *testing.T) { name: "when the parameters are correct", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(expectedResponse, nil) @@ -112,7 +112,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is a bad request", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(badRequestResponse, nil) @@ -137,7 +137,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is an internal service error", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(internalServerResponse, nil) @@ -162,7 +162,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is a not found", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(notFoundResponse, nil) @@ -187,7 +187,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is unauthorized", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(unauthorizedResponse, nil) @@ -265,17 +265,17 @@ func TestClient_NewRequest(t *testing.T) { requestMocked.Header.Set("Content-Type", "application/json") type fields struct { - HTTP common.HttpClient + HTTP common.HTTPClient Auth common.Authentication Site *url.URL } type args struct { - ctx context.Context - method string - urlStr string - type_ string - body interface{} + ctx context.Context + method string + urlStr string + contentType string + body interface{} } testCases := []struct { @@ -293,11 +293,11 @@ func TestClient_NewRequest(t *testing.T) { Site: siteAsURL, }, args: args{ - ctx: context.Background(), - method: http.MethodGet, - urlStr: "rest/2/issue/attachment", - type_: "", - body: bytes.NewReader([]byte("Hello World")), + ctx: context.Background(), + method: http.MethodGet, + urlStr: "rest/2/issue/attachment", + contentType: "", + body: bytes.NewReader([]byte("Hello World")), }, want: requestMocked, wantErr: false, @@ -351,7 +351,7 @@ func TestClient_NewRequest(t *testing.T) { testCase.args.ctx, testCase.args.method, testCase.args.urlStr, - testCase.args.type_, + testCase.args.contentType, testCase.args.body, ) @@ -374,7 +374,7 @@ func TestClient_NewRequest(t *testing.T) { func TestClient_processResponse(t *testing.T) { - expectedJsonResponse := ` + expectedJSONResponse := ` { "id": 4, "self": "https://ctreminiom.atlassian.net/rest/agile/1.0/board/4", @@ -384,7 +384,7 @@ func TestClient_processResponse(t *testing.T) { expectedResponse := &http.Response{ StatusCode: http.StatusOK, - Body: io.NopCloser(strings.NewReader(expectedJsonResponse)), + Body: io.NopCloser(strings.NewReader(expectedJSONResponse)), Request: &http.Request{ Method: http.MethodGet, URL: &url.URL{}, @@ -392,7 +392,7 @@ func TestClient_processResponse(t *testing.T) { } type fields struct { - HTTP common.HttpClient + HTTP common.HTTPClient Site *url.URL Authentication common.Authentication } @@ -420,7 +420,7 @@ func TestClient_processResponse(t *testing.T) { Response: expectedResponse, Code: http.StatusOK, Method: http.MethodGet, - Bytes: *bytes.NewBufferString(expectedJsonResponse), + Bytes: *bytes.NewBufferString(expectedJSONResponse), }, wantErr: false, }, @@ -469,7 +469,7 @@ func TestNew(t *testing.T) { noURLClientMocked, _ := New(nil, "") type args struct { - httpClient common.HttpClient + httpClient common.HTTPClient site string } diff --git a/jira/sm/internal/comment_impl.go b/jira/sm/internal/comment_impl.go index 0c4f4ee2..3ad20459 100644 --- a/jira/sm/internal/comment_impl.go +++ b/jira/sm/internal/comment_impl.go @@ -44,7 +44,7 @@ func (s *CommentService) Gets(ctx context.Context, issueKeyOrID string, options // Get returns details of a customer request's comment. // -// GET /rest/servicedeskapi/request/{issueKeyOrID}/comment/{commentId} +// GET /rest/servicedeskapi/request/{issueKeyOrID}/comment/{commentID} // // https://docs.go-atlassian.io/jira-service-management-cloud/request/comments#get-request-comment-by-id func (s *CommentService) Get(ctx context.Context, issueKeyOrID string, commentID int, expand []string) (*model.RequestCommentScheme, *model.ResponseScheme, error) { @@ -62,7 +62,7 @@ func (s *CommentService) Create(ctx context.Context, issueKeyOrID, body string, // Attachments returns the attachments referenced in a comment. // -// GET /rest/servicedeskapi/request/{issueKeyOrID}/comment/{commentId}/attachment +// GET /rest/servicedeskapi/request/{issueKeyOrID}/comment/{commentID}/attachment // // https://docs.go-atlassian.io/jira-service-management-cloud/request/comments#get-comment-attachments func (s *CommentService) Attachments(ctx context.Context, issueKeyOrID string, commentID, start, limit int) (*model.RequestAttachmentPageScheme, *model.ResponseScheme, error) { diff --git a/jira/sm/internal/type_impl.go b/jira/sm/internal/type_impl.go index 047e62e6..08392af5 100644 --- a/jira/sm/internal/type_impl.go +++ b/jira/sm/internal/type_impl.go @@ -165,13 +165,13 @@ func (i *internalTypeImpl) Create(ctx context.Context, serviceDeskID int, payloa return nil, nil, err } - type_ := new(model.RequestTypeScheme) - res, err := i.c.Call(req, type_) + requestType := new(model.RequestTypeScheme) + res, err := i.c.Call(req, requestType) if err != nil { return nil, res, err } - return type_, res, nil + return requestType, res, nil } func (i *internalTypeImpl) Get(ctx context.Context, serviceDeskID, requestTypeID int) (*model.RequestTypeScheme, *model.ResponseScheme, error) { @@ -191,13 +191,13 @@ func (i *internalTypeImpl) Get(ctx context.Context, serviceDeskID, requestTypeID return nil, nil, err } - type_ := new(model.RequestTypeScheme) - res, err := i.c.Call(req, type_) + requestType := new(model.RequestTypeScheme) + res, err := i.c.Call(req, requestType) if err != nil { return nil, res, err } - return type_, res, nil + return requestType, res, nil } func (i *internalTypeImpl) Delete(ctx context.Context, serviceDeskID, requestTypeID int) (*model.ResponseScheme, error) { diff --git a/jira/v2/api_client_impl.go b/jira/v2/api_client_impl.go index 9ff45f21..976aa234 100644 --- a/jira/v2/api_client_impl.go +++ b/jira/v2/api_client_impl.go @@ -15,9 +15,13 @@ import ( "github.com/ctreminiom/go-atlassian/service/common" ) -const ApiVersion = "2" +// APIVersion is the version of the Jira API that this client targets. +const APIVersion = "2" -func New(httpClient common.HttpClient, site string) (*Client, error) { +// New creates a new Jira API client. +// If a nil httpClient is provided, http.DefaultClient will be used. +// If the site is empty, an error will be returned. +func New(httpClient common.HTTPClient, site string) (*Client, error) { if httpClient == nil { httpClient = http.DefaultClient @@ -43,157 +47,157 @@ func New(httpClient common.HttpClient, site string) (*Client, error) { client.Auth = internal.NewAuthenticationService(client) - auditRecordService, err := internal.NewAuditRecordService(client, ApiVersion) + auditRecordService, err := internal.NewAuditRecordService(client, APIVersion) if err != nil { return nil, err } - applicationRoleService, err := internal.NewApplicationRoleService(client, ApiVersion) + applicationRoleService, err := internal.NewApplicationRoleService(client, APIVersion) if err != nil { return nil, err } - dashboardService, err := internal.NewDashboardService(client, ApiVersion) + dashboardService, err := internal.NewDashboardService(client, APIVersion) if err != nil { return nil, err } - filterShareService, err := internal.NewFilterShareService(client, ApiVersion) + filterShareService, err := internal.NewFilterShareService(client, APIVersion) if err != nil { return nil, err } - filterService, err := internal.NewFilterService(client, ApiVersion, filterShareService) + filterService, err := internal.NewFilterService(client, APIVersion, filterShareService) if err != nil { return nil, err } - groupUserPickerService, err := internal.NewGroupUserPickerService(client, ApiVersion) + groupUserPickerService, err := internal.NewGroupUserPickerService(client, APIVersion) if err != nil { return nil, err } - groupService, err := internal.NewGroupService(client, ApiVersion) + groupService, err := internal.NewGroupService(client, APIVersion) if err != nil { return nil, err } - issueAttachmentService, err := internal.NewIssueAttachmentService(client, ApiVersion) + issueAttachmentService, err := internal.NewIssueAttachmentService(client, APIVersion) if err != nil { return nil, err } - _, commentService, err := internal.NewCommentService(client, ApiVersion) + _, commentService, err := internal.NewCommentService(client, APIVersion) if err != nil { return nil, err } - fieldConfigurationItemService, err := internal.NewIssueFieldConfigurationItemService(client, ApiVersion) + fieldConfigurationItemService, err := internal.NewIssueFieldConfigurationItemService(client, APIVersion) if err != nil { return nil, err } - fieldConfigurationSchemeService, err := internal.NewIssueFieldConfigurationSchemeService(client, ApiVersion) + fieldConfigurationSchemeService, err := internal.NewIssueFieldConfigurationSchemeService(client, APIVersion) if err != nil { return nil, err } - fieldConfigService, err := internal.NewIssueFieldConfigurationService(client, ApiVersion, fieldConfigurationItemService, fieldConfigurationSchemeService) + fieldConfigService, err := internal.NewIssueFieldConfigurationService(client, APIVersion, fieldConfigurationItemService, fieldConfigurationSchemeService) if err != nil { return nil, err } - optionService, err := internal.NewIssueFieldContextOptionService(client, ApiVersion) + optionService, err := internal.NewIssueFieldContextOptionService(client, APIVersion) if err != nil { return nil, err } - fieldContextService, err := internal.NewIssueFieldContextService(client, ApiVersion, optionService) + fieldContextService, err := internal.NewIssueFieldContextService(client, APIVersion, optionService) if err != nil { return nil, err } - fieldTrashService, err := internal.NewIssueFieldTrashService(client, ApiVersion) + fieldTrashService, err := internal.NewIssueFieldTrashService(client, APIVersion) if err != nil { return nil, err } - issueFieldService, err := internal.NewIssueFieldService(client, ApiVersion, fieldConfigService, fieldContextService, fieldTrashService) + issueFieldService, err := internal.NewIssueFieldService(client, APIVersion, fieldConfigService, fieldContextService, fieldTrashService) if err != nil { return nil, err } - label, err := internal.NewLabelService(client, ApiVersion) + label, err := internal.NewLabelService(client, APIVersion) if err != nil { return nil, err } - linkType, err := internal.NewLinkTypeService(client, ApiVersion) + linkType, err := internal.NewLinkTypeService(client, APIVersion) if err != nil { return nil, err } - remoteLink, err := internal.NewRemoteLinkService(client, ApiVersion) + remoteLink, err := internal.NewRemoteLinkService(client, APIVersion) if err != nil { return nil, err } - _, link, err := internal.NewLinkService(client, ApiVersion, linkType, remoteLink) + _, link, err := internal.NewLinkService(client, APIVersion, linkType, remoteLink) if err != nil { return nil, err } - metadata, err := internal.NewMetadataService(client, ApiVersion) + metadata, err := internal.NewMetadataService(client, APIVersion) if err != nil { return nil, err } - priority, err := internal.NewPriorityService(client, ApiVersion) + priority, err := internal.NewPriorityService(client, APIVersion) if err != nil { return nil, err } - resolution, err := internal.NewResolutionService(client, ApiVersion) + resolution, err := internal.NewResolutionService(client, APIVersion) if err != nil { return nil, err } - _, search, err := internal.NewSearchService(client, ApiVersion) + _, search, err := internal.NewSearchService(client, APIVersion) if err != nil { return nil, err } - typeScheme, err := internal.NewTypeSchemeService(client, ApiVersion) + typeScheme, err := internal.NewTypeSchemeService(client, APIVersion) if err != nil { return nil, err } - issueTypeScreenScheme, err := internal.NewTypeScreenSchemeService(client, ApiVersion) + issueTypeScreenScheme, err := internal.NewTypeScreenSchemeService(client, APIVersion) if err != nil { return nil, err } - type_, err := internal.NewTypeService(client, ApiVersion, typeScheme, issueTypeScreenScheme) + typ, err := internal.NewTypeService(client, APIVersion, typeScheme, issueTypeScreenScheme) if err != nil { return nil, err } - vote, err := internal.NewVoteService(client, ApiVersion) + vote, err := internal.NewVoteService(client, APIVersion) if err != nil { return nil, err } - watcher, err := internal.NewWatcherService(client, ApiVersion) + watcher, err := internal.NewWatcherService(client, APIVersion) if err != nil { return nil, err } - worklog, err := internal.NewWorklogRichTextService(client, ApiVersion) + worklog, err := internal.NewWorklogRichTextService(client, APIVersion) if err != nil { return nil, err } - issueProperty, err := internal.NewIssuePropertyService(client, ApiVersion) + issueProperty, err := internal.NewIssuePropertyService(client, APIVersion) if err != nil { return nil, err } @@ -208,89 +212,89 @@ func New(httpClient common.HttpClient, site string) (*Client, error) { Priority: priority, Resolution: resolution, SearchRT: search, - Type: type_, + Type: typ, Vote: vote, Watcher: watcher, WorklogRichText: worklog, Property: issueProperty, } - issueService, _, err := internal.NewIssueService(client, ApiVersion, issueServices) + issueService, _, err := internal.NewIssueService(client, APIVersion, issueServices) if err != nil { return nil, err } - mySelf, err := internal.NewMySelfService(client, ApiVersion) + mySelf, err := internal.NewMySelfService(client, APIVersion) if err != nil { return nil, err } - permissionSchemeGrant, err := internal.NewPermissionSchemeGrantService(client, ApiVersion) + permissionSchemeGrant, err := internal.NewPermissionSchemeGrantService(client, APIVersion) if err != nil { return nil, err } - permissionScheme, err := internal.NewPermissionSchemeService(client, ApiVersion, permissionSchemeGrant) + permissionScheme, err := internal.NewPermissionSchemeService(client, APIVersion, permissionSchemeGrant) if err != nil { return nil, err } - permission, err := internal.NewPermissionService(client, ApiVersion, permissionScheme) + permission, err := internal.NewPermissionService(client, APIVersion, permissionScheme) if err != nil { return nil, err } - projectCategory, err := internal.NewProjectCategoryService(client, ApiVersion) + projectCategory, err := internal.NewProjectCategoryService(client, APIVersion) if err != nil { return nil, err } - projectComponent, err := internal.NewProjectComponentService(client, ApiVersion) + projectComponent, err := internal.NewProjectComponentService(client, APIVersion) if err != nil { return nil, err } - projectFeature, err := internal.NewProjectFeatureService(client, ApiVersion) + projectFeature, err := internal.NewProjectFeatureService(client, APIVersion) if err != nil { return nil, err } - projectPermission, err := internal.NewProjectPermissionSchemeService(client, ApiVersion) + projectPermission, err := internal.NewProjectPermissionSchemeService(client, APIVersion) if err != nil { return nil, err } - projectProperties, err := internal.NewProjectPropertyService(client, ApiVersion) + projectProperties, err := internal.NewProjectPropertyService(client, APIVersion) if err != nil { return nil, err } - projectRoleActor, err := internal.NewProjectRoleActorService(client, ApiVersion) + projectRoleActor, err := internal.NewProjectRoleActorService(client, APIVersion) if err != nil { return nil, err } - projectRole, err := internal.NewProjectRoleService(client, ApiVersion, projectRoleActor) + projectRole, err := internal.NewProjectRoleService(client, APIVersion, projectRoleActor) if err != nil { return nil, err } - projectType, err := internal.NewProjectTypeService(client, ApiVersion) + projectType, err := internal.NewProjectTypeService(client, APIVersion) if err != nil { return nil, err } - projectValidator, err := internal.NewProjectValidatorService(client, ApiVersion) + projectValidator, err := internal.NewProjectValidatorService(client, APIVersion) if err != nil { return nil, err } - projectVersion, err := internal.NewProjectVersionService(client, ApiVersion) + projectVersion, err := internal.NewProjectVersionService(client, APIVersion) if err != nil { return nil, err } - projectNotificationScheme, err := internal.NewNotificationSchemeService(client, ApiVersion) + projectNotificationScheme, err := internal.NewNotificationSchemeService(client, APIVersion) if err != nil { return nil, err } @@ -307,67 +311,67 @@ func New(httpClient common.HttpClient, site string) (*Client, error) { Version: projectVersion, } - project, err := internal.NewProjectService(client, ApiVersion, projectSubService) + project, err := internal.NewProjectService(client, APIVersion, projectSubService) if err != nil { return nil, err } - screenFieldTabField, err := internal.NewScreenTabFieldService(client, ApiVersion) + screenFieldTabField, err := internal.NewScreenTabFieldService(client, APIVersion) if err != nil { return nil, err } - screenTab, err := internal.NewScreenTabService(client, ApiVersion, screenFieldTabField) + screenTab, err := internal.NewScreenTabService(client, APIVersion, screenFieldTabField) if err != nil { return nil, err } - screenScheme, err := internal.NewScreenSchemeService(client, ApiVersion) + screenScheme, err := internal.NewScreenSchemeService(client, APIVersion) if err != nil { return nil, err } - screen, err := internal.NewScreenService(client, ApiVersion, screenScheme, screenTab) + screen, err := internal.NewScreenService(client, APIVersion, screenScheme, screenTab) if err != nil { return nil, err } - task, err := internal.NewTaskService(client, ApiVersion) + task, err := internal.NewTaskService(client, APIVersion) if err != nil { return nil, err } - server, err := internal.NewServerService(client, ApiVersion) + server, err := internal.NewServerService(client, APIVersion) if err != nil { return nil, err } - userSearch, err := internal.NewUserSearchService(client, ApiVersion) + userSearch, err := internal.NewUserSearchService(client, APIVersion) if err != nil { return nil, err } - user, err := internal.NewUserService(client, ApiVersion, userSearch) + user, err := internal.NewUserService(client, APIVersion, userSearch) if err != nil { return nil, err } workflowScheme := internal.NewWorkflowSchemeService( client, - ApiVersion, - internal.NewWorkflowSchemeIssueTypeService(client, ApiVersion)) + APIVersion, + internal.NewWorkflowSchemeIssueTypeService(client, APIVersion)) - workflowStatus, err := internal.NewWorkflowStatusService(client, ApiVersion) + workflowStatus, err := internal.NewWorkflowStatusService(client, APIVersion) if err != nil { return nil, err } - workflow, err := internal.NewWorkflowService(client, ApiVersion, workflowScheme, workflowStatus) + workflow, err := internal.NewWorkflowService(client, APIVersion, workflowScheme, workflowStatus) if err != nil { return nil, err } - jql, err := internal.NewJQLService(client, ApiVersion) + jql, err := internal.NewJQLService(client, APIVersion) if err != nil { return nil, err } @@ -376,7 +380,7 @@ func New(httpClient common.HttpClient, site string) (*Client, error) { client.Permission = permission client.MySelf = mySelf client.Auth = internal.NewAuthenticationService(client) - client.Banner = internal.NewAnnouncementBannerService(client, ApiVersion) + client.Banner = internal.NewAnnouncementBannerService(client, APIVersion) client.Role = applicationRoleService client.Dashboard = dashboardService client.Filter = filterService @@ -397,7 +401,7 @@ func New(httpClient common.HttpClient, site string) (*Client, error) { } type Client struct { - HTTP common.HttpClient + HTTP common.HTTPClient Auth common.Authentication Site *url.URL Role *internal.ApplicationRoleService @@ -421,7 +425,8 @@ type Client struct { Team *internal.TeamService } -func (c *Client) NewRequest(ctx context.Context, method, urlStr, type_ string, body interface{}) (*http.Request, error) { +// NewRequest creates an API request. +func (c *Client) NewRequest(ctx context.Context, method, urlStr, contentType string, body interface{}) (*http.Request, error) { rel, err := url.Parse(urlStr) if err != nil { @@ -454,9 +459,9 @@ func (c *Client) NewRequest(ctx context.Context, method, urlStr, type_ string, b req.Header.Set("Content-Type", "application/json") } - if type_ != "" { - // When the type_ is provided, it means the request needs to be created to handle files - req.Header.Set("Content-Type", type_) + if contentType != "" { + // When the contentType is provided, it means the request needs to be created to handle files + req.Header.Set("Content-Type", contentType) req.Header.Set("X-Atlassian-Token", "no-check") } diff --git a/jira/v2/api_client_impl_test.go b/jira/v2/api_client_impl_test.go index f28b19c0..e0762969 100644 --- a/jira/v2/api_client_impl_test.go +++ b/jira/v2/api_client_impl_test.go @@ -4,16 +4,18 @@ import ( "bytes" "context" "errors" - "github.com/ctreminiom/go-atlassian/jira/internal" - model "github.com/ctreminiom/go-atlassian/pkg/infra/models" - "github.com/ctreminiom/go-atlassian/service/common" - "github.com/ctreminiom/go-atlassian/service/mocks" - "github.com/stretchr/testify/assert" "io" "net/http" "net/url" "strings" "testing" + + "github.com/stretchr/testify/assert" + + "github.com/ctreminiom/go-atlassian/jira/internal" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" + "github.com/ctreminiom/go-atlassian/service/common" + "github.com/ctreminiom/go-atlassian/service/mocks" ) func TestClient_Call(t *testing.T) { @@ -64,7 +66,7 @@ func TestClient_Call(t *testing.T) { } type fields struct { - HTTP common.HttpClient + HTTP common.HTTPClient Site *url.URL Auth common.Authentication } @@ -86,7 +88,7 @@ func TestClient_Call(t *testing.T) { name: "when the parameters are correct", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(expectedResponse, nil) @@ -110,7 +112,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is a bad request", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(badRequestResponse, nil) @@ -135,7 +137,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is an internal service error", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(internalServerResponse, nil) @@ -160,7 +162,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is a not found", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(notFoundResponse, nil) @@ -185,7 +187,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is unauthorized", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(unauthorizedResponse, nil) @@ -263,17 +265,17 @@ func TestClient_NewRequest(t *testing.T) { requestMocked.Header.Set("Content-Type", "application/json") type fields struct { - HTTP common.HttpClient + HTTP common.HTTPClient Auth common.Authentication Site *url.URL } type args struct { - ctx context.Context - method string - urlStr string - type_ string - body interface{} + ctx context.Context + method string + urlStr string + contentType string + body interface{} } testCases := []struct { @@ -291,11 +293,11 @@ func TestClient_NewRequest(t *testing.T) { Site: siteAsURL, }, args: args{ - ctx: context.Background(), - method: http.MethodGet, - urlStr: "rest/2/issue/attachment", - type_: "", - body: bytes.NewReader([]byte("Hello World")), + ctx: context.Background(), + method: http.MethodGet, + urlStr: "rest/2/issue/attachment", + contentType: "", + body: bytes.NewReader([]byte("Hello World")), }, want: requestMocked, wantErr: false, @@ -309,11 +311,11 @@ func TestClient_NewRequest(t *testing.T) { Site: siteAsURL, }, args: args{ - ctx: context.Background(), - method: http.MethodGet, - urlStr: "rest/2/issue/attachment", - type_: "type_sample", - body: bytes.NewReader([]byte("Hello World")), + ctx: context.Background(), + method: http.MethodGet, + urlStr: "rest/2/issue/attachment", + contentType: "type_sample", + body: bytes.NewReader([]byte("Hello World")), }, want: requestMocked, wantErr: false, @@ -367,7 +369,7 @@ func TestClient_NewRequest(t *testing.T) { testCase.args.ctx, testCase.args.method, testCase.args.urlStr, - testCase.args.type_, + testCase.args.contentType, testCase.args.body, ) @@ -389,7 +391,7 @@ func TestClient_NewRequest(t *testing.T) { func TestClient_processResponse(t *testing.T) { - expectedJsonResponse := ` + expectedJSONResponse := ` { "id": 4, "self": "https://ctreminiom.atlassian.net/rest/agile/1.0/board/4", @@ -399,7 +401,7 @@ func TestClient_processResponse(t *testing.T) { expectedResponse := &http.Response{ StatusCode: http.StatusOK, - Body: io.NopCloser(strings.NewReader(expectedJsonResponse)), + Body: io.NopCloser(strings.NewReader(expectedJSONResponse)), Request: &http.Request{ Method: http.MethodGet, URL: &url.URL{}, @@ -407,7 +409,7 @@ func TestClient_processResponse(t *testing.T) { } type fields struct { - HTTP common.HttpClient + HTTP common.HTTPClient Site *url.URL Authentication common.Authentication } @@ -435,7 +437,7 @@ func TestClient_processResponse(t *testing.T) { Response: expectedResponse, Code: http.StatusOK, Method: http.MethodGet, - Bytes: *bytes.NewBufferString(expectedJsonResponse), + Bytes: *bytes.NewBufferString(expectedJSONResponse), }, wantErr: false, }, @@ -484,7 +486,7 @@ func TestNew(t *testing.T) { noURLClientMocked, _ := New(nil, "") type args struct { - httpClient common.HttpClient + httpClient common.HTTPClient site string } diff --git a/jira/v3/api_client_impl.go b/jira/v3/api_client_impl.go index 69058218..6f6297cd 100644 --- a/jira/v3/api_client_impl.go +++ b/jira/v3/api_client_impl.go @@ -15,9 +15,13 @@ import ( "github.com/ctreminiom/go-atlassian/service/common" ) -const ApiVersion = "3" +// APIVersion is the version of the Jira API that this client targets. +const APIVersion = "3" -func New(httpClient common.HttpClient, site string) (*Client, error) { +// New creates a new Jira API client. +// If a nil httpClient is provided, http.DefaultClient will be used. +// If the site is empty, an error will be returned. +func New(httpClient common.HTTPClient, site string) (*Client, error) { if httpClient == nil { httpClient = http.DefaultClient @@ -43,157 +47,157 @@ func New(httpClient common.HttpClient, site string) (*Client, error) { client.Auth = internal.NewAuthenticationService(client) - auditRecord, err := internal.NewAuditRecordService(client, ApiVersion) + auditRecord, err := internal.NewAuditRecordService(client, APIVersion) if err != nil { return nil, err } - applicationRoleService, err := internal.NewApplicationRoleService(client, ApiVersion) + applicationRoleService, err := internal.NewApplicationRoleService(client, APIVersion) if err != nil { return nil, err } - dashboardService, err := internal.NewDashboardService(client, ApiVersion) + dashboardService, err := internal.NewDashboardService(client, APIVersion) if err != nil { return nil, err } - filterShareService, err := internal.NewFilterShareService(client, ApiVersion) + filterShareService, err := internal.NewFilterShareService(client, APIVersion) if err != nil { return nil, err } - filterService, err := internal.NewFilterService(client, ApiVersion, filterShareService) + filterService, err := internal.NewFilterService(client, APIVersion, filterShareService) if err != nil { return nil, err } - groupUserPickerService, err := internal.NewGroupUserPickerService(client, ApiVersion) + groupUserPickerService, err := internal.NewGroupUserPickerService(client, APIVersion) if err != nil { return nil, err } - groupService, err := internal.NewGroupService(client, ApiVersion) + groupService, err := internal.NewGroupService(client, APIVersion) if err != nil { return nil, err } - issueAttachmentService, err := internal.NewIssueAttachmentService(client, ApiVersion) + issueAttachmentService, err := internal.NewIssueAttachmentService(client, APIVersion) if err != nil { return nil, err } - commentService, _, err := internal.NewCommentService(client, ApiVersion) + commentService, _, err := internal.NewCommentService(client, APIVersion) if err != nil { return nil, err } - fieldConfigurationItemService, err := internal.NewIssueFieldConfigurationItemService(client, ApiVersion) + fieldConfigurationItemService, err := internal.NewIssueFieldConfigurationItemService(client, APIVersion) if err != nil { return nil, err } - fieldConfigurationSchemeService, err := internal.NewIssueFieldConfigurationSchemeService(client, ApiVersion) + fieldConfigurationSchemeService, err := internal.NewIssueFieldConfigurationSchemeService(client, APIVersion) if err != nil { return nil, err } - fieldConfigService, err := internal.NewIssueFieldConfigurationService(client, ApiVersion, fieldConfigurationItemService, fieldConfigurationSchemeService) + fieldConfigService, err := internal.NewIssueFieldConfigurationService(client, APIVersion, fieldConfigurationItemService, fieldConfigurationSchemeService) if err != nil { return nil, err } - optionService, err := internal.NewIssueFieldContextOptionService(client, ApiVersion) + optionService, err := internal.NewIssueFieldContextOptionService(client, APIVersion) if err != nil { return nil, err } - fieldContextService, err := internal.NewIssueFieldContextService(client, ApiVersion, optionService) + fieldContextService, err := internal.NewIssueFieldContextService(client, APIVersion, optionService) if err != nil { return nil, err } - fieldTrashService, err := internal.NewIssueFieldTrashService(client, ApiVersion) + fieldTrashService, err := internal.NewIssueFieldTrashService(client, APIVersion) if err != nil { return nil, err } - issueFieldService, err := internal.NewIssueFieldService(client, ApiVersion, fieldConfigService, fieldContextService, fieldTrashService) + issueFieldService, err := internal.NewIssueFieldService(client, APIVersion, fieldConfigService, fieldContextService, fieldTrashService) if err != nil { return nil, err } - label, err := internal.NewLabelService(client, ApiVersion) + label, err := internal.NewLabelService(client, APIVersion) if err != nil { return nil, err } - linkType, err := internal.NewLinkTypeService(client, ApiVersion) + linkType, err := internal.NewLinkTypeService(client, APIVersion) if err != nil { return nil, err } - remoteLink, err := internal.NewRemoteLinkService(client, ApiVersion) + remoteLink, err := internal.NewRemoteLinkService(client, APIVersion) if err != nil { return nil, err } - link, _, err := internal.NewLinkService(client, ApiVersion, linkType, remoteLink) + link, _, err := internal.NewLinkService(client, APIVersion, linkType, remoteLink) if err != nil { return nil, err } - metadata, err := internal.NewMetadataService(client, ApiVersion) + metadata, err := internal.NewMetadataService(client, APIVersion) if err != nil { return nil, err } - priority, err := internal.NewPriorityService(client, ApiVersion) + priority, err := internal.NewPriorityService(client, APIVersion) if err != nil { return nil, err } - resolution, err := internal.NewResolutionService(client, ApiVersion) + resolution, err := internal.NewResolutionService(client, APIVersion) if err != nil { return nil, err } - search, _, err := internal.NewSearchService(client, ApiVersion) + search, _, err := internal.NewSearchService(client, APIVersion) if err != nil { return nil, err } - typeScheme, err := internal.NewTypeSchemeService(client, ApiVersion) + typeScheme, err := internal.NewTypeSchemeService(client, APIVersion) if err != nil { return nil, err } - issueTypeScreenScheme, err := internal.NewTypeScreenSchemeService(client, ApiVersion) + issueTypeScreenScheme, err := internal.NewTypeScreenSchemeService(client, APIVersion) if err != nil { return nil, err } - type_, err := internal.NewTypeService(client, ApiVersion, typeScheme, issueTypeScreenScheme) + typ, err := internal.NewTypeService(client, APIVersion, typeScheme, issueTypeScreenScheme) if err != nil { return nil, err } - vote, err := internal.NewVoteService(client, ApiVersion) + vote, err := internal.NewVoteService(client, APIVersion) if err != nil { return nil, err } - watcher, err := internal.NewWatcherService(client, ApiVersion) + watcher, err := internal.NewWatcherService(client, APIVersion) if err != nil { return nil, err } - worklog, err := internal.NewWorklogADFService(client, ApiVersion) + worklog, err := internal.NewWorklogADFService(client, APIVersion) if err != nil { return nil, err } - issueProperty, err := internal.NewIssuePropertyService(client, ApiVersion) + issueProperty, err := internal.NewIssuePropertyService(client, APIVersion) if err != nil { return nil, err } @@ -208,89 +212,89 @@ func New(httpClient common.HttpClient, site string) (*Client, error) { Priority: priority, Resolution: resolution, SearchADF: search, - Type: type_, + Type: typ, Vote: vote, Watcher: watcher, WorklogAdf: worklog, Property: issueProperty, } - mySelf, err := internal.NewMySelfService(client, ApiVersion) + mySelf, err := internal.NewMySelfService(client, APIVersion) if err != nil { return nil, err } - permissionSchemeGrant, err := internal.NewPermissionSchemeGrantService(client, ApiVersion) + permissionSchemeGrant, err := internal.NewPermissionSchemeGrantService(client, APIVersion) if err != nil { return nil, err } - permissionScheme, err := internal.NewPermissionSchemeService(client, ApiVersion, permissionSchemeGrant) + permissionScheme, err := internal.NewPermissionSchemeService(client, APIVersion, permissionSchemeGrant) if err != nil { return nil, err } - permission, err := internal.NewPermissionService(client, ApiVersion, permissionScheme) + permission, err := internal.NewPermissionService(client, APIVersion, permissionScheme) if err != nil { return nil, err } - _, issueService, err := internal.NewIssueService(client, ApiVersion, issueServices) + _, issueService, err := internal.NewIssueService(client, APIVersion, issueServices) if err != nil { return nil, err } - projectCategory, err := internal.NewProjectCategoryService(client, ApiVersion) + projectCategory, err := internal.NewProjectCategoryService(client, APIVersion) if err != nil { return nil, err } - projectComponent, err := internal.NewProjectComponentService(client, ApiVersion) + projectComponent, err := internal.NewProjectComponentService(client, APIVersion) if err != nil { return nil, err } - projectFeature, err := internal.NewProjectFeatureService(client, ApiVersion) + projectFeature, err := internal.NewProjectFeatureService(client, APIVersion) if err != nil { return nil, err } - projectPermission, err := internal.NewProjectPermissionSchemeService(client, ApiVersion) + projectPermission, err := internal.NewProjectPermissionSchemeService(client, APIVersion) if err != nil { return nil, err } - projectProperties, err := internal.NewProjectPropertyService(client, ApiVersion) + projectProperties, err := internal.NewProjectPropertyService(client, APIVersion) if err != nil { return nil, err } - projectRoleActor, err := internal.NewProjectRoleActorService(client, ApiVersion) + projectRoleActor, err := internal.NewProjectRoleActorService(client, APIVersion) if err != nil { return nil, err } - projectRole, err := internal.NewProjectRoleService(client, ApiVersion, projectRoleActor) + projectRole, err := internal.NewProjectRoleService(client, APIVersion, projectRoleActor) if err != nil { return nil, err } - projectType, err := internal.NewProjectTypeService(client, ApiVersion) + projectType, err := internal.NewProjectTypeService(client, APIVersion) if err != nil { return nil, err } - projectValidator, err := internal.NewProjectValidatorService(client, ApiVersion) + projectValidator, err := internal.NewProjectValidatorService(client, APIVersion) if err != nil { return nil, err } - projectVersion, err := internal.NewProjectVersionService(client, ApiVersion) + projectVersion, err := internal.NewProjectVersionService(client, APIVersion) if err != nil { return nil, err } - projectNotificationScheme, err := internal.NewNotificationSchemeService(client, ApiVersion) + projectNotificationScheme, err := internal.NewNotificationSchemeService(client, APIVersion) if err != nil { return nil, err } @@ -307,67 +311,67 @@ func New(httpClient common.HttpClient, site string) (*Client, error) { Version: projectVersion, } - project, err := internal.NewProjectService(client, ApiVersion, projectSubService) + project, err := internal.NewProjectService(client, APIVersion, projectSubService) if err != nil { return nil, err } - screenFieldTabField, err := internal.NewScreenTabFieldService(client, ApiVersion) + screenFieldTabField, err := internal.NewScreenTabFieldService(client, APIVersion) if err != nil { return nil, err } - screenTab, err := internal.NewScreenTabService(client, ApiVersion, screenFieldTabField) + screenTab, err := internal.NewScreenTabService(client, APIVersion, screenFieldTabField) if err != nil { return nil, err } - screenScheme, err := internal.NewScreenSchemeService(client, ApiVersion) + screenScheme, err := internal.NewScreenSchemeService(client, APIVersion) if err != nil { return nil, err } - screen, err := internal.NewScreenService(client, ApiVersion, screenScheme, screenTab) + screen, err := internal.NewScreenService(client, APIVersion, screenScheme, screenTab) if err != nil { return nil, err } - task, err := internal.NewTaskService(client, ApiVersion) + task, err := internal.NewTaskService(client, APIVersion) if err != nil { return nil, err } - server, err := internal.NewServerService(client, ApiVersion) + server, err := internal.NewServerService(client, APIVersion) if err != nil { return nil, err } - userSearch, err := internal.NewUserSearchService(client, ApiVersion) + userSearch, err := internal.NewUserSearchService(client, APIVersion) if err != nil { return nil, err } - user, err := internal.NewUserService(client, ApiVersion, userSearch) + user, err := internal.NewUserService(client, APIVersion, userSearch) if err != nil { return nil, err } workflowScheme := internal.NewWorkflowSchemeService( client, - ApiVersion, - internal.NewWorkflowSchemeIssueTypeService(client, ApiVersion)) + APIVersion, + internal.NewWorkflowSchemeIssueTypeService(client, APIVersion)) - workflowStatus, err := internal.NewWorkflowStatusService(client, ApiVersion) + workflowStatus, err := internal.NewWorkflowStatusService(client, APIVersion) if err != nil { return nil, err } - workflow, err := internal.NewWorkflowService(client, ApiVersion, workflowScheme, workflowStatus) + workflow, err := internal.NewWorkflowService(client, APIVersion, workflowScheme, workflowStatus) if err != nil { return nil, err } - jql, err := internal.NewJQLService(client, ApiVersion) + jql, err := internal.NewJQLService(client, APIVersion) if err != nil { return nil, err } @@ -376,7 +380,7 @@ func New(httpClient common.HttpClient, site string) (*Client, error) { client.Permission = permission client.MySelf = mySelf client.Auth = internal.NewAuthenticationService(client) - client.Banner = internal.NewAnnouncementBannerService(client, ApiVersion) + client.Banner = internal.NewAnnouncementBannerService(client, APIVersion) client.Role = applicationRoleService client.Dashboard = dashboardService client.Filter = filterService @@ -397,7 +401,7 @@ func New(httpClient common.HttpClient, site string) (*Client, error) { } type Client struct { - HTTP common.HttpClient + HTTP common.HTTPClient Auth common.Authentication Site *url.URL Audit *internal.AuditRecordService @@ -421,7 +425,8 @@ type Client struct { Team *internal.TeamService } -func (c *Client) NewRequest(ctx context.Context, method, urlStr, type_ string, body interface{}) (*http.Request, error) { +// NewRequest creates an API request. +func (c *Client) NewRequest(ctx context.Context, method, urlStr, contentType string, body interface{}) (*http.Request, error) { rel, err := url.Parse(urlStr) if err != nil { @@ -454,9 +459,9 @@ func (c *Client) NewRequest(ctx context.Context, method, urlStr, type_ string, b req.Header.Set("Content-Type", "application/json") } - if type_ != "" { - // When the type_ is provided, it means the request needs to be created to handle files - req.Header.Set("Content-Type", type_) + if contentType != "" { + // When the contentType is provided, it means the request needs to be created to handle files + req.Header.Set("Content-Type", contentType) req.Header.Set("X-Atlassian-Token", "no-check") } diff --git a/jira/v3/api_client_impl_test.go b/jira/v3/api_client_impl_test.go index 7fe347a1..e9b5affe 100644 --- a/jira/v3/api_client_impl_test.go +++ b/jira/v3/api_client_impl_test.go @@ -4,16 +4,18 @@ import ( "bytes" "context" "errors" - "github.com/ctreminiom/go-atlassian/jira/internal" - model "github.com/ctreminiom/go-atlassian/pkg/infra/models" - "github.com/ctreminiom/go-atlassian/service/common" - "github.com/ctreminiom/go-atlassian/service/mocks" - "github.com/stretchr/testify/assert" "io" "net/http" "net/url" "strings" "testing" + + "github.com/stretchr/testify/assert" + + "github.com/ctreminiom/go-atlassian/jira/internal" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" + "github.com/ctreminiom/go-atlassian/service/common" + "github.com/ctreminiom/go-atlassian/service/mocks" ) func TestClient_Call(t *testing.T) { @@ -64,7 +66,7 @@ func TestClient_Call(t *testing.T) { } type fields struct { - HTTP common.HttpClient + HTTP common.HTTPClient Site *url.URL Auth common.Authentication } @@ -86,7 +88,7 @@ func TestClient_Call(t *testing.T) { name: "when the parameters are correct", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(expectedResponse, nil) @@ -110,7 +112,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is a bad request", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(badRequestResponse, nil) @@ -135,7 +137,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is an internal service error", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(internalServerResponse, nil) @@ -160,7 +162,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is a not found", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(notFoundResponse, nil) @@ -185,7 +187,7 @@ func TestClient_Call(t *testing.T) { name: "when the response status is unauthorized", on: func(fields *fields) { - client := mocks.NewHttpClient(t) + client := mocks.NewHTTPClient(t) client.On("Do", (*http.Request)(nil)). Return(unauthorizedResponse, nil) @@ -263,17 +265,17 @@ func TestClient_NewRequest(t *testing.T) { requestMocked.Header.Set("Content-Type", "application/json") type fields struct { - HTTP common.HttpClient + HTTP common.HTTPClient Auth common.Authentication Site *url.URL } type args struct { - ctx context.Context - method string - urlStr string - type_ string - body interface{} + ctx context.Context + method string + urlStr string + contentType string + body interface{} } testCases := []struct { @@ -291,11 +293,11 @@ func TestClient_NewRequest(t *testing.T) { Site: siteAsURL, }, args: args{ - ctx: context.Background(), - method: http.MethodGet, - urlStr: "rest/2/issue/attachment", - type_: "", - body: bytes.NewReader([]byte("Hello World")), + ctx: context.Background(), + method: http.MethodGet, + urlStr: "rest/2/issue/attachment", + contentType: "", + body: bytes.NewReader([]byte("Hello World")), }, want: requestMocked, wantErr: false, @@ -326,11 +328,11 @@ func TestClient_NewRequest(t *testing.T) { Site: siteAsURL, }, args: args{ - ctx: context.Background(), - method: http.MethodGet, - urlStr: "rest/2/issue/attachment", - type_: "type_sample", - body: bytes.NewReader([]byte("Hello World")), + ctx: context.Background(), + method: http.MethodGet, + urlStr: "rest/2/issue/attachment", + contentType: "type_sample", + body: bytes.NewReader([]byte("Hello World")), }, want: requestMocked, wantErr: false, @@ -367,7 +369,7 @@ func TestClient_NewRequest(t *testing.T) { testCase.args.ctx, testCase.args.method, testCase.args.urlStr, - testCase.args.type_, + testCase.args.contentType, testCase.args.body, ) @@ -389,7 +391,7 @@ func TestClient_NewRequest(t *testing.T) { func TestClient_processResponse(t *testing.T) { - expectedJsonResponse := ` + expectedJSONResponse := ` { "id": 4, "self": "https://ctreminiom.atlassian.net/rest/agile/1.0/board/4", @@ -399,7 +401,7 @@ func TestClient_processResponse(t *testing.T) { expectedResponse := &http.Response{ StatusCode: http.StatusOK, - Body: io.NopCloser(strings.NewReader(expectedJsonResponse)), + Body: io.NopCloser(strings.NewReader(expectedJSONResponse)), Request: &http.Request{ Method: http.MethodGet, URL: &url.URL{}, @@ -407,7 +409,7 @@ func TestClient_processResponse(t *testing.T) { } type fields struct { - HTTP common.HttpClient + HTTP common.HTTPClient Site *url.URL Authentication common.Authentication } @@ -435,7 +437,7 @@ func TestClient_processResponse(t *testing.T) { Response: expectedResponse, Code: http.StatusOK, Method: http.MethodGet, - Bytes: *bytes.NewBufferString(expectedJsonResponse), + Bytes: *bytes.NewBufferString(expectedJSONResponse), }, wantErr: false, }, @@ -484,7 +486,7 @@ func TestNew(t *testing.T) { noURLClientMocked, _ := New(nil, "") type args struct { - httpClient common.HttpClient + httpClient common.HTTPClient site string } diff --git a/pkg/infra/models/agile_board.go b/pkg/infra/models/agile_board.go index 1746c6af..a912a3c9 100644 --- a/pkg/infra/models/agile_board.go +++ b/pkg/infra/models/agile_board.go @@ -213,5 +213,5 @@ type BoardBacklogPayloadScheme struct { Issues []string `json:"issues,omitempty"` RankBeforeIssue string `json:"rankBeforeIssue,omitempty"` RankAfterIssue string `json:"rankAfterIssue,omitempty"` - RankCustomFieldId int `json:"rankCustomFieldId,omitempty"` + RankCustomFieldID int `json:"rankCustomFieldId,omitempty"` } diff --git a/pkg/infra/models/assets_aql.go b/pkg/infra/models/assets_aql.go index b925e562..de2123d1 100644 --- a/pkg/infra/models/assets_aql.go +++ b/pkg/infra/models/assets_aql.go @@ -58,8 +58,8 @@ type ObjectPageScheme struct { // PageNumber is the number of the page. PageNumber int `json:"pageNumber"` - // OrderByTypeAttrId is the ID of the attribute used for ordering. - OrderByTypeAttrId int `json:"orderByTypeAttrId"` + // OrderByTypeAttrID is the ID of the attribute used for ordering. + OrderByTypeAttrID int `json:"orderByTypeAttrId"` // OrderWay is the way of ordering (ascending or descending). OrderWay string `json:"orderWay"` diff --git a/pkg/infra/models/errors.go b/pkg/infra/models/errors.go index 730301c3..3135269b 100644 --- a/pkg/infra/models/errors.go +++ b/pkg/infra/models/errors.go @@ -87,7 +87,7 @@ var ( ErrNoCustomFieldID = errors.New("jira: no custom-field id set") ErrNoWorkflowStatuses = errors.New("jira: no workflow statuses set") ErrNoWorkflowScope = errors.New("jira: no workflow scope set") - ErrNoWorkflowStatusNameOrId = errors.New("jira: no workflow status name or id set") + ErrNoWorkflowStatusNameOrID = errors.New("jira: no workflow status name or id set") ErrNoFieldContextID = errors.New("jira: no field context id set") ErrNoIssueTypes = errors.New("jira: no issue types id's set") ErrNoProjects = errors.New("jira: no projects set") @@ -140,7 +140,7 @@ var ( ErrNoFieldInformation = errors.New("custom-field: please provide a buffer with a valid fields object") ErrNoMultiSelectType = errors.New("custom-field: no multiselect type found") ErrNoAssetType = errors.New("custom-field: no asset type found") - ErrNoUrlType = errors.New("custom-field: no url type set") + ErrNoURLType = errors.New("custom-field: no url type set") ErrNoTextType = errors.New("custom-field: no text type set") ErrNoDatePickerType = errors.New("custom-field: no datepicker type set") ErrNoDateTimeType = errors.New("custom-field: no datetime type set") diff --git a/pkg/infra/models/jira_changelog.go b/pkg/infra/models/jira_changelog.go index 95a36e5c..507007b2 100644 --- a/pkg/infra/models/jira_changelog.go +++ b/pkg/infra/models/jira_changelog.go @@ -21,7 +21,7 @@ type IssueChangelogAuthor struct { Self string `json:"self,omitempty"` // The URL of the author's profile. AccountID string `json:"accountId,omitempty"` // The account ID of the author. EmailAddress string `json:"emailAddress,omitempty"` // The email address of the author. - AvatarUrls *AvatarURLScheme `json:"avatarUrls,omitempty"` // The URLs for different sizes of the author's avatar. + AvatarURLs *AvatarURLScheme `json:"avatarUrls,omitempty"` // The URLs for different sizes of the author's avatar. DisplayName string `json:"displayName,omitempty"` // The display name of the author. Active bool `json:"active,omitempty"` // Indicates if the author's account is active. TimeZone string `json:"timeZone,omitempty"` // The time zone of the author. diff --git a/pkg/infra/models/jira_custom_fields.go b/pkg/infra/models/jira_custom_fields.go index c0633f5f..23e8b0f1 100644 --- a/pkg/infra/models/jira_custom_fields.go +++ b/pkg/infra/models/jira_custom_fields.go @@ -70,7 +70,7 @@ func (c *CustomFields) URL(customFieldID, URL string) error { } if len(URL) == 0 { - return ErrNoUrlType + return ErrNoURLType } var urlNode = map[string]interface{}{} diff --git a/pkg/infra/models/jira_custom_fields_test.go b/pkg/infra/models/jira_custom_fields_test.go index 20c6b9ec..8064f27d 100644 --- a/pkg/infra/models/jira_custom_fields_test.go +++ b/pkg/infra/models/jira_custom_fields_test.go @@ -1,9 +1,10 @@ package models import ( - "github.com/stretchr/testify/assert" "testing" "time" + + "github.com/stretchr/testify/assert" ) func TestCustomFields_Cascading(t *testing.T) { @@ -807,7 +808,7 @@ func TestCustomFields_URL(t *testing.T) { URL: "", }, wantErr: true, - Err: ErrNoUrlType, + Err: ErrNoURLType, }, } for _, testCase := range testCases { diff --git a/pkg/infra/models/jira_field_configuration_scheme.go b/pkg/infra/models/jira_field_configuration_scheme.go index 28b82f6f..009ea4dd 100644 --- a/pkg/infra/models/jira_field_configuration_scheme.go +++ b/pkg/infra/models/jira_field_configuration_scheme.go @@ -43,7 +43,7 @@ type FieldConfigurationSchemeProjectPageScheme struct { // FieldConfigurationSchemeProjectScheme represents a field configuration scheme project in Jira. type FieldConfigurationSchemeProjectScheme struct { - ProjectIds []string `json:"projectIds,omitempty"` // The IDs of the projects. + ProjectIDs []string `json:"projectIds,omitempty"` // The IDs of the projects. FieldConfigurationScheme *FieldConfigurationSchemeScheme `json:"fieldConfigurationScheme,omitempty"` // The field configuration scheme. } diff --git a/pkg/infra/models/jira_issue_custom_fields_test.go b/pkg/infra/models/jira_issue_custom_fields_test.go index 0ff60333..e3c3930b 100644 --- a/pkg/infra/models/jira_issue_custom_fields_test.go +++ b/pkg/infra/models/jira_issue_custom_fields_test.go @@ -2198,7 +2198,7 @@ func TestParseRequestTypeCustomField(t *testing.T) { HelpText: "", IssueTypeID: "10039", ServiceDeskID: "2", - GroupIds: []string{}, + GroupIDs: []string{}, }, CurrentStatus: &CustomerRequestCurrentStatusScheme{ Status: "Check billing account", @@ -6513,7 +6513,7 @@ func TestParseRequestTypeCustomFields(t *testing.T) { HelpText: "", IssueTypeID: "10039", ServiceDeskID: "2", - GroupIds: []string{}, + GroupIDs: []string{}, }, CurrentStatus: &CustomerRequestCurrentStatusScheme{ Status: "Check billing account", @@ -6539,7 +6539,7 @@ func TestParseRequestTypeCustomFields(t *testing.T) { HelpText: "", IssueTypeID: "10039", ServiceDeskID: "2", - GroupIds: []string{}, + GroupIDs: []string{}, }, CurrentStatus: &CustomerRequestCurrentStatusScheme{ Status: "Check billing account", diff --git a/pkg/infra/models/jira_issue_search.go b/pkg/infra/models/jira_issue_search.go index 3f64c07b..080a1dac 100644 --- a/pkg/infra/models/jira_issue_search.go +++ b/pkg/infra/models/jira_issue_search.go @@ -2,7 +2,7 @@ package models // IssueSearchCheckPayloadScheme represents the payload for checking issue search in Jira. type IssueSearchCheckPayloadScheme struct { - IssueIds []int `json:"issueIds,omitempty"` // The IDs of the issues. + IssueIDs []int `json:"issueIds,omitempty"` // The IDs of the issues. JQLs []string `json:"jqls,omitempty"` // The JQLs for the issue search. } diff --git a/pkg/infra/models/jira_issue_type_scheme.go b/pkg/infra/models/jira_issue_type_scheme.go index aec22342..250808e2 100644 --- a/pkg/infra/models/jira_issue_type_scheme.go +++ b/pkg/infra/models/jira_issue_type_scheme.go @@ -3,7 +3,7 @@ package models // IssueTypeSchemePayloadScheme represents the payload for an issue type scheme in Jira. type IssueTypeSchemePayloadScheme struct { DefaultIssueTypeID string `json:"defaultIssueTypeId,omitempty"` // The default issue type ID. - IssueTypeIds []string `json:"issueTypeIds,omitempty"` // The issue type IDs. + IssueTypeIDs []string `json:"issueTypeIds,omitempty"` // The issue type IDs. Name string `json:"name,omitempty"` // The name of the issue type scheme. Description string `json:"description,omitempty"` // The description of the issue type scheme. } diff --git a/pkg/infra/models/sm_request.go b/pkg/infra/models/sm_request.go index 60c5de9d..bf956dad 100644 --- a/pkg/infra/models/sm_request.go +++ b/pkg/infra/models/sm_request.go @@ -62,7 +62,7 @@ type CustomerRequestTypeScheme struct { HelpText string `json:"helpText,omitempty"` // The help text for the customer request type. IssueTypeID string `json:"issueTypeId,omitempty"` // The issue type ID for the customer request type. ServiceDeskID string `json:"serviceDeskId,omitempty"` // The service desk ID for the customer request type. - GroupIds []string `json:"groupIds,omitempty"` // The group IDs for the customer request type. + GroupIDs []string `json:"groupIds,omitempty"` // The group IDs for the customer request type. } // CustomerRequestServiceDeskScheme represents a service desk for a customer request. diff --git a/service/admin/organization.go b/service/admin/organization.go index 3db4aeb8..bf83acee 100644 --- a/service/admin/organization.go +++ b/service/admin/organization.go @@ -2,6 +2,7 @@ package admin import ( "context" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -18,49 +19,49 @@ type OrganizationConnector interface { // Get returns information about a single organization by ID // - // GET /admin/v1/orgs/{orgId} + // GET /admin/v1/orgs/{organizationID} // // https://docs.go-atlassian.io/atlassian-admin-cloud/organization#get-an-organization-by-id Get(ctx context.Context, organizationID string) (*model.AdminOrganizationScheme, *model.ResponseScheme, error) // Users returns a list of users in an organization. // - // GET /admin/v1/orgs/{orgId}/users + // GET /admin/v1/orgs/{organizationID}/users // // https://docs.go-atlassian.io/atlassian-admin-cloud/organization#get-users-in-an-organization Users(ctx context.Context, organizationID, cursor string) (*model.OrganizationUserPageScheme, *model.ResponseScheme, error) // Domains returns a list of domains in an organization one page at a time. // - // GET /admin/v1/orgs/{orgId}/domains + // GET /admin/v1/orgs/{organizationID}/domains // // https://docs.go-atlassian.io/atlassian-admin-cloud/organization#get-domains-in-an-organization Domains(ctx context.Context, organizationID, cursor string) (*model.OrganizationDomainPageScheme, *model.ResponseScheme, error) // Domain returns information about a single verified domain by ID. // - // GET /admin/v1/orgs/{orgId}/domains/{domainId} + // GET /admin/v1/orgs/{organizationID}/domains/{domainID} // // https://docs.go-atlassian.io/atlassian-admin-cloud/organization#get-domain-by-id Domain(ctx context.Context, organizationID, domainID string) (*model.OrganizationDomainScheme, *model.ResponseScheme, error) // Events returns an audit log of events from an organization one page at a time. // - // GET /admin/v1/orgs/{orgId}/events + // GET /admin/v1/orgs/{organizationID}/events // // https://docs.go-atlassian.io/atlassian-admin-cloud/organization#get-an-audit-log-of-events Events(ctx context.Context, organizationID string, options *model.OrganizationEventOptScheme, cursor string) (*model.OrganizationEventPageScheme, *model.ResponseScheme, error) // Event returns information about a single event by ID. // - // GET /admin/v1/orgs/{orgId}/events/{eventId} + // GET /admin/v1/orgs/{organizationID}/events/{eventID} // // https://docs.go-atlassian.io/atlassian-admin-cloud/organization#get-an-event-by-id Event(ctx context.Context, organizationID, eventID string) (*model.OrganizationEventScheme, *model.ResponseScheme, error) // Actions returns information localized event actions. // - // GET /admin/v1/orgs/{orgId}/event-actions + // GET /admin/v1/orgs/{organizationID}/event-actions // // https://docs.go-atlassian.io/atlassian-admin-cloud/organization#get-list-of-event-actions Actions(ctx context.Context, organizationID string) (*model.OrganizationEventActionScheme, *model.ResponseScheme, error) diff --git a/service/admin/organization_directory.go b/service/admin/organization_directory.go index 79ba97dc..3d35609c 100644 --- a/service/admin/organization_directory.go +++ b/service/admin/organization_directory.go @@ -2,6 +2,7 @@ package admin import ( "context" + "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -19,7 +20,7 @@ type OrganizationDirectoryConnector interface { // // The added_to_org date field is available only to customers using the new user management experience. // - // GET /admin/v1/orgs/{orgId}/directory/users/{accountId}/last-active-dates + // GET /admin/v1/orgs/{organizationID}/directory/users/{accountID}/last-active-dates // // https://docs.go-atlassian.io/atlassian-admin-cloud/organization/directory#users-last-active-dates Activity(ctx context.Context, organizationID, accountID string) (*models.UserProductAccessScheme, *models.ResponseScheme, error) @@ -30,7 +31,7 @@ type OrganizationDirectoryConnector interface { // // Note: Users with emails whose domain is claimed can still be found in Managed accounts in Directory. // - // DELETE /admin/v1/orgs/{orgId}/directory/users/{accountId} + // DELETE /admin/v1/orgs/{organizationID}/directory/users/{accountID} // // https://docs.go-atlassian.io/atlassian-admin-cloud/organization/directory#remove-user-access Remove(ctx context.Context, organizationID, accountID string) (*models.ResponseScheme, error) @@ -41,7 +42,7 @@ type OrganizationDirectoryConnector interface { // // Note: Users with emails whose domain is claimed can still be found in Managed accounts in Directory. // - // POST /admin/v1/orgs/{orgId}/directory/users/{accountId}/suspend-access + // POST /admin/v1/orgs/{organizationID}/directory/users/{accountID}/suspend-access // // https://docs.go-atlassian.io/atlassian-admin-cloud/organization/directory#suspend-user-access Suspend(ctx context.Context, organizationID, accountID string) (*models.GenericActionSuccessScheme, *models.ResponseScheme, error) @@ -52,7 +53,7 @@ type OrganizationDirectoryConnector interface { // // Note: Users with emails whose domain is claimed can still be found in Managed accounts in Directory. // - // POST /admin/v1/orgs/{orgId}/directory/users/{accountId}/restore-access + // POST /admin/v1/orgs/{organizationID}/directory/users/{accountID}/restore-access // // https://docs.go-atlassian.io/atlassian-admin-cloud/organization/directory#restore-user-access Restore(ctx context.Context, organizationID, accountID string) (*models.GenericActionSuccessScheme, *models.ResponseScheme, error) diff --git a/service/admin/policy.go b/service/admin/policy.go index b48c2442..aeebf9a6 100644 --- a/service/admin/policy.go +++ b/service/admin/policy.go @@ -2,6 +2,7 @@ package admin import ( "context" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -11,35 +12,35 @@ type OrganizationPolicyConnector interface { // Gets returns information about org policies. // - // GET /admin/v1/orgs/{orgId}/policies + // GET /admin/v1/orgs/{organizationID}/policies // // https://docs.go-atlassian.io/atlassian-admin-cloud/organization/policy#get-list-of-policies Gets(ctx context.Context, organizationID, policyType, cursor string) (*model.OrganizationPolicyPageScheme, *model.ResponseScheme, error) // Get returns information about a single policy by ID. // - // GET /admin/v1/orgs/{orgId}/policies/{policyId} + // GET /admin/v1/orgs/{organizationID}/policies/{policyID} // // https://docs.go-atlassian.io/atlassian-admin-cloud/organization/policy#get-a-policy-by-id Get(ctx context.Context, organizationID, policyID string) (*model.OrganizationPolicyScheme, *model.ResponseScheme, error) // Create creates a policy for an org // - // POST /admin/v1/orgs/{orgId}/policies + // POST /admin/v1/orgs/{organizationID}/policies // // https://docs.go-atlassian.io/atlassian-admin-cloud/organization/policy#create-a-policy Create(ctx context.Context, organizationID string, payload *model.OrganizationPolicyData) (*model.OrganizationPolicyScheme, *model.ResponseScheme, error) // Update updates a policy for an org // - // PUT /admin/v1/orgs/{orgId}/policies/{policyId} + // PUT /admin/v1/orgs/{organizationID}/policies/{policyID} // // https://docs.go-atlassian.io/atlassian-admin-cloud/organization/policy#update-a-policy Update(ctx context.Context, organizationID, policyID string, payload *model.OrganizationPolicyData) (*model.OrganizationPolicyScheme, *model.ResponseScheme, error) // Delete deletes a policy for an org. // - // DELETE /admin/v1/orgs/{orgId}/policies/{policyId} + // DELETE /admin/v1/orgs/{organizationID}/policies/{policyID} // // https://docs.go-atlassian.io/atlassian-admin-cloud/organization/policy#delete-a-policy Delete(ctx context.Context, organizationID, policyID string) (*model.ResponseScheme, error) diff --git a/service/admin/scim_group.go b/service/admin/scim_group.go index b5b6124f..1ef62d24 100644 --- a/service/admin/scim_group.go +++ b/service/admin/scim_group.go @@ -2,6 +2,7 @@ package admin import ( "context" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -17,21 +18,21 @@ type SCIMGroupConnector interface { // // Sorting is not supported. // - // GET /scim/directory/{directoryId}/Groups + // GET /scim/directory/{directoryID}/Groups // // https://docs.go-atlassian.io/atlassian-admin-cloud/scim/groups#get-groups Gets(ctx context.Context, directoryID, filter string, startAt, maxResults int) (*model.ScimGroupPageScheme, *model.ResponseScheme, error) // Get returns a group from a directory by group ID. // - // GET /scim/directory/{directoryId}/Groups/{id} + // GET /scim/directory/{directoryID}/Groups/{groupID} // // https://docs.go-atlassian.io/atlassian-admin-cloud/scim/groups#get-a-group-by-id Get(ctx context.Context, directoryID, groupID string) (*model.ScimGroupScheme, *model.ResponseScheme, error) // Update updates a group in a directory by group ID. // - // PUT /scim/directory/{directoryId}/Groups/{id} + // PUT /scim/directory/{directoryID}/Groups/{groupID} // // https://docs.go-atlassian.io/atlassian-admin-cloud/scim/groups#update-a-group-by-id Update(ctx context.Context, directoryID, groupID string, newGroupName string) (*model.ScimGroupScheme, *model.ResponseScheme, error) @@ -40,7 +41,7 @@ type SCIMGroupConnector interface { // // An attempt to delete a non-existent group fails with a 404 (Resource Not found) error. // - // DELETE /scim/directory/{directoryId}/Groups/{id} + // DELETE /scim/directory/{directoryID}/Groups/{groupID} // // https://docs.go-atlassian.io/atlassian-admin-cloud/scim/groups#delete-a-group-by-id Delete(ctx context.Context, directoryID, groupID string) (*model.ResponseScheme, error) @@ -49,16 +50,16 @@ type SCIMGroupConnector interface { // // An attempt to create a group with an existing name fails with a 409 (Conflict) error. // - // POST /scim/directory/{directoryId}/Groups + // POST /scim/directory/{directoryID}/Groups // // https://docs.go-atlassian.io/atlassian-admin-cloud/scim/groups#create-a-group Create(ctx context.Context, directoryID, groupName string) (*model.ScimGroupScheme, *model.ResponseScheme, error) - // Path update a group's information in a directory by groupId via PATCH. + // Path update a group's information in a directory by group id via PATCH. // // You can use this API to manage group membership. // - // PATCH /scim/directory/{directoryId}/Groups/{id} + // PATCH /scim/directory/{directoryID}/Groups/{groupID} // // https://docs.go-atlassian.io/atlassian-admin-cloud/scim/groups#update-a-group-by-id-patch Path(ctx context.Context, directoryID, groupID string, payload *model.SCIMGroupPathScheme) (*model.ScimGroupScheme, *model.ResponseScheme, error) diff --git a/service/admin/scim_schema.go b/service/admin/scim_schema.go index bcf6c26e..2c9a8dd4 100644 --- a/service/admin/scim_schema.go +++ b/service/admin/scim_schema.go @@ -2,6 +2,7 @@ package admin import ( "context" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -13,7 +14,7 @@ type SCIMSchemaConnector interface { // // Filtering, pagination and sorting are not supported. // - // GET /scim/directory/{directoryId}/Schemas + // GET /scim/directory/{directoryID}/Schemas // // https://docs.go-atlassian.io/atlassian-admin-cloud/scim/schemas#get-all-schemas Gets(ctx context.Context, directoryID string) (*model.SCIMSchemasScheme, *model.ResponseScheme, error) @@ -22,7 +23,7 @@ type SCIMSchemaConnector interface { // // Filtering, pagination and sorting are not supported. // - // GET /scim/directory/{directoryId}/Schemas/urn:ietf:params:scim:schemas:core:2.0:Group + // GET /scim/directory/{directoryID}/Schemas/urn:ietf:params:scim:schemas:core:2.0:Group // // https://docs.go-atlassian.io/atlassian-admin-cloud/scim/schemas#get-group-schemas Group(ctx context.Context, directoryID string) (*model.SCIMSchemaScheme, *model.ResponseScheme, error) @@ -31,7 +32,7 @@ type SCIMSchemaConnector interface { // // Filtering, pagination and sorting are not supported. // - // GET /scim/directory/{directoryId}/Schemas/urn:ietf:params:scim:schemas:core:2.0:User + // GET /scim/directory/{directoryID}/Schemas/urn:ietf:params:scim:schemas:core:2.0:User // // https://docs.go-atlassian.io/atlassian-admin-cloud/scim/schemas#get-user-schemas User(ctx context.Context, directoryID string) (*model.SCIMSchemaScheme, *model.ResponseScheme, error) @@ -40,7 +41,7 @@ type SCIMSchemaConnector interface { // // Filtering, pagination and sorting are not supported. // - // GET /scim/directory/{directoryId}/Schemas/urn:ietf:params:scim:schemas:extension:enterprise:2.0:User + // GET /scim/directory/{directoryID}/Schemas/urn:ietf:params:scim:schemas:extension:enterprise:2.0:User // // https://docs.go-atlassian.io/atlassian-admin-cloud/scim/schemas#get-user-enterprise-extension-schemas Enterprise(ctx context.Context, directoryID string) (*model.SCIMSchemaScheme, *model.ResponseScheme, error) @@ -51,7 +52,7 @@ type SCIMSchemaConnector interface { // // Filtering, pagination and sorting are not supported. // - // GET /scim/directory/{directoryId}/ServiceProviderConfig + // GET /scim/directory/{directoryID}/ServiceProviderConfig // // https://docs.go-atlassian.io/atlassian-admin-cloud/scim/schemas#get-feature-metadata Feature(ctx context.Context, directoryID string) (*model.ServiceProviderConfigScheme, *model.ResponseScheme, error) diff --git a/service/admin/scim_user.go b/service/admin/scim_user.go index 9920c801..c87ab615 100644 --- a/service/admin/scim_user.go +++ b/service/admin/scim_user.go @@ -2,6 +2,7 @@ package admin import ( "context" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -19,56 +20,56 @@ type SCIMUserConnector interface { // // the user in your identity provider is linked to the user in your Atlassian organization. // - // POST /scim/directory/{directoryId}/Users + // POST /scim/directory/{directoryID}/Users // // https://docs.go-atlassian.io/atlassian-admin-cloud/scim/users#create-a-user Create(ctx context.Context, directoryID string, payload *model.SCIMUserScheme, attributes, excludedAttributes []string) (*model.SCIMUserScheme, *model.ResponseScheme, error) // Gets get users from the specified directory. // - // Filtering is supported with a single exact match (eq) against the userName and externalId attributes. + // Filtering is supported with a single exact match (eq) against the userName and external id attributes. // // Pagination is supported. // // Sorting is not supported. // - // GET /scim/directory/{directoryId}/Users + // GET /scim/directory/{directoryID}/Users // // https://docs.go-atlassian.io/atlassian-admin-cloud/scim/users#get-users Gets(ctx context.Context, directoryID string, opts *model.SCIMUserGetsOptionsScheme, startIndex, count int) (*model.SCIMUserPageScheme, *model.ResponseScheme, error) - // Get gets a user from a directory by userId. + // Get gets a user from a directory by user id. // - // GET /scim/directory/{directoryId}/Users/{userId} + // GET /scim/directory/{directoryID}/Users/{userID} // // https://docs.go-atlassian.io/atlassian-admin-cloud/scim/users#get-a-user-by-id Get(ctx context.Context, directoryID, userID string, attributes, excludedAttributes []string) (*model.SCIMUserScheme, *model.ResponseScheme, error) - // Deactivate deactivates a user by userId. + // Deactivate deactivates a user by user id. // // The user is not available for future requests until activated again. // // Any future operation for the deactivated user returns the 404 (resource not found) error. // - // DELETE /scim/directory/{directoryId}/Users/{userId} + // DELETE /scim/directory/{directoryID}/Users/{userID} Deactivate(ctx context.Context, directoryID, userID string) (*model.ResponseScheme, error) - // Path updates a user's information in a directory by userId via PATCH. + // Path updates a user's information in a directory by user id via PATCH. // // Refer to GET /ServiceProviderConfig for details on the supported operations. // - // PATCH /scim/directory/{directoryId}/Users/{userId} + // PATCH /scim/directory/{directoryID}/Users/{userID} // // https://docs.go-atlassian.io/atlassian-admin-cloud/scim/users#update-user-by-id-patch Path(ctx context.Context, directoryID, userID string, payload *model.SCIMUserToPathScheme, attributes, excludedAttributes []string) (*model.SCIMUserScheme, *model.ResponseScheme, error) - // Update updates a user's information in a directory by userId via user attributes. + // Update updates a user's information in a directory by user id via user attributes. // // User information is replaced attribute-by-attribute, except immutable and read-only attributes. // // Existing values of unspecified attributes are cleaned. // - // PUT /scim/directory/{directoryId}/Users/{userId} + // PUT /scim/directory/{directoryID}/Users/{userID} // // https://docs.go-atlassian.io/atlassian-admin-cloud/scim/users#update-user-via-user-attributes Update(ctx context.Context, directoryID, userID string, payload *model.SCIMUserScheme, attributes, excludedAttributes []string) (*model.SCIMUserScheme, *model.ResponseScheme, error) diff --git a/service/admin/token.go b/service/admin/token.go index c9217cbd..f14325c7 100644 --- a/service/admin/token.go +++ b/service/admin/token.go @@ -2,6 +2,7 @@ package admin import ( "context" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -11,14 +12,14 @@ type UserTokenConnector interface { // Gets gets the API tokens owned by the specified user. // - // GET /users/{account_id}/manage/api-tokens + // GET /users/{accountID}/manage/api-tokens // // https://docs.go-atlassian.io/atlassian-admin-cloud/user/token#get-api-tokens Gets(ctx context.Context, accountID string) ([]*model.UserTokensScheme, *model.ResponseScheme, error) // Delete deletes a specified API token by ID. // - // DELETE /users/{account_id}/manage/api-tokens/{tokenId} + // DELETE /users/{accountID}/manage/api-tokens/{tokenID} // // https://docs.go-atlassian.io/atlassian-admin-cloud/user/token#delete-api-token Delete(ctx context.Context, accountID, tokenID string) (*model.ResponseScheme, error) diff --git a/service/agile/board.go b/service/agile/board.go index 781c1100..e2874dac 100644 --- a/service/agile/board.go +++ b/service/agile/board.go @@ -164,7 +164,7 @@ type BoardConnector interface { // // Issues are returned ordered by rank. JQL order has higher priority than default rank. // - // GET /rest/agile/1.0/board/{boardID}/sprint/{sprintId}/issue + // GET /rest/agile/1.0/board/{boardID}/sprint/{sprintID}/issue // // https://docs.go-atlassian.io/jira-agile/boards#get-board-issues-for-sprint IssuesBySprint(ctx context.Context, boardID, sprintID int, opts *model.IssueOptionScheme, startAt, maxResults int) ( @@ -178,7 +178,7 @@ type BoardConnector interface { // // Returned versions are ordered by the name of the project from which they belong and then by sequence defined by user. // - // GET /rest/agile/1.0/board/{boardID}/sprint/{sprintId}/issue + // GET /rest/agile/1.0/board/{boardID}/sprint/{sprintID}/issue // // https://docs.go-atlassian.io/jira-agile/boards#get-all-versions Versions(ctx context.Context, boardID, startAt, maxResults int, released bool) (*model.BoardVersionPageScheme, diff --git a/service/agile/sprint.go b/service/agile/sprint.go index 31bfc08c..384a8260 100644 --- a/service/agile/sprint.go +++ b/service/agile/sprint.go @@ -2,6 +2,7 @@ package agile import ( "context" + "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -13,7 +14,7 @@ type SprintConnector interface { // // or view at least one of the issues in the sprint. // - // GET /rest/agile/1.0/sprint/{sprintId} + // GET /rest/agile/1.0/sprint/{sprintID} // // https://docs.go-atlassian.io/jira-agile/sprints#get-sprint Get(ctx context.Context, sprintID int) (*models.SprintScheme, *models.ResponseScheme, error) @@ -35,7 +36,7 @@ type SprintConnector interface { // // Any fields not present in the request JSON will be set to null. // - // PUT /rest/agile/1.0/sprint/{sprintId} + // PUT /rest/agile/1.0/sprint/{sprintID} // // https://docs.go-atlassian.io/jira-agile/sprints#update-sprint Update(ctx context.Context, sprintID int, payload *models.SprintPayloadScheme) (*models.SprintScheme, *models.ResponseScheme, error) @@ -44,7 +45,7 @@ type SprintConnector interface { // // A partial update means that fields not present in the request JSON will not be updated. // - // POST /rest/agile/1.0/sprint/{sprintId} + // POST /rest/agile/1.0/sprint/{sprintID} // // https://docs.go-atlassian.io/jira-agile/sprints#partially-update-sprint Path(ctx context.Context, sprintID int, payload *models.SprintPayloadScheme) (*models.SprintScheme, *models.ResponseScheme, error) @@ -53,7 +54,7 @@ type SprintConnector interface { // // Once a sprint is deleted, all open issues in the sprint will be moved to the backlog. // - // DELETE /rest/agile/1.0/sprint/{sprintId} + // DELETE /rest/agile/1.0/sprint/{sprintID} // // https://docs.go-atlassian.io/jira-agile/sprints#delete-sprint Delete(ctx context.Context, sprintID int) (*models.ResponseScheme, error) @@ -64,21 +65,21 @@ type SprintConnector interface { // // By default, the returned issues are ordered by rank. // - // GET /rest/agile/1.0/sprint/{sprintId}/issue + // GET /rest/agile/1.0/sprint/{sprintID}/issue // // https://docs.go-atlassian.io/jira-agile/sprints#get-issues-for-sprint Issues(ctx context.Context, sprintID int, opts *models.IssueOptionScheme, startAt, maxResults int) (*models.SprintIssuePageScheme, *models.ResponseScheme, error) // Start initiate the Sprint // - // PUT /rest/agile/1.0/sprint/{sprintId} + // PUT /rest/agile/1.0/sprint/{sprintID} // // https://docs.go-atlassian.io/jira-agile/sprints#start-sprint Start(ctx context.Context, sprintID int) (*models.ResponseScheme, error) // Close closes the Sprint // - // PUT /rest/agile/1.0/sprint/{sprintId} + // PUT /rest/agile/1.0/sprint/{sprintID} // // https://docs.go-atlassian.io/jira-agile/sprints#close-sprint Close(ctx context.Context, sprintID int) (*models.ResponseScheme, error) @@ -89,7 +90,7 @@ type SprintConnector interface { // // The maximum number of issues that can be moved in one operation is 50. // - // POST /rest/agile/1.0/sprint/{sprintId}/issue + // POST /rest/agile/1.0/sprint/{sprintID}/issue // // https://docs.go-atlassian.io/jira-agile/sprints#move-issues-to-sprint Move(ctx context.Context, sprintID int, payload *models.SprintMovePayloadScheme) (*models.ResponseScheme, error) diff --git a/service/assets/aql.go b/service/assets/aql.go index 9ec3dee2..c5b2e661 100644 --- a/service/assets/aql.go +++ b/service/assets/aql.go @@ -2,6 +2,7 @@ package assets import ( "context" + "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -11,7 +12,7 @@ type AQLAssetConnector interface { // Filter search objects based on Assets Query Language (AQL) // - // POST /jsm/assets/workspace/{workspaceId}/v1/aql/objects + // POST /jsm/assets/workspace/{workspaceID}/v1/aql/objects // // Deprecated. Please use Object.Filter() instead. // diff --git a/service/assets/icon.go b/service/assets/icon.go index f4157d68..ef60760a 100644 --- a/service/assets/icon.go +++ b/service/assets/icon.go @@ -2,6 +2,7 @@ package assets import ( "context" + "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -11,14 +12,14 @@ type IconConnector interface { // Get loads a single asset icon by id. // - // GET /jsm/assets/workspace/{workspaceId}/v1/icon/{id} + // GET /jsm/assets/workspace/{workspaceID}/v1/icon/{id} // // https://docs.go-atlassian.io/jira-assets/icons#get-icon Get(ctx context.Context, workspaceID, iconID string) (*models.IconScheme, *models.ResponseScheme, error) // Global returns all global icons i.e. icons not associated with a particular object schema. // - // GET /jsm/assets/workspace/{workspaceId}/v1/icon/global + // GET /jsm/assets/workspace/{workspaceID}/v1/icon/global // // https://docs.go-atlassian.io/jira-assets/icons#get-global-icons Global(ctx context.Context, workspaceID string) ([]*models.IconScheme, *models.ResponseScheme, error) diff --git a/service/assets/object.go b/service/assets/object.go index 8eb2f8d1..449f677f 100644 --- a/service/assets/object.go +++ b/service/assets/object.go @@ -2,6 +2,7 @@ package assets import ( "context" + "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -11,63 +12,63 @@ type ObjectConnector interface { // Get loads one object. // - // GET /jsm/assets/workspace/{workspaceId}/v1/object/{id} + // GET /jsm/assets/workspace/{workspaceID}/v1/object/{objectID} // // https://docs.go-atlassian.io/jira-assets/object#get-object-by-id Get(ctx context.Context, workspaceID, objectID string) (*models.ObjectScheme, *models.ResponseScheme, error) // Update updates an existing object in Assets. // - // PUT /jsm/assets/workspace/{workspaceId}/v1/object/{id} + // PUT /jsm/assets/workspace/{workspaceID}/v1/object/{objectID} // // https://docs.go-atlassian.io/jira-assets/object#update-object-by-id Update(ctx context.Context, workspaceID, objectID string, payload *models.ObjectPayloadScheme) (*models.ObjectScheme, *models.ResponseScheme, error) // Delete deletes the referenced object // - // DELETE /jsm/assets/workspace/{workspaceId}/v1/object/{id} + // DELETE /jsm/assets/workspace/{workspaceID}/v1/object/{objectID} // // https://docs.go-atlassian.io/jira-assets/object#delete-object-by-id Delete(ctx context.Context, workspaceID, objectID string) (*models.ResponseScheme, error) // Attributes list all attributes for the given object. // - // GET /jsm/assets/workspace/{workspaceId}/v1/object/{id}/attributes + // GET /jsm/assets/workspace/{workspaceID}/v1/object/{objectID}/attributes // // https://docs.go-atlassian.io/jira-assets/object#get-object-attributes Attributes(ctx context.Context, workspaceID, objectID string) ([]*models.ObjectAttributeScheme, *models.ResponseScheme, error) // History retrieves the history entries for this object. // - // GET /jsm/assets/workspace/{workspaceId}/v1/object/{id}/history + // GET /jsm/assets/workspace/{workspaceID}/v1/object/{objectID}/history // // https://docs.go-atlassian.io/jira-assets/object#get-object-changelogs History(ctx context.Context, workspaceID, objectID string, ascOrder bool) ([]*models.ObjectHistoryScheme, *models.ResponseScheme, error) // References finds all references for an object. // - // GET /jsm/assets/workspace/{workspaceId}/v1/object/{id}/referenceinfo + // GET /jsm/assets/workspace/{workspaceID}/v1/object/{objectID}/referenceinfo // // https://docs.go-atlassian.io/jira-assets/object#get-object-references References(ctx context.Context, workspaceID, objectID string) ([]*models.ObjectReferenceTypeInfoScheme, *models.ResponseScheme, error) // Create creates a new object in Assets. // - // POST /jsm/assets/workspace/{workspaceId}/v1/object/create + // POST /jsm/assets/workspace/{workspaceID}/v1/object/create // // https://docs.go-atlassian.io/jira-assets/object#create-object Create(ctx context.Context, workspaceID string, payload *models.ObjectPayloadScheme) (*models.ObjectScheme, *models.ResponseScheme, error) // Relation returns the relation between Jira issues and Assets objects // - // GET /jsm/assets/workspace/{workspaceId}/v1/objectconnectedtickets/{objectId}/tickets + // GET /jsm/assets/workspace/{workspaceID}/v1/objectconnectedtickets/{objectID}/tickets // // https://docs.go-atlassian.io/jira-assets/object#get-object-tickets Relation(ctx context.Context, workspaceID, objectID string) (*models.TicketPageScheme, *models.ResponseScheme, error) // Filter fetch Objects by AQL. // - // POST /jsm/assets/workspace/{workspaceId}/v1/object/aql + // POST /jsm/assets/workspace/{workspaceID}/v1/object/aql // // https://docs.go-atlassian.io/jira-assets/object#filter-objects Filter(ctx context.Context, workspaceID, aql string, attributes bool, startAt, maxResults int) (*models.ObjectListResultScheme, *models.ResponseScheme, error) @@ -76,7 +77,7 @@ type ObjectConnector interface { // // Note that the preferred endpoint is /aql // - // POST /jsm/assets/workspace/{workspaceId}/v1/object/navlist/aql + // POST /jsm/assets/workspace/{workspaceID}/v1/object/navlist/aql // // https://docs.go-atlassian.io/jira-assets/object#search-objects Search(ctx context.Context, workspaceID string, payload *models.ObjectSearchParamsScheme) (*models.ObjectListScheme, *models.ResponseScheme, error) diff --git a/service/assets/object_schema.go b/service/assets/object_schema.go index c4e4a492..a477510f 100644 --- a/service/assets/object_schema.go +++ b/service/assets/object_schema.go @@ -2,6 +2,7 @@ package assets import ( "context" + "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -11,14 +12,14 @@ type ObjectSchemaConnector interface { // List returns all the object schemas available on Assets // - // GET /jsm/assets/workspace/{workspaceId}/v1/objectschema/list + // GET /jsm/assets/workspace/{workspaceID}/v1/objectschema/list // // https://docs.go-atlassian.io/jira-assets/object/schema#get-object-schema-list List(ctx context.Context, workspaceID string) (*models.ObjectSchemaPageScheme, *models.ResponseScheme, error) // Create creates a new object schema // - // POST /jsm/assets/workspace/{workspaceId}/v1/objectschema/create + // POST /jsm/assets/workspace/{workspaceID}/v1/objectschema/create // // https://docs.go-atlassian.io/jira-assets/object/schema#create-object-schema Create(ctx context.Context, workspaceID string, payload *models.ObjectSchemaPayloadScheme) (*models.ObjectSchemaScheme, @@ -26,14 +27,14 @@ type ObjectSchemaConnector interface { // Get returns an object schema by ID // - // GET /jsm/assets/workspace/{workspaceId}/v1/objectschema/{id} + // GET /jsm/assets/workspace/{workspaceID}/v1/objectschema/{objectSchemaID} // // https://docs.go-atlassian.io/jira-assets/object/schema#get-object-schema Get(ctx context.Context, workspaceID, objectSchemaID string) (*models.ObjectSchemaScheme, *models.ResponseScheme, error) // Update updates an object schema // - // PUT /jsm/assets/workspace/{workspaceId}/v1/objectschema/{id} + // PUT /jsm/assets/workspace/{workspaceID}/v1/objectschema/{objectSchemaID} // // https://docs.go-atlassian.io/jira-assets/object/schema#update-object-schema Update(ctx context.Context, workspaceID, objectSchemaID string, payload *models.ObjectSchemaPayloadScheme) ( @@ -41,14 +42,14 @@ type ObjectSchemaConnector interface { // Delete deletes a schema // - // DELETE /jsm/assets/workspace/{workspaceId}/v1/objectschema/{id} + // DELETE /jsm/assets/workspace/{workspaceID}/v1/objectschema/{objectSchemaID} // // https://docs.go-atlassian.io/jira-assets/object/schema#delete-object-schema Delete(ctx context.Context, workspaceID, objectSchemaID string) (*models.ObjectSchemaScheme, *models.ResponseScheme, error) // Attributes finds all object type attributes for this object schema // - // GET /jsm/assets/workspace/{workspaceId}/v1/objectschema/{id}/attributes + // GET /jsm/assets/workspace/{workspaceID}/v1/objectschema/{objectSchemaID}/attributes // // https://docs.go-atlassian.io/jira-assets/object/schema#get-object-schema-attributes Attributes(ctx context.Context, workspaceID, objectSchemaID string, options *models.ObjectSchemaAttributesParamsScheme) ( @@ -56,7 +57,7 @@ type ObjectSchemaConnector interface { // ObjectTypes returns all object types for this object schema // - // GET /jsm/assets/workspace/{workspaceId}/v1/objectschema/{id}/objecttypes + // GET /jsm/assets/workspace/{workspaceID}/v1/objectschema/{objectSchemaID}/objecttypes // // https://docs.go-atlassian.io/jira-assets/object/schema#get-object-schema-types ObjectTypes(ctx context.Context, workspaceID, objectSchemaID string, excludeAbstract bool) ( diff --git a/service/assets/object_type.go b/service/assets/object_type.go index 7a700dab..b3fc7c28 100644 --- a/service/assets/object_type.go +++ b/service/assets/object_type.go @@ -2,6 +2,7 @@ package assets import ( "context" + "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -11,14 +12,14 @@ type ObjectTypeConnector interface { // Get finds an object type by id // - // GET /jsm/assets/workspace/{workspaceId}/v1/objecttype/{id} + // GET /jsm/assets/workspace/{workspaceID}/v1/objecttype/{objectTypeID} // // https://docs.go-atlassian.io/jira-assets/object/type#get-object-type Get(ctx context.Context, workspaceID, objectTypeID string) (*models.ObjectTypeScheme, *models.ResponseScheme, error) // Update updates an existing object type // - // PUT /jsm/assets/workspace/{workspaceId}/v1/objecttype/{id} + // PUT /jsm/assets/workspace/{workspaceID}/v1/objecttype/{objectTypeID} // // https://docs.go-atlassian.io/jira-assets/object/type#update-object-type Update(ctx context.Context, workspaceID, objectTypeID string, payload *models.ObjectTypePayloadScheme) ( @@ -26,7 +27,7 @@ type ObjectTypeConnector interface { // Create creates a new object type // - // POST /jsm/assets/workspace/{workspaceId}/v1/objecttype/create + // POST /jsm/assets/workspace/{workspaceID}/v1/objecttype/create // // https://docs.go-atlassian.io/jira-assets/object/type#create-object-type Create(ctx context.Context, workspaceID string, payload *models.ObjectTypePayloadScheme) ( @@ -34,14 +35,14 @@ type ObjectTypeConnector interface { // Delete deletes an object type // - // DELETE /jsm/assets/workspace/{workspaceId}/v1/objecttype/{id} + // DELETE /jsm/assets/workspace/{workspaceID}/v1/objecttype/{objectTypeID} // // https://docs.go-atlassian.io/jira-assets/object/type#delete-object-type Delete(ctx context.Context, workspaceID, objectTypeID string) (*models.ObjectTypeScheme, *models.ResponseScheme, error) // Attributes finds all attributes for this object type // - // GET /jsm/assets/workspace/{workspaceId}/v1/objecttype/{id}/attributes + // GET /jsm/assets/workspace/{workspaceID}/v1/objecttype/{objectTypeID}/attributes // // https://docs.go-atlassian.io/jira-assets/object/type#get-object-type-attributes Attributes(ctx context.Context, workspaceID, objectTypeID string, options *models.ObjectTypeAttributesParamsScheme) ( @@ -49,7 +50,7 @@ type ObjectTypeConnector interface { // Position changes the position of this object type // - // POST /jsm/assets/workspace/{workspaceId}/v1/objecttype/{id}/position + // POST /jsm/assets/workspace/{workspaceID}/v1/objecttype/{objectTypeID}/position // // https://docs.go-atlassian.io/jira-assets/object/type#update-object-type-position Position(ctx context.Context, workspaceID, objectTypeID string, payload *models.ObjectTypePositionPayloadScheme) ( diff --git a/service/assets/object_type_attribute.go b/service/assets/object_type_attribute.go index bc06dba8..8e89be41 100644 --- a/service/assets/object_type_attribute.go +++ b/service/assets/object_type_attribute.go @@ -2,6 +2,7 @@ package assets import ( "context" + "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -11,7 +12,7 @@ type ObjectTypeAttributeConnector interface { // Create creates a new attribute on the given object type // - // POST /jsm/assets/workspace/{workspaceId}/v1/objecttypeattribute/{objectTypeId} + // POST /jsm/assets/workspace/{workspaceID}/v1/objecttypeattribute/{objectTypeID} // // https://docs.go-atlassian.io/jira-assets/object/type/attribute#create-object-type-attribute Create(ctx context.Context, workspaceID, objectTypeID string, payload *models.ObjectTypeAttributePayloadScheme) ( @@ -19,7 +20,7 @@ type ObjectTypeAttributeConnector interface { // Update updates an existing object type attribute // - // PUT /jsm/assets/workspace/{workspaceId}/v1/objecttypeattribute/{objectTypeId}/{id} + // PUT /jsm/assets/workspace/{workspaceID}/v1/objecttypeattribute/{objectTypeID}/{id} // // https://docs.go-atlassian.io/jira-assets/object/type/attribute#update-object-type-attribute Update(ctx context.Context, workspaceID, objectTypeID, attributeID string, payload *models.ObjectTypeAttributePayloadScheme) ( @@ -27,7 +28,7 @@ type ObjectTypeAttributeConnector interface { // Delete deletes an existing object type attribute // - // DELETE /jsm/assets/workspace/{workspaceId}/v1/objecttypeattribute/{id} + // DELETE /jsm/assets/workspace/{workspaceID}/v1/objecttypeattribute/{attributeID} // // https://docs.go-atlassian.io/jira-assets/object/type/attribute#delete-object-type-attribute Delete(ctx context.Context, workspaceID, attributeID string) (*models.ResponseScheme, error) diff --git a/service/common/client.go b/service/common/client.go index 92561809..6fb605d3 100644 --- a/service/common/client.go +++ b/service/common/client.go @@ -2,13 +2,14 @@ package common import ( "context" - "github.com/ctreminiom/go-atlassian/pkg/infra/models" "io" "net/http" + + "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) type Client interface { - NewJsonRequest(ctx context.Context, method, apiEndpoint string, payload io.Reader) (*http.Request, error) + NewJSONRequest(ctx context.Context, method, apiEndpoint string, payload io.Reader) (*http.Request, error) NewRequest(ctx context.Context, method, apiEndpoint string, payload io.Reader) (*http.Request, error) NewFormRequest(ctx context.Context, method, apiEndpoint, formDataContentType string, payload io.Reader) (*http.Request, error) Call(request *http.Request, structure interface{}) (*models.ResponseScheme, error) diff --git a/service/common/http.go b/service/common/http.go index 7bdb7fd3..71fdf196 100644 --- a/service/common/http.go +++ b/service/common/http.go @@ -2,6 +2,6 @@ package common import "net/http" -type HttpClient interface { +type HTTPClient interface { Do(request *http.Request) (*http.Response, error) } diff --git a/service/confluence/children-descendant.go b/service/confluence/children-descendant.go index b638989b..3ff67c2e 100644 --- a/service/confluence/children-descendant.go +++ b/service/confluence/children-descendant.go @@ -2,6 +2,7 @@ package confluence import ( "context" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -21,7 +22,7 @@ type ChildrenDescendantConnector interface { // // comment: child content is attachment // - // GET /wiki/rest/api/content/{id}/child + // GET /wiki/rest/api/content/{contentID}/child // // https://docs.go-atlassian.io/confluence-cloud/content/children-descendants#get-content-children Children(ctx context.Context, contentID string, expand []string, parentVersion int) (*model.ContentChildrenScheme, *model.ResponseScheme, error) @@ -40,16 +41,16 @@ type ChildrenDescendantConnector interface { // append: page will be a child of the target and be appended to targets list of // children // - // PUT /wiki/rest/api/content/{pageId}/move/{position}/{targetId} + // PUT /wiki/rest/api/content/{contentID}/move/{position}/{targetID} // // https://docs.go-atlassian.io/confluence-cloud/content/children-descendants#move - Move(ctx context.Context, pageID string, position string, targetID string) (*model.ContentMoveScheme, *model.ResponseScheme, error) + Move(ctx context.Context, contentID string, position string, targetID string) (*model.ContentMoveScheme, *model.ResponseScheme, error) // ChildrenByType returns all children of a given type, for a piece of content. // // A piece of content has different types of child content // - // GET /wiki/rest/api/content/{id}/child/{type} + // GET /wiki/rest/api/content/{contentID}/child/{type} // // https://docs.go-atlassian.io/confluence-cloud/content/children-descendants#get-content-children-by-type ChildrenByType(ctx context.Context, contentID, contentType string, parentVersion int, expand []string, startAt, maxResults int) (*model.ContentPageScheme, *model.ResponseScheme, error) @@ -60,7 +61,7 @@ type ChildrenDescendantConnector interface { // // rather than just the direct child pages. // - // GET /wiki/rest/api/content/{id}/descendant + // GET /wiki/rest/api/content/{contentID}/descendant // // https://docs.go-atlassian.io/confluence-cloud/content/children-descendants#get-content-descendants Descendants(ctx context.Context, contentID string, expand []string) (*model.ContentChildrenScheme, *model.ResponseScheme, error) @@ -71,7 +72,7 @@ type ChildrenDescendantConnector interface { // // except that this method returns child pages at all levels, rather than just the direct child pages. // - // GET /wiki/rest/api/content/{id}/descendant/{type} + // GET /wiki/rest/api/content/{contentID}/descendant/{type} // // https://docs.go-atlassian.io/confluence-cloud/content/children-descendants#get-content-descendants-by-type DescendantsByType(ctx context.Context, contentID, contentType, depth string, expand []string, startAt, maxResults int) (*model.ContentPageScheme, *model.ResponseScheme, error) @@ -80,7 +81,7 @@ type ChildrenDescendantConnector interface { // // permissions and attachments. The id path parameter refers to the content id of the page to copy, // - // and the new parent of this copied page is defined using the destinationPageId in the request body. + // and the new parent of this copied page is defined using the destinationPage id in the request body. // // The titleOptions object defines the rules of renaming page titles during the copy; // @@ -88,7 +89,7 @@ type ChildrenDescendantConnector interface { // // RESPONSE = Use the /longtask/ REST API to get the copy task status. // - // POST /wiki/rest/api/content/{id}/pagehierarchy/copy + // POST /wiki/rest/api/content/{contentID}/pagehierarchy/copy // // https://docs.go-atlassian.io/confluence-cloud/content/children-descendants#copy-page-hierarchy CopyHierarchy(ctx context.Context, contentID string, options *model.CopyOptionsScheme) (*model.TaskScheme, *model.ResponseScheme, error) @@ -107,7 +108,7 @@ type ChildrenDescendantConnector interface { // // By default, the following objects are expanded: space, history, version. // - // POST /wiki/rest/api/content/{id}/copy + // POST /wiki/rest/api/content/{contentID}/copy // // https://docs.go-atlassian.io/confluence-cloud/content/children-descendants#copy-single-page CopyPage(ctx context.Context, contentID string, expand []string, options *model.CopyOptionsScheme) (*model.ContentScheme, *model.ResponseScheme, error) diff --git a/service/confluence/custom-content.go b/service/confluence/custom-content.go index 6ae411c7..8db46d7f 100644 --- a/service/confluence/custom-content.go +++ b/service/confluence/custom-content.go @@ -2,6 +2,7 @@ package confluence import ( "context" + "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -12,7 +13,7 @@ type CustomContentConnector interface { // GET /wiki/api/v2/custom-content // // https://docs.go-atlassian.io/confluence-cloud/v2/custom-content#get-custom-content-by-type - Gets(ctx context.Context, type_ string, options *models.CustomContentOptionsScheme, cursor string, limit int) ( + Gets(ctx context.Context, typ string, options *models.CustomContentOptionsScheme, cursor string, limit int) ( *models.CustomContentPageScheme, *models.ResponseScheme, error) // Create creates a new custom content in the given space, page, blogpost or other custom content. @@ -31,9 +32,9 @@ type CustomContentConnector interface { // Update updates a custom content by id. // - // The spaceId is always required and maximum one of pageId, blogPostId, + // The space id is always required and maximum one of page id, blog post id, // - // or customContentId is allowed in the request body + // or custom content id is allowed in the request body // // PUT /wiki/api/v2/custom-content/{id} // diff --git a/service/confluence/restriction.go b/service/confluence/restriction.go index fdc52c40..7cd4ac64 100644 --- a/service/confluence/restriction.go +++ b/service/confluence/restriction.go @@ -2,6 +2,7 @@ package confluence import ( "context" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -65,7 +66,7 @@ type RestrictionGroupOperationConnector interface { // // as it does not account for account-inherited restrictions, space permissions, or even product access. // - // GET /wiki/rest/api/content/{id}/restriction/byOperation/{operationKey}/byGroupId/{groupId} + // GET /wiki/rest/api/content/{id}/restriction/byOperation/{operationKey}/byGroupId/{groupNameOrID} // // https://docs.go-atlassian.io/confluence-cloud/content/restrictions/operations/group#get-content-restriction-status-for-group Get(ctx context.Context, contentID, operationKey, groupNameOrID string) (*model.ResponseScheme, error) @@ -74,7 +75,7 @@ type RestrictionGroupOperationConnector interface { // // That is, grant read or update permission to the group for a piece of content. // - // PUT /wiki/rest/api/content/{id}/restriction/byOperation/{operationKey}/byGroupId/{groupId} + // PUT /wiki/rest/api/content/{id}/restriction/byOperation/{operationKey}/byGroupId/{groupNameOrID} // // https://docs.go-atlassian.io/confluence-cloud/content/restrictions/operations/group#add-group-to-content-restriction Add(ctx context.Context, contentID, operationKey, groupNameOrID string) (*model.ResponseScheme, error) @@ -83,7 +84,7 @@ type RestrictionGroupOperationConnector interface { // // That is, remove read or update permission for the group for a piece of content. // - // DELETE /wiki/rest/api/content/{id}/restriction/byOperation/{operationKey}/byGroupId/{groupId} + // DELETE /wiki/rest/api/content/{id}/restriction/byOperation/{operationKey}/byGroupId/{groupNameOrID} // // https://docs.go-atlassian.io/confluence-cloud/content/restrictions/operations/group#remove-group-from-content-restriction Remove(ctx context.Context, contentID, operationKey, groupNameOrID string) (*model.ResponseScheme, error) diff --git a/service/http.go b/service/http.go index e0ec078a..2e19d5da 100644 --- a/service/http.go +++ b/service/http.go @@ -2,11 +2,12 @@ package service import ( "context" - "github.com/ctreminiom/go-atlassian/pkg/infra/models" "net/http" + + "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) type Connector interface { - NewRequest(ctx context.Context, method, urlStr, type_ string, body interface{}) (*http.Request, error) + NewRequest(ctx context.Context, method, urlStr, contentType string, body interface{}) (*http.Request, error) Call(request *http.Request, structure interface{}) (*models.ResponseScheme, error) } diff --git a/service/jira/attachment.go b/service/jira/attachment.go index 3b3afef2..d870c261 100644 --- a/service/jira/attachment.go +++ b/service/jira/attachment.go @@ -2,8 +2,9 @@ package jira import ( "context" - model "github.com/ctreminiom/go-atlassian/pkg/infra/models" "io" + + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) type AttachmentConnector interface { @@ -17,35 +18,35 @@ type AttachmentConnector interface { // Metadata returns the metadata for an attachment. Note that the attachment itself is not returned. // - // GET /rest/api/{2-3}/attachment/{id} + // GET /rest/api/{2-3}/attachment/{attachmentID} // // https://docs.go-atlassian.io/jira-software-cloud/issues/attachments#get-attachment-metadata - Metadata(ctx context.Context, attachmentId string) (*model.IssueAttachmentMetadataScheme, *model.ResponseScheme, error) + Metadata(ctx context.Context, attachmentID string) (*model.IssueAttachmentMetadataScheme, *model.ResponseScheme, error) // Delete deletes an attachment from an issue. // - // DELETE /rest/api/{2-3}/attachment/{id} + // DELETE /rest/api/{2-3}/attachment/{attachmentID} // // https://docs.go-atlassian.io/jira-software-cloud/issues/attachments#delete-attachment - Delete(ctx context.Context, attachmentId string) (*model.ResponseScheme, error) + Delete(ctx context.Context, attachmentID string) (*model.ResponseScheme, error) // Human returns the metadata for the contents of an attachment, if it is an archive, and metadata for the attachment itself. // // For example, if the attachment is a ZIP archive, then information about the files in the archive is returned and metadata for the ZIP archive. // - // GET /rest/api/{2-3}/attachment/{id}/expand/human + // GET /rest/api/{2-3}/attachment/{attachmentID}/expand/human // // Experimental Endpoint // // https://docs.go-atlassian.io/jira-software-cloud/issues/attachments#get-all-metadata-for-an-expanded-attachment - Human(ctx context.Context, attachmentId string) (*model.IssueAttachmentHumanMetadataScheme, *model.ResponseScheme, error) + Human(ctx context.Context, attachmentID string) (*model.IssueAttachmentHumanMetadataScheme, *model.ResponseScheme, error) // Add adds one attachment to an issue. Attachments are posted as multipart/form-data (RFC 1867). // - // POST /rest/api/{2-3}/issue/{issueIdOrKey}/attachments + // POST /rest/api/{2-3}/issue/{issueKeyOrID}/attachments // // https://docs.go-atlassian.io/jira-software-cloud/issues/attachments#add-attachment - Add(ctx context.Context, issueKeyOrId, fileName string, file io.Reader) ([]*model.IssueAttachmentScheme, *model.ResponseScheme, error) + Add(ctx context.Context, issueKeyOrID, fileName string, file io.Reader) ([]*model.IssueAttachmentScheme, *model.ResponseScheme, error) // Download returns the contents of an attachment. A Range header can be set to define a range of bytes within the attachment to download. // diff --git a/service/jira/comment.go b/service/jira/comment.go index f3d9fbcb..f837aca3 100644 --- a/service/jira/comment.go +++ b/service/jira/comment.go @@ -2,6 +2,7 @@ package jira import ( "context" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -10,24 +11,24 @@ type CommentRichTextConnector interface { // Gets returns all comments for an issue. // - // GET /rest/api/{2-3}/issue/{issueIdOrKey}/comment + // GET /rest/api/{2-3}/issue/{issueKeyOrID}/comment // // https://docs.go-atlassian.io/jira-software-cloud/issues/comments#get-comments - Gets(ctx context.Context, issueKeyOrId, orderBy string, expand []string, startAt, maxResults int) (*model.IssueCommentPageSchemeV2, *model.ResponseScheme, error) + Gets(ctx context.Context, issueKeyOrID, orderBy string, expand []string, startAt, maxResults int) (*model.IssueCommentPageSchemeV2, *model.ResponseScheme, error) // Get returns a comment. // - // GET /rest/api/{2-3}/issue/{issueIdOrKey}/comment/{id} + // GET /rest/api/{2-3}/issue/{issueKeyOrID}/comment/{id} // // https://docs.go-atlassian.io/jira-software-cloud/issues/comments#get-comment - Get(ctx context.Context, issueKeyOrId, commentId string) (*model.IssueCommentSchemeV2, *model.ResponseScheme, error) + Get(ctx context.Context, issueKeyOrID, commentID string) (*model.IssueCommentSchemeV2, *model.ResponseScheme, error) // Add adds a comment to an issue. // - // POST /rest/api/{2-3}/issue/{issueIdOrKey}/comment + // POST /rest/api/{2-3}/issue/{issueKeyOrID}/comment // //https://docs.go-atlassian.io/jira-software-cloud/issues/comments#add-comment - Add(ctx context.Context, issueKeyOrId string, payload *model.CommentPayloadSchemeV2, expand []string) (*model.IssueCommentSchemeV2, *model.ResponseScheme, error) + Add(ctx context.Context, issueKeyOrID string, payload *model.CommentPayloadSchemeV2, expand []string) (*model.IssueCommentSchemeV2, *model.ResponseScheme, error) } type CommentADFConnector interface { @@ -35,32 +36,32 @@ type CommentADFConnector interface { // Gets returns all comments for an issue. // - // GET /rest/api/{2-3}/issue/{issueIdOrKey}/comment + // GET /rest/api/{2-3}/issue/{issueKeyOrID}/comment // // https://docs.go-atlassian.io/jira-software-cloud/issues/comments#get-comments - Gets(ctx context.Context, issueKeyOrId, orderBy string, expand []string, startAt, maxResults int) (*model.IssueCommentPageScheme, *model.ResponseScheme, error) + Gets(ctx context.Context, issueKeyOrID, orderBy string, expand []string, startAt, maxResults int) (*model.IssueCommentPageScheme, *model.ResponseScheme, error) // Get returns a comment. // - // GET /rest/api/{2-3}/issue/{issueIdOrKey}/comment/{id} + // GET /rest/api/{2-3}/issue/{issueKeyOrID}/comment/{id} // // https://docs.go-atlassian.io/jira-software-cloud/issues/comments#get-comment - Get(ctx context.Context, issueKeyOrId, commentId string) (*model.IssueCommentScheme, *model.ResponseScheme, error) + Get(ctx context.Context, issueKeyOrID, commentID string) (*model.IssueCommentScheme, *model.ResponseScheme, error) // Add adds a comment to an issue. // - // POST /rest/api/{2-3}/issue/{issueIdOrKey}/comment + // POST /rest/api/{2-3}/issue/{issueKeyOrID}/comment // // https://docs.go-atlassian.io/jira-software-cloud/issues/comments#add-comment - Add(ctx context.Context, issueKeyOrId string, payload *model.CommentPayloadScheme, expand []string) (*model.IssueCommentScheme, *model.ResponseScheme, error) + Add(ctx context.Context, issueKeyOrID string, payload *model.CommentPayloadScheme, expand []string) (*model.IssueCommentScheme, *model.ResponseScheme, error) } type CommentSharedConnector interface { // Delete deletes a comment. // - // DELETE /rest/api/{2-3}/issue/{issueIdOrKey}/comment/{id} + // DELETE /rest/api/{2-3}/issue/{issueKeyOrID}/comment/{id} // // https://docs.go-atlassian.io/jira-software-cloud/issues/comments#delete-comment - Delete(ctx context.Context, issueKeyOrId, commentId string) (*model.ResponseScheme, error) + Delete(ctx context.Context, issueKeyOrID, commentID string) (*model.ResponseScheme, error) } diff --git a/service/jira/dashboard.go b/service/jira/dashboard.go index 5cd796be..838ad6a2 100644 --- a/service/jira/dashboard.go +++ b/service/jira/dashboard.go @@ -2,6 +2,7 @@ package jira import ( "context" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -34,31 +35,31 @@ type DashboardConnector interface { // Get returns a dashboard. // - // GET /rest/api/{2-3}/dashboard/{id} + // GET /rest/api/{2-3}/dashboard/{dashboardID} // // https://docs.go-atlassian.io/jira-software-cloud/dashboards#get-dashboard - Get(ctx context.Context, dashboardId string) (*model.DashboardScheme, *model.ResponseScheme, error) + Get(ctx context.Context, dashboardID string) (*model.DashboardScheme, *model.ResponseScheme, error) // Delete deletes a dashboard. // - // DELETE /rest/api/{2-3}/dashboard/{id} + // DELETE /rest/api/{2-3}/dashboard/{dashboardID} // // https://docs.go-atlassian.io/jira-software-cloud/dashboards#delete-dashboard - Delete(ctx context.Context, dashboardId string) (*model.ResponseScheme, error) + Delete(ctx context.Context, dashboardID string) (*model.ResponseScheme, error) // Copy copies a dashboard. // // Any values provided in the dashboard parameter replace those in the copied dashboard. // - // POST /rest/api/{2-3}/dashboard/{id}/copy + // POST /rest/api/{2-3}/dashboard/{dashboardID}/copy // // https://docs.go-atlassian.io/jira-software-cloud/dashboards#copy-dashboard - Copy(ctx context.Context, dashboardId string, payload *model.DashboardPayloadScheme) (*model.DashboardScheme, *model.ResponseScheme, error) + Copy(ctx context.Context, dashboardID string, payload *model.DashboardPayloadScheme) (*model.DashboardScheme, *model.ResponseScheme, error) // Update updates a dashboard // - // PUT /rest/api/{2-3}/dashboard/{id} + // PUT /rest/api/{2-3}/dashboard/{dashboardID} // // https://docs.go-atlassian.io/jira-software-cloud/dashboards#update-dashboard - Update(ctx context.Context, dashboardId string, payload *model.DashboardPayloadScheme) (*model.DashboardScheme, *model.ResponseScheme, error) + Update(ctx context.Context, dashboardID string, payload *model.DashboardPayloadScheme) (*model.DashboardScheme, *model.ResponseScheme, error) } diff --git a/service/jira/filter.go b/service/jira/filter.go index 288a838c..926944fc 100644 --- a/service/jira/filter.go +++ b/service/jira/filter.go @@ -67,5 +67,5 @@ type FilterConnector interface { // PUT /rest/api/{2-3}/filter/{filterID}/owner // // https://docs.go-atlassian.io/jira-software-cloud/filters#change-filter-owner - Change(ctx context.Context, filterID int, accountId string) (*model.ResponseScheme, error) + Change(ctx context.Context, filterID int, accountID string) (*model.ResponseScheme, error) } diff --git a/service/jira/group.go b/service/jira/group.go index 36b851e4..0ccaf039 100644 --- a/service/jira/group.go +++ b/service/jira/group.go @@ -2,6 +2,7 @@ package jira import ( "context" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -41,14 +42,14 @@ type GroupConnector interface { // POST /rest/api/{2-3}/group/user // // https://docs.go-atlassian.io/jira-software-cloud/groups#add-user-to-group - Add(ctx context.Context, groupName, accountId string) (*model.GroupScheme, *model.ResponseScheme, error) + Add(ctx context.Context, groupName, accountID string) (*model.GroupScheme, *model.ResponseScheme, error) // Remove removes a user from a group. // // DELETE /rest/api/{2-3}/group/user // // https://docs.go-atlassian.io/jira-software-cloud/groups#remove-user-from-group - Remove(ctx context.Context, groupName, accountId string) (*model.ResponseScheme, error) + Remove(ctx context.Context, groupName, accountID string) (*model.ResponseScheme, error) // TODO: GET /rest/api/3/groups/picker needs to be parsed } diff --git a/service/jira/issue.go b/service/jira/issue.go index fcbac752..0a9dd062 100644 --- a/service/jira/issue.go +++ b/service/jira/issue.go @@ -2,6 +2,7 @@ package jira import ( "context" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -15,10 +16,10 @@ type IssueSharedConnector interface { // // 3.This causes the issue's subtasks to be deleted with the issue. // - // DELETE /rest/api/{2-3}/issue/{issueIdOrKey} + // DELETE /rest/api/{2-3}/issue/{issueKeyOrID} // // https://docs.go-atlassian.io/jira-software-cloud/issues#delete-issue - Delete(ctx context.Context, issueKeyOrId string, deleteSubTasks bool) (*model.ResponseScheme, error) + Delete(ctx context.Context, issueKeyOrID string, deleteSubTasks bool) (*model.ResponseScheme, error) // Assign assigns an issue to a user. // @@ -26,22 +27,22 @@ type IssueSharedConnector interface { // // Assign issue permission for the project that the issue is in. // - // If accountId is set to: + // If accountID is set to: // // 1. "-1", the issue is assigned to the default assignee for the project. // 2. null, the issue is set to unassigned. // - // PUT /rest/api/{2-3}/issue/{issueIdOrKey}/assignee + // PUT /rest/api/{2-3}/issue/{issueKeyOrID}/assignee // // https://docs.go-atlassian.io/jira-software-cloud/issues#assign-issue - Assign(ctx context.Context, issueKeyOrId, accountId string) (*model.ResponseScheme, error) + Assign(ctx context.Context, issueKeyOrID, accountID string) (*model.ResponseScheme, error) // Notify creates an email notification for an issue and adds it to the mail queue. // - // POST /rest/api/{2-3}/issue/{issueIdOrKey}/notify + // POST /rest/api/{2-3}/issue/{issueKeyOrID}/notify // // https://docs.go-atlassian.io/jira-software-cloud/issues#send-notification-for-issue - Notify(ctx context.Context, issueKeyOrId string, options *model.IssueNotifyOptionsScheme) (*model.ResponseScheme, error) + Notify(ctx context.Context, issueKeyOrID string, options *model.IssueNotifyOptionsScheme) (*model.ResponseScheme, error) // Transitions returns either all transitions or a transition that can be performed by the user on an issue, based on the issue's status. // @@ -49,11 +50,11 @@ type IssueSharedConnector interface { // // given its status, the response will return any empty transitions list. // - // GET /rest/api/{2-3}/issue/{issueIdOrKey}/transitions + // GET /rest/api/{2-3}/issue/{issueKeyOrID}/transitions // // https://docs.go-atlassian.io/jira-software-cloud/issues#get-transitions - Transitions(ctx context.Context, issueKeyOrId string) (*model.IssueTransitionsScheme, *model.ResponseScheme, error) - // TODO The Transitions methods requires more parameters such as expand, transitionId, and more + Transitions(ctx context.Context, issueKeyOrID string) (*model.IssueTransitionsScheme, *model.ResponseScheme, error) + // TODO The Transitions methods requires more parameters such as expand, transitionID, and more // The parameters are documented on this [page](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-transitions-get) } @@ -86,10 +87,10 @@ type IssueRichTextConnector interface { // // The issue key returned to the response is the key of the issue found. // - // GET /rest/api/{2-3}/issue/{issueIdOrKey} + // GET /rest/api/{2-3}/issue/{issueKeyOrID} // // https://docs.go-atlassian.io/jira-software-cloud/issues#get-issue - Get(ctx context.Context, issueKeyOrId string, fields, expand []string) (*model.IssueSchemeV2, *model.ResponseScheme, error) + Get(ctx context.Context, issueKeyOrID string, fields, expand []string) (*model.IssueSchemeV2, *model.ResponseScheme, error) // Update edits an issue. // @@ -97,20 +98,20 @@ type IssueRichTextConnector interface { // // The edits to the issue's fields are defined using update and fields // - // PUT /rest/api/{2-3}/issue/{issueIdOrKey} + // PUT /rest/api/{2-3}/issue/{issueKeyOrID} // // https://docs.go-atlassian.io/jira-software-cloud/issues#edit-issue - Update(ctx context.Context, issueKeyOrId string, notify bool, payload *model.IssueSchemeV2, customFields *model.CustomFields, + Update(ctx context.Context, issueKeyOrID string, notify bool, payload *model.IssueSchemeV2, customFields *model.CustomFields, operations *model.UpdateOperations) (*model.ResponseScheme, error) // Move performs an issue transition and, if the transition has a screen, updates the fields from the transition screen. // // sortByCategory To update the fields on the transition screen, specify the fields in the fields or update parameters in the request body. Get details about the fields using Get transitions with the transitions.fields expand. // - // POST /rest/api/{2-3}/issue/{issueIdOrKey}/transitions + // POST /rest/api/{2-3}/issue/{issueKeyOrID}/transitions // // https://docs.go-atlassian.io/jira-software-cloud/issues#transition-issue - Move(ctx context.Context, issueKeyOrId, transitionId string, options *model.IssueMoveOptionsV2) (*model.ResponseScheme, error) + Move(ctx context.Context, issueKeyOrID, transitionID string, options *model.IssueMoveOptionsV2) (*model.ResponseScheme, error) } type IssueADFConnector interface { @@ -142,10 +143,10 @@ type IssueADFConnector interface { // // The issue key returned to the response is the key of the issue found. // - // GET /rest/api/{2-3}/issue/{issueIdOrKey} + // GET /rest/api/{2-3}/issue/{issueKeyOrID} // // https://docs.go-atlassian.io/jira-software-cloud/issues#get-issue - Get(ctx context.Context, issueKeyOrId string, fields, expand []string) (*model.IssueScheme, *model.ResponseScheme, error) + Get(ctx context.Context, issueKeyOrID string, fields, expand []string) (*model.IssueScheme, *model.ResponseScheme, error) // Update edits an issue. // @@ -153,18 +154,18 @@ type IssueADFConnector interface { // // The edits to the issue's fields are defined using update and fields // - // PUT /rest/api/{2-3}/issue/{issueIdOrKey} + // PUT /rest/api/{2-3}/issue/{issueKeyOrID} // // https://docs.go-atlassian.io/jira-software-cloud/issues#edit-issue - Update(ctx context.Context, issueKeyOrId string, notify bool, payload *model.IssueScheme, customFields *model.CustomFields, + Update(ctx context.Context, issueKeyOrID string, notify bool, payload *model.IssueScheme, customFields *model.CustomFields, operations *model.UpdateOperations) (*model.ResponseScheme, error) // Move performs an issue transition and, if the transition has a screen, updates the fields from the transition screen. // // sortByCategory To update the fields on the transition screen, specify the fields in the fields or update parameters in the request body. Get details about the fields using Get transitions with the transitions.fields expand. // - // POST /rest/api/{2-3}/issue/{issueIdOrKey}/transitions + // POST /rest/api/{2-3}/issue/{issueKeyOrID}/transitions // // https://docs.go-atlassian.io/jira-software-cloud/issues#transition-issue - Move(ctx context.Context, issueKeyOrId, transitionId string, options *model.IssueMoveOptionsV3) (*model.ResponseScheme, error) + Move(ctx context.Context, issueKeyOrID, transitionID string, options *model.IssueMoveOptionsV3) (*model.ResponseScheme, error) } diff --git a/service/jira/link.go b/service/jira/link.go index 38d700ed..bd975898 100644 --- a/service/jira/link.go +++ b/service/jira/link.go @@ -2,6 +2,7 @@ package jira import ( "context" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -9,22 +10,22 @@ type LinkSharedConnector interface { // Get returns an issue link. // - // GET /rest/api/{2-3}/issueLink/{linkId} + // GET /rest/api/{2-3}/issueLink/{linkID} // // https://docs.go-atlassian.io/jira-software-cloud/issues/link#get-issue-link - Get(ctx context.Context, linkId string) (*model.IssueLinkScheme, *model.ResponseScheme, error) + Get(ctx context.Context, linkID string) (*model.IssueLinkScheme, *model.ResponseScheme, error) // Gets get the issue links ID's associated with a Jira Issue // // https://docs.go-atlassian.io/jira-software-cloud/issues/link#get-issue-links - Gets(ctx context.Context, issueKeyOrId string) (*model.IssueLinkPageScheme, *model.ResponseScheme, error) + Gets(ctx context.Context, issueKeyOrID string) (*model.IssueLinkPageScheme, *model.ResponseScheme, error) // Delete deletes an issue link. // - // DELETE /rest/api/{2-3}/issueLink/{linkId} + // DELETE /rest/api/{2-3}/issueLink/{linkID} // // https://docs.go-atlassian.io/jira-software-cloud/issues/link#delete-issue-link - Delete(ctx context.Context, linkId string) (*model.ResponseScheme, error) + Delete(ctx context.Context, linkID string) (*model.ResponseScheme, error) } type LinkRichTextConnector interface { @@ -67,10 +68,10 @@ type LinkTypeConnector interface { // Get returns an issue link type. // // - // GET /rest/api/{2-3}/issueLinkType/{issueLinkTypeId} + // GET /rest/api/{2-3}/issueLinkType/{issueLinkTypeID} // // https://docs.go-atlassian.io/jira-software-cloud/issues/link/types#get-issue-link-type - Get(ctx context.Context, issueLinkTypeId string) (*model.LinkTypeScheme, *model.ResponseScheme, error) + Get(ctx context.Context, issueLinkTypeID string) (*model.LinkTypeScheme, *model.ResponseScheme, error) // Create creates an issue link type. // @@ -85,15 +86,15 @@ type LinkTypeConnector interface { // Update updates an issue link type. // - // PUT /rest/api/{2-3}/issueLinkType/{issueLinkTypeId} + // PUT /rest/api/{2-3}/issueLinkType/{issueLinkTypeID} // // https://docs.go-atlassian.io/jira-software-cloud/issues/link/types#update-issue-link-type - Update(ctx context.Context, issueLinkTypeId string, payload *model.LinkTypeScheme) (*model.LinkTypeScheme, *model.ResponseScheme, error) + Update(ctx context.Context, issueLinkTypeID string, payload *model.LinkTypeScheme) (*model.LinkTypeScheme, *model.ResponseScheme, error) // Delete deletes an issue link type. // - // DELETE /rest/api/{2-3}/issueLinkType/{issueLinkTypeId} + // DELETE /rest/api/{2-3}/issueLinkType/{issueLinkTypeID} // // https://docs.go-atlassian.io/jira-software-cloud/issues/link/types#delete-issue-link-type - Delete(ctx context.Context, issueLinkTypeId string) (*model.ResponseScheme, error) + Delete(ctx context.Context, issueLinkTypeID string) (*model.ResponseScheme, error) } diff --git a/service/jira/metadata.go b/service/jira/metadata.go index 2937ca42..bc3b5c29 100644 --- a/service/jira/metadata.go +++ b/service/jira/metadata.go @@ -2,8 +2,10 @@ package jira import ( "context" - model "github.com/ctreminiom/go-atlassian/pkg/infra/models" + "github.com/tidwall/gjson" + + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) type MetadataConnector interface { @@ -12,10 +14,10 @@ type MetadataConnector interface { // // Use the information to populate the requests in Edit issue. // - // GET /rest/api/{2-3}/issue/{issueIdOrKey}/editmeta + // GET /rest/api/{2-3}/issue/{issueKeyOrID}/editmeta // // https://docs.go-atlassian.io/jira-software-cloud/issues/metadata#get-edit-issue-metadata - Get(ctx context.Context, issueKeyOrId string, overrideScreenSecurity, overrideEditableFlag bool) (gjson.Result, *model.ResponseScheme, error) + Get(ctx context.Context, issueKeyOrID string, overrideScreenSecurity, overrideEditableFlag bool) (gjson.Result, *model.ResponseScheme, error) // Create returns details of projects, issue types within projects, and, when requested, // diff --git a/service/jira/notification.go b/service/jira/notification.go index 91901407..847dc71d 100644 --- a/service/jira/notification.go +++ b/service/jira/notification.go @@ -67,14 +67,14 @@ type NotificationSchemeConnector interface { // Delete deletes a notification scheme. // - // DELETE /rest/api/{2-3}/notificationscheme/{notificationSchemeId} + // DELETE /rest/api/{2-3}/notificationscheme/{schemeID} // // https://docs.go-atlassian.io/jira-software-cloud/projects/notification-schemes#delete-notification-scheme Delete(ctx context.Context, schemeID string) (*models.ResponseScheme, error) // Remove removes a notification from a notification scheme. // - // DELETE /rest/api/{2-3}/notificationscheme/{notificationSchemeId}/notification/{notificationId} + // DELETE /rest/api/{2-3}/notificationscheme/{schemeID}/notification/{notificationID} // // https://docs.go-atlassian.io/jira-software-cloud/projects/notification-schemes#remove-notifications-to-scheme Remove(ctx context.Context, schemeID, notificationID string) (*models.ResponseScheme, error) diff --git a/service/jira/priority.go b/service/jira/priority.go index 48d53152..e13a3035 100644 --- a/service/jira/priority.go +++ b/service/jira/priority.go @@ -2,6 +2,7 @@ package jira import ( "context" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -16,8 +17,8 @@ type PriorityConnector interface { // Get returns an issue priority. // - // GET /rest/api/{2-3}/priority/{id} + // GET /rest/api/{2-3}/priority/{priorityID} // // https://docs.go-atlassian.io/jira-software-cloud/issues/priorities#get-priority - Get(ctx context.Context, priorityId string) (*model.PriorityScheme, *model.ResponseScheme, error) + Get(ctx context.Context, priorityID string) (*model.PriorityScheme, *model.ResponseScheme, error) } diff --git a/service/jira/resolution.go b/service/jira/resolution.go index c16f1896..0239ba3d 100644 --- a/service/jira/resolution.go +++ b/service/jira/resolution.go @@ -2,6 +2,7 @@ package jira import ( "context" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -17,8 +18,8 @@ type ResolutionConnector interface { // Get returns an issue resolution value. // // - // GET /rest/api/{2-3}/resolution/{id} + // GET /rest/api/{2-3}/resolution/{resolutionID} // // https://docs.go-atlassian.io/jira-software-cloud/issues/resolutions#get-resolution - Get(ctx context.Context, resolutionId string) (*model.ResolutionScheme, *model.ResponseScheme, error) + Get(ctx context.Context, resolutionID string) (*model.ResolutionScheme, *model.ResponseScheme, error) } diff --git a/service/jira/type.go b/service/jira/type.go index 5f7cd9d6..988f1a6e 100644 --- a/service/jira/type.go +++ b/service/jira/type.go @@ -24,36 +24,36 @@ type TypeConnector interface { // Get returns an issue type. // - // GET /rest/api/{2-3}/issuetype/{id} + // GET /rest/api/{2-3}/issuetype/{issueTypeID} // // https://docs.go-atlassian.io/jira-software-cloud/issues/type#get-issue-type - Get(ctx context.Context, issueTypeId string) (*model.IssueTypeScheme, *model.ResponseScheme, error) + Get(ctx context.Context, issueTypeID string) (*model.IssueTypeScheme, *model.ResponseScheme, error) // Update updates the issue type. // - // PUT /rest/api/{2-3}/issuetype/{id} + // PUT /rest/api/{2-3}/issuetype/{issueTypeID} // // https://docs.go-atlassian.io/jira-software-cloud/issues/type#update-issue-type - Update(ctx context.Context, issueTypeId string, payload *model.IssueTypePayloadScheme) (*model.IssueTypeScheme, *model.ResponseScheme, error) + Update(ctx context.Context, issueTypeID string, payload *model.IssueTypePayloadScheme) (*model.IssueTypeScheme, *model.ResponseScheme, error) // Delete deletes the issue type. // // If the issue type is in use, all uses are updated with the alternative issue type (alternativeIssueTypeId). // A list of alternative issue types are obtained from the Get alternative issue types resource. // - // DELETE /rest/api/{2-3}/issuetype/{id} + // DELETE /rest/api/{2-3}/issuetype/{issueTypeID} // // https://docs.go-atlassian.io/jira-software-cloud/issues/type#delete-issue-type - Delete(ctx context.Context, issueTypeId string) (*model.ResponseScheme, error) + Delete(ctx context.Context, issueTypeID string) (*model.ResponseScheme, error) // Alternatives returns a list of issue types that can be used to replace the issue type. // // The alternative issue types are those assigned to the same workflow scheme, field configuration scheme, and screen scheme. // - // GET /rest/api/{2-3}/issuetype/{id}/alternatives + // GET /rest/api/{2-3}/issuetype/{issueTypeID}/alternatives // // https://docs.go-atlassian.io/jira-software-cloud/issues/type#get-alternative-issue-types - Alternatives(ctx context.Context, issueTypeId string) ([]*model.IssueTypeScheme, *model.ResponseScheme, error) + Alternatives(ctx context.Context, issueTypeID string) ([]*model.IssueTypeScheme, *model.ResponseScheme, error) } type TypeSchemeConnector interface { @@ -63,7 +63,7 @@ type TypeSchemeConnector interface { // GET /rest/api/{2-3}/issuetypescheme // // https://docs.go-atlassian.io/jira-software-cloud/issues/types/scheme#get-all-issue-type-schemes - Gets(ctx context.Context, issueTypeSchemeIds []int, startAt, maxResults int) (*model.IssueTypeSchemePageScheme, *model.ResponseScheme, error) + Gets(ctx context.Context, issueTypeSchemeIDs []int, startAt, maxResults int) (*model.IssueTypeSchemePageScheme, *model.ResponseScheme, error) // Create creates an issue type scheme. // @@ -77,28 +77,28 @@ type TypeSchemeConnector interface { // GET /rest/api/{2-3}/issuetypescheme/mapping // // https://docs.go-atlassian.io/jira-software-cloud/issues/types/scheme#get-issue-type-scheme-items - Items(ctx context.Context, issueTypeSchemeIds []int, startAt, maxResults int) (*model.IssueTypeSchemeItemPageScheme, *model.ResponseScheme, error) + Items(ctx context.Context, issueTypeSchemeIDs []int, startAt, maxResults int) (*model.IssueTypeSchemeItemPageScheme, *model.ResponseScheme, error) // Projects returns a paginated list of issue type schemes and, for each issue type scheme, a list of the projects that use it. // // GET /rest/api/{2-3}/issuetypescheme/project // // https://docs.go-atlassian.io/jira-software-cloud/issues/types/scheme#get-issue-type-schemes-for-projects - Projects(ctx context.Context, projectIds []int, startAt, maxResults int) (*model.ProjectIssueTypeSchemePageScheme, *model.ResponseScheme, error) + Projects(ctx context.Context, projectIDs []int, startAt, maxResults int) (*model.ProjectIssueTypeSchemePageScheme, *model.ResponseScheme, error) // Assign assigns an issue type scheme to a project. // // PUT /rest/api/{2-3}/issuetypescheme/project // // https://docs.go-atlassian.io/jira-software-cloud/issues/types/scheme#assign-issue-type-scheme-to-project - Assign(ctx context.Context, issueTypeSchemeId, projectID string) (*model.ResponseScheme, error) + Assign(ctx context.Context, issueTypeSchemeID, projectID string) (*model.ResponseScheme, error) // Update updates an issue type scheme. // - // PUT /rest/api/{2-3}/issuetypescheme/{issueTypeSchemeId} + // PUT /rest/api/{2-3}/issuetypescheme/{issueTypeSchemeID} // // https://docs.go-atlassian.io/jira-software-cloud/issues/types/scheme#update-issue-type-scheme - Update(ctx context.Context, issueTypeSchemeId int, payload *model.IssueTypeSchemePayloadScheme) (*model.ResponseScheme, error) + Update(ctx context.Context, issueTypeSchemeID int, payload *model.IssueTypeSchemePayloadScheme) (*model.ResponseScheme, error) // Delete deletes an issue type scheme. // @@ -106,10 +106,10 @@ type TypeSchemeConnector interface { // // 2.Any projects assigned to the scheme are reassigned to the default issue type scheme. // - // DELETE /rest/api/{2-3}/issuetypescheme/{issueTypeSchemeId} + // DELETE /rest/api/{2-3}/issuetypescheme/{issueTypeSchemeID} // // https://docs.go-atlassian.io/jira-software-cloud/issues/types/scheme#delete-issue-type-scheme - Delete(ctx context.Context, issueTypeSchemeId int) (*model.ResponseScheme, error) + Delete(ctx context.Context, issueTypeSchemeID int) (*model.ResponseScheme, error) // Append adds issue types to an issue type scheme. // @@ -117,10 +117,10 @@ type TypeSchemeConnector interface { // // 2.If any of the issue types exist in the issue type scheme, the operation fails and no issue types are added. // - // PUT /rest/api/{2-3}/issuetypescheme/{issueTypeSchemeId}/issuetype + // PUT /rest/api/{2-3}/issuetypescheme/{issueTypeSchemeID}/issuetype // // https://docs.go-atlassian.io/jira-software-cloud/issues/types/scheme#add-issue-types-to-issue-type-scheme - Append(ctx context.Context, issueTypeSchemeId int, issueTypeIds []int) (*model.ResponseScheme, error) + Append(ctx context.Context, issueTypeSchemeID int, issueTypeIDs []int) (*model.ResponseScheme, error) // Remove removes an issue type from an issue type scheme, this operation cannot remove: // @@ -130,11 +130,11 @@ type TypeSchemeConnector interface { // // 3.the last standard issue type from an issue type scheme. // - // DELETE /rest/api/{2-3}/issuetypescheme/{issueTypeSchemeId}/issuetype/{issueTypeId} + // DELETE /rest/api/{2-3}/issuetypescheme/{issueTypeSchemeID}/issuetype/{issueTypeID} // // // https://docs.go-atlassian.io/jira-software-cloud/issues/types/scheme#remove-issue-type-from-issue-type-scheme - Remove(ctx context.Context, issueTypeSchemeId, issueTypeId int) (*model.ResponseScheme, error) + Remove(ctx context.Context, issueTypeSchemeID, issueTypeID int) (*model.ResponseScheme, error) } type TypeScreenSchemeConnector interface { @@ -170,7 +170,7 @@ type TypeScreenSchemeConnector interface { // GET /rest/api/{2-3}/issuetypescreenscheme/project // // https://docs.go-atlassian.io/jira-software-cloud/issues/types/screen-scheme#assign-issue-type-screen-scheme-to-project - Projects(ctx context.Context, projectIds []int, startAt, maxResults int) (*model.IssueTypeProjectScreenSchemePageScheme, *model.ResponseScheme, error) + Projects(ctx context.Context, projectIDs []int, startAt, maxResults int) (*model.IssueTypeProjectScreenSchemePageScheme, *model.ResponseScheme, error) // Mapping returns a paginated list of issue type screen scheme items. // @@ -179,7 +179,7 @@ type TypeScreenSchemeConnector interface { // GET /rest/api/{2-3}/issuetypescreenscheme/mapping // // https://docs.go-atlassian.io/jira-software-cloud/issues/types/screen-scheme#get-issue-type-screen-scheme-items - Mapping(ctx context.Context, issueTypeScreenSchemeIds []int, startAt, maxResults int) (*model.IssueTypeScreenSchemeMappingScheme, *model.ResponseScheme, error) + Mapping(ctx context.Context, issueTypeScreenSchemeIDs []int, startAt, maxResults int) (*model.IssueTypeScreenSchemeMappingScheme, *model.ResponseScheme, error) // Update updates an issue type screen scheme. // @@ -215,7 +215,7 @@ type TypeScreenSchemeConnector interface { // POST /rest/api/{2-3}/issuetypescreenscheme/{issueTypeScreenSchemeID}/mapping/remove // // https://docs.go-atlassian.io/jira-software-cloud/issues/types/screen-scheme#remove-mappings-from-issue-type-screen-scheme - Remove(ctx context.Context, issueTypeScreenSchemeID string, issueTypeIds []string) (*model.ResponseScheme, error) + Remove(ctx context.Context, issueTypeScreenSchemeID string, issueTypeIDs []string) (*model.ResponseScheme, error) // SchemesByProject returns a paginated list of projects associated with an issue type screen scheme. // diff --git a/service/jira/user.go b/service/jira/user.go index c9eccdf1..e394c0e2 100644 --- a/service/jira/user.go +++ b/service/jira/user.go @@ -2,6 +2,7 @@ package jira import ( "context" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -12,7 +13,7 @@ type UserConnector interface { // GET /rest/api/{2-3}/user // // https://docs.go-atlassian.io/jira-software-cloud/users#get-user - Get(ctx context.Context, accountId string, expand []string) (*model.UserScheme, *model.ResponseScheme, error) + Get(ctx context.Context, accountID string, expand []string) (*model.UserScheme, *model.ResponseScheme, error) // Create creates a user. This resource is retained for legacy compatibility. // @@ -38,14 +39,14 @@ type UserConnector interface { // DELETE /rest/api/{2-3}/user // // https://docs.go-atlassian.io/jira-software-cloud/users#delete-user - Delete(ctx context.Context, accountId string) (*model.ResponseScheme, error) + Delete(ctx context.Context, accountID string) (*model.ResponseScheme, error) // Find returns a paginated list of the users specified by one or more account IDs. // // GET /rest/api/{2-3}/user/bulk // // https://docs.go-atlassian.io/jira-software-cloud/users#bulk-get-users - Find(ctx context.Context, accountIds []string, startAt, maxResults int) (*model.UserSearchPageScheme, *model.ResponseScheme, + Find(ctx context.Context, accountIDs []string, startAt, maxResults int) (*model.UserSearchPageScheme, *model.ResponseScheme, error) // Groups returns the groups to which a user belongs. @@ -53,7 +54,7 @@ type UserConnector interface { // GET /rest/api/{2-3}/user/groups // // https://docs.go-atlassian.io/jira-software-cloud/users#get-user-groups - Groups(ctx context.Context, accountIds string) ([]*model.UserGroupScheme, *model.ResponseScheme, error) + Groups(ctx context.Context, accountIDs string) ([]*model.UserGroupScheme, *model.ResponseScheme, error) // Gets returns a list of all (active and inactive) users. // @@ -72,7 +73,7 @@ type UserSearchConnector interface { // GET /rest/api/{2-3}/user/assignable/multiProjectSearch // // https://docs.go-atlassian.io/jira-software-cloud/users/search#find-users-assignable-to-projects - Projects(ctx context.Context, accountId string, projectKeys []string, startAt, maxResults int) ( + Projects(ctx context.Context, accountID string, projectKeys []string, startAt, maxResults int) ( []*model.UserScheme, *model.ResponseScheme, error) // Do return a list of users that match the search string and property. @@ -87,7 +88,7 @@ type UserSearchConnector interface { // GET /rest/api/{2-3}/user/search // // https://docs.go-atlassian.io/jira-software-cloud/users/search#find-users - Do(ctx context.Context, accountId, query string, startAt, maxResults int) ([]*model.UserScheme, *model.ResponseScheme, error) + Do(ctx context.Context, accountID, query string, startAt, maxResults int) ([]*model.UserScheme, *model.ResponseScheme, error) // Check returns a list of users who fulfill these criteria: // diff --git a/service/jira/vote.go b/service/jira/vote.go index 213556be..dda0c662 100644 --- a/service/jira/vote.go +++ b/service/jira/vote.go @@ -2,6 +2,7 @@ package jira import ( "context" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -13,26 +14,26 @@ type VoteConnector interface { // // This operation requires allowing users to vote on issues option to be ON // - // GET /rest/api/{2-3}/issue/{issueIdOrKey}/votes + // GET /rest/api/{2-3}/issue/{issueKeyOrID}/votes // // https://docs.go-atlassian.io/jira-software-cloud/issues/vote#get-votes - Gets(ctx context.Context, issueKeyOrId string) (*model.IssueVoteScheme, *model.ResponseScheme, error) + Gets(ctx context.Context, issueKeyOrID string) (*model.IssueVoteScheme, *model.ResponseScheme, error) // Add adds the user's vote to an issue. This is the equivalent of the user clicking Vote on an issue in Jira. // // This operation requires the Allow users to vote on issues option to be ON. // - // POST /rest/api/{2-3}/issue/{issueIdOrKey}/votes + // POST /rest/api/{2-3}/issue/{issueKeyOrID}/votes // // https://docs.go-atlassian.io/jira-software-cloud/issues/vote#add-vote - Add(ctx context.Context, issueKeyOrId string) (*model.ResponseScheme, error) + Add(ctx context.Context, issueKeyOrID string) (*model.ResponseScheme, error) // Delete deletes a user's vote from an issue. This is the equivalent of the user clicking Unvote on an issue in Jira. // // This operation requires the Allow users to vote on issues option to be ON. // - // DELETE /rest/api/{2-3}/issue/{issueIdOrKey}/votes + // DELETE /rest/api/{2-3}/issue/{issueKeyOrID}/votes // // https://docs.go-atlassian.io/jira-software-cloud/issues/vote#delete-vote - Delete(ctx context.Context, issueKeyOrId string) (*model.ResponseScheme, error) + Delete(ctx context.Context, issueKeyOrID string) (*model.ResponseScheme, error) } diff --git a/service/jira/watcher.go b/service/jira/watcher.go index db0609dc..0081db26 100644 --- a/service/jira/watcher.go +++ b/service/jira/watcher.go @@ -2,6 +2,7 @@ package jira import ( "context" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -11,7 +12,7 @@ type WatcherConnector interface { // Gets returns the watchers for an issue. // - // GET /rest/api/{2-3}/issue/{issueIdOrKey}/watchers + // GET /rest/api/{2-3}/issue/{issueKeyOrID}/watchers // // https://docs.go-atlassian.io/jira-software-cloud/issues/watcher#get-issue-watchers Gets(ctx context.Context, issueKeyOrID string) (*model.IssueWatcherScheme, *model.ResponseScheme, error) @@ -20,14 +21,14 @@ type WatcherConnector interface { // // For example, "5b10ac8d82e05b22cc7d4ef5". If no user is specified the calling user is added. // - // POST /rest/api/{2-3}/issue/{issueIdOrKey}/watchers + // POST /rest/api/{2-3}/issue/{issueKeyOrID}/watchers // // https://docs.go-atlassian.io/jira-software-cloud/issues/watcher#add-watcher Add(ctx context.Context, issueKeyOrID string, accountID ...string) (*model.ResponseScheme, error) // Delete deletes a user as a watcher of an issue. // - // DELETE /rest/api/{2-3}/issue/{issueIdOrKey}/watchers + // DELETE /rest/api/{2-3}/issue/{issueKeyOrID}/watchers // // https://docs.go-atlassian.io/jira-software-cloud/issues/watcher#delete-watcher Delete(ctx context.Context, issueKeyOrID, accountID string) (*model.ResponseScheme, error) diff --git a/service/jira/workflow.go b/service/jira/workflow.go index 111188fc..78886559 100644 --- a/service/jira/workflow.go +++ b/service/jira/workflow.go @@ -39,10 +39,10 @@ type WorkflowConnector interface { // 3. associated with any workflow scheme. // 4. associated with any draft workflow scheme. // - // DELETE /rest/api/{2-3}/workflow/{entityId} + // DELETE /rest/api/{2-3}/workflow/{workflowID} // // https://docs.go-atlassian.io/jira-software-cloud/workflow#search-workflows - Delete(ctx context.Context, workflowId string) (*model.ResponseScheme, error) + Delete(ctx context.Context, workflowID string) (*model.ResponseScheme, error) // Search searches for workflows based on specified criteria. // @@ -234,7 +234,7 @@ type WorkflowSchemeConnector interface { // GET /rest/api/{2-3}/workflowscheme/project // // https://docs.go-atlassian.io/jira-software-cloud/workflow/scheme#get-workflow-schemes-associations - Associations(ctx context.Context, projectIds []int) (*model.WorkflowSchemeAssociationPageScheme, *model.ResponseScheme, error) + Associations(ctx context.Context, projectIDs []int) (*model.WorkflowSchemeAssociationPageScheme, *model.ResponseScheme, error) // Assign assigns a workflow scheme to a project. // diff --git a/service/jira/worklog.go b/service/jira/worklog.go index a7fdbfe6..81721b09 100644 --- a/service/jira/worklog.go +++ b/service/jira/worklog.go @@ -2,6 +2,7 @@ package jira import ( "context" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -11,10 +12,10 @@ type WorklogSharedConnector interface { // // Time tracking must be enabled in Jira, otherwise this operation returns an error. // - // DELETE /rest/api/{2-3}/issue/{issueIdOrKey}/worklog/{id} + // DELETE /rest/api/{2-3}/issue/{issueKeyOrID}/worklog/{worklogID} // // https://docs.go-atlassian.io/jira-software-cloud/issues/worklogs#delete-worklog - Delete(ctx context.Context, issueKeyOrId, worklogId string, options *model.WorklogOptionsScheme) (*model.ResponseScheme, error) + Delete(ctx context.Context, issueKeyOrID, worklogID string, options *model.WorklogOptionsScheme) (*model.ResponseScheme, error) // Deleted returns a list of IDs and delete timestamps for worklogs deleted after a date and time. // @@ -55,31 +56,31 @@ type WorklogRichTextConnector interface { // POST /rest/api/{2-3}/worklog/list // // https://docs.go-atlassian.io/jira-software-cloud/issues/worklogs#get-worklogs - Gets(ctx context.Context, worklogIds []int, expand []string) ([]*model.IssueWorklogRichTextScheme, *model.ResponseScheme, error) + Gets(ctx context.Context, worklogIDs []int, expand []string) ([]*model.IssueWorklogRichTextScheme, *model.ResponseScheme, error) // Get returns a worklog. // // Time tracking must be enabled in Jira, otherwise this operation returns an error. // - // GET /rest/api/{2-3}/issue/{issueIdOrKey}/worklog/{id} + // GET /rest/api/{2-3}/issue/{issueKeyOrID}/worklog/{worklogID} // // https://docs.go-atlassian.io/jira-software-cloud/issues/worklogs#get-worklog - Get(ctx context.Context, issueKeyOrId, worklogId string, expand []string) (*model.IssueWorklogRichTextScheme, *model.ResponseScheme, error) + Get(ctx context.Context, issueKeyOrID, worklogID string, expand []string) (*model.IssueWorklogRichTextScheme, *model.ResponseScheme, error) // Issue returns worklogs for an issue, starting from the oldest worklog or from the worklog started on or after a date and time. // // Time tracking must be enabled in Jira, otherwise this operation returns an error. // - // GET /rest/api/{2-3}/issue/{issueIdOrKey}/worklog + // GET /rest/api/{2-3}/issue/{issueKeyOrID}/worklog // // https://docs.go-atlassian.io/jira-software-cloud/issues/worklogs#get-issue-worklogs - Issue(ctx context.Context, issueKeyOrId string, startAt, maxResults, after int, expand []string) (*model.IssueWorklogRichTextPageScheme, *model.ResponseScheme, error) + Issue(ctx context.Context, issueKeyOrID string, startAt, maxResults, after int, expand []string) (*model.IssueWorklogRichTextPageScheme, *model.ResponseScheme, error) // Add adds a worklog to an issue. // // Time tracking must be enabled in Jira, otherwise this operation returns an error. // - // POST /rest/api/2/issue/{issueIdOrKey}/worklog + // POST /rest/api/2/issue/{issueKeyOrID}/worklog // // https://docs.go-atlassian.io/jira-software-cloud/issues/worklogs#add-worklog Add(ctx context.Context, issueKeyOrID string, payload *model.WorklogRichTextPayloadScheme, options *model.WorklogOptionsScheme) (*model.IssueWorklogRichTextScheme, @@ -89,10 +90,10 @@ type WorklogRichTextConnector interface { // // Time tracking must be enabled in Jira, otherwise this operation returns an error. // - // PUT /rest/api/2/issue/{issueIdOrKey}/worklog/{id} + // PUT /rest/api/2/issue/{issueKeyOrID}/worklog/{id} // // https://docs.go-atlassian.io/jira-software-cloud/issues/worklogs#update-worklog - Update(ctx context.Context, issueKeyOrId, worklogId string, payload *model.WorklogRichTextPayloadScheme, options *model.WorklogOptionsScheme) ( + Update(ctx context.Context, issueKeyOrID, worklogID string, payload *model.WorklogRichTextPayloadScheme, options *model.WorklogOptionsScheme) ( *model.IssueWorklogRichTextScheme, *model.ResponseScheme, error) } @@ -106,31 +107,31 @@ type WorklogADFConnector interface { // POST /rest/api/{2-3}/worklog/list // // https://docs.go-atlassian.io/jira-software-cloud/issues/worklogs#get-worklogs - Gets(ctx context.Context, worklogIds []int, expand []string) ([]*model.IssueWorklogADFScheme, *model.ResponseScheme, error) + Gets(ctx context.Context, worklogIDs []int, expand []string) ([]*model.IssueWorklogADFScheme, *model.ResponseScheme, error) // Get returns a worklog. // // Time tracking must be enabled in Jira, otherwise this operation returns an error. // - // GET /rest/api/{2-3}/issue/{issueIdOrKey}/worklog/{id} + // GET /rest/api/{2-3}/issue/{issueKeyOrID}/worklog/{worklogID} // // https://docs.go-atlassian.io/jira-software-cloud/issues/worklogs#get-worklog - Get(ctx context.Context, issueKeyOrId, worklogId string, expand []string) (*model.IssueWorklogADFScheme, *model.ResponseScheme, error) + Get(ctx context.Context, issueKeyOrID, worklogID string, expand []string) (*model.IssueWorklogADFScheme, *model.ResponseScheme, error) // Issue returns worklogs for an issue, starting from the oldest worklog or from the worklog started on or after a date and time. // // Time tracking must be enabled in Jira, otherwise this operation returns an error. // - // GET /rest/api/{2-3}/issue/{issueIdOrKey}/worklog + // GET /rest/api/{2-3}/issue/{issueKeyOrID}/worklog // // https://docs.go-atlassian.io/jira-software-cloud/issues/worklogs#get-issue-worklogs - Issue(ctx context.Context, issueKeyOrId string, startAt, maxResults, after int, expand []string) (*model.IssueWorklogADFPageScheme, *model.ResponseScheme, error) + Issue(ctx context.Context, issueKeyOrID string, startAt, maxResults, after int, expand []string) (*model.IssueWorklogADFPageScheme, *model.ResponseScheme, error) // Add adds a worklog to an issue. // // Time tracking must be enabled in Jira, otherwise this operation returns an error. // - // POST /rest/api/3/issue/{issueIdOrKey}/worklog + // POST /rest/api/3/issue/{issueKeyOrID}/worklog // // https://docs.go-atlassian.io/jira-software-cloud/issues/worklogs#add-worklog Add(ctx context.Context, issueKeyOrID string, payload *model.WorklogADFPayloadScheme, options *model.WorklogOptionsScheme) (*model.IssueWorklogADFScheme, @@ -140,9 +141,9 @@ type WorklogADFConnector interface { // // Time tracking must be enabled in Jira, otherwise this operation returns an error. // - // PUT /rest/api/3/issue/{issueIdOrKey}/worklog/{id} + // PUT /rest/api/3/issue/{issueKeyOrID}/worklog/{worklogID} // // https://docs.go-atlassian.io/jira-software-cloud/issues/worklogs#update-worklog - Update(ctx context.Context, issueKeyOrId, worklogId string, payload *model.WorklogADFPayloadScheme, options *model.WorklogOptionsScheme) ( + Update(ctx context.Context, issueKeyOrID, worklogID string, payload *model.WorklogADFPayloadScheme, options *model.WorklogOptionsScheme) ( *model.IssueWorklogADFScheme, *model.ResponseScheme, error) } diff --git a/service/mocks/Connector.go b/service/mocks/Connector.go index 2399b9a0..17d8e5a5 100644 --- a/service/mocks/Connector.go +++ b/service/mocks/Connector.go @@ -42,17 +42,17 @@ func (_m *Connector) Call(request *http.Request, structure interface{}) (*models return r0, r1 } -// NewRequest provides a mock function with given fields: ctx, method, urlStr, type_, body -func (_m *Connector) NewRequest(ctx context.Context, method string, urlStr string, type_ string, body interface{}) (*http.Request, error) { - ret := _m.Called(ctx, method, urlStr, type_, body) +// NewRequest provides a mock function with given fields: ctx, method, urlStr, contentType, body +func (_m *Connector) NewRequest(ctx context.Context, method string, urlStr string, contentType string, body interface{}) (*http.Request, error) { + ret := _m.Called(ctx, method, urlStr, contentType, body) var r0 *http.Request var r1 error if rf, ok := ret.Get(0).(func(context.Context, string, string, string, interface{}) (*http.Request, error)); ok { - return rf(ctx, method, urlStr, type_, body) + return rf(ctx, method, urlStr, contentType, body) } if rf, ok := ret.Get(0).(func(context.Context, string, string, string, interface{}) *http.Request); ok { - r0 = rf(ctx, method, urlStr, type_, body) + r0 = rf(ctx, method, urlStr, contentType, body) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(*http.Request) @@ -60,7 +60,7 @@ func (_m *Connector) NewRequest(ctx context.Context, method string, urlStr strin } if rf, ok := ret.Get(1).(func(context.Context, string, string, string, interface{}) error); ok { - r1 = rf(ctx, method, urlStr, type_, body) + r1 = rf(ctx, method, urlStr, contentType, body) } else { r1 = ret.Error(1) } diff --git a/service/mocks/HttpClient.go b/service/mocks/HttpClient.go index 1f965d01..e4536bee 100644 --- a/service/mocks/HttpClient.go +++ b/service/mocks/HttpClient.go @@ -8,13 +8,13 @@ import ( mock "github.com/stretchr/testify/mock" ) -// HttpClient is an autogenerated mock type for the HttpClient type -type HttpClient struct { +// HTTPClient is an autogenerated mock type for the HTTPClient type +type HTTPClient struct { mock.Mock } // Do provides a mock function with given fields: request -func (_m *HttpClient) Do(request *http.Request) (*http.Response, error) { +func (_m *HTTPClient) Do(request *http.Request) (*http.Response, error) { ret := _m.Called(request) var r0 *http.Response @@ -36,14 +36,14 @@ func (_m *HttpClient) Do(request *http.Request) (*http.Response, error) { return r0, r1 } -type NewHttpClientT interface { +type NewHTTPClientT interface { mock.TestingT Cleanup(func()) } -// NewHttpClient creates a new instance of HttpClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewHttpClient(t NewHttpClientT) *HttpClient { - mock := &HttpClient{} +// NewHTTPClient creates a new instance of HTTPClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewHTTPClient(t NewHTTPClientT) *HTTPClient { + mock := &HTTPClient{} mock.Mock.Test(t) t.Cleanup(func() { mock.AssertExpectations(t) }) diff --git a/service/sm/approval.go b/service/sm/approval.go index 3adaa1eb..126491f8 100644 --- a/service/sm/approval.go +++ b/service/sm/approval.go @@ -2,6 +2,7 @@ package sm import ( "context" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -9,14 +10,14 @@ type ApprovalConnector interface { // Gets returns all approvals on a customer request. // - // GET /rest/servicedeskapi/request/{issueIdOrKey}/approval + // GET /rest/servicedeskapi/request/{issueKeyOrID}/approval // // https://docs.go-atlassian.io/jira-service-management-cloud/request/approval#get-approvals Gets(ctx context.Context, issueKeyOrID string, start, limit int) (*model.CustomerApprovalPageScheme, *model.ResponseScheme, error) // Get returns an approval. Use this method to determine the status of an approval and the list of approvers. // - // GET /rest/servicedeskapi/request/{issueIdOrKey}/approval/{approvalId} + // GET /rest/servicedeskapi/request/{issueKeyOrID}/approval/{approvalID} // // https://docs.go-atlassian.io/jira-service-management-cloud/request/approval#get-approval-by-id Get(ctx context.Context, issueKeyOrID string, approvalID int) (*model.CustomerApprovalScheme, *model.ResponseScheme, error) @@ -25,7 +26,7 @@ type ApprovalConnector interface { // // The approval is assumed to be owned by the user making the call. // - // POST /rest/servicedeskapi/request/{issueIdOrKey}/approval/{approvalId} + // POST /rest/servicedeskapi/request/{issueKeyOrID}/approval/{approvalID} // // https://docs.go-atlassian.io/jira-service-management-cloud/request/approval#answer-approval Answer(ctx context.Context, issueKeyOrID string, approvalID int, approve bool) (*model.CustomerApprovalScheme, *model.ResponseScheme, error) diff --git a/service/sm/attachment.go b/service/sm/attachment.go index a3770f1f..3f8da0ea 100644 --- a/service/sm/attachment.go +++ b/service/sm/attachment.go @@ -10,16 +10,16 @@ type AttachmentConnector interface { // Gets returns all the attachments for a customer requests. // - // GET /rest/servicedeskapi/request/{issueIdOrKey}/attachment + // GET /rest/servicedeskapi/request/{issueKeyOrID}/attachment // // https://docs.go-atlassian.io/jira-service-management-cloud/request/attachment#get-attachments-for-request Gets(ctx context.Context, issueKeyOrID string, start, limit int) (*model.RequestAttachmentPageScheme, *model.ResponseScheme, error) // Create adds one or more temporary files (attached to the request's service desk using // - // servicedesk/{serviceDeskId}/attachTemporaryFile) as attachments to a customer request + // servicedesk/{serviceDeskID}/attachTemporaryFile) as attachments to a customer request // - // POST /rest/servicedeskapi/request/{issueIdOrKey}/attachment + // POST /rest/servicedeskapi/request/{issueKeyOrID}/attachment // // https://docs.go-atlassian.io/jira-service-management-cloud/request/attachment#create-attachment Create(ctx context.Context, issueKeyOrID string, payload *model.RequestAttachmentCreationPayloadScheme) (*model.RequestAttachmentCreationScheme, *model.ResponseScheme, error) diff --git a/service/sm/comment.go b/service/sm/comment.go index 83374fe0..ac8dbf86 100644 --- a/service/sm/comment.go +++ b/service/sm/comment.go @@ -15,28 +15,28 @@ type CommentConnector interface { // // the method simply returns an empty response. // - // GET /rest/servicedeskapi/request/{issueIdOrKey}/comment + // GET /rest/servicedeskapi/request/{issueKeyOrID}/comment // // https://docs.go-atlassian.io/jira-service-management-cloud/request/comments#get-request-comments Gets(ctx context.Context, issueKeyOrID string, options *model.RequestCommentOptionsScheme) (*model.RequestCommentPageScheme, *model.ResponseScheme, error) // Get returns details of a customer request's comment. // - // GET /rest/servicedeskapi/request/{issueIdOrKey}/comment/{commentId} + // GET /rest/servicedeskapi/request/{issueKeyOrID}/comment/{commentID} // // https://docs.go-atlassian.io/jira-service-management-cloud/request/comments#get-request-comment-by-id Get(ctx context.Context, issueKeyOrID string, commentID int, expand []string) (*model.RequestCommentScheme, *model.ResponseScheme, error) // Create creates a public or private (internal) comment on a customer request, with the comment visibility set by public. // - // POST /rest/servicedeskapi/request/{issueIdOrKey}/comment + // POST /rest/servicedeskapi/request/{issueKeyOrID}/comment // // https://docs.go-atlassian.io/jira-service-management-cloud/request/comments#create-request-comment Create(ctx context.Context, issueKeyOrID, body string, public bool) (*model.RequestCommentScheme, *model.ResponseScheme, error) // Attachments returns the attachments referenced in a comment. // - // GET /rest/servicedeskapi/request/{issueIdOrKey}/comment/{commentId}/attachment + // GET /rest/servicedeskapi/request/{issueKeyOrID}/comment/{commentID}/attachment // // https://docs.go-atlassian.io/jira-service-management-cloud/request/comments#get-comment-attachments Attachments(ctx context.Context, issueKeyOrID string, commentID, start, limit int) (*model.RequestAttachmentPageScheme, *model.ResponseScheme, error) diff --git a/service/sm/customer.go b/service/sm/customer.go index ad409030..f10c8042 100644 --- a/service/sm/customer.go +++ b/service/sm/customer.go @@ -23,21 +23,21 @@ type CustomerConnector interface { // Gets returns a list of the customers on a service desk. // - // GET /rest/servicedeskapi/servicedesk/{serviceDeskId}/customer + // GET /rest/servicedeskapi/servicedesk/{serviceDeskID}/customer // // https://docs.go-atlassian.io/jira-service-management-cloud/customer#get-customers Gets(ctx context.Context, serviceDeskID string, query string, start, limit int) (*model.CustomerPageScheme, *model.ResponseScheme, error) // Add adds one or more customers to a service desk. // - // POST /rest/servicedeskapi/servicedesk/{serviceDeskId}/customer + // POST /rest/servicedeskapi/servicedesk/{serviceDeskID}/customer // // https://docs.go-atlassian.io/jira-service-management-cloud/customer#add-customers Add(ctx context.Context, serviceDeskID string, accountIDs []string) (*model.ResponseScheme, error) // Remove removes one or more customers from a service desk. The service desk must have closed access // - // DELETE /rest/servicedeskapi/servicedesk/{serviceDeskId}/customer + // DELETE /rest/servicedeskapi/servicedesk/{serviceDeskID}/customer // // https://docs.go-atlassian.io/jira-service-management-cloud/customer#remove-customers Remove(ctx context.Context, serviceDeskID string, accountIDs []string) (*model.ResponseScheme, error) diff --git a/service/sm/feedback.go b/service/sm/feedback.go index 768a0ad5..3c0fd9be 100644 --- a/service/sm/feedback.go +++ b/service/sm/feedback.go @@ -2,28 +2,29 @@ package sm import ( "context" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) type FeedbackConnector interface { - // Get retrieves a feedback of a request using it's requestKey or requestId + // Get retrieves a feedback of a request using it's request key or request id // - // GET /rest/servicedeskapi/request/{requestIdOrKey}/feedback + // GET /rest/servicedeskapi/request/{requestIDOrKey}/feedback // // https://docs.go-atlassian.io/jira-service-management-cloud/request/feedback#get-feedback Get(ctx context.Context, requestIDOrKey string) (*model.CustomerFeedbackScheme, *model.ResponseScheme, error) - // Post adds a feedback on a request using its requestKey or requestId + // Post adds a feedback on a request using its request key or request id // - // POST /rest/servicedeskapi/request/{requestIdOrKey}/feedback + // POST /rest/servicedeskapi/request/{requestIDOrKey}/feedback // // https://docs.go-atlassian.io/jira-service-management-cloud/request/feedback#post-feedback Post(ctx context.Context, requestIDOrKey string, rating int, comment string) (*model.CustomerFeedbackScheme, *model.ResponseScheme, error) - // Delete deletes the feedback of request using its requestKey or requestId + // Delete deletes the feedback of request using its request key or request id // - // DELETE /rest/servicedeskapi/request/{requestIdOrKey}/feedback + // DELETE /rest/servicedeskapi/request/{requestIDOrKey}/feedback // // https://docs.go-atlassian.io/jira-service-management-cloud/request/feedback#delete-feedback Delete(ctx context.Context, requestIDOrKey string) (*model.ResponseScheme, error) diff --git a/service/sm/knowledgebase.go b/service/sm/knowledgebase.go index 6f0f265f..da37b2c8 100644 --- a/service/sm/knowledgebase.go +++ b/service/sm/knowledgebase.go @@ -2,6 +2,7 @@ package sm import ( "context" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -16,7 +17,7 @@ type KnowledgeBaseConnector interface { // Gets returns articles which match the given query string across all service desks. // - // GET /rest/servicedeskapi/servicedesk/{serviceDeskId}/knowledgebase/article + // GET /rest/servicedeskapi/servicedesk/{serviceDeskID}/knowledgebase/article // // https://docs.go-atlassian.io/jira-service-management-cloud/knowledgebase#get-articles Gets(ctx context.Context, serviceDeskID int, query string, highlight bool, start, limit int) (*model.ArticlePageScheme, *model.ResponseScheme, error) diff --git a/service/sm/organization.go b/service/sm/organization.go index 92688eaa..521513ce 100644 --- a/service/sm/organization.go +++ b/service/sm/organization.go @@ -2,6 +2,7 @@ package sm import ( "context" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -22,7 +23,7 @@ type OrganizationConnector interface { // // but needs to display other organization details. // - // GET /rest/servicedeskapi/organization/{organizationId} + // GET /rest/servicedeskapi/organization/{organizationID} // // https://docs.go-atlassian.io/jira-service-management-cloud/organization#get-organization Get(ctx context.Context, organizationID int) (*model.OrganizationScheme, *model.ResponseScheme, error) @@ -33,7 +34,7 @@ type OrganizationConnector interface { // // For example, associations with service desks. // - // DELETE /rest/servicedeskapi/organization/{organizationId} + // DELETE /rest/servicedeskapi/organization/{organizationID} // // https://docs.go-atlassian.io/jira-service-management/organization#delete-organization Delete(ctx context.Context, organizationID int) (*model.ResponseScheme, error) @@ -51,28 +52,28 @@ type OrganizationConnector interface { // // organization or determine if a user is associated with an organization. // - // GET /rest/servicedeskapi/organization/{organizationId}/user + // GET /rest/servicedeskapi/organization/{organizationID}/user // // https://docs.go-atlassian.io/jira-service-management-cloud/organization#get-users-in-organization Users(ctx context.Context, organizationID, start, limit int) (*model.OrganizationUsersPageScheme, *model.ResponseScheme, error) // Add adds users to an organization. // - // POST /rest/servicedeskapi/organization/{organizationId}/user + // POST /rest/servicedeskapi/organization/{organizationID}/user // // https://docs.go-atlassian.io/jira-service-management-cloud/organization#add-users-to-organization Add(ctx context.Context, organizationID int, accountIDs []string) (*model.ResponseScheme, error) // Remove removes users from an organization. // - // DELETE /rest/servicedeskapi/organization/{organizationId}/user + // DELETE /rest/servicedeskapi/organization/{organizationID}/user // // https://docs.go-atlassian.io/jira-service-management-cloud/organization#remove-users-from-organization Remove(ctx context.Context, organizationID int, accountIDs []string) (*model.ResponseScheme, error) // Project returns a list of all organizations associated with a service desk. // - // GET /rest/servicedeskapi/servicedesk/{serviceDeskId}/organization + // GET /rest/servicedeskapi/servicedesk/{organizationID}/organization // // https://docs.go-atlassian.io/jira-service-management/organization#get-project-organizations Project(ctx context.Context, accountID string, serviceDeskID, start, limit int) (*model.OrganizationPageScheme, *model.ResponseScheme, error) @@ -83,7 +84,7 @@ type OrganizationConnector interface { // // no change is made and the resource returns a 204 success code. // - // POST /rest/servicedeskapi/servicedesk/{serviceDeskId}/organization + // POST /rest/servicedeskapi/servicedesk/{organizationID}/organization // // https://docs.go-atlassian.io/jira-service-management-cloud/organization#associate-organization Associate(ctx context.Context, serviceDeskID, organizationID int) (*model.ResponseScheme, error) @@ -94,7 +95,7 @@ type OrganizationConnector interface { // // no change is made and the resource returns a 204 success code. // - // DELETE /rest/servicedeskapi/servicedesk/{serviceDeskId}/organization + // DELETE /rest/servicedeskapi/servicedesk/{organizationID}/organization // // https://docs.go-atlassian.io/jira-service-management-cloud/organization#detach-organization Detach(ctx context.Context, serviceDeskID, organizationID int) (*model.ResponseScheme, error) diff --git a/service/sm/participant.go b/service/sm/participant.go index 090c1071..7119882d 100644 --- a/service/sm/participant.go +++ b/service/sm/participant.go @@ -2,6 +2,7 @@ package sm import ( "context" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -9,21 +10,21 @@ type ParticipantConnector interface { // Gets returns a list of all the participants on a customer request. // - // GET /rest/servicedeskapi/request/{issueIdOrKey}/participant + // GET /rest/servicedeskapi/request/{issueKeyOrID}/participant // // https://docs.go-atlassian.io/jira-service-management-cloud/request/participants#get-request-participants Gets(ctx context.Context, issueKeyOrID string, start, limit int) (*model.RequestParticipantPageScheme, *model.ResponseScheme, error) // Add adds participants to a customer request. // - // POST /rest/servicedeskapi/request/{issueIdOrKey}/participant + // POST /rest/servicedeskapi/request/{issueKeyOrID}/participant // // https://docs.go-atlassian.io/jira-service-management-cloud/request/participants#add-request-participants Add(ctx context.Context, issueKeyOrID string, accountIDs []string) (*model.RequestParticipantPageScheme, *model.ResponseScheme, error) // Remove removes participants from a customer request. // - // DELETE /rest/servicedeskapi/request/{issueIdOrKey}/participant + // DELETE /rest/servicedeskapi/request/{issueKeyOrID}/participant // // https://docs.go-atlassian.io/jira-service-management-cloud/request/participants#remove-request-participants Remove(ctx context.Context, issueKeyOrID string, accountIDs []string) (*model.RequestParticipantPageScheme, *model.ResponseScheme, error) diff --git a/service/sm/queue.go b/service/sm/queue.go index 99b1bca8..b287d21e 100644 --- a/service/sm/queue.go +++ b/service/sm/queue.go @@ -2,6 +2,7 @@ package sm import ( "context" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -9,21 +10,21 @@ type QueueConnector interface { // Gets returns the queues in a service desk // - // GET /rest/servicedeskapi/servicedesk/{serviceDeskId}/queue + // GET /rest/servicedeskapi/servicedesk/{serviceDeskID}/queue // // https://docs.go-atlassian.io/jira-service-management-cloud/request/service-desk/queue#get-queues Gets(ctx context.Context, serviceDeskID int, includeCount bool, start, limit int) (*model.ServiceDeskQueuePageScheme, *model.ResponseScheme, error) // Get returns a specific queues in a service desk. // - // GET /rest/servicedeskapi/servicedesk/{serviceDeskId}/queue/{queueId} + // GET /rest/servicedeskapi/servicedesk/{serviceDeskID}/queue/{queueID} // // https://docs.go-atlassian.io/jira-service-management-cloud/request/service-desk/queue#get-queue Get(ctx context.Context, serviceDeskID, queueID int, includeCount bool) (*model.ServiceDeskQueueScheme, *model.ResponseScheme, error) // Issues returns the customer requests in a queue // - // GET /rest/servicedeskapi/servicedesk/{serviceDeskId}/queue/{queueId}/issue + // GET /rest/servicedeskapi/servicedesk/{serviceDeskID}/queue/{queueID}/issue // // https://docs.go-atlassian.io/jira-service-management-cloud/request/service-desk/queue#get-issues-in-queue Issues(ctx context.Context, serviceDeskID, queueID, start, limit int) (*model.ServiceDeskIssueQueueScheme, *model.ResponseScheme, error) diff --git a/service/sm/request.go b/service/sm/request.go index ffab7ab4..4ab09e93 100644 --- a/service/sm/request.go +++ b/service/sm/request.go @@ -2,6 +2,7 @@ package sm import ( "context" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -27,28 +28,28 @@ type RequestConnector interface { // Get returns a customer request. // - // GET /rest/servicedeskapi/request/{issueIdOrKey} + // GET /rest/servicedeskapi/request/{issueKeyOrID} // // https://docs.go-atlassian.io/jira-service-management-cloud/request#get-customer-request-by-id-or-key Get(ctx context.Context, issueKeyOrID string, expand []string) (*model.CustomerRequestScheme, *model.ResponseScheme, error) // Subscribe subscribes the user to receiving notifications from a customer request. // - // PUT /rest/servicedeskapi/request/{issueIdOrKey}/notification + // PUT /rest/servicedeskapi/request/{issueKeyOrID}/notification // // https://docs.go-atlassian.io/jira-service-management-cloud/request#subscribe Subscribe(ctx context.Context, issueKeyOrID string) (*model.ResponseScheme, error) // Unsubscribe unsubscribes the user from notifications from a customer request. // - // DELETE /rest/servicedeskapi/request/{issueIdOrKey}/notification + // DELETE /rest/servicedeskapi/request/{issueKeyOrID}/notification // // https://docs.go-atlassian.io/jira-service-management-cloud/request#unsubscribe Unsubscribe(ctx context.Context, issueKeyOrID string) (*model.ResponseScheme, error) // Transitions returns a list of transitions, the workflow processes that moves a customer request from one status to another, that the user can perform on a request. // - // GET /rest/servicedeskapi/request/{issueIdOrKey}/transition + // GET /rest/servicedeskapi/request/{issueKeyOrID}/transition // // https://docs.go-atlassian.io/jira-service-management-cloud/request#get-customer-transitions Transitions(ctx context.Context, issueKeyOrID string, start, limit int) (*model.CustomerRequestTransitionPageScheme, *model.ResponseScheme, error) @@ -57,7 +58,7 @@ type RequestConnector interface { // // An optional comment can be included to provide a reason for the transition. // - // POST /rest/servicedeskapi/request/{issueIdOrKey}/transition + // POST /rest/servicedeskapi/request/{issueKeyOrID}/transition // // https://docs.go-atlassian.io/jira-service-management-cloud/request#perform-customer-transition Transition(ctx context.Context, issueKeyOrID, transitionID, comment string) (*model.ResponseScheme, error) diff --git a/service/sm/service_desk.go b/service/sm/service_desk.go index 4e6f23f9..a625624f 100644 --- a/service/sm/service_desk.go +++ b/service/sm/service_desk.go @@ -22,14 +22,14 @@ type ServiceDeskConnector interface { // // but needs to display other service desk details. // - // GET /rest/servicedeskapi/servicedesk/{serviceDeskId} + // GET /rest/servicedeskapi/servicedesk/{serviceDeskID} // // https://docs.go-atlassian.io/jira-service-management-cloud/request/service-desk#get-service-desk-by-id Get(ctx context.Context, serviceDeskID string) (*model.ServiceDeskScheme, *model.ResponseScheme, error) // Attach one temporary attachments to a service desk // - // POST /rest/servicedeskapi/servicedesk/{serviceDeskId}/attachTemporaryFile + // POST /rest/servicedeskapi/servicedesk/{serviceDeskID}/attachTemporaryFile // // https://docs.go-atlassian.io/jira-service-management-cloud/request/service-desk#attach-temporary-file Attach(ctx context.Context, serviceDeskID string, fileName string, file io.Reader) (*model.ServiceDeskTemporaryFileScheme, *model.ResponseScheme, error) diff --git a/service/sm/sla.go b/service/sm/sla.go index 0573b6e9..6ff9fd4f 100644 --- a/service/sm/sla.go +++ b/service/sm/sla.go @@ -2,6 +2,7 @@ package sm import ( "context" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" ) @@ -11,14 +12,14 @@ type ServiceLevelAgreementConnector interface { // // A customer request can have zero or more SLAs. Each SLA can have recordings for zero or more "completed cycles" and zero or 1 "ongoing cycle". // - // GET /rest/servicedeskapi/request/{issueIdOrKey}/sla + // GET /rest/servicedeskapi/request/{issueKeyOrID}/sla // // https://docs.go-atlassian.io/jira-service-management-cloud/request/sla#get-sla-information Gets(ctx context.Context, issueKeyOrID string, start, limit int) (*model.RequestSLAPageScheme, *model.ResponseScheme, error) // Get returns the details for an SLA on a customer request. // - // GET /rest/servicedeskapi/request/{issueIdOrKey}/sla/{slaMetricId} + // GET /rest/servicedeskapi/request/{issueKeyOrID}/sla/{metricID} // // https://docs.go-atlassian.io/jira-service-management-cloud/request/sla#get-sla-information-by-id Get(ctx context.Context, issueKeyOrID string, metricID int) (*model.RequestSLAScheme, *model.ResponseScheme, error) diff --git a/service/sm/type.go b/service/sm/type.go index 2c58542b..6a2df1d6 100644 --- a/service/sm/type.go +++ b/service/sm/type.go @@ -18,42 +18,42 @@ type TypeConnector interface { // Gets returns all customer request types from a service desk. // - // GET /rest/servicedeskapi/servicedesk/{serviceDeskId}/requesttype + // GET /rest/servicedeskapi/servicedesk/{serviceDeskID}/requesttype // // https://docs.go-atlassian.io/jira-service-management-cloud/request/types#get-request-types Gets(ctx context.Context, serviceDeskID, groupID, start, limit int) (*model.ProjectRequestTypePageScheme, *model.ResponseScheme, error) // Create enables a customer request type to be added to a service desk based on an issue type. // - // POST /rest/servicedeskapi/servicedesk/{serviceDeskId}/requesttype + // POST /rest/servicedeskapi/servicedesk/{serviceDeskID}/requesttype // // https://docs.go-atlassian.io/jira-service-management-cloud/request/types#create-request-type Create(ctx context.Context, serviceDeskID int, payload *model.RequestTypePayloadScheme) (*model.RequestTypeScheme, *model.ResponseScheme, error) // Get returns a customer request type from a service desk. // - // GET /rest/servicedeskapi/servicedesk/{serviceDeskId}/requesttype/{requestTypeId} + // GET /rest/servicedeskapi/servicedesk/{serviceDeskID}/requesttype/{requestTypeID} // // https://docs.go-atlassian.io/jira-service-management-cloud/request/types#get-request-type-by-id Get(ctx context.Context, serviceDeskID, requestTypeID int) (*model.RequestTypeScheme, *model.ResponseScheme, error) // Delete deletes a customer request type from a service desk, and removes it from all customer requests. // - // DELETE /rest/servicedeskapi/servicedesk/{serviceDeskId}/requesttype/{requestTypeId} + // DELETE /rest/servicedeskapi/servicedesk/{serviceDeskID}/requesttype/{requestTypeID} // // https://docs.go-atlassian.io/jira-service-management-cloud/request/types#delete-request-type Delete(ctx context.Context, serviceDeskID, requestTypeID int) (*model.ResponseScheme, error) // Fields returns the fields for a service desk's customer request type. // - // GET /rest/servicedeskapi/servicedesk/{serviceDeskId}/requesttype/{requestTypeId}/field + // GET /rest/servicedeskapi/servicedesk/{serviceDeskID}/requesttype/{requestTypeID}/field // // https://docs.go-atlassian.io/jira-service-management-cloud/request/types#get-request-type-fields Fields(ctx context.Context, serviceDeskID, requestTypeID int) (*model.RequestTypeFieldsScheme, *model.ResponseScheme, error) // Groups returns the groups for a service desk's customer request types. // - // GET /rest/servicedeskapi/servicedesk/{serviceDeskId}/requesttypegroup + // GET /rest/servicedeskapi/servicedesk/{serviceDeskID}/requesttypegroup // // https://docs.go-atlassian.io/jira-service-management-cloud/request/types#get-request-type-groups Groups(ctx context.Context, serviceDeskID int) (*model.RequestTypeGroupPageScheme, *model.ResponseScheme, error)