From 6d47de5fc91f1753af45789fcaa06d14e1c2813f Mon Sep 17 00:00:00 2001 From: Carlos Treminio Date: Sat, 20 Nov 2021 00:36:17 -0600 Subject: [PATCH] :truck: Moved the common models to a dedicated shared package --- jira/sm/customer.go | 68 ++------- jira/sm/customer_test.go | 69 --------- jira/sm/info.go | 23 +-- jira/sm/knowledgebase.go | 50 +------ jira/sm/knowledgebase_test.go | 6 +- jira/sm/organization.go | 77 ++-------- jira/sm/request.go | 133 ++---------------- jira/sm/requestApproval.go | 73 +--------- jira/sm/requestAttachment.go | 76 +--------- jira/sm/requestComment.go | 61 ++------ jira/sm/requestFeedback.go | 29 ++-- jira/sm/requestParticipant.go | 55 ++------ jira/sm/requestSLA.go | 44 +----- jira/sm/requestType.go | 116 ++------------- jira/sm/serviceDesk.go | 52 +------ jira/sm/serviceDeskQueue.go | 84 +---------- jira/sm/sm.go | 4 +- jira/sm/sm_test.go | 11 +- pkg/infra/models/ITSM_Info.go | 21 +++ pkg/infra/models/ITSM_Knowledge_Base.go | 34 +++++ pkg/infra/models/ITSM_Organization.go | 61 ++++++++ pkg/infra/models/ITSM_Request.go | 121 ++++++++++++++++ pkg/infra/models/ITSM_Request_Approval.go | 56 ++++++++ pkg/infra/models/ITSM_Request_Attachments.go | 62 ++++++++ pkg/infra/models/ITSM_Request_Comment.go | 39 +++++ pkg/infra/models/ITSM_Request_Feedback.go | 11 ++ pkg/infra/models/ITSM_Request_Participants.go | 35 +++++ pkg/infra/models/ITSM_Request_SLA.go | 36 +++++ pkg/infra/models/ITSM_Request_Type.go | 78 ++++++++++ pkg/infra/models/ITSM_Service_Desk.go | 37 +++++ pkg/infra/models/ITSM_Service_Desk_Queue.go | 37 +++++ pkg/infra/models/customer.go | 35 +++++ pkg/infra/models/errors.go | 19 ++- 33 files changed, 798 insertions(+), 915 deletions(-) create mode 100644 pkg/infra/models/ITSM_Info.go create mode 100644 pkg/infra/models/ITSM_Knowledge_Base.go create mode 100644 pkg/infra/models/ITSM_Organization.go create mode 100644 pkg/infra/models/ITSM_Request.go create mode 100644 pkg/infra/models/ITSM_Request_Approval.go create mode 100644 pkg/infra/models/ITSM_Request_Attachments.go create mode 100644 pkg/infra/models/ITSM_Request_Comment.go create mode 100644 pkg/infra/models/ITSM_Request_Feedback.go create mode 100644 pkg/infra/models/ITSM_Request_Participants.go create mode 100644 pkg/infra/models/ITSM_Request_SLA.go create mode 100644 pkg/infra/models/ITSM_Request_Type.go create mode 100644 pkg/infra/models/ITSM_Service_Desk.go create mode 100644 pkg/infra/models/ITSM_Service_Desk_Queue.go create mode 100644 pkg/infra/models/customer.go diff --git a/jira/sm/customer.go b/jira/sm/customer.go index 3ca9a033..0a61ee1f 100644 --- a/jira/sm/customer.go +++ b/jira/sm/customer.go @@ -3,9 +3,9 @@ package sm import ( "context" "fmt" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" "net/http" "net/url" - "regexp" "strconv" ) @@ -16,20 +16,15 @@ type CustomerService struct{ client *Client } // The display name does not need to be unique. The record's identifiers, // name and key, are automatically generated from the request details. // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/customer#create-customer -func (c *CustomerService) Create(ctx context.Context, email, displayName string) (result *CustomerScheme, +func (c *CustomerService) Create(ctx context.Context, email, displayName string) (result *model.CustomerScheme, response *ResponseScheme, err error) { if len(email) == 0 { - return nil, nil, fmt.Errorf("error, please provide a valid email value") - } - - //Check the email - if !isEmailValid(email) { - return nil, nil, fmt.Errorf("error, the email (%v) is not valid mail", email) + return nil, nil, model.ErrNoCustomerMailError } if len(displayName) == 0 { - return nil, nil, fmt.Errorf("error, please provide a valid displayName value") + return nil, nil, model.ErrNoCustomerDisplayNameError } payload := struct { @@ -40,9 +35,10 @@ func (c *CustomerService) Create(ctx context.Context, email, displayName string) Email: email, } - payloadAsReader, _ := transformStructToReader(&payload) - - var endpoint = "rest/servicedeskapi/customer" + var ( + payloadAsReader, _ = transformStructToReader(&payload) + endpoint = "rest/servicedeskapi/customer" + ) request, err := c.client.newRequest(ctx, http.MethodPost, endpoint, payloadAsReader) if err != nil { @@ -60,36 +56,9 @@ func (c *CustomerService) Create(ctx context.Context, email, displayName string) return } -type CustomerScheme struct { - AccountID string `json:"accountId"` - Name string `json:"name"` - Key string `json:"key"` - EmailAddress string `json:"emailAddress"` - DisplayName string `json:"displayName"` - Active bool `json:"active"` - TimeZone string `json:"timeZone"` - Links struct { - JiraRest string `json:"jiraRest"` - AvatarUrls struct { - Four8X48 string `json:"48x48"` - Two4X24 string `json:"24x24"` - One6X16 string `json:"16x16"` - Three2X32 string `json:"32x32"` - } `json:"avatarUrls"` - Self string `json:"self"` - } `json:"_links"` -} - -func isEmailValid(email string) bool { - const emailRegexPattern = "^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$" - - var regex = regexp.MustCompile(emailRegexPattern) - return regex.MatchString(email) -} - // Gets returns a list of the customers on a service desk. // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/customer#get-customers -func (c *CustomerService) Gets(ctx context.Context, serviceDeskID int, query string, start, limit int) (result *CustomerPageScheme, +func (c *CustomerService) Gets(ctx context.Context, serviceDeskID int, query string, start, limit int) (result *model.CustomerPageScheme, response *ResponseScheme, err error) { params := url.Values{} @@ -128,7 +97,7 @@ func (c *CustomerService) Gets(ctx context.Context, serviceDeskID int, query str func (c *CustomerService) Add(ctx context.Context, serviceDeskID int, accountIDs []string) (response *ResponseScheme, err error) { if len(accountIDs) == 0 { - return nil, fmt.Errorf("error, please provide a valid accountIDs slice value") + return nil, model.ErrNoAccountSliceError } payload := struct { @@ -161,7 +130,7 @@ func (c *CustomerService) Add(ctx context.Context, serviceDeskID int, accountIDs func (c *CustomerService) Remove(ctx context.Context, serviceDeskID int, accountIDs []string) (response *ResponseScheme, err error) { if len(accountIDs) == 0 { - return nil, fmt.Errorf("error, please provide a valid accountIDs slice value") + return nil, model.ErrNoAccountSliceError } payload := struct { @@ -194,18 +163,3 @@ func (c *CustomerService) Remove(ctx context.Context, serviceDeskID int, account return } - -type CustomerPageScheme struct { - Expands []interface{} `json:"_expands"` - Size int `json:"size"` - Start int `json:"start"` - Limit int `json:"limit"` - IsLastPage bool `json:"isLastPage"` - Links struct { - Base string `json:"base"` - Context string `json:"context"` - Next string `json:"next"` - Prev string `json:"prev"` - } `json:"_links"` - Values []*CustomerScheme `json:"values"` -} diff --git a/jira/sm/customer_test.go b/jira/sm/customer_test.go index f9b47a3a..da60544d 100644 --- a/jira/sm/customer_test.go +++ b/jira/sm/customer_test.go @@ -57,30 +57,6 @@ func TestCustomerService_Create(t *testing.T) { wantErr: true, }, - { - name: "CreateCustomerWhenTheEmailIsIncorrect", - email: "examplegmail.com", - displayName: "Example", - mockFile: "./mocks/create-customer.json", - wantHTTPMethod: http.MethodPost, - endpoint: "/rest/servicedeskapi/customer", - context: context.Background(), - wantHTTPCodeReturn: http.StatusCreated, - wantErr: true, - }, - - { - name: "CreateCustomerWhenTheEmailIsToShort", - email: "exa", - displayName: "Example", - mockFile: "./mocks/create-customer.json", - wantHTTPMethod: http.MethodPost, - endpoint: "/rest/servicedeskapi/customer", - context: context.Background(), - wantHTTPCodeReturn: http.StatusCreated, - wantErr: true, - }, - { name: "CreateCustomerWhenTheRequestMethodIsIncorrect", email: "example@gmail.com", @@ -210,51 +186,6 @@ func TestCustomerService_Create(t *testing.T) { } -func Test_isEmailValid(t *testing.T) { - - testCases := []struct { - name string - email string - wantErr bool - }{ - { - name: "ValidateEmailWhenTheEmailIsCorrect", - email: "example@gmail.com", - wantErr: false, - }, - { - name: "ValidateEmailWhenTheEmailDoesNotHaveFormat", - email: "ex", - wantErr: true, - }, - { - name: "ValidateEmailWhenTheEmailIsIncorrect", - email: "exampleeaasc", - wantErr: true, - }, - { - name: "ValidateEmailWhenTheEmailIsEmpty", - email: "", - wantErr: true, - }, - } - - for _, testCase := range testCases { - t.Run(testCase.name, func(t *testing.T) { - - isValid := isEmailValid(testCase.email) - - if testCase.wantErr { - assert.Equal(t, false, isValid) - } else { - assert.Equal(t, true, isValid) - } - - }) - } - -} - func TestCustomerService_Get(t *testing.T) { testCases := []struct { diff --git a/jira/sm/info.go b/jira/sm/info.go index 71d58924..7307b9b3 100644 --- a/jira/sm/info.go +++ b/jira/sm/info.go @@ -2,6 +2,7 @@ package sm import ( "context" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" "net/http" ) @@ -10,7 +11,7 @@ type InfoService struct{ client *Client } // Get retrieves information about the Jira Service Management instance such as software version, // builds, and related links. // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/info#get-info -func (i *InfoService) Get(ctx context.Context) (result *InfoScheme, response *ResponseScheme, err error) { +func (i *InfoService) Get(ctx context.Context) (result *model.InfoScheme, response *ResponseScheme, err error) { var endpoint = "rest/servicedeskapi/info" @@ -28,23 +29,3 @@ func (i *InfoService) Get(ctx context.Context) (result *InfoScheme, response *Re return } - -type InfoScheme struct { - Version string `json:"version"` - PlatformVersion string `json:"platformVersion"` - BuildDate *InfoBuildDataScheme `json:"buildDate"` - BuildChangeSet string `json:"buildChangeSet"` - IsLicensedForUse bool `json:"isLicensedForUse"` - Links *InfoLinkScheme `json:"_links"` -} - -type InfoBuildDataScheme struct { - Iso8601 string `json:"iso8601"` - Jira string `json:"jira"` - Friendly string `json:"friendly"` - EpochMillis int64 `json:"epochMillis"` -} - -type InfoLinkScheme struct { - Self string `json:"self"` -} diff --git a/jira/sm/knowledgebase.go b/jira/sm/knowledgebase.go index 7c2c5121..189f74a5 100644 --- a/jira/sm/knowledgebase.go +++ b/jira/sm/knowledgebase.go @@ -3,20 +3,21 @@ package sm import ( "context" "fmt" + "github.com/ctreminiom/go-atlassian/pkg/infra/models" "net/http" "net/url" "strconv" ) -type KnowledgebaseService struct{ client *Client } +type KnowledgeBaseService struct{ client *Client } // Search returns articles which match the given query string across all service desks. // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/knowledgebase#search-articles -func (k *KnowledgebaseService) Search(ctx context.Context, query string, highlight bool, start, limit int) ( - result *ArticlePageScheme, response *ResponseScheme, err error) { +func (k *KnowledgeBaseService) Search(ctx context.Context, query string, highlight bool, start, limit int) ( + result *models.ArticlePageScheme, response *ResponseScheme, err error) { if len(query) == 0 { - return nil, nil, notQueryError + return nil, nil, models.ErrNoKBQueryError } params := url.Values{} @@ -48,8 +49,8 @@ func (k *KnowledgebaseService) Search(ctx context.Context, query string, highlig // Gets returns articles which match the given query string across all service desks. // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/knowledgebase#get-articles -func (k *KnowledgebaseService) Gets(ctx context.Context, serviceDeskID int, query string, highlight bool, start, - limit int) (result *ArticlePageScheme, response *ResponseScheme, err error) { +func (k *KnowledgeBaseService) Gets(ctx context.Context, serviceDeskID int, query string, highlight bool, start, + limit int) (result *models.ArticlePageScheme, response *ResponseScheme, err error) { params := url.Values{} params.Add("start", strconv.Itoa(start)) @@ -80,40 +81,3 @@ func (k *KnowledgebaseService) Gets(ctx context.Context, serviceDeskID int, quer return } - -type ArticlePageScheme struct { - Size int `json:"size"` - Start int `json:"start"` - Limit int `json:"limit"` - IsLastPage bool `json:"isLastPage"` - Values []*ArticleScheme `json:"values"` - Expands []string `json:"_expands"` - Links *ArticlePageLinkScheme `json:"_links"` -} - -type ArticlePageLinkScheme struct { - Self string `json:"self"` - Base string `json:"base"` - Context string `json:"context"` - Next string `json:"next"` - Prev string `json:"prev"` -} - -type ArticleScheme struct { - Title string `json:"title,omitempty"` - Excerpt string `json:"excerpt,omitempty"` - Source *ArticleSourceScheme `json:"source,omitempty"` - Content *ArticleContentScheme `json:"content,omitempty"` -} - -type ArticleSourceScheme struct { - Type string `json:"type,omitempty"` -} - -type ArticleContentScheme struct { - IframeSrc string `json:"iframeSrc,omitempty"` -} - -var ( - notQueryError = fmt.Errorf("error, please provide a valid query value") -) diff --git a/jira/sm/knowledgebase_test.go b/jira/sm/knowledgebase_test.go index f213521d..2312ddf9 100644 --- a/jira/sm/knowledgebase_test.go +++ b/jira/sm/knowledgebase_test.go @@ -9,7 +9,7 @@ import ( "testing" ) -func TestKnowledgebaseService_Search(t *testing.T) { +func TestKnowledgeBaseService_Search(t *testing.T) { testCases := []struct { name string @@ -159,7 +159,7 @@ func TestKnowledgebaseService_Search(t *testing.T) { t.Fatal(err) } - service := &KnowledgebaseService{client: mockClient} + service := &KnowledgeBaseService{client: mockClient} gotResult, gotResponse, err := service.Search(testCase.context, testCase.query, testCase.highlight, testCase.start, testCase.limit) if testCase.wantErr { @@ -347,7 +347,7 @@ func TestKnowledgebaseService_Gets(t *testing.T) { t.Fatal(err) } - service := &KnowledgebaseService{client: mockClient} + service := &KnowledgeBaseService{client: mockClient} gotResult, gotResponse, err := service.Gets(testCase.context, testCase.serviceDeskID, testCase.query, testCase.highlight, testCase.start, testCase.limit) if testCase.wantErr { diff --git a/jira/sm/organization.go b/jira/sm/organization.go index 58507aba..fc604352 100644 --- a/jira/sm/organization.go +++ b/jira/sm/organization.go @@ -3,6 +3,7 @@ package sm import ( "context" "fmt" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" "net/http" "net/url" "strconv" @@ -14,7 +15,7 @@ type OrganizationService struct{ client *Client } // Use this method when you want to present a list of organizations or want to locate an organization by name. // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/organization#get-organizations func (o *OrganizationService) Gets(ctx context.Context, accountID string, start, limit int) ( - result *OrganizationPageScheme, response *ResponseScheme, err error) { + result *model.OrganizationPageScheme, response *ResponseScheme, err error) { params := url.Values{} params.Add("start", strconv.Itoa(start)) @@ -45,7 +46,7 @@ func (o *OrganizationService) Gets(ctx context.Context, accountID string, start, // Use this method to get organization details whenever your application component is passed an organization ID // but needs to display other organization details. // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/organization#get-organization -func (o *OrganizationService) Get(ctx context.Context, organizationID int) (result *OrganizationScheme, +func (o *OrganizationService) Get(ctx context.Context, organizationID int) (result *model.OrganizationScheme, response *ResponseScheme, err error) { var endpoint = fmt.Sprintf("rest/servicedeskapi/organization/%v", organizationID) @@ -87,11 +88,11 @@ func (o *OrganizationService) Delete(ctx context.Context, organizationID int) (r // Create creates an organization by passing the name of the organization. // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/organization#create-organization -func (o *OrganizationService) Create(ctx context.Context, name string) (result *OrganizationScheme, +func (o *OrganizationService) Create(ctx context.Context, name string) (result *model.OrganizationScheme, response *ResponseScheme, err error) { if len(name) == 0 { - return nil, nil, fmt.Errorf("error, please provide a valid name value") + return nil, nil, model.ErrNoOrganizationNameError } payload := struct { @@ -125,7 +126,7 @@ func (o *OrganizationService) Create(ctx context.Context, name string) (result * // organization or determine if a user is associated with an organization. // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/organization#get-users-in-organization func (o *OrganizationService) Users(ctx context.Context, organizationID, start, limit int) ( - result *OrganizationUsersPageScheme, response *ResponseScheme, err error) { + result *model.OrganizationUsersPageScheme, response *ResponseScheme, err error) { params := url.Values{} params.Add("start", strconv.Itoa(start)) @@ -153,7 +154,7 @@ func (o *OrganizationService) Users(ctx context.Context, organizationID, start, func (o *OrganizationService) Add(ctx context.Context, organizationID int, accountIDs []string) (response *ResponseScheme, err error) { if len(accountIDs) == 0 { - return nil, fmt.Errorf("error, please provide a valid accountIDs list of values") + return nil, model.ErrNoAccountSliceError } payload := struct { @@ -186,7 +187,7 @@ func (o *OrganizationService) Add(ctx context.Context, organizationID int, accou func (o *OrganizationService) Remove(ctx context.Context, organizationID int, accountIDs []string) (response *ResponseScheme, err error) { if len(accountIDs) == 0 { - return nil, fmt.Errorf("error, please provide a valid accountIDs list of values") + return nil, model.ErrNoAccountSliceError } payload := struct { @@ -216,7 +217,7 @@ func (o *OrganizationService) Remove(ctx context.Context, organizationID int, ac // Project returns a list of all organizations associated with a service desk. func (o *OrganizationService) Project(ctx context.Context, accountID string, serviceDeskPortalID, start, - limit int) (result *OrganizationPageScheme, response *ResponseScheme, err error) { + limit int) (result *model.OrganizationPageScheme, response *ResponseScheme, err error) { params := url.Values{} params.Add("start", strconv.Itoa(start)) @@ -305,63 +306,3 @@ func (o *OrganizationService) Detach(ctx context.Context, serviceDeskPortalID, o return } - -type OrganizationUsersPageScheme struct { - Size int `json:"size"` - Start int `json:"start"` - Limit int `json:"limit"` - IsLastPage bool `json:"isLastPage"` - Values []*OrganizationUserScheme `json:"values"` - Expands []string `json:"_expands"` - Links *OrganizationUsersPageLinkScheme `json:"_links"` -} - -type OrganizationUsersPageLinkScheme struct { - Self string `json:"self"` - Base string `json:"base"` - Context string `json:"context"` - Next string `json:"next"` - Prev string `json:"prev"` -} - -type OrganizationUserScheme struct { - AccountID string `json:"accountId"` - Name string `json:"name"` - Key string `json:"key"` - EmailAddress string `json:"emailAddress"` - DisplayName string `json:"displayName"` - Active bool `json:"active"` - TimeZone string `json:"timeZone"` - Links *OrganizationUserLinkScheme `json:"_links"` -} - -type OrganizationUserLinkScheme struct { - Self string `json:"self"` - JiraRest string `json:"jiraRest"` -} - -type OrganizationPageScheme struct { - Size int `json:"size"` - Start int `json:"start"` - Limit int `json:"limit"` - IsLastPage bool `json:"isLastPage"` - Values []*OrganizationScheme `json:"values"` - Expands []string `json:"_expands"` - Links *OrganizationPageLinkScheme `json:"_links"` -} - -type OrganizationPageLinkScheme struct { - Self string `json:"self"` - Base string `json:"base"` - Context string `json:"context"` - Next string `json:"next"` - Prev string `json:"prev"` -} - -type OrganizationScheme struct { - ID string `json:"id"` - Name string `json:"name"` - Links struct { - Self string `json:"self"` - } `json:"_links"` -} diff --git a/jira/sm/request.go b/jira/sm/request.go index db4d6d06..62ceb873 100644 --- a/jira/sm/request.go +++ b/jira/sm/request.go @@ -3,6 +3,7 @@ package sm import ( "context" "fmt" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" "net/http" "net/url" "strconv" @@ -35,7 +36,7 @@ type RequestGetOptionsScheme struct { // The returned customer requests are ordered chronologically by the latest activity on each request. For example, the latest status transition or comment. // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/request#get-customer-requests func (r *RequestService) Gets(ctx context.Context, options *RequestGetOptionsScheme, start, limit int) ( - result *CustomerRequestsScheme, response *ResponseScheme, err error) { + result *model.CustomerRequestsScheme, response *ResponseScheme, err error) { params := url.Values{} params.Add("start", strconv.Itoa(start)) @@ -95,11 +96,11 @@ func (r *RequestService) Gets(ctx context.Context, options *RequestGetOptionsSch // Get returns a customer request. // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/request#get-customer-request-by-id-or-key -func (r *RequestService) Get(ctx context.Context, issueKeyOrID string, expand []string) (result *CustomerRequestScheme, +func (r *RequestService) Get(ctx context.Context, issueKeyOrID string, expand []string) (result *model.CustomerRequestScheme, response *ResponseScheme, err error) { if len(issueKeyOrID) == 0 { - return nil, nil, notIssueError + return nil, nil, model.ErrNoIssueKeyOrIDError } params := url.Values{} @@ -134,7 +135,7 @@ func (r *RequestService) Get(ctx context.Context, issueKeyOrID string, expand [] func (r *RequestService) Subscribe(ctx context.Context, issueKeyOrID string) (response *ResponseScheme, err error) { if len(issueKeyOrID) == 0 { - return nil, notIssueError + return nil, model.ErrNoIssueKeyOrIDError } var endpoint = fmt.Sprintf("rest/servicedeskapi/request/%v/notification", issueKeyOrID) @@ -157,7 +158,7 @@ func (r *RequestService) Subscribe(ctx context.Context, issueKeyOrID string) (re func (r *RequestService) Unsubscribe(ctx context.Context, issueKeyOrID string) (response *ResponseScheme, err error) { if len(issueKeyOrID) == 0 { - return nil, notIssueError + return nil, model.ErrNoIssueKeyOrIDError } var endpoint = fmt.Sprintf("rest/servicedeskapi/request/%v/notification", issueKeyOrID) @@ -179,10 +180,10 @@ func (r *RequestService) Unsubscribe(ctx context.Context, issueKeyOrID string) ( // that the user can perform on a request. // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/request#get-customer-transitions func (r *RequestService) Transitions(ctx context.Context, issueKeyOrID string, start, limit int) ( - result *CustomerRequestTransitionPageScheme, response *ResponseScheme, err error) { + result *model.CustomerRequestTransitionPageScheme, response *ResponseScheme, err error) { if len(issueKeyOrID) == 0 { - return nil, nil, notIssueError + return nil, nil, model.ErrNoIssueKeyOrIDError } params := url.Values{} @@ -213,11 +214,11 @@ func (r *RequestService) Transition(ctx context.Context, issueKeyOrID, transitio response *ResponseScheme, err error) { if len(issueKeyOrID) == 0 { - return nil, notIssueError + return nil, model.ErrNoIssueKeyOrIDError } if len(transitionID) == 0 { - return nil, notTransitionIDError + return nil, model.ErrNoTransitionIDError } payload := struct { @@ -251,117 +252,3 @@ func (r *RequestService) Transition(ctx context.Context, issueKeyOrID, transitio return } - -type CustomerRequestTransitionPageScheme struct { - Size int `json:"size,omitempty"` - Start int `json:"start,omitempty"` - Limit int `json:"limit,omitempty"` - IsLastPage bool `json:"isLastPage,omitempty"` - Values []*CustomerRequestTransitionScheme `json:"values,omitempty"` - Expands []string `json:"_expands,omitempty"` - Links *CustomerRequestTransitionPageLinkScheme `json:"_links,omitempty"` -} - -type CustomerRequestTransitionScheme struct { - ID string `json:"id,omitempty"` - Name string `json:"name,omitempty"` -} - -type CustomerRequestTransitionPageLinkScheme struct { - Self string `json:"self,omitempty"` - Base string `json:"base,omitempty"` - Context string `json:"context,omitempty"` - Next string `json:"next,omitempty"` - Prev string `json:"prev,omitempty"` -} - -type CustomerRequestsScheme struct { - Size int `json:"size,omitempty"` - Start int `json:"start,omitempty"` - Limit int `json:"limit,omitempty"` - IsLastPage bool `json:"isLastPage,omitempty"` - Values []*CustomerRequestScheme `json:"values,omitempty"` - Expands []string `json:"_expands,omitempty"` - Links *CustomerRequestsLinksScheme `json:"_links,omitempty"` -} - -type CustomerRequestsLinksScheme struct { - Self string `json:"self"` - Base string `json:"base"` - Context string `json:"context"` - Next string `json:"next"` - Prev string `json:"prev"` -} - -type CustomerRequestTypeScheme struct { - ID string `json:"id"` - Name string `json:"name"` - Description string `json:"description"` - HelpText string `json:"helpText"` - IssueTypeID string `json:"issueTypeId"` - ServiceDeskID string `json:"serviceDeskId"` - GroupIds []string `json:"groupIds"` -} - -type CustomerRequestServiceDeskScheme struct { - ID string `json:"id"` - ProjectID string `json:"projectId"` - ProjectName string `json:"projectName"` - ProjectKey string `json:"projectKey"` -} - -type CustomerRequestDateScheme struct { - Iso8601 string `json:"iso8601"` - Jira string `json:"jira"` - Friendly string `json:"friendly"` - EpochMillis int `json:"epochMillis"` -} - -type CustomerRequestReporterScheme struct { - AccountID string `json:"accountId"` - Name string `json:"name"` - Key string `json:"key"` - EmailAddress string `json:"emailAddress"` - DisplayName string `json:"displayName"` - Active bool `json:"active"` - TimeZone string `json:"timeZone"` -} - -type CustomerRequestRequestFieldValueScheme struct { - FieldID string `json:"fieldId"` - Label string `json:"label"` -} - -type CustomerRequestCurrentStatusScheme struct { - Status string `json:"status"` - StatusCategory string `json:"statusCategory"` - StatusDate struct { - } `json:"statusDate"` -} - -type CustomerRequestLinksScheme struct { - Self string `json:"self"` - JiraRest string `json:"jiraRest"` - Web string `json:"web"` - Agent string `json:"agent"` -} - -type CustomerRequestScheme struct { - IssueID string `json:"issueId,omitempty"` - IssueKey string `json:"issueKey,omitempty"` - RequestTypeID string `json:"requestTypeId,omitempty"` - RequestType *CustomerRequestTypeScheme `json:"requestType,omitempty"` - ServiceDeskID string `json:"serviceDeskId,omitempty"` - ServiceDesk *CustomerRequestServiceDeskScheme `json:"serviceDesk,omitempty"` - CreatedDate *CustomerRequestDateScheme `json:"createdDate,omitempty"` - Reporter *CustomerRequestReporterScheme `json:"reporter,omitempty"` - RequestFieldValues []*CustomerRequestRequestFieldValueScheme `json:"requestFieldValues,omitempty"` - CurrentStatus *CustomerRequestCurrentStatusScheme `json:"currentStatus,omitempty"` - Expands []string `json:"_expands,omitempty"` - Links *CustomerRequestLinksScheme `json:"_links,omitempty"` -} - -var ( - notIssueError = fmt.Errorf("error, please provide a valid issueKeyOrID value") - notTransitionIDError = fmt.Errorf("error, please provide a valid transitionID value") -) diff --git a/jira/sm/requestApproval.go b/jira/sm/requestApproval.go index 7890bf74..a05a5122 100644 --- a/jira/sm/requestApproval.go +++ b/jira/sm/requestApproval.go @@ -3,6 +3,7 @@ package sm import ( "context" "fmt" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" "net/http" "net/url" "strconv" @@ -12,11 +13,11 @@ type RequestApprovalService struct{ client *Client } // Gets returns all approvals on a customer request. // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/request/approval#get-approvals -func (r *RequestApprovalService) Gets(ctx context.Context, issueKeyOrID string, start, limit int) (result *CustomerApprovalPageScheme, +func (r *RequestApprovalService) Gets(ctx context.Context, issueKeyOrID string, start, limit int) (result *model.CustomerApprovalPageScheme, response *ResponseScheme, err error) { if len(issueKeyOrID) == 0 { - return nil, nil, notIssueError + return nil, nil, model.ErrNoIssueKeyOrIDError } params := url.Values{} @@ -42,11 +43,11 @@ func (r *RequestApprovalService) Gets(ctx context.Context, issueKeyOrID string, // Get returns an approval. Use this method to determine the status of an approval and the list of approvers. // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/request/approval#get-approval-by-id -func (r *RequestApprovalService) Get(ctx context.Context, issueKeyOrID string, approvalID int) (result *CustomerApprovalScheme, +func (r *RequestApprovalService) Get(ctx context.Context, issueKeyOrID string, approvalID int) (result *model.CustomerApprovalScheme, response *ResponseScheme, err error) { if len(issueKeyOrID) == 0 { - return nil, nil, notIssueError + return nil, nil, model.ErrNoIssueKeyOrIDError } var endpoint = fmt.Sprintf("rest/servicedeskapi/request/%v/approval/%v", issueKeyOrID, approvalID) @@ -70,10 +71,10 @@ func (r *RequestApprovalService) Get(ctx context.Context, issueKeyOrID string, a // The approval is assumed to be owned by the user making the call. // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/request/approval#answer-approval func (r *RequestApprovalService) Answer(ctx context.Context, issueKeyOrID string, approvalID int, approve bool) ( - result *CustomerApprovalScheme, response *ResponseScheme, err error) { + result *model.CustomerApprovalScheme, response *ResponseScheme, err error) { if len(issueKeyOrID) == 0 { - return nil, nil, notIssueError + return nil, nil, model.ErrNoIssueKeyOrIDError } var ( @@ -109,63 +110,3 @@ func (r *RequestApprovalService) Answer(ctx context.Context, issueKeyOrID string return } - -type CustomerApprovalPageScheme struct { - Size int `json:"size,omitempty"` - Start int `json:"start,omitempty"` - Limit int `json:"limit,omitempty"` - IsLastPage bool `json:"isLastPage,omitempty"` - Values []*CustomerApprovalScheme `json:"values,omitempty"` - Expands []string `json:"_expands,omitempty"` - Links *CustomerApprovalPageLinkScheme `json:"_links,omitempty"` -} - -type CustomerApprovalPageLinkScheme struct { - Self string `json:"self,omitempty"` - Base string `json:"base,omitempty"` - Context string `json:"context,omitempty"` - Next string `json:"next,omitempty"` - Prev string `json:"prev,omitempty"` -} - -type CustomerApprovalScheme struct { - ID string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - FinalDecision string `json:"finalDecision,omitempty"` - CanAnswerApproval bool `json:"canAnswerApproval,omitempty"` - Approvers []*CustomerApproverScheme `json:"approvers,omitempty"` - CreatedDate *CustomerRequestDateScheme `json:"createdDate,omitempty"` - CompletedDate *CustomerRequestDateScheme `json:"completedDate,omitempty"` - Links *CustomerApprovalLinkScheme `json:"_links,omitempty"` -} - -type CustomerApprovalLinkScheme struct { - Self string `json:"self"` -} - -type CustomerApproverScheme struct { - Approver *ApproverScheme `json:"approver,omitempty"` - ApproverDecision string `json:"approverDecision,omitempty"` -} - -type ApproverScheme struct { - AccountID string `json:"accountId,omitempty"` - Name string `json:"name,omitempty"` - Key string `json:"key,omitempty"` - EmailAddress string `json:"emailAddress,omitempty"` - DisplayName string `json:"displayName,omitempty"` - Active bool `json:"active,omitempty"` - TimeZone string `json:"timeZone,omitempty"` - Links *ApproverLinkScheme `json:"_links,omitempty"` -} - -type ApproverLinkScheme struct { - JiraRest string `json:"jiraRest"` - AvatarUrls struct { - Four8X48 string `json:"48x48"` - Two4X24 string `json:"24x24"` - One6X16 string `json:"16x16"` - Three2X32 string `json:"32x32"` - } `json:"avatarUrls"` - Self string `json:"self"` -} diff --git a/jira/sm/requestAttachment.go b/jira/sm/requestAttachment.go index 9935c805..67ae5302 100644 --- a/jira/sm/requestAttachment.go +++ b/jira/sm/requestAttachment.go @@ -3,6 +3,7 @@ package sm import ( "context" "fmt" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" "net/http" "net/url" "strconv" @@ -13,10 +14,10 @@ type RequestAttachmentService struct{ client *Client } // Gets returns all the attachments for a customer requests. // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/request/attachment#get-attachments-for-request func (r *RequestAttachmentService) Gets(ctx context.Context, issueKeyOrID string, start, limit int) ( - result *RequestAttachmentPageScheme, response *ResponseScheme, err error) { + result *model.RequestAttachmentPageScheme, response *ResponseScheme, err error) { if len(issueKeyOrID) == 0 { - return nil, nil, notIssueError + return nil, nil, model.ErrNoIssueKeyOrIDError } params := url.Values{} @@ -44,14 +45,14 @@ func (r *RequestAttachmentService) Gets(ctx context.Context, issueKeyOrID string // servicedesk/{serviceDeskId}/attachTemporaryFile) as attachments to a customer request // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/request/attachment#create-attachment func (r *RequestAttachmentService) Create(ctx context.Context, issueKeyOrID string, temporaryAttachmentIDs []string, - public bool) (result *RequestAttachmentCreationScheme, response *ResponseScheme, err error) { + public bool) (result *model.RequestAttachmentCreationScheme, response *ResponseScheme, err error) { if len(issueKeyOrID) == 0 { - return nil, nil, notIssueError + return nil, nil, model.ErrNoIssueKeyOrIDError } if len(temporaryAttachmentIDs) == 0 { - return nil, nil, notAttachmentsError + return nil, nil, model.ErrNoAttachmentIDError } var endpoint = fmt.Sprintf("rest/servicedeskapi/request/%v/attachment", issueKeyOrID) @@ -80,68 +81,3 @@ func (r *RequestAttachmentService) Create(ctx context.Context, issueKeyOrID stri return } - -type RequestAttachmentPageScheme struct { - Size int `json:"size,omitempty"` - Start int `json:"start,omitempty"` - Limit int `json:"limit,omitempty"` - IsLastPage bool `json:"isLastPage,omitempty"` - Values []*RequestAttachmentScheme `json:"values,omitempty"` - Expands []string `json:"_expands,omitempty"` - Links *RequestAttachmentPageLinkScheme `json:"_links,omitempty"` -} - -type RequestAttachmentPageLinkScheme struct { - Self string `json:"self,omitempty"` - Base string `json:"base,omitempty"` - Context string `json:"context,omitempty"` - Next string `json:"next,omitempty"` - Prev string `json:"prev,omitempty"` -} - -type RequestAttachmentScheme struct { - Filename string `json:"filename,omitempty"` - Author *RequestAuthorScheme `json:"author,omitempty"` - Created *CustomerRequestDateScheme `json:"created,omitempty"` - Size int `json:"size,omitempty"` - MimeType string `json:"mimeType,omitempty"` - Links *RequestAttachmentLinkScheme `json:"_links,omitempty"` -} - -type RequestAttachmentLinkScheme struct { - Self string `json:"self,omitempty"` - JiraRest string `json:"jiraRest,omitempty"` - Content string `json:"content,omitempty"` - Thumbnail string `json:"thumbnail,omitempty"` -} - -type RequestAuthorScheme struct { - AccountID string `json:"accountId,omitempty"` - Name string `json:"name,omitempty"` - Key string `json:"key,omitempty"` - EmailAddress string `json:"emailAddress,omitempty"` - DisplayName string `json:"displayName,omitempty"` - Active bool `json:"active,omitempty"` - TimeZone string `json:"timeZone,omitempty"` -} - -type RequestAttachmentCreationCommentScheme struct { - Expands []string `json:"_expands,omitempty"` - ID string `json:"id,omitempty"` - Body string `json:"body,omitempty"` - Public bool `json:"public,omitempty"` - Author RequestAuthorScheme `json:"author,omitempty"` - Created *CustomerRequestDateScheme `json:"created,omitempty"` - Links struct { - Self string `json:"self,omitempty"` - } `json:"_links,omitempty"` -} - -type RequestAttachmentCreationScheme struct { - Comment *RequestAttachmentCreationCommentScheme `json:"comment,omitempty"` - Attachments *RequestAttachmentPageScheme `json:"attachments,omitempty"` -} - -var ( - notAttachmentsError = fmt.Errorf("error, please provide a valid temporaryAttachmentIDs slice value") -) diff --git a/jira/sm/requestComment.go b/jira/sm/requestComment.go index 050880e0..018d385d 100644 --- a/jira/sm/requestComment.go +++ b/jira/sm/requestComment.go @@ -3,6 +3,7 @@ package sm import ( "context" "fmt" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" "net/http" "net/url" "strconv" @@ -16,10 +17,10 @@ type RequestCommentService struct{ client *Client } // the method simply returns an empty response. // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/request/comments#get-request-comments func (r *RequestCommentService) Gets(ctx context.Context, issueKeyOrID string, public bool, expand []string, start, - limit int) (result *RequestCommentPageScheme, response *ResponseScheme, err error) { + limit int) (result *model.RequestCommentPageScheme, response *ResponseScheme, err error) { if len(issueKeyOrID) == 0 { - return nil, nil, notIssueError + return nil, nil, model.ErrNoIssueKeyOrIDError } params := url.Values{} @@ -54,10 +55,10 @@ func (r *RequestCommentService) Gets(ctx context.Context, issueKeyOrID string, p // Get returns details of a customer request's comment. // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/request/comments#get-request-comment-by-id func (r *RequestCommentService) Get(ctx context.Context, issueKeyOrID string, commentID int, expand []string) ( - result *RequestCommentScheme, response *ResponseScheme, err error) { + result *model.RequestCommentScheme, response *ResponseScheme, err error) { if len(issueKeyOrID) == 0 { - return nil, nil, notIssueError + return nil, nil, model.ErrNoIssueKeyOrIDError } params := url.Values{} @@ -90,14 +91,14 @@ func (r *RequestCommentService) Get(ctx context.Context, issueKeyOrID string, co // Create creates a public or private (internal) comment on a customer request, with the comment visibility set by public. // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/request/comments#create-request-comment func (r *RequestCommentService) Create(ctx context.Context, issueKeyOrID, body string, public bool) ( - result *RequestCommentScheme, response *ResponseScheme, err error) { + result *model.RequestCommentScheme, response *ResponseScheme, err error) { if len(issueKeyOrID) == 0 { - return nil, nil, notIssueError + return nil, nil, model.ErrNoIssueKeyOrIDError } if len(body) == 0 { - return nil, nil, notBodyMessageError + return nil, nil, model.ErrNoCommentBodyError } payload := struct { @@ -130,10 +131,10 @@ func (r *RequestCommentService) Create(ctx context.Context, issueKeyOrID, body s // Attachments returns the attachments referenced in a comment. // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/request/comments#get-comment-attachments func (r *RequestCommentService) Attachments(ctx context.Context, issueKeyOrID string, commentID, start, limit int) ( - result *RequestAttachmentPageScheme, response *ResponseScheme, err error) { + result *model.RequestAttachmentPageScheme, response *ResponseScheme, err error) { if len(issueKeyOrID) == 0 { - return nil, nil, notIssueError + return nil, nil, model.ErrNoIssueKeyOrIDError } params := url.Values{} @@ -157,45 +158,3 @@ func (r *RequestCommentService) Attachments(ctx context.Context, issueKeyOrID st return } - -type RequestCommentPageScheme struct { - Size int `json:"size"` - Start int `json:"start"` - Limit int `json:"limit"` - IsLastPage bool `json:"isLastPage"` - Values []*RequestCommentScheme `json:"values"` - Expands []string `json:"_expands"` - Links *RequestCommentPageLinkScheme `json:"_links"` -} - -type RequestCommentPageLinkScheme struct { - Self string `json:"self"` - Base string `json:"base"` - Context string `json:"context"` - Next string `json:"next"` - Prev string `json:"prev"` -} - -type RequestCommentScheme struct { - ID string `json:"id,omitempty"` - Body string `json:"body,omitempty"` - RenderedBody *RequestCommentRenderScheme `json:"renderedBody,omitempty"` - Author *RequestAuthorScheme `json:"author,omitempty"` - Created *CustomerRequestDateScheme `json:"created,omitempty"` - Attachments *RequestAttachmentPageScheme `json:"attachments,omitempty"` - Expands []string `json:"_expands,omitempty"` - Public bool `json:"public,omitempty"` - Links *RequestCommentLinkScheme `json:"_links,omitempty"` -} - -type RequestCommentLinkScheme struct { - Self string `json:"self"` -} - -type RequestCommentRenderScheme struct { - HTML string `json:"html"` -} - -var ( - notBodyMessageError = fmt.Errorf("error, please provide a valid body value") -) diff --git a/jira/sm/requestFeedback.go b/jira/sm/requestFeedback.go index 04d84a95..c325557c 100644 --- a/jira/sm/requestFeedback.go +++ b/jira/sm/requestFeedback.go @@ -3,6 +3,7 @@ package sm import ( "context" "fmt" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" "net/http" ) @@ -10,11 +11,11 @@ type RequestFeedbackService struct{ client *Client } // Get retrieves a feedback of a request using it's requestKey or requestId // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/request/feedback#get-feedback -func (r *RequestFeedbackService) Get(ctx context.Context, requestIDOrKey string) (result *CustomerFeedbackScheme, +func (r *RequestFeedbackService) Get(ctx context.Context, requestIDOrKey string) (result *model.CustomerFeedbackScheme, response *ResponseScheme, err error) { if len(requestIDOrKey) == 0 { - return nil, nil, notRequestIDOrKeyError + return nil, nil, model.ErrNoIssueKeyOrIDError } var endpoint = fmt.Sprintf("rest/servicedeskapi/request/%v/feedback", requestIDOrKey) @@ -35,13 +36,13 @@ func (r *RequestFeedbackService) Get(ctx context.Context, requestIDOrKey string) return } -// Post adds a feedback on an request using it's requestKey or requestId +// Post adds a feedback on a request using its requestKey or requestId // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/request/feedback#post-feedback func (r *RequestFeedbackService) Post(ctx context.Context, requestIDOrKey string, rating int, comment string) ( - result *CustomerFeedbackScheme, response *ResponseScheme, err error) { + result *model.CustomerFeedbackScheme, response *ResponseScheme, err error) { if len(requestIDOrKey) == 0 { - return nil, nil, notRequestIDOrKeyError + return nil, nil, model.ErrNoIssueKeyOrIDError } payload := struct { @@ -80,12 +81,12 @@ func (r *RequestFeedbackService) Post(ctx context.Context, requestIDOrKey string return } -// Delete deletes the feedback of request using it's requestKey or requestId +// Delete deletes the feedback of request using its requestKey or requestId // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/request/feedback#delete-feedback func (r *RequestFeedbackService) Delete(ctx context.Context, requestIDOrKey string) (response *ResponseScheme, err error) { if len(requestIDOrKey) == 0 { - return nil, notRequestIDOrKeyError + return nil, model.ErrNoIssueKeyOrIDError } var endpoint = fmt.Sprintf("rest/servicedeskapi/request/%v/feedback", requestIDOrKey) @@ -105,17 +106,3 @@ func (r *RequestFeedbackService) Delete(ctx context.Context, requestIDOrKey stri return } - -type CustomerFeedbackScheme struct { - Type string `json:"type,omitempty"` - Rating int `json:"rating,omitempty"` - Comment *CustomerFeedbackCommentScheme `json:"comment,omitempty"` -} - -type CustomerFeedbackCommentScheme struct { - Body string `json:"body,omitempty"` -} - -var ( - notRequestIDOrKeyError = fmt.Errorf("error, please provide a valid requestIDOrKey value") -) diff --git a/jira/sm/requestParticipant.go b/jira/sm/requestParticipant.go index 941b7499..ecb9ec79 100644 --- a/jira/sm/requestParticipant.go +++ b/jira/sm/requestParticipant.go @@ -3,6 +3,7 @@ package sm import ( "context" "fmt" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" "net/http" "net/url" "strconv" @@ -13,10 +14,10 @@ type RequestParticipantService struct{ client *Client } // Gets returns a list of all the participants on a customer request. // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/request/participants#get-request-participants func (r *RequestParticipantService) Gets(ctx context.Context, issueKeyOrID string, start, limit int) ( - result *RequestParticipantPageScheme, response *ResponseScheme, err error) { + result *model.RequestParticipantPageScheme, response *ResponseScheme, err error) { if len(issueKeyOrID) == 0 { - return nil, nil, notIssueError + return nil, nil, model.ErrNoIssueKeyOrIDError } params := url.Values{} @@ -43,14 +44,14 @@ func (r *RequestParticipantService) Gets(ctx context.Context, issueKeyOrID strin // Add adds participants to a customer request. // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/request/participants#add-request-participants func (r *RequestParticipantService) Add(ctx context.Context, issueKeyOrID string, accountIDs []string) ( - result *RequestParticipantPageScheme, response *ResponseScheme, err error) { + result *model.RequestParticipantPageScheme, response *ResponseScheme, err error) { if len(issueKeyOrID) == 0 { - return nil, nil, notIssueError + return nil, nil, model.ErrNoIssueKeyOrIDError } if len(accountIDs) == 0 { - return nil, nil, notAccountsError + return nil, nil, model.ErrNoAccountSliceError } payload := struct { @@ -82,14 +83,14 @@ func (r *RequestParticipantService) Add(ctx context.Context, issueKeyOrID string // Remove removes participants from a customer request. // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/request/participants#remove-request-participants func (r *RequestParticipantService) Remove(ctx context.Context, issueKeyOrID string, accountIDs []string) ( - result *RequestParticipantPageScheme, response *ResponseScheme, err error) { + result *model.RequestParticipantPageScheme, response *ResponseScheme, err error) { if len(issueKeyOrID) == 0 { - return nil, nil, notIssueError + return nil, nil, model.ErrNoIssueKeyOrIDError } if len(accountIDs) == 0 { - return nil, nil, notAccountsError + return nil, nil, model.ErrNoAccountSliceError } payload := struct { @@ -116,41 +117,3 @@ func (r *RequestParticipantService) Remove(ctx context.Context, issueKeyOrID str return } - -type RequestParticipantPageScheme struct { - Size int `json:"size,omitempty"` - Start int `json:"start,omitempty"` - Limit int `json:"limit,omitempty"` - IsLastPage bool `json:"isLastPage,omitempty"` - Values []*RequestParticipantScheme `json:"values,omitempty"` - Expands []string `json:"_expands,omitempty"` - Links *RequestParticipantPageLinkScheme `json:"_links,omitempty"` -} - -type RequestParticipantPageLinkScheme struct { - Self string `json:"self,omitempty"` - Base string `json:"base,omitempty"` - Context string `json:"context,omitempty"` - Next string `json:"next,omitempty"` - Prev string `json:"prev,omitempty"` -} - -type RequestParticipantScheme struct { - AccountID string `json:"accountId,omitempty"` - Name string `json:"name,omitempty"` - Key string `json:"key,omitempty"` - EmailAddress string `json:"emailAddress,omitempty"` - DisplayName string `json:"displayName,omitempty"` - Active bool `json:"active,omitempty"` - TimeZone string `json:"timeZone,omitempty"` - Links *RequestParticipantLinkScheme `json:"_links,omitempty"` -} - -type RequestParticipantLinkScheme struct { - Self string `json:"self,omitempty"` - JiraRest string `json:"jiraRest,omitempty"` -} - -var ( - notAccountsError = fmt.Errorf("error, please provide a valid accountIDs slice value") -) diff --git a/jira/sm/requestSLA.go b/jira/sm/requestSLA.go index 8734df41..f8634013 100644 --- a/jira/sm/requestSLA.go +++ b/jira/sm/requestSLA.go @@ -3,6 +3,7 @@ package sm import ( "context" "fmt" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" "net/http" "net/url" "strconv" @@ -13,10 +14,10 @@ type RequestSLAService struct{ client *Client } // Gets returns all the SLA records on a customer request. // 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". // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/request/sla#get-sla-information -func (r *RequestSLAService) Gets(ctx context.Context, issueKeyOrID string, start, limit int) (result *RequestSLAPageScheme, response *ResponseScheme, err error) { +func (r *RequestSLAService) Gets(ctx context.Context, issueKeyOrID string, start, limit int) (result *model.RequestSLAPageScheme, response *ResponseScheme, err error) { if len(issueKeyOrID) == 0 { - return nil, nil, notIssueError + return nil, nil, model.ErrNoIssueKeyOrIDError } params := url.Values{} @@ -42,10 +43,10 @@ func (r *RequestSLAService) Gets(ctx context.Context, issueKeyOrID string, start // Get returns the details for an SLA on a customer request. // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/request/sla#get-sla-information-by-id -func (r *RequestSLAService) Get(ctx context.Context, issueKeyOrID string, slaMetricID int) (result *RequestSLAScheme, response *ResponseScheme, err error) { +func (r *RequestSLAService) Get(ctx context.Context, issueKeyOrID string, slaMetricID int) (result *model.RequestSLAScheme, response *ResponseScheme, err error) { if len(issueKeyOrID) == 0 { - return nil, nil, notIssueError + return nil, nil, model.ErrNoIssueKeyOrIDError } var endpoint = fmt.Sprintf("rest/servicedeskapi/request/%v/sla/%v", issueKeyOrID, slaMetricID) @@ -64,38 +65,3 @@ func (r *RequestSLAService) Get(ctx context.Context, issueKeyOrID string, slaMet return } - -type RequestSLAPageScheme struct { - Size int `json:"size,omitempty"` - Start int `json:"start,omitempty"` - Limit int `json:"limit,omitempty"` - IsLastPage bool `json:"isLastPage,omitempty"` - Values []*RequestSLAScheme `json:"values,omitempty"` - Expands []string `json:"_expands,omitempty"` - Links *RequestSLAPageLinkScheme `json:"_links,omitempty"` -} - -type RequestSLAPageLinkScheme struct { - Self string `json:"self,omitempty"` - Base string `json:"base,omitempty"` - Context string `json:"context,omitempty"` - Next string `json:"next,omitempty"` - Prev string `json:"prev,omitempty"` -} - -type RequestSLAScheme struct { - ID string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - OngoingCycle *RequestSLAOngoingCycleScheme `json:"ongoingCycle,omitempty"` - Links *RequestSLALinkScheme `json:"_links,omitempty"` -} - -type RequestSLAOngoingCycleScheme struct { - Breached bool `json:"breached,omitempty"` - Paused bool `json:"paused,omitempty"` - WithinCalendarHours bool `json:"withinCalendarHours,omitempty"` -} - -type RequestSLALinkScheme struct { - Self string `json:"self,omitempty"` -} diff --git a/jira/sm/requestType.go b/jira/sm/requestType.go index 98635067..6bcd4500 100644 --- a/jira/sm/requestType.go +++ b/jira/sm/requestType.go @@ -3,6 +3,7 @@ package sm import ( "context" "fmt" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" "net/http" "net/url" "strconv" @@ -13,7 +14,7 @@ type RequestTypeService struct{ client *Client } // Search returns all customer request types used in the Jira Service Management instance, // optionally filtered by a query string. // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/request/types#get-all-request-types -func (r *RequestTypeService) Search(ctx context.Context, query string, start, limit int) (result *RequestTypePageScheme, +func (r *RequestTypeService) Search(ctx context.Context, query string, start, limit int) (result *model.RequestTypePageScheme, response *ResponseScheme, err error) { params := url.Values{} @@ -51,10 +52,10 @@ func (r *RequestTypeService) Search(ctx context.Context, query string, start, li // There are two parameters for filtering the returned list: // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/request/types#get-request-types func (r *RequestTypeService) Gets(ctx context.Context, serviceDeskID, groupID, start, limit int) ( - result *ProjectRequestTypePageScheme, response *ResponseScheme, err error) { + result *model.ProjectRequestTypePageScheme, response *ResponseScheme, err error) { if serviceDeskID == 0 { - return nil, nil, notServiceDeskError + return nil, nil, model.ErrNoServiceDeskIDError } params := url.Values{} @@ -82,30 +83,13 @@ func (r *RequestTypeService) Gets(ctx context.Context, serviceDeskID, groupID, s return } -type ProjectRequestTypePageScheme struct { - Expands []string `json:"_expands"` - Size int `json:"size"` - Start int `json:"start"` - Limit int `json:"limit"` - IsLastPage bool `json:"isLastPage"` - Values []*RequestTypeScheme `json:"values"` - Links *ProjectRequestTypePageLinkScheme `json:"_links"` -} - -type ProjectRequestTypePageLinkScheme struct { - Base string `json:"base"` - Context string `json:"context"` - Next string `json:"next"` - Prev string `json:"prev"` -} - // Create enables a customer request type to be added to a service desk based on an issue type. // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/request/types#create-request-type func (r *RequestTypeService) Create(ctx context.Context, serviceDeskID int, issueTypeID, name, description, - helpText string) (result *RequestTypeScheme, response *ResponseScheme, err error) { + helpText string) (result *model.RequestTypeScheme, response *ResponseScheme, err error) { if serviceDeskID == 0 { - return nil, nil, notServiceDeskError + return nil, nil, model.ErrNoServiceDeskIDError } payload := struct { @@ -147,15 +131,15 @@ func (r *RequestTypeService) Create(ctx context.Context, serviceDeskID int, issu // Get returns a customer request type from a service desk. // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/request/types#get-request-type-by-id -func (r *RequestTypeService) Get(ctx context.Context, serviceDeskID, requestTypeID int) (result *RequestTypeScheme, +func (r *RequestTypeService) Get(ctx context.Context, serviceDeskID, requestTypeID int) (result *model.RequestTypeScheme, response *ResponseScheme, err error) { if serviceDeskID == 0 { - return nil, nil, notServiceDeskError + return nil, nil, model.ErrNoServiceDeskIDError } if requestTypeID == 0 { - return nil, nil, notRequestTypeError + return nil, nil, model.ErrNoRequestTypeIDError } var endpoint = fmt.Sprintf("rest/servicedeskapi/servicedesk/%v/requesttype/%v", serviceDeskID, requestTypeID) @@ -180,11 +164,11 @@ func (r *RequestTypeService) Get(ctx context.Context, serviceDeskID, requestType func (r *RequestTypeService) Delete(ctx context.Context, serviceDeskID, requestTypeID int) (response *ResponseScheme, err error) { if serviceDeskID == 0 { - return nil, notServiceDeskError + return nil, model.ErrNoServiceDeskIDError } if requestTypeID == 0 { - return nil, notRequestTypeError + return nil, model.ErrNoRequestTypeIDError } var endpoint = fmt.Sprintf("rest/servicedeskapi/servicedesk/%v/requesttype/%v", serviceDeskID, requestTypeID) @@ -213,14 +197,14 @@ func (r *RequestTypeService) Delete(ctx context.Context, serviceDeskID, requestT // Fields returns the fields for a service desk's customer request type. // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/request/types#get-request-type-fields func (r *RequestTypeService) Fields(ctx context.Context, serviceDeskID, requestTypeID int) ( - result *RequestTypeFieldsScheme, response *ResponseScheme, err error) { + result *model.RequestTypeFieldsScheme, response *ResponseScheme, err error) { if serviceDeskID == 0 { - return nil, nil, notServiceDeskError + return nil, nil, model.ErrNoServiceDeskIDError } if requestTypeID == 0 { - return nil, nil, notRequestTypeError + return nil, nil, model.ErrNoRequestTypeIDError } var endpoint = fmt.Sprintf("rest/servicedeskapi/servicedesk/%v/requesttype/%v/field", serviceDeskID, requestTypeID) @@ -239,75 +223,3 @@ func (r *RequestTypeService) Fields(ctx context.Context, serviceDeskID, requestT return } - -type RequestTypePageScheme struct { - Size int `json:"size"` - Start int `json:"start"` - Limit int `json:"limit"` - IsLastPage bool `json:"isLastPage"` - Values []*RequestTypeScheme `json:"values"` - Expands []string `json:"_expands"` - Links *RequestTypePageLinkScheme `json:"_links"` -} - -type RequestTypePageLinkScheme struct { - Self string `json:"self"` - Base string `json:"base"` - Context string `json:"context"` - Next string `json:"next"` - Prev string `json:"prev"` -} - -type RequestTypeScheme struct { - ID string `json:"id"` - Name string `json:"name"` - Description string `json:"description"` - HelpText string `json:"helpText"` - IssueTypeID string `json:"issueTypeId"` - ServiceDeskID string `json:"serviceDeskId"` - GroupIds []string `json:"groupIds"` - Fields struct { - CanRaiseOnBehalfOf bool `json:"canRaiseOnBehalfOf"` - CanAddRequestParticipants bool `json:"canAddRequestParticipants"` - } `json:"fields"` - Expands []string `json:"_expands"` - Links struct { - Self string `json:"self"` - } `json:"_links"` -} - -type RequestTypeFieldsScheme struct { - RequestTypeFields []struct { - FieldID string `json:"fieldId"` - Name string `json:"name"` - Description string `json:"description"` - Required bool `json:"required"` - DefaultValues []struct { - Value string `json:"value"` - Label string `json:"label"` - Children []interface{} `json:"children"` - } `json:"defaultValues"` - ValidValues []struct { - Value string `json:"value"` - Label string `json:"label"` - Children []interface{} `json:"children"` - } `json:"validValues"` - JiraSchema struct { - Type string `json:"type"` - Items string `json:"items"` - System string `json:"system"` - Custom string `json:"custom"` - CustomID int `json:"customId"` - Configuration struct { - } `json:"configuration"` - } `json:"jiraSchema"` - Visible bool `json:"visible"` - } `json:"requestTypeFields"` - CanRaiseOnBehalfOf bool `json:"canRaiseOnBehalfOf"` - CanAddRequestParticipants bool `json:"canAddRequestParticipants"` -} - -var ( - notServiceDeskError = fmt.Errorf("error, please provide a valid serviceDeskID value") - notRequestTypeError = fmt.Errorf("error, please provide a valid requestTypeID value") -) diff --git a/jira/sm/serviceDesk.go b/jira/sm/serviceDesk.go index 5f2d6177..6d5addf5 100644 --- a/jira/sm/serviceDesk.go +++ b/jira/sm/serviceDesk.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "fmt" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" "io" "mime/multipart" "net/http" @@ -18,7 +19,7 @@ type ServiceDeskService struct { // Gets returns all the service desks in the Jira Service Management instance that the user has permission to access. // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/request/service-desk#get-service-desks -func (s *ServiceDeskService) Gets(ctx context.Context, start, limit int) (result *ServiceDeskPageScheme, +func (s *ServiceDeskService) Gets(ctx context.Context, start, limit int) (result *model.ServiceDeskPageScheme, response *ResponseScheme, err error) { params := url.Values{} @@ -46,7 +47,7 @@ func (s *ServiceDeskService) Gets(ctx context.Context, start, limit int) (result // Use this method to get service desk details whenever your application component is passed a service desk ID // but needs to display other service desk details. // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/request/service-desk#get-service-desk-by-id -func (s *ServiceDeskService) Get(ctx context.Context, serviceDeskID int) (result *ServiceDeskScheme, +func (s *ServiceDeskService) Get(ctx context.Context, serviceDeskID int) (result *model.ServiceDeskScheme, response *ResponseScheme, err error) { var endpoint = fmt.Sprintf("rest/servicedeskapi/servicedesk/%v", serviceDeskID) @@ -69,18 +70,18 @@ func (s *ServiceDeskService) Get(ctx context.Context, serviceDeskID int) (result // Attach one temporary attachments to a service desk // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/request/service-desk#attach-temporary-file func (s *ServiceDeskService) Attach(ctx context.Context, serviceDeskID int, fileName string, file io.Reader) ( - result *ServiceDeskTemporaryFileScheme, response *ResponseScheme, err error) { + result *model.ServiceDeskTemporaryFileScheme, response *ResponseScheme, err error) { if serviceDeskID == 0 { - return nil, nil, notServiceDeskError + return nil, nil, model.ErrNoServiceDeskIDError } if len(fileName) == 0 { - return nil, nil, notFileNameError + return nil, nil, model.ErrNoFileNameError } if file == nil { - return nil, nil, notReaderError + return nil, nil, model.ErrNoFileReaderError } var ( @@ -117,42 +118,3 @@ func (s *ServiceDeskService) Attach(ctx context.Context, serviceDeskID int, file return } - -type ServiceDeskTemporaryFileScheme struct { - TemporaryAttachments []struct { - TemporaryAttachmentID string `json:"temporaryAttachmentId,omitempty"` - FileName string `json:"fileName,omitempty"` - } `json:"temporaryAttachments,omitempty"` -} - -type ServiceDeskPageScheme struct { - Expands []string `json:"_expands,omitempty"` - Size int `json:"size,omitempty"` - Start int `json:"start,omitempty"` - Limit int `json:"limit,omitempty"` - IsLastPage bool `json:"isLastPage,omitempty"` - Links *ServiceDeskPageLinkScheme `json:"_links,omitempty"` - Values []*ServiceDeskScheme `json:"values,omitempty"` -} - -type ServiceDeskPageLinkScheme struct { - Base string `json:"base,omitempty"` - Context string `json:"context,omitempty"` - Next string `json:"next,omitempty"` - Prev string `json:"prev,omitempty"` -} - -type ServiceDeskScheme struct { - ID string `json:"id,omitempty"` - ProjectID string `json:"projectId,omitempty"` - ProjectName string `json:"projectName,omitempty"` - ProjectKey string `json:"projectKey,omitempty"` - Links struct { - Self string `json:"self,omitempty"` - } `json:"_links,omitempty"` -} - -var ( - notFileNameError = fmt.Errorf("error, the fileName is required, please provide a valid value") - notReaderError = fmt.Errorf("error, the io.Reader cannot be nil, please provide a valid value") -) diff --git a/jira/sm/serviceDeskQueue.go b/jira/sm/serviceDeskQueue.go index 82e9e3f3..333dda97 100644 --- a/jira/sm/serviceDeskQueue.go +++ b/jira/sm/serviceDeskQueue.go @@ -3,6 +3,7 @@ package sm import ( "context" "fmt" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" "net/http" "net/url" "strconv" @@ -14,7 +15,7 @@ type ServiceDeskQueueService struct{ client *Client } // Gets returns the queues in a service desk // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/request/service-desk/queue#get-queues func (s *ServiceDeskQueueService) Gets(ctx context.Context, serviceDeskID int, includeCount bool, start, limit int) ( - result *ServiceDeskQueuePageScheme, response *ResponseScheme, err error) { + result *model.ServiceDeskQueuePageScheme, response *ResponseScheme, err error) { params := url.Values{} params.Add("start", strconv.Itoa(start)) @@ -44,7 +45,7 @@ func (s *ServiceDeskQueueService) Gets(ctx context.Context, serviceDeskID int, i // Get returns a specific queues in a service desk. // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/request/service-desk/queue#get-queue func (s *ServiceDeskQueueService) Get(ctx context.Context, serviceDeskID, queueID int, includeCount bool) ( - result *ServiceDeskQueueScheme, response *ResponseScheme, err error) { + result *model.ServiceDeskQueueScheme, response *ResponseScheme, err error) { params := url.Values{} if includeCount { @@ -76,7 +77,7 @@ func (s *ServiceDeskQueueService) Get(ctx context.Context, serviceDeskID, queueI // Issues returns the customer requests in a queue // Docs: https://docs.go-atlassian.io/jira-service-management-cloud/request/service-desk/queue#get-issues-in-queue func (s *ServiceDeskQueueService) Issues(ctx context.Context, serviceDeskID, queueID, start, limit int) ( - result *ServiceDeskIssueQueueScheme, response *ResponseScheme, err error) { + result *model.ServiceDeskIssueQueueScheme, response *ResponseScheme, err error) { params := url.Values{} params.Add("start", strconv.Itoa(start)) @@ -98,80 +99,3 @@ func (s *ServiceDeskQueueService) Issues(ctx context.Context, serviceDeskID, que return } - -type ServiceDeskQueuePageScheme struct { - Size int `json:"size,omitempty"` - Start int `json:"start,omitempty"` - Limit int `json:"limit,omitempty"` - IsLastPage bool `json:"isLastPage,omitempty"` - Values []*ServiceDeskQueueScheme `json:"values,omitempty"` - Expands []string `json:"_expands,omitempty"` - Links *ServiceDeskQueuePageLinkScheme `json:"_links,omitempty"` -} - -type ServiceDeskQueuePageLinkScheme struct { - Self string `json:"self,omitempty"` - Base string `json:"base,omitempty"` - Context string `json:"context,omitempty"` - Next string `json:"next,omitempty"` - Prev string `json:"prev,omitempty"` -} - -type ServiceDeskQueueScheme struct { - ID string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Jql string `json:"jql,omitempty"` - Fields []string `json:"fields,omitempty"` - IssueCount int `json:"issueCount,omitempty"` - Links struct { - Self string `json:"self,omitempty"` - } `json:"_links,omitempty"` -} - -type ServiceDeskIssueQueueScheme struct { - Size int `json:"size"` - Start int `json:"start"` - Limit int `json:"limit"` - IsLastPage bool `json:"isLastPage"` - Values []struct { - Expand string `json:"expand"` - ID string `json:"id"` - Self string `json:"self"` - Key string `json:"key"` - Transitions []struct { - ID string `json:"id"` - Name string `json:"name"` - HasScreen bool `json:"hasScreen"` - IsGlobal bool `json:"isGlobal"` - IsInitial bool `json:"isInitial"` - IsAvailable bool `json:"isAvailable"` - IsConditional bool `json:"isConditional"` - Expand string `json:"expand"` - Looped bool `json:"looped"` - } `json:"transitions"` - - Changelog struct { - StartAt int `json:"startAt"` - MaxResults int `json:"maxResults"` - Total int `json:"total"` - Histories []struct { - } `json:"histories"` - } `json:"changelog"` - - FieldsToInclude struct { - Included []string `json:"included"` - ActuallyIncluded []string `json:"actuallyIncluded"` - Excluded []string `json:"excluded"` - } `json:"fieldsToInclude"` - Fields struct { - } `json:"fields"` - } `json:"values"` - Expands []string `json:"_expands"` - Links struct { - Self string `json:"self"` - Base string `json:"base"` - Context string `json:"context"` - Next string `json:"next"` - Prev string `json:"prev"` - } `json:"_links"` -} diff --git a/jira/sm/sm.go b/jira/sm/sm.go index 2322181f..eb9f7f00 100644 --- a/jira/sm/sm.go +++ b/jira/sm/sm.go @@ -21,7 +21,7 @@ type Client struct { Auth *AuthenticationService Customer *CustomerService Info *InfoService - Knowledgebase *KnowledgebaseService + Knowledgebase *KnowledgeBaseService Organization *OrganizationService Request *RequestService RequestType *RequestTypeService @@ -50,7 +50,7 @@ func New(httpClient *http.Client, site string) (client *Client, err error) { client.Auth = &AuthenticationService{client: client} client.Customer = &CustomerService{client: client} client.Info = &InfoService{client: client} - client.Knowledgebase = &KnowledgebaseService{client: client} + client.Knowledgebase = &KnowledgeBaseService{client: client} client.Organization = &OrganizationService{client: client} client.RequestType = &RequestTypeService{client: client} diff --git a/jira/sm/sm_test.go b/jira/sm/sm_test.go index 5bb8168a..547d161a 100644 --- a/jira/sm/sm_test.go +++ b/jira/sm/sm_test.go @@ -3,6 +3,7 @@ package sm import ( "context" "fmt" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" "github.com/stretchr/testify/assert" "io" "io/ioutil" @@ -247,7 +248,7 @@ func Test_transformStructToReader(t *testing.T) { { name: "TransformStructToReaderWhenTheParametersAreCorrect", args: args{ - structure: &RequestSLAPageScheme{ + structure: &model.RequestSLAPageScheme{ Size: 1, }, }, @@ -256,7 +257,7 @@ func Test_transformStructToReader(t *testing.T) { }, { - name: "TransformStructToReaderWhenTheStructureIsNil", + name: "TransformStructToReaderWhenTheStructureIsNil", wantReader: nil, wantErr: true, }, @@ -290,7 +291,7 @@ func Test_transformTheHTTPResponse(t *testing.T) { "mock-response": "./mocks/get-contents.json", "method": http.MethodGet, "status": http.StatusBadRequest, - "closed?": false, + "closed?": false, } responseConfigurations["badRequestResponseWithNotResponseBody"] = map[string]interface{}{ @@ -298,7 +299,7 @@ func Test_transformTheHTTPResponse(t *testing.T) { "mock-response": "", "method": http.MethodGet, "status": http.StatusBadRequest, - "closed?": true, + "closed?": true, } responseConfigurations["OkRequestResponseWithNotResponseBody"] = map[string]interface{}{ @@ -306,7 +307,7 @@ func Test_transformTheHTTPResponse(t *testing.T) { "mock-response": "./mocks/get-contents.json", "method": http.MethodGet, "status": http.StatusOK, - "closed?": true, + "closed?": true, } for scenario, configuration := range responseConfigurations { diff --git a/pkg/infra/models/ITSM_Info.go b/pkg/infra/models/ITSM_Info.go new file mode 100644 index 00000000..b04ba0fe --- /dev/null +++ b/pkg/infra/models/ITSM_Info.go @@ -0,0 +1,21 @@ +package models + +type InfoScheme struct { + Version string `json:"version,omitempty"` + PlatformVersion string `json:"platformVersion,omitempty"` + BuildDate *InfoBuildDataScheme `json:"buildDate,omitempty"` + BuildChangeSet string `json:"buildChangeSet,omitempty"` + IsLicensedForUse bool `json:"isLicensedForUse,omitempty"` + Links *InfoLinkScheme `json:"_links,omitempty"` +} + +type InfoBuildDataScheme struct { + Iso8601 string `json:"iso8601,omitempty"` + Jira string `json:"jira,omitempty"` + Friendly string `json:"friendly,omitempty"` + EpochMillis int64 `json:"epochMillis,omitempty"` +} + +type InfoLinkScheme struct { + Self string `json:"self,omitempty"` +} diff --git a/pkg/infra/models/ITSM_Knowledge_Base.go b/pkg/infra/models/ITSM_Knowledge_Base.go new file mode 100644 index 00000000..64597e3b --- /dev/null +++ b/pkg/infra/models/ITSM_Knowledge_Base.go @@ -0,0 +1,34 @@ +package models + +type ArticlePageScheme struct { + Size int `json:"size,omitempty"` + Start int `json:"start,omitempty"` + Limit int `json:"limit,omitempty"` + IsLastPage bool `json:"isLastPage,omitempty"` + Values []*ArticleScheme `json:"values,omitempty"` + Expands []string `json:"_expands,omitempty"` + Links *ArticlePageLinkScheme `json:"_links,omitempty"` +} + +type ArticlePageLinkScheme struct { + Self string `json:"self,omitempty"` + Base string `json:"base,omitempty"` + Context string `json:"context,omitempty"` + Next string `json:"next,omitempty"` + Prev string `json:"prev,omitempty"` +} + +type ArticleScheme struct { + Title string `json:"title,omitempty"` + Excerpt string `json:"excerpt,omitempty"` + Source *ArticleSourceScheme `json:"source,omitempty"` + Content *ArticleContentScheme `json:"content,omitempty"` +} + +type ArticleSourceScheme struct { + Type string `json:"type,omitempty"` +} + +type ArticleContentScheme struct { + IframeSrc string `json:"iframeSrc,omitempty"` +} diff --git a/pkg/infra/models/ITSM_Organization.go b/pkg/infra/models/ITSM_Organization.go new file mode 100644 index 00000000..229b2cf6 --- /dev/null +++ b/pkg/infra/models/ITSM_Organization.go @@ -0,0 +1,61 @@ +package models + +type OrganizationUsersPageScheme struct { + Size int `json:"size,omitempty"` + Start int `json:"start,omitempty"` + Limit int `json:"limit,omitempty"` + IsLastPage bool `json:"isLastPage,omitempty"` + Values []*OrganizationUserScheme `json:"values,omitempty"` + Expands []string `json:"_expands,omitempty"` + Links *OrganizationUsersPageLinkScheme `json:"_links,omitempty"` +} + +type OrganizationUsersPageLinkScheme struct { + Self string `json:"self,omitempty"` + Base string `json:"base,omitempty"` + Context string `json:"context,omitempty"` + Next string `json:"next,omitempty"` + Prev string `json:"prev,omitempty"` +} + +type OrganizationUserScheme struct { + AccountID string `json:"accountId,omitempty"` + Name string `json:"name,omitempty"` + Key string `json:"key,omitempty"` + EmailAddress string `json:"emailAddress,omitempty"` + DisplayName string `json:"displayName,omitempty"` + Active bool `json:"active,omitempty"` + TimeZone string `json:"timeZone,omitempty"` + Links *OrganizationUserLinkScheme `json:"_links,omitempty"` +} + +type OrganizationUserLinkScheme struct { + Self string `json:"self,omitempty"` + JiraRest string `json:"jiraRest,omitempty"` +} + +type OrganizationPageScheme struct { + Size int `json:"size,omitempty"` + Start int `json:"start,omitempty"` + Limit int `json:"limit,omitempty"` + IsLastPage bool `json:"isLastPage,omitempty"` + Values []*OrganizationScheme `json:"values,omitempty"` + Expands []string `json:"_expands,omitempty"` + Links *OrganizationPageLinkScheme `json:"_links,omitempty"` +} + +type OrganizationPageLinkScheme struct { + Self string `json:"self,omitempty"` + Base string `json:"base,omitempty"` + Context string `json:"context,omitempty"` + Next string `json:"next,omitempty"` + Prev string `json:"prev,omitempty"` +} + +type OrganizationScheme struct { + ID string `json:"id,omitempty"` + Name string `json:"name,omitempty"` + Links struct { + Self string `json:"self,omitempty"` + } `json:"_links,omitempty"` +} diff --git a/pkg/infra/models/ITSM_Request.go b/pkg/infra/models/ITSM_Request.go new file mode 100644 index 00000000..54961db7 --- /dev/null +++ b/pkg/infra/models/ITSM_Request.go @@ -0,0 +1,121 @@ +package models + +type RequestGetOptionsScheme struct { + SearchTerm string + RequestOwnerships []string + RequestStatus string + ApprovalStatus string + OrganizationId int + ServiceDeskID int + RequestTypeID int + Expand []string +} + +type CustomerRequestTransitionPageScheme struct { + Size int `json:"size,omitempty"` + Start int `json:"start,omitempty"` + Limit int `json:"limit,omitempty"` + IsLastPage bool `json:"isLastPage,omitempty"` + Values []*CustomerRequestTransitionScheme `json:"values,omitempty"` + Expands []string `json:"_expands,omitempty"` + Links *CustomerRequestTransitionPageLinkScheme `json:"_links,omitempty"` +} + +type CustomerRequestTransitionScheme struct { + ID string `json:"id,omitempty"` + Name string `json:"name,omitempty"` +} + +type CustomerRequestTransitionPageLinkScheme struct { + Self string `json:"self,omitempty"` + Base string `json:"base,omitempty"` + Context string `json:"context,omitempty"` + Next string `json:"next,omitempty"` + Prev string `json:"prev,omitempty"` +} + +type CustomerRequestsScheme struct { + Size int `json:"size,omitempty"` + Start int `json:"start,omitempty"` + Limit int `json:"limit,omitempty"` + IsLastPage bool `json:"isLastPage,omitempty"` + Values []*CustomerRequestScheme `json:"values,omitempty"` + Expands []string `json:"_expands,omitempty"` + Links *CustomerRequestsLinksScheme `json:"_links,omitempty"` +} + +type CustomerRequestsLinksScheme struct { + Self string `json:"self,omitempty"` + Base string `json:"base,omitempty"` + Context string `json:"context,omitempty"` + Next string `json:"next,omitempty"` + Prev string `json:"prev,omitempty"` +} + +type CustomerRequestTypeScheme struct { + ID string `json:"id,omitempty"` + Name string `json:"name,omitempty"` + Description string `json:"description,omitempty"` + HelpText string `json:"helpText,omitempty"` + IssueTypeID string `json:"issueTypeId,omitempty"` + ServiceDeskID string `json:"serviceDeskId,omitempty"` + GroupIds []string `json:"groupIds,omitempty"` +} + +type CustomerRequestServiceDeskScheme struct { + ID string `json:"id,omitempty"` + ProjectID string `json:"projectId,omitempty"` + ProjectName string `json:"projectName,omitempty"` + ProjectKey string `json:"projectKey,omitempty"` +} + +type CustomerRequestDateScheme struct { + Iso8601 string `json:"iso8601,omitempty"` + Jira string `json:"jira,omitempty"` + Friendly string `json:"friendly,omitempty"` + EpochMillis int `json:"epochMillis,omitempty"` +} + +type CustomerRequestReporterScheme struct { + AccountID string `json:"accountId,omitempty"` + Name string `json:"name,omitempty"` + Key string `json:"key,omitempty"` + EmailAddress string `json:"emailAddress,omitempty"` + DisplayName string `json:"displayName,omitempty"` + Active bool `json:"active,omitempty"` + TimeZone string `json:"timeZone,omitempty"` +} + +type CustomerRequestRequestFieldValueScheme struct { + FieldID string `json:"fieldId,omitempty"` + Label string `json:"label,omitempty"` +} + +type CustomerRequestCurrentStatusScheme struct { + Status string `json:"status,omitempty"` + StatusCategory string `json:"statusCategory,omitempty"` + StatusDate struct { + } `json:"statusDate,omitempty"` +} + +type CustomerRequestLinksScheme struct { + Self string `json:"self,omitempty"` + JiraRest string `json:"jiraRest,omitempty"` + Web string `json:"web,omitempty"` + Agent string `json:"agent,omitempty"` +} + +type CustomerRequestScheme struct { + IssueID string `json:"issueId,omitempty"` + IssueKey string `json:"issueKey,omitempty"` + RequestTypeID string `json:"requestTypeId,omitempty"` + RequestType *CustomerRequestTypeScheme `json:"requestType,omitempty"` + ServiceDeskID string `json:"serviceDeskId,omitempty"` + ServiceDesk *CustomerRequestServiceDeskScheme `json:"serviceDesk,omitempty"` + CreatedDate *CustomerRequestDateScheme `json:"createdDate,omitempty"` + Reporter *CustomerRequestReporterScheme `json:"reporter,omitempty"` + RequestFieldValues []*CustomerRequestRequestFieldValueScheme `json:"requestFieldValues,omitempty"` + CurrentStatus *CustomerRequestCurrentStatusScheme `json:"currentStatus,omitempty"` + Expands []string `json:"_expands,omitempty"` + Links *CustomerRequestLinksScheme `json:"_links,omitempty"` +} diff --git a/pkg/infra/models/ITSM_Request_Approval.go b/pkg/infra/models/ITSM_Request_Approval.go new file mode 100644 index 00000000..3e34d5fd --- /dev/null +++ b/pkg/infra/models/ITSM_Request_Approval.go @@ -0,0 +1,56 @@ +package models + +type CustomerApprovalPageScheme struct { + Size int `json:"size,omitempty"` + Start int `json:"start,omitempty"` + Limit int `json:"limit,omitempty"` + IsLastPage bool `json:"isLastPage,omitempty"` + Values []*CustomerApprovalScheme `json:"values,omitempty"` + Expands []string `json:"_expands,omitempty"` + Links *CustomerApprovalPageLinkScheme `json:"_links,omitempty"` +} + +type CustomerApprovalPageLinkScheme struct { + Self string `json:"self,omitempty"` + Base string `json:"base,omitempty"` + Context string `json:"context,omitempty"` + Next string `json:"next,omitempty"` + Prev string `json:"prev,omitempty"` +} + +type CustomerApprovalScheme struct { + ID string `json:"id,omitempty"` + Name string `json:"name,omitempty"` + FinalDecision string `json:"finalDecision,omitempty"` + CanAnswerApproval bool `json:"canAnswerApproval,omitempty"` + Approvers []*CustomerApproveScheme `json:"approvers,omitempty"` + CreatedDate *CustomerRequestDateScheme `json:"createdDate,omitempty"` + CompletedDate *CustomerRequestDateScheme `json:"completedDate,omitempty"` + Links *CustomerApprovalLinkScheme `json:"_links,omitempty"` +} + +type CustomerApprovalLinkScheme struct { + Self string `json:"self"` +} + +type CustomerApproveScheme struct { + Approver *ApproverScheme `json:"approver,omitempty"` + ApproverDecision string `json:"approverDecision,omitempty"` +} + +type ApproverScheme struct { + AccountID string `json:"accountId,omitempty"` + Name string `json:"name,omitempty"` + Key string `json:"key,omitempty"` + EmailAddress string `json:"emailAddress,omitempty"` + DisplayName string `json:"displayName,omitempty"` + Active bool `json:"active,omitempty"` + TimeZone string `json:"timeZone,omitempty"` + Links *ApproverLinkScheme `json:"_links,omitempty"` +} + +type ApproverLinkScheme struct { + JiraRest string `json:"jiraRest,omitempty"` + AvatarUrls *AvatarURLScheme `json:"avatarUrls,omitempty"` + Self string `json:"self,omitempty"` +} diff --git a/pkg/infra/models/ITSM_Request_Attachments.go b/pkg/infra/models/ITSM_Request_Attachments.go new file mode 100644 index 00000000..31c9eed9 --- /dev/null +++ b/pkg/infra/models/ITSM_Request_Attachments.go @@ -0,0 +1,62 @@ +package models + +type RequestAttachmentPageScheme struct { + Size int `json:"size,omitempty"` + Start int `json:"start,omitempty"` + Limit int `json:"limit,omitempty"` + IsLastPage bool `json:"isLastPage,omitempty"` + Values []*RequestAttachmentScheme `json:"values,omitempty"` + Expands []string `json:"_expands,omitempty"` + Links *RequestAttachmentPageLinkScheme `json:"_links,omitempty"` +} + +type RequestAttachmentPageLinkScheme struct { + Self string `json:"self,omitempty"` + Base string `json:"base,omitempty"` + Context string `json:"context,omitempty"` + Next string `json:"next,omitempty"` + Prev string `json:"prev,omitempty"` +} + +type RequestAttachmentScheme struct { + Filename string `json:"filename,omitempty"` + Author *RequestAuthorScheme `json:"author,omitempty"` + Created *CustomerRequestDateScheme `json:"created,omitempty"` + Size int `json:"size,omitempty"` + MimeType string `json:"mimeType,omitempty"` + Links *RequestAttachmentLinkScheme `json:"_links,omitempty"` +} + +type RequestAttachmentLinkScheme struct { + Self string `json:"self,omitempty"` + JiraRest string `json:"jiraRest,omitempty"` + Content string `json:"content,omitempty"` + Thumbnail string `json:"thumbnail,omitempty"` +} + +type RequestAuthorScheme struct { + AccountID string `json:"accountId,omitempty"` + Name string `json:"name,omitempty"` + Key string `json:"key,omitempty"` + EmailAddress string `json:"emailAddress,omitempty"` + DisplayName string `json:"displayName,omitempty"` + Active bool `json:"active,omitempty"` + TimeZone string `json:"timeZone,omitempty"` +} + +type RequestAttachmentCreationCommentScheme struct { + Expands []string `json:"_expands,omitempty"` + ID string `json:"id,omitempty"` + Body string `json:"body,omitempty"` + Public bool `json:"public,omitempty"` + Author RequestAuthorScheme `json:"author,omitempty"` + Created *CustomerRequestDateScheme `json:"created,omitempty"` + Links struct { + Self string `json:"self,omitempty"` + } `json:"_links,omitempty"` +} + +type RequestAttachmentCreationScheme struct { + Comment *RequestAttachmentCreationCommentScheme `json:"comment,omitempty"` + Attachments *RequestAttachmentPageScheme `json:"attachments,omitempty"` +} diff --git a/pkg/infra/models/ITSM_Request_Comment.go b/pkg/infra/models/ITSM_Request_Comment.go new file mode 100644 index 00000000..3ba6b27e --- /dev/null +++ b/pkg/infra/models/ITSM_Request_Comment.go @@ -0,0 +1,39 @@ +package models + +type RequestCommentPageScheme struct { + Size int `json:"size"` + Start int `json:"start"` + Limit int `json:"limit"` + IsLastPage bool `json:"isLastPage"` + Values []*RequestCommentScheme `json:"values"` + Expands []string `json:"_expands"` + Links *RequestCommentPageLinkScheme `json:"_links"` +} + +type RequestCommentPageLinkScheme struct { + Self string `json:"self"` + Base string `json:"base"` + Context string `json:"context"` + Next string `json:"next"` + Prev string `json:"prev"` +} + +type RequestCommentScheme struct { + ID string `json:"id,omitempty"` + Body string `json:"body,omitempty"` + RenderedBody *RequestCommentRenderScheme `json:"renderedBody,omitempty"` + Author *RequestAuthorScheme `json:"author,omitempty"` + Created *CustomerRequestDateScheme `json:"created,omitempty"` + Attachments *RequestAttachmentPageScheme `json:"attachments,omitempty"` + Expands []string `json:"_expands,omitempty"` + Public bool `json:"public,omitempty"` + Links *RequestCommentLinkScheme `json:"_links,omitempty"` +} + +type RequestCommentLinkScheme struct { + Self string `json:"self"` +} + +type RequestCommentRenderScheme struct { + HTML string `json:"html"` +} diff --git a/pkg/infra/models/ITSM_Request_Feedback.go b/pkg/infra/models/ITSM_Request_Feedback.go new file mode 100644 index 00000000..98083ec1 --- /dev/null +++ b/pkg/infra/models/ITSM_Request_Feedback.go @@ -0,0 +1,11 @@ +package models + +type CustomerFeedbackScheme struct { + Type string `json:"type,omitempty"` + Rating int `json:"rating,omitempty"` + Comment *CustomerFeedbackCommentScheme `json:"comment,omitempty"` +} + +type CustomerFeedbackCommentScheme struct { + Body string `json:"body,omitempty"` +} diff --git a/pkg/infra/models/ITSM_Request_Participants.go b/pkg/infra/models/ITSM_Request_Participants.go new file mode 100644 index 00000000..3aba93ef --- /dev/null +++ b/pkg/infra/models/ITSM_Request_Participants.go @@ -0,0 +1,35 @@ +package models + +type RequestParticipantPageScheme struct { + Size int `json:"size,omitempty"` + Start int `json:"start,omitempty"` + Limit int `json:"limit,omitempty"` + IsLastPage bool `json:"isLastPage,omitempty"` + Values []*RequestParticipantScheme `json:"values,omitempty"` + Expands []string `json:"_expands,omitempty"` + Links *RequestParticipantPageLinkScheme `json:"_links,omitempty"` +} + +type RequestParticipantPageLinkScheme struct { + Self string `json:"self,omitempty"` + Base string `json:"base,omitempty"` + Context string `json:"context,omitempty"` + Next string `json:"next,omitempty"` + Prev string `json:"prev,omitempty"` +} + +type RequestParticipantScheme struct { + AccountID string `json:"accountId,omitempty"` + Name string `json:"name,omitempty"` + Key string `json:"key,omitempty"` + EmailAddress string `json:"emailAddress,omitempty"` + DisplayName string `json:"displayName,omitempty"` + Active bool `json:"active,omitempty"` + TimeZone string `json:"timeZone,omitempty"` + Links *RequestParticipantLinkScheme `json:"_links,omitempty"` +} + +type RequestParticipantLinkScheme struct { + Self string `json:"self,omitempty"` + JiraRest string `json:"jiraRest,omitempty"` +} diff --git a/pkg/infra/models/ITSM_Request_SLA.go b/pkg/infra/models/ITSM_Request_SLA.go new file mode 100644 index 00000000..53ff6fa0 --- /dev/null +++ b/pkg/infra/models/ITSM_Request_SLA.go @@ -0,0 +1,36 @@ +package models + +type RequestSLAPageScheme struct { + Size int `json:"size,omitempty"` + Start int `json:"start,omitempty"` + Limit int `json:"limit,omitempty"` + IsLastPage bool `json:"isLastPage,omitempty"` + Values []*RequestSLAScheme `json:"values,omitempty"` + Expands []string `json:"_expands,omitempty"` + Links *RequestSLAPageLinkScheme `json:"_links,omitempty"` +} + +type RequestSLAPageLinkScheme struct { + Self string `json:"self,omitempty"` + Base string `json:"base,omitempty"` + Context string `json:"context,omitempty"` + Next string `json:"next,omitempty"` + Prev string `json:"prev,omitempty"` +} + +type RequestSLAScheme struct { + ID string `json:"id,omitempty"` + Name string `json:"name,omitempty"` + OngoingCycle *RequestSLAOngoingCycleScheme `json:"ongoingCycle,omitempty"` + Links *RequestSLALinkScheme `json:"_links,omitempty"` +} + +type RequestSLAOngoingCycleScheme struct { + Breached bool `json:"breached,omitempty"` + Paused bool `json:"paused,omitempty"` + WithinCalendarHours bool `json:"withinCalendarHours,omitempty"` +} + +type RequestSLALinkScheme struct { + Self string `json:"self,omitempty"` +} diff --git a/pkg/infra/models/ITSM_Request_Type.go b/pkg/infra/models/ITSM_Request_Type.go new file mode 100644 index 00000000..f75925ac --- /dev/null +++ b/pkg/infra/models/ITSM_Request_Type.go @@ -0,0 +1,78 @@ +package models + +type RequestTypePageScheme struct { + Size int `json:"size,omitempty"` + Start int `json:"start,omitempty"` + Limit int `json:"limit,omitempty"` + IsLastPage bool `json:"isLastPage,omitempty"` + Values []*RequestTypeScheme `json:"values,omitempty"` + Expands []string `json:"_expands,omitempty"` + Links *RequestTypePageLinkScheme `json:"_links,omitempty"` +} + +type RequestTypePageLinkScheme struct { + Self string `json:"self,omitempty"` + Base string `json:"base,omitempty"` + Context string `json:"context,omitempty"` + Next string `json:"next,omitempty"` + Prev string `json:"prev,omitempty"` +} + +type ProjectRequestTypePageScheme struct { + Expands []string `json:"_expands,omitempty"` + Size int `json:"size,omitempty"` + Start int `json:"start,omitempty"` + Limit int `json:"limit,omitempty"` + IsLastPage bool `json:"isLastPage,omitempty"` + Values []*RequestTypeScheme `json:"values,omitempty"` + Links *ProjectRequestTypePageLinkScheme `json:"_links,omitempty"` +} + +type ProjectRequestTypePageLinkScheme struct { + Base string `json:"base,omitempty"` + Context string `json:"context,omitempty"` + Next string `json:"next,omitempty"` + Prev string `json:"prev,omitempty"` +} + +type RequestTypeScheme struct { + ID string `json:"id,omitempty"` + Name string `json:"name,omitempty"` + Description string `json:"description,omitempty"` + HelpText string `json:"helpText,omitempty"` + IssueTypeID string `json:"issueTypeId,omitempty"` + ServiceDeskID string `json:"serviceDeskId,omitempty"` + GroupIds []string `json:"groupIds,omitempty"` + Expands []string `json:"_expands,omitempty"` +} + +type RequestTypeFieldsScheme struct { + RequestTypeFields []*RequestTypeFieldScheme `json:"requestTypeFields,omitempty"` + CanRaiseOnBehalfOf bool `json:"canRaiseOnBehalfOf,omitempty"` + CanAddRequestParticipants bool `json:"canAddRequestParticipants,omitempty"` +} + +type RequestTypeFieldScheme struct { + FieldID string `json:"fieldId,omitempty"` + Name string `json:"name,omitempty"` + Description string `json:"description,omitempty"` + Required bool `json:"required,omitempty"` + DefaultValues []*RequestTypeFieldValueScheme `json:"defaultValues,omitempty"` + ValidValues []*RequestTypeFieldValueScheme `json:"validValues,omitempty"` + JiraSchema *RequestTypeJiraSchema `json:"jiraSchema,omitempty"` + Visible bool `json:"visible,omitempty"` +} + +type RequestTypeFieldValueScheme struct { + Value string `json:"value,omitempty"` + Label string `json:"label,omitempty"` + Children []interface{} `json:"children,omitempty"` +} + +type RequestTypeJiraSchema struct { + Type string `json:"type,omitempty"` + Items string `json:"items,omitempty"` + System string `json:"system,omitempty"` + Custom string `json:"custom,omitempty"` + CustomID int `json:"customId,omitempty"` +} diff --git a/pkg/infra/models/ITSM_Service_Desk.go b/pkg/infra/models/ITSM_Service_Desk.go new file mode 100644 index 00000000..6fa1c8db --- /dev/null +++ b/pkg/infra/models/ITSM_Service_Desk.go @@ -0,0 +1,37 @@ +package models + +type ServiceDeskTemporaryFileScheme struct { + TemporaryAttachments []*TemporaryAttachmentScheme `json:"temporaryAttachments,omitempty"` +} + +type TemporaryAttachmentScheme struct { + TemporaryAttachmentID string `json:"temporaryAttachmentId,omitempty"` + FileName string `json:"fileName,omitempty"` +} + +type ServiceDeskPageScheme struct { + Expands []string `json:"_expands,omitempty"` + Size int `json:"size,omitempty"` + Start int `json:"start,omitempty"` + Limit int `json:"limit,omitempty"` + IsLastPage bool `json:"isLastPage,omitempty"` + Links *ServiceDeskPageLinkScheme `json:"_links,omitempty"` + Values []*ServiceDeskScheme `json:"values,omitempty"` +} + +type ServiceDeskPageLinkScheme struct { + Base string `json:"base,omitempty"` + Context string `json:"context,omitempty"` + Next string `json:"next,omitempty"` + Prev string `json:"prev,omitempty"` +} + +type ServiceDeskScheme struct { + ID string `json:"id,omitempty"` + ProjectID string `json:"projectId,omitempty"` + ProjectName string `json:"projectName,omitempty"` + ProjectKey string `json:"projectKey,omitempty"` + Links struct { + Self string `json:"self,omitempty"` + } `json:"_links,omitempty"` +} diff --git a/pkg/infra/models/ITSM_Service_Desk_Queue.go b/pkg/infra/models/ITSM_Service_Desk_Queue.go new file mode 100644 index 00000000..bbc8c516 --- /dev/null +++ b/pkg/infra/models/ITSM_Service_Desk_Queue.go @@ -0,0 +1,37 @@ +package models + +type ServiceDeskQueuePageScheme struct { + Size int `json:"size,omitempty"` + Start int `json:"start,omitempty"` + Limit int `json:"limit,omitempty"` + IsLastPage bool `json:"isLastPage,omitempty"` + Values []*ServiceDeskQueueScheme `json:"values,omitempty"` + Expands []string `json:"_expands,omitempty"` + Links *ServiceDeskQueuePageLinkScheme `json:"_links,omitempty"` +} + +type ServiceDeskQueuePageLinkScheme struct { + Self string `json:"self,omitempty"` + Base string `json:"base,omitempty"` + Context string `json:"context,omitempty"` + Next string `json:"next,omitempty"` + Prev string `json:"prev,omitempty"` +} + +type ServiceDeskQueueScheme struct { + ID string `json:"id,omitempty"` + Name string `json:"name,omitempty"` + Jql string `json:"jql,omitempty"` + Fields []string `json:"fields,omitempty"` + IssueCount int `json:"issueCount,omitempty"` +} + +type ServiceDeskIssueQueueScheme struct { + Size int `json:"size,omitempty"` + Start int `json:"start,omitempty"` + Limit int `json:"limit,omitempty"` + IsLastPage bool `json:"isLastPage,omitempty"` + Values []*IssueSchemeV2 `json:"values,omitempty"` + Expands []string `json:"_expands,omitempty"` + Links *ServiceDeskQueuePageLinkScheme `json:"_links,omitempty"` +} diff --git a/pkg/infra/models/customer.go b/pkg/infra/models/customer.go new file mode 100644 index 00000000..48e3952b --- /dev/null +++ b/pkg/infra/models/customer.go @@ -0,0 +1,35 @@ +package models + +type CustomerPageScheme struct { + Expands []interface{} `json:"_expands,omitempty"` + Size int `json:"size,omitempty"` + Start int `json:"start,omitempty"` + Limit int `json:"limit,omitempty"` + IsLastPage bool `json:"isLastPage,omitempty"` + Links *CustomerPageLinksScheme `json:"_links,omitempty"` + Values []*CustomerScheme `json:"values,omitempty"` +} + +type CustomerPageLinksScheme struct { + Base string `json:"base,omitempty"` + Context string `json:"context,omitempty"` + Next string `json:"next,omitempty"` + Prev string `json:"prev,omitempty"` +} + +type CustomerScheme struct { + AccountID string `json:"accountId,omitempty"` + Name string `json:"name,omitempty"` + Key string `json:"key,omitempty"` + EmailAddress string `json:"emailAddress,omitempty"` + DisplayName string `json:"displayName,omitempty"` + Active bool `json:"active,omitempty"` + TimeZone string `json:"timeZone,omitempty"` + Links *CustomerLinkScheme `json:"_links,omitempty"` +} + +type CustomerLinkScheme struct { + JiraRest string `json:"jiraRest"` + AvatarUrls *AvatarURLScheme `json:"avatarUrls"` + Self string `json:"self"` +} diff --git a/pkg/infra/models/errors.go b/pkg/infra/models/errors.go index 862a9b9c..101c1ffd 100644 --- a/pkg/infra/models/errors.go +++ b/pkg/infra/models/errors.go @@ -5,10 +5,21 @@ import ( ) var ( - ErrNoBoardIDError = errors.New("agile: no board id set") - ErrNoFilterIDError = errors.New("agile: no filter id set") - ErrNoEpicIDError = errors.New("agile: no epic id set") - ErrNoSprintIDError = errors.New("agile: no sprint id set") + ErrNoCustomerMailError = errors.New("sm: no customer mail set") + ErrNoCustomerDisplayNameError = errors.New("sm: no customer display name set") + ErrNoKBQueryError = errors.New("sm: no knowledge base query set") + ErrNoOrganizationNameError = errors.New("sm: no organization name set") + ErrNoCommentBodyError = errors.New("sm/jira: no comment body set") + ErrNoServiceDeskIDError = errors.New("sm: no service desk id set") + ErrNoRequestTypeIDError = errors.New("sm: no request type id set") + ErrNoFileNameError = errors.New("sm: no file name set") + ErrNoFileReaderError = errors.New("sm: no io.Reader set") + + ErrNoBoardIDError = errors.New("agile: no board id set") + ErrNoFilterIDError = errors.New("agile: no filter id set") + ErrNoEpicIDError = errors.New("agile: no epic id set") + ErrNoSprintIDError = errors.New("agile: no sprint id set") + ErrNoApplicationRoleError = errors.New("jira: no application role key set") ErrNoDashboardIDError = errors.New("jira: no dashboard id set") ErrNoGroupNameError = errors.New("jira: no group name set")