Repository: ctreminiom/go-atlassian
Pull request #121 (2022-06-09 05:12:18)

🔢 SM Customer Request creation


Patch:
diff --git a/codecov.yml b/codecov.yml
index e412bfe..5237dab 100644
--- a/codecov.yml
+++ b/codecov.yml
@@ -1,34 +1,8 @@
 coverage:
-  range: 80..100
-  round: down
-  precisi.on: 2
-
   status:
-    project:                   # measuring the overall project coverage
-      default:                 # context, you can create multiple ones with custom titles
-        enabled: yes           # must be yes|true to enable this status
-        target: 90             # specify the target coverage for each commit status
-        #   option: "auto" (must increase from parent commit or pull request base)
-        #   option: "X%" a static target percentage to hit
-        threshold: null        # allowed to drop X% and still result in a "success" commit status
-        if_not_found: success  # if parent is not found report status as success, error, or failure
-        if_ci_failed: error    # if ci fails report status as success, error, or failure
     patch:
       default:
-        enabled: no
-=======
-# Team Yaml
-coverage:
-  round: down
-  precision: 5
-
-# Repository Yaml
-coverage:
-  round: up
-  range: 0..10
-
-# Used in Codecov after updating
-coverage:
-  round: up
-  range: 0..10
-  precision: 5
+        target: 80%
+    project:                   # measuring the overall project coverage
+      default:                 # context, you can create multiple ones with custom titles
+        target: 90%             # specify the target coverage for each commit status
\ No newline at end of file
diff --git a/jira/sm/request.go b/jira/sm/request.go
index 62ceb87..84a5c6d 100644
--- a/jira/sm/request.go
+++ b/jira/sm/request.go
@@ -32,6 +32,44 @@ type RequestGetOptionsScheme struct {
 	Expand            []string
 }
 
+// Create creates a customer request in a service desk.
+// The JSON request must include the service desk and customer request type, as well as any fields that are required for
+// the request type.
+// Docs: https://docs.go-atlassian.io/jira-service-management/request#create-customer-request
+func (r *RequestService) Create(ctx context.Context, payload *model.CreateCustomerRequestPayloadScheme, fields *model.CustomerRequestFields) (
+	result *model.CustomerRequestScheme, response *ResponseScheme, err error) {
+
+	if fields == nil {
+		return nil, nil, model.ErrNoCustomRequestFieldsError
+	}
+
+	payloadWithCustomFields, err := payload.MergeFields(fields)
+	if err != nil {
+		return nil, nil, err
+	}
+
+	reader, err := transformStructToReader(&payloadWithCustomFields)
+	if err != nil {
+		return nil, nil, err
+	}
+
+	endpoint := "rest/servicedeskapi/request"
+	request, err := r.client.newRequest(ctx, http.MethodPost, endpoint, reader)
+	if err != nil {
+		return
+	}
+
+	request.Header.Set("Accept", "application/json")
+	request.Header.Set("Content-Type", "application/json")
+
+	response, err = r.client.Call(request, &result)
+	if err != nil {
+		return
+	}
+
+	return
+}
+
 // Gets returns all customer requests for the user executing the query.
 // 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
diff --git a/pkg/infra/models/errors.go b/pkg/infra/models/errors.go
index 777d5f1..f97bb75 100644
--- a/pkg/infra/models/errors.go
+++ b/pkg/infra/models/errors.go
@@ -25,6 +25,7 @@ var (
 	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")
+	ErrNoCustomRequestFieldsError = errors.New("sm: no customer request fields set")
 
 	ErrNoContentIDError             = errors.New("confluence: no content id set")
 	ErrNoCQLError                   = errors.New("confluence: no CQL query set")
diff --git a/pkg/infra/models/jira_issue_v2.go b/pkg/infra/models/jira_issue_v2.go
index 6aa8436..9857ae9 100644
--- a/pkg/infra/models/jira_issue_v2.go
+++ b/pkg/infra/models/jira_issue_v2.go
@@ -86,6 +86,7 @@ type IssueFieldsSchemeV2 struct {
 	Components               []*ComponentScheme        `json:"components,omitempty"`
 	Creator                  *UserScheme               `json:"creator,omitempty"`
 	Reporter                 *UserScheme               `json:"reporter,omitempty"`
+	Assignee                 *UserScheme               `json:"assignee,omitempty"`
 	Resolution               *ResolutionScheme         `json:"resolution,omitempty"`
 	Resolutiondate           string                    `json:"resolutiondate,omitempty"`
 	Workratio                int                       `json:"workratio,omitempty"`
@@ -99,6 +100,7 @@ type IssueFieldsSchemeV2 struct {
 	Description              string                    `json:"description,omitempty"`
 	Comment                  *IssueCommentPageSchemeV2 `json:"comment,omitempty"`
 	Subtasks                 []*IssueScheme            `json:"subtasks,omitempty"`
+	Security                 *SecurityScheme           `json:"security,omitempty"`
 }
 
 type IssueResponseScheme struct {
diff --git a/pkg/infra/models/jira_issue_v3.go b/pkg/infra/models/jira_issue_v3.go
index 83242df..1c14bd5 100644
--- a/pkg/infra/models/jira_issue_v3.go
+++ b/pkg/infra/models/jira_issue_v3.go
@@ -86,6 +86,7 @@ type IssueFieldsScheme struct {
 	Components               []*ComponentScheme      `json:"components,omitempty"`
 	Creator                  *UserScheme             `json:"creator,omitempty"`
 	Reporter                 *UserScheme             `json:"reporter,omitempty"`
+	Assignee                 *UserScheme             `json:"assignee,omitempty"`
 	Resolution               *ResolutionScheme       `json:"resolution,omitempty"`
 	Resolutiondate           string                  `json:"resolutiondate,omitempty"`
 	Workratio                int                     `json:"workratio,omitempty"`
@@ -99,6 +100,7 @@ type IssueFieldsScheme struct {
 	Description              *CommentNodeScheme      `json:"description,omitempty"`
 	Comment                  *IssueCommentPageScheme `json:"comment,omitempty"`
 	Subtasks                 []*IssueScheme          `json:"subtasks,omitempty"`
+	Security                 *SecurityScheme         `json:"security,omitempty"`
 }
 
 type IssueTransitionScheme struct {
diff --git a/pkg/infra/models/jira_security.go b/pkg/infra/models/jira_security.go
new file mode 100644
index 0000000..abeba40
--- /dev/null
+++ b/pkg/infra/models/jira_security.go
@@ -0,0 +1,8 @@
+package models
+
+type SecurityScheme struct {
+	Self        string `json:"self,omitempty"`
+	ID          string `json:"id,omitempty"`
+	Name        string `json:"name,omitempty"`
+	Description string `json:"description,omitempty"`
+}
diff --git a/pkg/infra/models/sm_request_field.go b/pkg/infra/models/sm_request_field.go
new file mode 100644
index 0000000..77995eb
--- /dev/null
+++ b/pkg/infra/models/sm_request_field.go
@@ -0,0 +1,440 @@
+package models
+
+import (
+	"encoding/json"
+	"fmt"
+	"github.com/imdario/mergo"
+	"time"
+)
+
+type CreateCustomerRequestPayloadScheme struct {
+	RequestParticipants []string `json:"requestParticipants,omitempty"`
+	ServiceDeskID       string   `json:"serviceDeskId,omitempty"`
+	RequestTypeID       string   `json:"requestTypeId,omitempty"`
+}
+
+func (c *CreateCustomerRequestPayloadScheme) MergeFields(fields *CustomerRequestFields) (map[string]interface{}, error) {
+
+	if fields == nil {
+		return nil, fmt.Errorf("error, please provide a value *CustomFields pointer")
+	}
+
+	if len(fields.Fields) == 0 {
+		return nil, fmt.Errorf("error!, the Fields tag does not contains custom fields")
+	}
+
+	//Convert the IssueScheme struct to map[string]interface{}
+	issueSchemeAsBytes, err := json.Marshal(c)
+	if err != nil {
+		return nil, err
+	}
+
+	issueSchemeAsMap := make(map[string]interface{})
+	if err := json.Unmarshal(issueSchemeAsBytes, &issueSchemeAsMap); err != nil {
+		return nil, err
+	}
+
+	//For each customField created, merge it into the eAsMap
+	for _, field := range fields.Fields {
+
+		if err := mergo.Merge(&issueSchemeAsMap, field, mergo.WithOverride); err != nil {
+			return nil, err
+		}
+	}
+
+	return issueSchemeAsMap, nil
+}
+
+type CustomerRequestFields struct{ Fields []map[string]interface{} }
+
+func (c *CustomerRequestFields) Attachments(attachments []string) error {
+
+	if len(attachments) == 0 {
+		return fmt.Errorf("error, please provide a valid attachments values")
+	}
+
+	var fieldNode = map[string]interface{}{}
+	fieldNode["attachments"] = attachments
+
+	var fieldsNode = map[string]interface{}{}
+	fieldsNode["requestFieldValues"] = fieldNode
+
+	c.Fields = append(c.Fields, fieldsNode)
+	return nil
+}
+
+func (c *CustomerRequestFields) Labels(labels []string) error {
+
+	if len(labels) == 0 {
+		return fmt.Errorf("error, please provide a valid labels values")
+	}
+
+	var fieldNode = map[string]interface{}{}
+	fieldNode["labels"] = labels
+
+	var fieldsNode = map[string]interface{}{}
+	fieldsNode["requestFieldValues"] = fieldNode
+
+	c.Fields = append(c.Fields, fieldsNode)
+	return nil
+}
+
+func (c *CustomerRequestFields) Components(components []string) error {
+
+	if len(components) == 0 {
+		return fmt.Errorf("error, please provide a valid components values")
+	}
+
+	var componentNode []map[string]interface{}
+	for _, component := range components {
+
+		var groupNode = map[string]interface{}{}
+		groupNode["name"] = component
+
+		componentNode = append(componentNode, groupNode)
+	}
+
+	var fieldNode = map[string]interface{}{}
+	fieldNode["components"] = componentNode
+
+	var fieldsNode = map[string]interface{}{}
+	fieldsNode["requestFieldValues"] = fieldNode
+
+	c.Fields = append(c.Fields, fieldsNode)
+	return nil
+}
+
+func (c *CustomerRequestFields) Groups(customFieldID string, groups []string) (err error) {
+
+	if len(customFieldID) == 0 {
+		return fmt.Errorf("error, please provide a valid customFieldID value")
+	}
+
+	if len(groups) == 0 {
+		return fmt.Errorf("error, please provide a valid groups value")
+	}
+
+	var groupsNode []map[string]interface{}
+	for _, group := range groups {
+
+		var groupNode = map[string]interface{}{}
+		groupNode["name"] = group
+
+		groupsNode = append(groupsNode, groupNode)
+	}
+
+	var fieldNode = map[string]interface{}{}
+	fieldNode[customFieldID] = groupsNode
+
+	var fieldsNode = map[string]interface{}{}
+	fieldsNode["requestFieldValues"] = fieldNode
+
+	c.Fields = append(c.Fields, fieldsNode)
+	return
+}
+
+func (c *CustomerRequestFields) Group(customFieldID, group string) (err error) {
+
+	if len(customFieldID) == 0 {
+		return fmt.Errorf("error, please provide a valid customFieldID value")
+	}
+
+	if len(group) == 0 {
+		return fmt.Errorf("error, please provide a valid group value")
+	}
+
+	var groupNode = map[string]interface{}{}
+	groupNode["name"] = group
+
+	var fieldNode = map[string]interface{}{}
+	fieldNode[customFieldID] = groupNode
+
+	var fieldsNode = map[string]interface{}{}
+	fieldsNode["requestFieldValues"] = fieldNode
+
+	c.Fields = append(c.Fields, fieldsNode)
+	return
+}
+
+func (c *CustomerRequestFields) URL(customFieldID, URL string) (err error) {
+
+	if len(customFieldID) == 0 {
+		return fmt.Errorf("error, please provide a valid customFieldID value")
+	}
+
+	if len(URL) == 0 {
+		return fmt.Errorf("error, please provide a valid URL value")
+	}
+
+	var urlNode = map[string]interface{}{}
+	urlNode[customFieldID] = URL
+
+	var fieldsNode = map[string]interface{}{}
+	fieldsNode["requestFieldValues"] = urlNode
+
+	c.Fields = append(c.Fields, fieldsNode)
+	return
+}
+
+func (c *CustomerRequestFields) Text(customFieldID, textValue string) (err error) {
+
+	if len(customFieldID) == 0 {
+		return fmt.Errorf("error, please provide a valid customFieldID value")
+	}
+
+	if len(textValue) == 0 {
+		return fmt.Errorf("error, please provide a valid textValue value")
+	}
+
+	var urlNode = map[string]interface{}{}
+	urlNode[customFieldID] = textValue
+
+	var fieldsNode = map[string]interface{}{}
+	fieldsNode["requestFieldValues"] = urlNode
+
+	c.Fields = append(c.Fields, fieldsNode)
+	return
+}
+
+func (c *CustomerRequestFields) DateTime(customFieldID string, dateValue time.Time) (err error) {
+
+	if len(customFieldID) == 0 {
+		return fmt.Errorf("error, please provide a valid customFieldID value")
+	}
+
+	if dateValue.IsZero() {
+		return fmt.Errorf("error, please provide a valid dateValue value")
+	}
+
+	var dateNode = map[string]interface{}{}
+	dateNode[customFieldID] = dateValue.Format(time.RFC3339)
+
+	var fieldsNode = map[string]interface{}{}
+	fieldsNode["requestFieldValues"] = dateNode
+
+	c.Fields = append(c.Fields, fieldsNode)
+	return
+}
+
+func (c *CustomerRequestFields) Date(customFieldID string, dateTimeValue time.Time) (err error) {
+
+	if len(customFieldID) == 0 {
+		return fmt.Errorf("error, please provide a valid customFieldID value")
+	}
+
+	if dateTimeValue.IsZero() {
+		return fmt.Errorf("error, please provide a valid dateValue value")
+	}
+
+	var dateTimeNode = map[string]interface{}{}
+	dateTimeNode[customFieldID] = dateTimeValue.Format("2006-01-02")
+
+	var fieldsNode = map[string]interface{}{}
+	fieldsNode["requestFieldValues"] = dateTimeNode
+
+	c.Fields = append(c.Fields, fieldsNode)
+	return
+}
+
+func (c *CustomerRequestFields) MultiSelect(customFieldID string, options []string) (err error) {
+
+	if len(customFieldID) == 0 {
+		return fmt.Errorf("error, please provide a valid customFieldID value")
+	}
+
+	if len(options) == 0 {
+		return fmt.Errorf("error, please provide a valid options value")
+	}
+
+	var groupsNode []map[string]interface{}
+	for _, group := range options {
+
+		var groupNode = map[string]interface{}{}
+		groupNode["value"] = group
+
+		groupsNode = append(groupsNode, groupNode)
+	}
+
+	var fieldNode = map[string]interface{}{}
+	fieldNode[customFieldID] = groupsNode
+
+	var fieldsNode = map[string]interface{}{}
+	fieldsNode["requestFieldValues"] = fieldNode
+
+	c.Fields = append(c.Fields, fieldsNode)
+	return
+}
+
+func (c *CustomerRequestFields) Select(customFieldID string, option string) (err error) {
+
+	if len(customFieldID) == 0 {
+		return fmt.Errorf("error, please provide a valid customFieldID value")
+	}
+
+	if len(option) == 0 {
+		return fmt.Errorf("error, please provide a valid option value")
+	}
+
+	var selectNode = map[string]interface{}{}
+	selectNode["value"] = option
+
+	var fieldNode = map[string]interface{}{}
+	fieldNode[customFieldID] = selectNode
+
+	var fieldsNode = map[string]interface{}{}
+	fieldsNode["requestFieldValues"] = fieldNode
+
+	c.Fields = append(c.Fields, fieldsNode)
+	return
+}
+
+func (c *CustomerRequestFields) RadioButton(customFieldID, button string) (err error) {
+
+	if len(customFieldID) == 0 {
+		return fmt.Errorf("error, please provide a valid customFieldID value")
+	}
+
+	if len(button) == 0 {
+		return fmt.Errorf("error, please provide a button option value")
+	}
+
+	var selectNode = map[string]interface{}{}
+	selectNode["value"] = button
+
+	var fieldNode = map[string]interface{}{}
+	fieldNode[customFieldID] = selectNode
+
+	var fieldsNode = map[string]interface{}{}
+	fieldsNode["requestFieldValues"] = fieldNode
+
+	c.Fields = append(c.Fields, fieldsNode)
+	return
+}
+
+func (c *CustomerRequestFields) User(customFieldID string, accountID string) (err error) {
+
+	if len(customFieldID) == 0 {
+		return fmt.Errorf("error, please provide a valid customFieldID value")
+	}
+
+	if len(accountID) == 0 {
+		return fmt.Errorf("error, please provide a accountID option value")
+	}
+
+	var userNode = map[string]interface{}{}
+	userNode["accountId"] = accountID
+
+	var fieldNode = map[string]interface{}{}
+	fieldNode[customFieldID] = userNode
+
+	var fieldsNode = map[string]interface{}{}
+	fieldsNode["requestFieldValues"] = fieldNode
+
+	c.Fields = append(c.Fields, fieldsNode)
+	return
+}
+
+func (c *CustomerRequestFields) Users(customFieldID string, accountIDs []string) (err error) {
+
+	if len(customFieldID) == 0 {
+		return fmt.Errorf("error, please provide a valid customFieldID value")
+	}
+
+	if len(accountIDs) == 0 {
+		return fmt.Errorf("error, please provide a accountIDs value")
+	}
+
+	var accountsNode []map[string]interface{}
+	for _, accountID := range accountIDs {
+
+		var groupNode = map[string]interface{}{}
+		groupNode["accountId"] = accountID
+
+		accountsNode = append(accountsNode, groupNode)
+	}
+
+	var fieldNode = map[string]interface{}{}
+	fieldNode[customFieldID] = accountsNode
+
+	var fieldsNode = map[string]interface{}{}
+	fieldsNode["requestFieldValues"] = fieldNode
+
+	c.Fields = append(c.Fields, fieldsNode)
+	return
+}
+
+func (c *CustomerRequestFields) Number(customFieldID string, numberValue float64) (err error) {
+
+	if len(customFieldID) == 0 {
+		return fmt.Errorf("error, please provide a valid customFieldID value")
+	}
+
+	var urlNode = map[string]interface{}{}
+	urlNode[customFieldID] = numberValue
+
+	var fieldsNode = map[string]interface{}{}
+	fieldsNode["requestFieldValues"] = urlNode
+
+	c.Fields = append(c.Fields, fieldsNode)
+	return
+}
+
+func (c *CustomerRequestFields) CheckBox(customFieldID string, options []string) (err error) {
+
+	if len(customFieldID) == 0 {
+		return fmt.Errorf("error, please provide a valid customFieldID value")
+	}
+
+	if len(options) == 0 {
+		return fmt.Errorf("error, please provide a valid options value")
+	}
+
+	var groupsNode []map[string]interface{}
+	for _, group := range options {
+
+		var groupNode = map[string]interface{}{}
+		groupNode["value"] = group
+
+		groupsNode = append(groupsNode, groupNode)
+	}
+
+	var fieldNode = map[string]interface{}{}
+	fieldNode[customFieldID] = groupsNode
+
+	var fieldsNode = map[string]interface{}{}
+	fieldsNode["requestFieldValues"] = fieldNode
+
+	c.Fields = append(c.Fields, fieldsNode)
+	return
+}
+
+func (c *CustomerRequestFields) Cascading(customFieldID, parent, child string) (err error) {
+
+	if len(customFieldID) == 0 {
+		return fmt.Errorf("error, please provide a valid customFieldID value")
+	}
+
+	if len(parent) == 0 {
+		return fmt.Errorf("error, please provide a parent value")
+	}
+
+	if len(child) == 0 {
+		return fmt.Errorf("error, please provide a child value")
+	}
+
+	var childNode = map[string]interface{}{}
+	childNode["value"] = child
+
+	var parentNode = map[string]interface{}{}
+	parentNode["value"] = parent
+	parentNode["child"] = childNode
+
+	var fieldNode = map[string]interface{}{}
+	fieldNode[customFieldID] = parentNode
+
+	var fieldsNode = map[string]interface{}{}
+	fieldsNode["requestFieldValues"] = fieldNode
+
+	c.Fields = append(c.Fields, fieldsNode)
+	return
+}


Test patch:
diff --git a/jira/sm/request_test.go b/jira/sm/request_test.go
index edc57cd..4dcd71d 100644
--- a/jira/sm/request_test.go
+++ b/jira/sm/request_test.go
@@ -3,12 +3,195 @@ package sm
 import (
 	"context"
 	"fmt"
+	model "github.com/ctreminiom/go-atlassian/pkg/infra/models"
 	"github.com/stretchr/testify/assert"
 	"net/http"
 	"net/url"
 	"testing"
 )
 
+func TestRequestService_Create(t *testing.T) {
+
+	var customFieldMockedWithFields = model.CustomerRequestFields{}
+
+	// Add a new custom field
+	err := customFieldMockedWithFields.Text("summary", "Request JSD help via REST")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	err = customFieldMockedWithFields.Text("description", "I need a new *mouse* for my Mac")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	var customFieldMockedWithoutFields = model.CustomerRequestFields{}
+
+	testCases := []struct {
+		name               string
+		payload            *model.CreateCustomerRequestPayloadScheme
+		fields             *model.CustomerRequestFields
+		mockFile           string
+		wantHTTPMethod     string
+		endpoint           string
+		context            context.Context
+		wantHTTPCodeReturn int
+		wantErr            bool
+	}{
+		{
+			name: "CreateCustomerRequestWhenTheParametersAreCorrect",
+			payload: &model.CreateCustomerRequestPayloadScheme{
+				RequestParticipants: []string{"sample-uuid", "sample-uuid"},
+				ServiceDeskID:       "300202",
+				RequestTypeID:       "211991",
+			},
+			fields:             &customFieldMockedWithFields,
+			mockFile:           "./mocks/get-customer-request.json",
+			wantHTTPMethod:     http.MethodPost,
+			endpoint:           "/rest/servicedeskapi/request",
+			context:            context.Background(),
+			wantHTTPCodeReturn: http.StatusOK,
+			wantErr:            false,
+		},
+
+		{
+			name: "CreateCustomerRequestWhenTheFieldsDoNotContainValues",
+			payload: &model.CreateCustomerRequestPayloadScheme{
+				RequestParticipants: []string{"sample-uuid", "sample-uuid"},
+				ServiceDeskID:       "300202",
+				RequestTypeID:       "211991",
+			},
+			fields:             &customFieldMockedWithoutFields,
+			mockFile:           "./mocks/get-customer-request.json",
+			wantHTTPMethod:     http.MethodPost,
+			endpoint:           "/rest/servicedeskapi/request",
+			context:            context.Background(),
+			wantHTTPCodeReturn: http.StatusOK,
+			wantErr:            true,
+		},
+
+		{
+			name: "CreateCustomerRequestWhenTheResponseIsEmpty",
+			payload: &model.CreateCustomerRequestPayloadScheme{
+				RequestParticipants: []string{"sample-uuid", "sample-uuid"},
+				ServiceDeskID:       "300202",
+				RequestTypeID:       "211991",
+			},
+			fields:             &customFieldMockedWithFields,
+			mockFile:           "./mocks/empty_json.json",
+			wantHTTPMethod:     http.MethodPost,
+			endpoint:           "/rest/servicedeskapi/request",
+			context:            context.Background(),
+			wantHTTPCodeReturn: http.StatusOK,
+			wantErr:            true,
+		},
+
+		{
+			name: "CreateCustomerRequestWhenTheContextIsNotProvided",
+			payload: &model.CreateCustomerRequestPayloadScheme{
+				RequestParticipants: []string{"sample-uuid", "sample-uuid"},
+				ServiceDeskID:       "300202",
+				RequestTypeID:       "211991",
+			},
+			fields:             &customFieldMockedWithFields,
+			mockFile:           "./mocks/get-customer-request.json",
+			wantHTTPMethod:     http.MethodPost,
+			endpoint:           "/rest/servicedeskapi/request",
+			context:            nil,
+			wantHTTPCodeReturn: http.StatusOK,
+			wantErr:            true,
+		},
+
+		{
+			name: "CreateCustomerRequestWhenTheFieldsAreNotProvided",
+			payload: &model.CreateCustomerRequestPayloadScheme{
+				RequestParticipants: []string{"sample-uuid", "sample-uuid"},
+				ServiceDeskID:       "300202",
+				RequestTypeID:       "211991",
+			},
+			fields:             nil,
+			mockFile:           "./mocks/get-customer-request.json",
+			wantHTTPMethod:     http.MethodPost,
+			endpoint:           "/rest/servicedeskapi/request",
+			context:            context.Background(),
+			wantHTTPCodeReturn: http.StatusOK,
+			wantErr:            true,
+		},
+	}
+
+	for _, testCase := range testCases {
+		t.Run(testCase.name, func(t *testing.T) {
+
+			//Init a new HTTP mock server
+			mockOptions := mockServerOptions{
+				Endpoint:           testCase.endpoint,
+				MockFilePath:       testCase.mockFile,
+				MethodAccepted:     testCase.wantHTTPMethod,
+				ResponseCodeWanted: testCase.wantHTTPCodeReturn,
+			}
+
+			mockServer, err := startMockServer(&mockOptions)
+			if err != nil {
+				t.Fatal(err)
+			}
+
+			defer mockServer.Close()
+
+			//Init the library instance
+			mockClient, err := startMockClient(mockServer.URL)
+			if err != nil {
+				t.Fatal(err)
+			}
+
+			service := &RequestService{client: mockClient}
+			gotResult, gotResponse, err := service.Create(testCase.context, testCase.payload, testCase.fields)
+
+			if testCase.wantErr {
+
+				if err != nil {
+					t.Logf("error returned: %v", err.Error())
+				}
+				assert.Error(t, err)
+
+				if gotResponse != nil {
+					t.Logf("HTTP Code Wanted: %v, HTTP Code Returned: %v", testCase.wantHTTPCodeReturn, gotResponse.Code)
+				}
+			} else {
+
+				assert.NoError(t, err)
+				assert.NotEqual(t, gotResponse, nil)
+				assert.NotEqual(t, gotResult, nil)
+
+				apiEndpoint, err := url.Parse(gotResponse.Endpoint)
+				if err != nil {
+					t.Fatal(err)
+				}
+
+				var endpointToAssert string
+
+				if apiEndpoint.Query().Encode() != "" {
+					endpointToAssert = fmt.Sprintf("%v?%v", apiEndpoint.Path, apiEndpoint.Query().Encode())
+				} else {
+					endpointToAssert = apiEndpoint.Path
+				}
+
+				t.Logf("HTTP Endpoint Wanted: %v, HTTP Endpoint Returned: %v", testCase.endpoint, endpointToAssert)
+				assert.Equal(t, testCase.endpoint, endpointToAssert)
+
+				t.Logf("HTTP Code Wanted: %v, HTTP Code Returned: %v", testCase.wantHTTPCodeReturn, gotResponse.Code)
+				assert.Equal(t, gotResponse.Code, testCase.wantHTTPCodeReturn)
+
+				t.Log("-------------------------------------------")
+				t.Logf("Custom Request Issue Key: %v", gotResult.IssueKey)
+				t.Logf("Custom Request Type Name: %v", gotResult.RequestType)
+				t.Log("-------------------------------------------")
+			}
+
+		})
+	}
+
+}
+
 func TestRequestService_Gets(t *testing.T) {
 
 	testCases := []struct {