๐Ÿ“™
Request

Get customer requests

This method returns all customer requests for the user executing the query.
package main
โ€‹
import (
"context"
"encoding/json"
"github.com/ctreminiom/go-atlassian/jira/sm"
"log"
"os"
)
โ€‹
func main() {
โ€‹
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
โ€‹
atlassian, err := sm.New(nil, host)
if err != nil {
return
}
โ€‹
atlassian.Auth.SetBasicAuth(mail, token)
atlassian.Auth.SetUserAgent("curl/7.54.0")
โ€‹
options := &sm.RequestGetOptionsScheme{
SearchTerm: "",
RequestOwnerships: []string{"OWNED_REQUESTS"},
RequestStatus: "ALL_REQUESTS",
ApprovalStatus: "",
OrganizationId: 0,
ServiceDeskID: 0,
RequestTypeID: 0,
Expand: []string{"serviceDesk", "requestType", "status", "action"},
}
โ€‹
customerRequests, response, err := atlassian.Request.Gets(context.Background(), options, 0, 50)
if err != nil {
if response != nil {
log.Println("Response HTTP Response", response.Bytes.String())
log.Println("HTTP Endpoint Used", response.Endpoint)
}
log.Fatal(err)
}
โ€‹
log.Println("Response HTTP Code", response.Code)
log.Println("HTTP Endpoint Used", response.Endpoint)
โ€‹
for _, customRequest := range customerRequests.Values {
โ€‹
dataAsJson, err := json.MarshalIndent(customRequest, "", "\t")
if err != nil {
log.Fatal(err)
}
โ€‹
log.Println(string(dataAsJson))
}
โ€‹
}

Get customer request by id or key

This method returns a customer request.
package main
โ€‹
import (
"context"
"encoding/json"
"github.com/ctreminiom/go-atlassian/jira/sm"
"log"
"os"
)
โ€‹
func main() {
โ€‹
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
โ€‹
atlassian, err := sm.New(nil, host)
if err != nil {
return
}
โ€‹
atlassian.Auth.SetBasicAuth(mail, token)
atlassian.Auth.SetUserAgent("curl/7.54.0")
โ€‹
var (
issueKey = "DESK-11"
expand = []string{"serviceDesk", "requestType"}
)
โ€‹
request, response, err := atlassian.Request.Get(context.Background(), issueKey, expand)
if err != nil {
if response != nil {
log.Println("Response HTTP Response", response.Bytes.String())
log.Println("HTTP Endpoint Used", response.Endpoint)
}
log.Fatal(err)
}
โ€‹
log.Println("Response HTTP Code", response.Code)
log.Println("HTTP Endpoint Used", response.Endpoint)
โ€‹
dataAsJson, err := json.MarshalIndent(request, "", "\t")
if err != nil {
log.Fatal(err)
}
โ€‹
log.Println(string(dataAsJson))
โ€‹
}

Subscribe

This method subscribes the user to receiving notifications from a customer request.
package main
โ€‹
import (
"context"
"github.com/ctreminiom/go-atlassian/jira/sm"
"log"
"os"
)
func main() {
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
atlassian, err := sm.New(nil, host)
if err != nil {
return
}
atlassian.Auth.SetBasicAuth(mail, token)
atlassian.Auth.SetUserAgent("curl/7.54.0")
response, err := atlassian.Request.Subscribe(context.Background(), "DUMMY-4")
if err != nil {
if response != nil {
log.Println("Response HTTP Response", response.Bytes.String())
log.Println("HTTP Endpoint Used", response.Endpoint)
}
log.Fatal(err)
}
log.Println("Response HTTP Code", response.Code)
log.Println("HTTP Endpoint Used", response.Endpoint)
}

Unsubscribe

This method unsubscribes the user from notifications from a customer request.
package main
โ€‹
import (
"context"
"github.com/ctreminiom/go-atlassian/jira/sm"
"log"
"os"
)
โ€‹
func main() {
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
atlassian, err := sm.New(nil, host)
if err != nil {
return
}
atlassian.Auth.SetBasicAuth(mail, token)
atlassian.Auth.SetUserAgent("curl/7.54.0")
response, err := atlassian.Request.Unsubscribe(context.Background(), "DUMMY-4")
if err != nil {
if response != nil {
log.Println("Response HTTP Response", string(response.Bytes.String()))
log.Println("HTTP Endpoint Used", response.Endpoint)
}
log.Fatal(err)
}
log.Println("Response HTTP Code", response.Code)
log.Println("HTTP Endpoint Used", response.Endpoint)
}
โ€‹

Get customer transitions

This method returns a list of transitions, the workflow processes that moves a customer request from one status to another, that the user can perform on a request. Use this method to provide a user with a list if the actions they can take on a customer request.
package main
โ€‹
import (
"context"
"github.com/ctreminiom/go-atlassian/jira/sm"
"log"
"os"
)
โ€‹
func main() {
โ€‹
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
โ€‹
atlassian, err := sm.New(nil, host)
if err != nil {
return
}
โ€‹
atlassian.Auth.SetBasicAuth(mail, token)
atlassian.Auth.SetUserAgent("curl/7.54.0")
โ€‹
var (
issueKeyOrID = "DESK-3"
start = 0
limit = 50
)
โ€‹
transitions, response, err := atlassian.Request.Transitions(context.Background(), issueKeyOrID, start, limit)
if err != nil {
if response != nil {
log.Println("Response HTTP Response", response.Bytes.String())
log.Println("HTTP Endpoint Used", response.Endpoint)
}
log.Fatal(err)
}
โ€‹
log.Println("Response HTTP Code", response.Code)
log.Println("HTTP Endpoint Used", response.Endpoint)
โ€‹
for _, transition := range transitions.Values {
log.Println(transition.ID, transition.Name)
}
}
โ€‹

Perform customer transition

This method performs a customer transition for a given request and transition. An optional comment can be included to provide a reason for the transition.
package main
โ€‹
import (
"context"
"github.com/ctreminiom/go-atlassian/jira/sm"
"log"
"os"
)
โ€‹
func main() {
โ€‹
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
โ€‹
atlassian, err := sm.New(nil, host)
if err != nil {
return
}
โ€‹
atlassian.Auth.SetBasicAuth(mail, token)
atlassian.Auth.SetUserAgent("curl/7.54.0")
โ€‹
var (
issueKeyOrID = "DESK-3"
transitionID = "921"
comment = "lorem"
)
โ€‹
response, err := atlassian.Request.Transition(context.Background(), issueKeyOrID, transitionID, comment)
if err != nil {
if response != nil {
log.Println("Response HTTP Response", response.Bytes.String())
log.Println("HTTP Endpoint Used", response.Endpoint)
}
log.Fatal(err)
}
โ€‹
log.Println("Response HTTP Code", response.Code)
log.Println("HTTP Endpoint Used", response.Endpoint)
}
โ€‹

Create Customer Request

This method creates a customer request at a service desk. The payload must include the service desk and customer request type, as well as any fields that are required for the request type. A list of the fields required by a customer request type can be obtained using the sm.RequestType.Fields method.
package main
โ€‹
import (
"context"
"fmt"
"github.com/ctreminiom/go-atlassian/jira/sm"
"github.com/ctreminiom/go-atlassian/pkg/infra/models"
"log"
"os"
"time"
)
โ€‹
func main() {
โ€‹
var (
host = os.Getenv("HOST")
mail = os.Getenv("MAIL")
token = os.Getenv("TOKEN")
)
โ€‹
atlassian, err := sm.New(nil, host)
if err != nil {
return
}
โ€‹
atlassian.Auth.SetBasicAuth(mail, token)
atlassian.Auth.SetUserAgent("curl/7.54.0")
โ€‹
form := &models.CustomerRequestFields{}
โ€‹
if err := form.Text("summary", "Summary Sample"); err != nil {
log.Fatal(err)
}
โ€‹
if err := form.Date("duedate", time.Now()); err != nil {
log.Fatal(err)
}
โ€‹
if err := form.Components([]string{"Intranet"}); err != nil {
log.Fatal(err)
}
โ€‹
if err := form.Labels([]string{"label-00", "label-01"}); err != nil {
log.Fatal(err)
}
โ€‹
payload := &models.CreateCustomerRequestPayloadScheme{
RequestParticipants: nil,
ServiceDeskID: "1",
RequestTypeID: "10",
}
โ€‹
ticket, response, err := atlassian.Request.Create(context.Background(), payload, form)
if err != nil {
log.Fatal(err)
}
โ€‹
log.Println("Response HTTP Code", response.Code)
log.Println("HTTP Endpoint Used", response.Endpoint)
โ€‹
fmt.Println("IssueID", ticket.IssueID)
fmt.Println("IssueKey", ticket.IssueKey)
fmt.Println("Reporter.EmailAddress", ticket.Reporter.EmailAddress)
fmt.Println("CreatedDate.Friendly", ticket.CreatedDate.Friendly)
โ€‹
for _, field := range ticket.RequestFieldValues {
fmt.Println(field)
}
}
Export as PDF
Copy link
On this page
Get customer requests
Get customer request by id or key
Subscribe
Unsubscribe
Get customer transitions
Perform customer transition
Create Customer Request