Repository: xanzy/go-gitlab
Pull request #1857 (2023-12-16 21:46:17)

Add Telegram service
Telegram integration support.

https://docs.gitlab.com/ee/api/integrations.html#telegram


Patch:
diff --git a/services.go b/services.go
index 0313ecc..f3c2c8d 100644
--- a/services.go
+++ b/services.go
@@ -1166,6 +1166,97 @@ type SetMattermostServiceOptions struct {
 	WikiPageChannel           *string `url:"wiki_page_channel,omitempty" json:"wiki_page_channel,omitempty"`
 }
 
+// MattermostSlashCommandsService represents Mattermost slash commands settings.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/integrations.html#mattermost-slash-commands
+type MattermostSlashCommandsService struct {
+	Service
+	Properties *MattermostSlashCommandsProperties `json:"properties"`
+}
+
+// MattermostSlashCommandsProperties represents Mattermost slash commands specific properties.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/integrations.html#mattermost-slash-commands
+type MattermostSlashCommandsProperties struct {
+	Token    string `json:"token"`
+	Username string `json:"username,omitempty"`
+}
+
+// GetMattermostSlashCommandsService gets Slack Mattermost commands service settings for a project.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/integrations.html#get-mattermost-slash-command-integration-settings
+func (s *ServicesService) GetMattermostSlashCommandsService(pid interface{}, options ...RequestOptionFunc) (*MattermostSlashCommandsService, *Response, error) {
+	project, err := parseID(pid)
+	if err != nil {
+		return nil, nil, err
+	}
+	u := fmt.Sprintf("projects/%s/services/mattermost-slash-commands", PathEscape(project))
+
+	req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
+	if err != nil {
+		return nil, nil, err
+	}
+
+	svc := new(MattermostSlashCommandsService)
+	resp, err := s.client.Do(req, svc)
+	if err != nil {
+		return nil, resp, err
+	}
+
+	return svc, resp, nil
+}
+
+// SetMattermostSlashCommandsServiceOptions represents the available SetSlackSlashCommandsService()
+// options.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/integrations.html#get-mattermost-slash-command-integration-settings
+type SetMattermostSlashCommandsServiceOptions struct {
+	Token    *string `url:"token,omitempty" json:"token,omitempty"`
+	Username *string `url:"username,omitempty" json:"username,omitempty"`
+}
+
+// SetMattermostSlashCommandsService sets Mattermost slash commands service for a project
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/integrations.html#createedit-mattermost-slash-command-integration
+func (s *ServicesService) SetMattermostSlashCommandsService(pid interface{}, opt *SetMattermostSlashCommandsServiceOptions, options ...RequestOptionFunc) (*Response, error) {
+	project, err := parseID(pid)
+	if err != nil {
+		return nil, err
+	}
+	u := fmt.Sprintf("projects/%s/services/mattermost-slash-commands", PathEscape(project))
+
+	req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
+	if err != nil {
+		return nil, err
+	}
+
+	return s.client.Do(req, nil)
+}
+
+// DeleteMattermostSlashCommandsService deletes Mattermost slash commands service for project.
+//
+// GitLab API docs:
+// https://docs.gitlab.com/ee/api/integrations.html#disable-mattermost-slash-command-integration
+func (s *ServicesService) DeleteMattermostSlashCommandsService(pid interface{}, options ...RequestOptionFunc) (*Response, error) {
+	project, err := parseID(pid)
+	if err != nil {
+		return nil, err
+	}
+	u := fmt.Sprintf("projects/%s/services/mattermost-slash-commands", PathEscape(project))
+
+	req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
+	if err != nil {
+		return nil, err
+	}
+
+	return s.client.Do(req, nil)
+}
+
 // SetMattermostService sets Mattermost service for a project.
 //
 // GitLab API docs:
@@ -1725,41 +1816,42 @@ func (s *ServicesService) DeleteSlackSlashCommandsService(pid interface{}, optio
 	return s.client.Do(req, nil)
 }
 
-// MattermostSlashCommandsService represents Mattermost slash commands settings.
+// TelegramService represents Telegram service settings.
 //
-// GitLab API docs:
-// https://docs.gitlab.com/ee/api/integrations.html#mattermost-slash-commands
-type MattermostSlashCommandsService struct {
+// Gitlab API docs:
+// https://docs.gitlab.com/ee/api/integrations.html#telegram
+type TelegramService struct {
 	Service
-	Properties *MattermostSlashCommandsProperties `json:"properties"`
+	Properties *TelegramServiceProperties `json:"properties"`
 }
 
-// MattermostSlashCommandsProperties represents Mattermost slash commands specific properties.
+// TelegramServiceProperties represents Telegram specific properties.
 //
 // GitLab API docs:
-// https://docs.gitlab.com/ee/api/integrations.html#mattermost-slash-commands
-type MattermostSlashCommandsProperties struct {
-	Token    string `json:"token"`
-	Username string `json:"username,omitempty"`
+// https://docs.gitlab.com/ee/api/integrations.html#set-up-telegram
+type TelegramServiceProperties struct {
+	Room                      string `json:"room"`
+	NotifyOnlyBrokenPipelines bool   `json:"notify_only_broken_pipelines"`
+	BranchesToBeNotified      string `json:"branches_to_be_notified"`
 }
 
-// GetMattermostSlashCommandsService gets Slack Mattermost commands service settings for a project.
+// GetTelegramService gets MicrosoftTeams service settings for a project.
 //
 // GitLab API docs:
-// https://docs.gitlab.com/ee/api/integrations.html#get-mattermost-slash-command-integration-settings
-func (s *ServicesService) GetMattermostSlashCommandsService(pid interface{}, options ...RequestOptionFunc) (*MattermostSlashCommandsService, *Response, error) {
+// https://docs.gitlab.com/ee/api/integrations.html#get-telegram-settings
+func (s *ServicesService) GetTelegramService(pid interface{}, options ...RequestOptionFunc) (*TelegramService, *Response, error) {
 	project, err := parseID(pid)
 	if err != nil {
 		return nil, nil, err
 	}
-	u := fmt.Sprintf("projects/%s/services/mattermost-slash-commands", PathEscape(project))
+	u := fmt.Sprintf("projects/%s/services/telegram", PathEscape(project))
 
 	req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
 	if err != nil {
 		return nil, nil, err
 	}
 
-	svc := new(MattermostSlashCommandsService)
+	svc := new(TelegramService)
 	resp, err := s.client.Do(req, svc)
 	if err != nil {
 		return nil, resp, err
@@ -1768,26 +1860,37 @@ func (s *ServicesService) GetMattermostSlashCommandsService(pid interface{}, opt
 	return svc, resp, nil
 }
 
-// SetMattermostSlashCommandsServiceOptions represents the available SetSlackSlashCommandsService()
+// SetTelegramServiceOptions represents the available SetTelegramService()
 // options.
 //
 // GitLab API docs:
-// https://docs.gitlab.com/ee/api/integrations.html#get-mattermost-slash-command-integration-settings
-type SetMattermostSlashCommandsServiceOptions struct {
-	Token    *string `url:"token,omitempty" json:"token,omitempty"`
-	Username *string `url:"username,omitempty" json:"username,omitempty"`
+// https://docs.gitlab.com/ee/api/integrations.html#set-up-telegram
+type SetTelegramServiceOptions struct {
+	Token                     *string `url:"token,omitempty" json:"token,omitempty"`
+	Room                      *string `url:"room,omitempty" json:"room,omitempty"`
+	NotifyOnlyBrokenPipelines *bool   `url:"notify_only_broken_pipelines,omitempty" json:"notify_only_broken_pipelines,omitempty"`
+	BranchesToBeNotified      *string `url:"branches_to_be_notified,omitempty" json:"branches_to_be_notified,omitempty"`
+	PushEvents                *bool   `url:"push_events,omitempty" json:"push_events,omitempty"`
+	IssuesEvents              *bool   `url:"issues_events,omitempty" json:"issues_events,omitempty"`
+	ConfidentialIssuesEvents  *bool   `url:"confidential_issues_events,omitempty" json:"confidential_issues_events,omitempty"`
+	MergeRequestsEvents       *bool   `url:"merge_requests_events,omitempty" json:"merge_requests_events,omitempty"`
+	TagPushEvents             *bool   `url:"tag_push_events,omitempty" json:"tag_push_events,omitempty"`
+	NoteEvents                *bool   `url:"note_events,omitempty" json:"note_events,omitempty"`
+	ConfidentialNoteEvents    *bool   `url:"confidential_note_events,omitempty" json:"confidential_note_events,omitempty"`
+	PipelineEvents            *bool   `url:"pipeline_events,omitempty" json:"pipeline_events,omitempty"`
+	WikiPageEvents            *bool   `url:"wiki_page_events,omitempty" json:"wiki_page_events,omitempty"`
 }
 
-// SetMattermostSlashCommandsService sets Mattermost slash commands service for a project
+// SetTelegramService sets Telegram service for a project
 //
 // GitLab API docs:
-// https://docs.gitlab.com/ee/api/integrations.html#createedit-mattermost-slash-command-integration
-func (s *ServicesService) SetMattermostSlashCommandsService(pid interface{}, opt *SetMattermostSlashCommandsServiceOptions, options ...RequestOptionFunc) (*Response, error) {
+// https://docs.gitlab.com/ee/api/integrations.html#set-up-telegram
+func (s *ServicesService) SetTelegramService(pid interface{}, opt *SetTelegramServiceOptions, options ...RequestOptionFunc) (*Response, error) {
 	project, err := parseID(pid)
 	if err != nil {
 		return nil, err
 	}
-	u := fmt.Sprintf("projects/%s/services/mattermost-slash-commands", PathEscape(project))
+	u := fmt.Sprintf("projects/%s/services/telegram", PathEscape(project))
 
 	req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
 	if err != nil {
@@ -1797,16 +1900,16 @@ func (s *ServicesService) SetMattermostSlashCommandsService(pid interface{}, opt
 	return s.client.Do(req, nil)
 }
 
-// DeleteMattermostSlashCommandsService deletes Mattermost slash commands service for project.
+// DeleteTelegramService deletes Telegram service for project.
 //
 // GitLab API docs:
-// https://docs.gitlab.com/ee/api/integrations.html#disable-mattermost-slash-command-integration
-func (s *ServicesService) DeleteMattermostSlashCommandsService(pid interface{}, options ...RequestOptionFunc) (*Response, error) {
+// https://docs.gitlab.com/ee/api/integrations.html#disable-telegram
+func (s *ServicesService) DeleteTelegramService(pid interface{}, options ...RequestOptionFunc) (*Response, error) {
 	project, err := parseID(pid)
 	if err != nil {
 		return nil, err
 	}
-	u := fmt.Sprintf("projects/%s/services/mattermost-slash-commands", PathEscape(project))
+	u := fmt.Sprintf("projects/%s/services/telegram", PathEscape(project))
 
 	req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
 	if err != nil {


Test patch:
diff --git a/services_test.go b/services_test.go
index fe8a8d4..c3c9acc 100644
--- a/services_test.go
+++ b/services_test.go
@@ -21,6 +21,7 @@ import (
 	"net/http"
 	"reflect"
 	"testing"
+	"time"
 )
 
 func TestListServices(t *testing.T) {
@@ -478,6 +479,55 @@ func TestDeleteMattermostService(t *testing.T) {
 	}
 }
 
+func TestGetMattermostSlashCommandsService(t *testing.T) {
+	mux, client := setup(t)
+
+	mux.HandleFunc("/api/v4/projects/1/services/mattermost-slash-commands", func(w http.ResponseWriter, r *http.Request) {
+		testMethod(t, r, http.MethodGet)
+		fmt.Fprint(w, `{"id":1}`)
+	})
+	want := &MattermostSlashCommandsService{Service: Service{ID: 1}}
+
+	service, _, err := client.Services.GetMattermostSlashCommandsService(1)
+	if err != nil {
+		t.Fatalf("Services.mattermost-slash-commands returns an error: %v", err)
+	}
+	if !reflect.DeepEqual(want, service) {
+		t.Errorf("Services.mattermost-slash-commands returned %+v, want %+v", service, want)
+	}
+}
+
+func TestSetMattermostSlashCommandsService(t *testing.T) {
+	mux, client := setup(t)
+
+	mux.HandleFunc("/api/v4/projects/1/services/mattermost-slash-commands", func(w http.ResponseWriter, r *http.Request) {
+		testMethod(t, r, http.MethodPut)
+	})
+
+	opt := &SetMattermostSlashCommandsServiceOptions{
+		Token:    Ptr("token"),
+		Username: Ptr("username"),
+	}
+
+	_, err := client.Services.SetMattermostSlashCommandsService(1, opt)
+	if err != nil {
+		t.Fatalf("Services.SetMattermostSlashCommandsService returns an error: %v", err)
+	}
+}
+
+func TestDeleteMattermostSlashCommandsService(t *testing.T) {
+	mux, client := setup(t)
+
+	mux.HandleFunc("/api/v4/projects/1/services/mattermost-slash-commands", func(w http.ResponseWriter, r *http.Request) {
+		testMethod(t, r, http.MethodDelete)
+	})
+
+	_, err := client.Services.DeleteMattermostSlashCommandsService(1)
+	if err != nil {
+		t.Fatalf("Services.DeleteMattermostSlashCommandsService returns an error: %v", err)
+	}
+}
+
 func TestGetPipelinesEmailService(t *testing.T) {
 	mux, client := setup(t)
 
@@ -627,150 +677,222 @@ func TestDeleteSlackService(t *testing.T) {
 	}
 }
 
-func TestGetYouTrackService(t *testing.T) {
+func TestGetSlackSlashCommandsService(t *testing.T) {
 	mux, client := setup(t)
 
-	mux.HandleFunc("/api/v4/projects/1/services/youtrack", func(w http.ResponseWriter, r *http.Request) {
+	mux.HandleFunc("/api/v4/projects/1/services/slack-slash-commands", func(w http.ResponseWriter, r *http.Request) {
 		testMethod(t, r, http.MethodGet)
 		fmt.Fprint(w, `{"id":1}`)
 	})
-	want := &YouTrackService{Service: Service{ID: 1}}
+	want := &SlackSlashCommandsService{Service: Service{ID: 1}}
 
-	service, _, err := client.Services.GetYouTrackService(1)
+	service, _, err := client.Services.GetSlackSlashCommandsService(1)
 	if err != nil {
-		t.Fatalf("Services.GetYouTrackService returns an error: %v", err)
+		t.Fatalf("Services.GetSlackSlashCommandsService returns an error: %v", err)
 	}
 	if !reflect.DeepEqual(want, service) {
-		t.Errorf("Services.GetYouTrackService returned %+v, want %+v", service, want)
+		t.Errorf("Services.GetSlackSlashCommandsService returned %+v, want %+v", service, want)
 	}
 }
 
-func TestSetYouTrackService(t *testing.T) {
+func TestSetSlackSlashCommandsService(t *testing.T) {
 	mux, client := setup(t)
 
-	mux.HandleFunc("/api/v4/projects/1/services/youtrack", func(w http.ResponseWriter, r *http.Request) {
+	mux.HandleFunc("/api/v4/projects/1/services/slack-slash-commands", func(w http.ResponseWriter, r *http.Request) {
 		testMethod(t, r, http.MethodPut)
 	})
 
-	opt := &SetYouTrackServiceOptions{
-		IssuesURL:   Ptr("https://example.org/youtrack/issue/:id"),
-		ProjectURL:  Ptr("https://example.org/youtrack/projects/1"),
-		Description: Ptr("description"),
-		PushEvents:  Ptr(true),
+	opt := &SetSlackSlashCommandsServiceOptions{
+		Token: Ptr("token"),
 	}
 
-	_, err := client.Services.SetYouTrackService(1, opt)
+	_, err := client.Services.SetSlackSlashCommandsService(1, opt)
 	if err != nil {
-		t.Fatalf("Services.SetYouTrackService returns an error: %v", err)
+		t.Fatalf("Services.SetSlackSlashCommandsService returns an error: %v", err)
 	}
 }
 
-func TestDeleteYouTrackService(t *testing.T) {
+func TestDeleteSlackSlashCommandsService(t *testing.T) {
 	mux, client := setup(t)
 
-	mux.HandleFunc("/api/v4/projects/1/services/youtrack", func(w http.ResponseWriter, r *http.Request) {
+	mux.HandleFunc("/api/v4/projects/1/services/slack-slash-commands", func(w http.ResponseWriter, r *http.Request) {
 		testMethod(t, r, http.MethodDelete)
 	})
 
-	_, err := client.Services.DeleteYouTrackService(1)
+	_, err := client.Services.DeleteSlackSlashCommandsService(1)
 	if err != nil {
-		t.Fatalf("Services.DeleteYouTrackService returns an error: %v", err)
+		t.Fatalf("Services.DeleteSlackSlashCommandsService returns an error: %v", err)
 	}
 }
 
-func TestGetSlackSlashCommandsService(t *testing.T) {
+func TestGetTelegramService(t *testing.T) {
 	mux, client := setup(t)
 
-	mux.HandleFunc("/api/v4/projects/1/services/slack-slash-commands", func(w http.ResponseWriter, r *http.Request) {
+	mux.HandleFunc("/api/v4/projects/1/services/telegram", func(w http.ResponseWriter, r *http.Request) {
 		testMethod(t, r, http.MethodGet)
-		fmt.Fprint(w, `{"id":1}`)
-	})
-	want := &SlackSlashCommandsService{Service: Service{ID: 1}}
+		fmt.Fprint(w, `
+			{
+			  "id": 1,
+			  "title": "Telegram",
+			  "slug": "telegram",
+			  "created_at": "2023-12-16T20:21:03.117Z",
+			  "updated_at": "2023-12-16T20:22:19.140Z",
+			  "active": true,
+			  "commit_events": true,
+			  "push_events": false,
+			  "issues_events": false,
+			  "incident_events": false,
+			  "alert_events": true,
+			  "confidential_issues_events": false,
+			  "merge_requests_events": false,
+			  "tag_push_events": false,
+			  "deployment_events": false,
+			  "note_events": false,
+			  "confidential_note_events": false,
+			  "pipeline_events": true,
+			  "wiki_page_events": false,
+			  "job_events": true,
+			  "comment_on_event_enabled": true,
+			  "vulnerability_events": false,
+			  "properties": {
+				"room": "-1000000000000",
+				"notify_only_broken_pipelines": false,
+				"branches_to_be_notified": "all"
+			  }
+			}
+		`)
+	})
+	wantCreatedAt, _ := time.Parse(time.RFC3339, "2023-12-16T20:21:03.117Z")
+	wantUpdatedAt, _ := time.Parse(time.RFC3339, "2023-12-16T20:22:19.140Z")
+	want := &TelegramService{
+		Service: Service{
+			ID:                       1,
+			Title:                    "Telegram",
+			Slug:                     "telegram",
+			CreatedAt:                &wantCreatedAt,
+			UpdatedAt:                &wantUpdatedAt,
+			Active:                   true,
+			CommitEvents:             true,
+			PushEvents:               false,
+			IssuesEvents:             false,
+			AlertEvents:              true,
+			ConfidentialIssuesEvents: false,
+			MergeRequestsEvents:      false,
+			TagPushEvents:            false,
+			DeploymentEvents:         false,
+			NoteEvents:               false,
+			ConfidentialNoteEvents:   false,
+			PipelineEvents:           true,
+			WikiPageEvents:           false,
+			JobEvents:                true,
+			CommentOnEventEnabled:    true,
+			VulnerabilityEvents:      false,
+		},
+		Properties: &TelegramServiceProperties{
+			Room:                      "-1000000000000",
+			NotifyOnlyBrokenPipelines: false,
+			BranchesToBeNotified:      "all",
+		},
+	}
 
-	service, _, err := client.Services.GetSlackSlashCommandsService(1)
+	service, _, err := client.Services.GetTelegramService(1)
 	if err != nil {
-		t.Fatalf("Services.GetSlackSlashCommandsService returns an error: %v", err)
+		t.Fatalf("Services.GetTelegramService returns an error: %v", err)
 	}
 	if !reflect.DeepEqual(want, service) {
-		t.Errorf("Services.GetSlackSlashCommandsService returned %+v, want %+v", service, want)
+		t.Errorf("Services.GetTelegramService returned %+v, want %+v", service, want)
 	}
 }
 
-func TestSetSlackSlashCommandsService(t *testing.T) {
+func TestSetTelegramService(t *testing.T) {
 	mux, client := setup(t)
 
-	mux.HandleFunc("/api/v4/projects/1/services/slack-slash-commands", func(w http.ResponseWriter, r *http.Request) {
+	mux.HandleFunc("/api/v4/projects/1/services/telegram", func(w http.ResponseWriter, r *http.Request) {
 		testMethod(t, r, http.MethodPut)
 	})
 
-	opt := &SetSlackSlashCommandsServiceOptions{
-		Token: Ptr("token"),
+	opt := &SetTelegramServiceOptions{
+		Token:                     Ptr("token"),
+		Room:                      Ptr("-1000"),
+		NotifyOnlyBrokenPipelines: Ptr(true),
+		BranchesToBeNotified:      Ptr("all"),
+		PushEvents:                Ptr(true),
+		IssuesEvents:              Ptr(true),
+		ConfidentialIssuesEvents:  Ptr(true),
+		MergeRequestsEvents:       Ptr(true),
+		TagPushEvents:             Ptr(true),
+		NoteEvents:                Ptr(true),
+		ConfidentialNoteEvents:    Ptr(true),
+		PipelineEvents:            Ptr(true),
+		WikiPageEvents:            Ptr(true),
 	}
 
-	_, err := client.Services.SetSlackSlashCommandsService(1, opt)
+	_, err := client.Services.SetTelegramService(1, opt)
 	if err != nil {
-		t.Fatalf("Services.SetSlackSlashCommandsService returns an error: %v", err)
+		t.Fatalf("Services.SetTelegramService returns an error: %v", err)
 	}
 }
 
-func TestDeleteSlackSlashCommandsService(t *testing.T) {
+func TestDeleteTelegramService(t *testing.T) {
 	mux, client := setup(t)
 
-	mux.HandleFunc("/api/v4/projects/1/services/slack-slash-commands", func(w http.ResponseWriter, r *http.Request) {
+	mux.HandleFunc("/api/v4/projects/1/services/telegram", func(w http.ResponseWriter, r *http.Request) {
 		testMethod(t, r, http.MethodDelete)
 	})
 
-	_, err := client.Services.DeleteSlackSlashCommandsService(1)
+	_, err := client.Services.DeleteTelegramService(1)
 	if err != nil {
-		t.Fatalf("Services.DeleteSlackSlashCommandsService returns an error: %v", err)
+		t.Fatalf("Services.DeleteTelegramService returns an error: %v", err)
 	}
 }
 
-func TestGetMattermostSlashCommandsService(t *testing.T) {
+func TestGetYouTrackService(t *testing.T) {
 	mux, client := setup(t)
 
-	mux.HandleFunc("/api/v4/projects/1/services/mattermost-slash-commands", func(w http.ResponseWriter, r *http.Request) {
+	mux.HandleFunc("/api/v4/projects/1/services/youtrack", func(w http.ResponseWriter, r *http.Request) {
 		testMethod(t, r, http.MethodGet)
 		fmt.Fprint(w, `{"id":1}`)
 	})
-	want := &MattermostSlashCommandsService{Service: Service{ID: 1}}
+	want := &YouTrackService{Service: Service{ID: 1}}
 
-	service, _, err := client.Services.GetMattermostSlashCommandsService(1)
+	service, _, err := client.Services.GetYouTrackService(1)
 	if err != nil {
-		t.Fatalf("Services.mattermost-slash-commands returns an error: %v", err)
+		t.Fatalf("Services.GetYouTrackService returns an error: %v", err)
 	}
 	if !reflect.DeepEqual(want, service) {
-		t.Errorf("Services.mattermost-slash-commands returned %+v, want %+v", service, want)
+		t.Errorf("Services.GetYouTrackService returned %+v, want %+v", service, want)
 	}
 }
 
-func TestSetMattermostSlashCommandsService(t *testing.T) {
+func TestSetYouTrackService(t *testing.T) {
 	mux, client := setup(t)
 
-	mux.HandleFunc("/api/v4/projects/1/services/mattermost-slash-commands", func(w http.ResponseWriter, r *http.Request) {
+	mux.HandleFunc("/api/v4/projects/1/services/youtrack", func(w http.ResponseWriter, r *http.Request) {
 		testMethod(t, r, http.MethodPut)
 	})
 
-	opt := &SetMattermostSlashCommandsServiceOptions{
-		Token:    Ptr("token"),
-		Username: Ptr("username"),
+	opt := &SetYouTrackServiceOptions{
+		IssuesURL:   Ptr("https://example.org/youtrack/issue/:id"),
+		ProjectURL:  Ptr("https://example.org/youtrack/projects/1"),
+		Description: Ptr("description"),
+		PushEvents:  Ptr(true),
 	}
 
-	_, err := client.Services.SetMattermostSlashCommandsService(1, opt)
+	_, err := client.Services.SetYouTrackService(1, opt)
 	if err != nil {
-		t.Fatalf("Services.SetMattermostSlashCommandsService returns an error: %v", err)
+		t.Fatalf("Services.SetYouTrackService returns an error: %v", err)
 	}
 }
 
-func TestDeleteMattermostSlashCommandsService(t *testing.T) {
+func TestDeleteYouTrackService(t *testing.T) {
 	mux, client := setup(t)
 
-	mux.HandleFunc("/api/v4/projects/1/services/mattermost-slash-commands", func(w http.ResponseWriter, r *http.Request) {
+	mux.HandleFunc("/api/v4/projects/1/services/youtrack", func(w http.ResponseWriter, r *http.Request) {
 		testMethod(t, r, http.MethodDelete)
 	})
 
-	_, err := client.Services.DeleteMattermostSlashCommandsService(1)
+	_, err := client.Services.DeleteYouTrackService(1)
 	if err != nil {
-		t.Fatalf("Services.DeleteMattermostSlashCommandsService returns an error: %v", err)
+		t.Fatalf("Services.DeleteYouTrackService returns an error: %v", err)
 	}
 }