Skip to content
This repository was archived by the owner on Dec 10, 2024. It is now read-only.

Commit 520bee9

Browse files
committed
Refactor PR so it matches the rest of the package
1 parent 9548712 commit 520bee9

File tree

2 files changed

+100
-109
lines changed

2 files changed

+100
-109
lines changed

appearance.go

+38-47
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,23 @@ package gitlab
1818

1919
import "net/http"
2020

21-
// AppearanceService handles communication with appearance
22-
// of the Gitlab API.
21+
// AppearanceService handles communication with appearance of the Gitlab API.
2322
//
2423
// Gitlab API docs : https://docs.gitlab.com/ee/api/appearance.html
2524
type AppearanceService struct {
2625
client *Client
2726
}
2827

29-
// Appearance represents a GitLab appearance
28+
// Appearance represents a GitLab appearance.
29+
//
30+
// Gitlab API docs : https://docs.gitlab.com/ee/api/appearance.html
3031
type Appearance struct {
3132
Title string `json:"title"`
3233
Description string `json:"description"`
33-
PwaName string `json:"pwa_name"`
34-
PwaShortName string `json:"pwa_short_name"`
35-
PwaDescription string `json:"pwa_description"`
36-
PwaIcon string `json:"pwa_icon"`
34+
PWAName string `json:"pwa_name"`
35+
PWAShortName string `json:"pwa_short_name"`
36+
PWADescription string `json:"pwa_description"`
37+
PWAIcon string `json:"pwa_icon"`
3738
Logo string `json:"logo"`
3839
HeaderLogo string `json:"header_logo"`
3940
Favicon string `json:"favicon"`
@@ -46,71 +47,61 @@ type Appearance struct {
4647
EmailHeaderAndFooterEnabled bool `json:"email_header_and_footer_enabled"`
4748
}
4849

49-
// GetAppearance Get current appearance configuration
50-
// List the current appearance configuration of the GitLab instance.
50+
// GetAppearance gets the current appearance configuration of the GitLab instance.
5151
//
52-
// Gitlab API docs : https://docs.gitlab.com/ee/api/appearance.html#get-current-appearance-configuration
52+
// Gitlab API docs:
53+
// https://docs.gitlab.com/ee/api/appearance.html#get-current-appearance-configuration
5354
func (s *AppearanceService) GetAppearance(options ...RequestOptionFunc) (*Appearance, *Response, error) {
5455
req, err := s.client.NewRequest(http.MethodGet, "application/appearance", nil, options)
55-
5656
if err != nil {
5757
return nil, nil, err
5858
}
5959

60-
// as := new(Appearance)
61-
// resp, err := s.client.Do(req, as)
62-
var as *Appearance
63-
resp, err := s.client.Do(req, &as)
60+
as := new(Appearance)
61+
resp, err := s.client.Do(req, as)
6462
if err != nil {
6563
return nil, resp, err
6664
}
6765

6866
return as, resp, nil
6967
}
7068

71-
// PutAppearanceRequestOptions represents the available
72-
// PutAppearance() options.
69+
// ChangeAppearanceOptions represents the available ChangeAppearance() options.
7370
//
7471
// GitLab API docs:
7572
// https://docs.gitlab.com/ee/api/appearance.html#change-appearance-configuration
76-
type PutAppearanceRequestOptions struct {
77-
Title string `url:"title,omitempty" json:"title,omitempty"`
78-
Description string `url:"description,omitempty" json:"description,omitempty"`
79-
PwaName string `url:"pwa_name,omitempty" json:"pwa_name,omitempty"`
80-
PwaShortName string `url:"pwa_short_name,omitempty" json:"pwa_short_name,omitempty"`
81-
PwaDescription string `url:"pwa_description,omitempty" json:"pwa_description,omitempty"`
82-
PwaIcon string `url:"pwa_icon,omitempty" json:"pwa_icon,omitempty"`
83-
Logo string `url:"logo,omitempty" json:"logo,omitempty"`
84-
HeaderLogo string `url:"header_logo,omitempty" json:"header_logo,omitempty"`
85-
Favicon string `url:"favicon,omitempty" json:"favicon,omitempty"`
86-
NewProjectGuidelines string `url:"new_project_guidelines,omitempty" json:"new_project_guidelines,omitempty"`
87-
ProfileImageGuidelines string `url:"profile_image_guidelines,omitempty" json:"profile_image_guidelines,omitempty"`
88-
HeaderMessage string `url:"header_message,omitempty" json:"header_message,omitempty"`
89-
FooterMessage string `url:"footer_message,omitempty" json:"footer_message,omitempty"`
90-
MessageBackgroundColor string `url:"message_background_color,omitempty" json:"message_background_color,omitempty"`
91-
MessageFontColor string `url:"message_font_color,omitempty" json:"message_font_color,omitempty"`
92-
EmailHeaderAndFooterEnabled bool `url:"email_header_and_footer_enabled,omitempty" json:"email_header_and_footer_enabled,omitempty"`
93-
URL string `url:"url,omitempty" json:"url,omitempty"`
73+
type ChangeAppearanceOptions struct {
74+
Title *string `url:"title,omitempty" json:"title,omitempty"`
75+
Description *string `url:"description,omitempty" json:"description,omitempty"`
76+
PWAName *string `url:"pwa_name,omitempty" json:"pwa_name,omitempty"`
77+
PWAShortName *string `url:"pwa_short_name,omitempty" json:"pwa_short_name,omitempty"`
78+
PWADescription *string `url:"pwa_description,omitempty" json:"pwa_description,omitempty"`
79+
PWAIcon *string `url:"pwa_icon,omitempty" json:"pwa_icon,omitempty"`
80+
Logo *string `url:"logo,omitempty" json:"logo,omitempty"`
81+
HeaderLogo *string `url:"header_logo,omitempty" json:"header_logo,omitempty"`
82+
Favicon *string `url:"favicon,omitempty" json:"favicon,omitempty"`
83+
NewProjectGuidelines *string `url:"new_project_guidelines,omitempty" json:"new_project_guidelines,omitempty"`
84+
ProfileImageGuidelines *string `url:"profile_image_guidelines,omitempty" json:"profile_image_guidelines,omitempty"`
85+
HeaderMessage *string `url:"header_message,omitempty" json:"header_message,omitempty"`
86+
FooterMessage *string `url:"footer_message,omitempty" json:"footer_message,omitempty"`
87+
MessageBackgroundColor *string `url:"message_background_color,omitempty" json:"message_background_color,omitempty"`
88+
MessageFontColor *string `url:"message_font_color,omitempty" json:"message_font_color,omitempty"`
89+
EmailHeaderAndFooterEnabled *bool `url:"email_header_and_footer_enabled,omitempty" json:"email_header_and_footer_enabled,omitempty"`
90+
URL *string `url:"url,omitempty" json:"url,omitempty"`
9491
}
9592

96-
// PutAppearance Change appearance configuration
97-
// Use an API
98-
99-
// PutAppearance Change appearance configuration
100-
// Use an API call to modify GitLab instance appearance configuration.
93+
// ChangeAppearance changes the appearance configuration.
10194
//
102-
// Gitlab API docs : https://docs.gitlab.com/ee/api/appearance.html#change-appearance-configuration
103-
func (s *AppearanceService) PutAppearance(opt *PutAppearanceRequestOptions, options ...RequestOptionFunc) (*Appearance, *Response, error) {
95+
// Gitlab API docs:
96+
// https://docs.gitlab.com/ee/api/appearance.html#change-appearance-configuration
97+
func (s *AppearanceService) ChangeAppearance(opt *ChangeAppearanceOptions, options ...RequestOptionFunc) (*Appearance, *Response, error) {
10498
req, err := s.client.NewRequest(http.MethodPut, "application/appearance", opt, options)
105-
10699
if err != nil {
107100
return nil, nil, err
108101
}
109102

110-
// as := new(Appearance)
111-
// resp, err := s.client.Do(req, as)
112-
var as *Appearance
113-
resp, err := s.client.Do(req, &as)
103+
as := new(Appearance)
104+
resp, err := s.client.Do(req, as)
114105
if err != nil {
115106
return nil, resp, err
116107
}

appearance_test.go

+62-62
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,23 @@ func TestGetAppearance(t *testing.T) {
2929
mux.HandleFunc("/api/v4/application/appearance", func(w http.ResponseWriter, r *http.Request) {
3030
testMethod(t, r, http.MethodGet)
3131
fmt.Fprint(w, `{
32-
"title": "GitLab Test Instance",
33-
"description": "gitlab-test.example.com",
34-
"pwa_name": "GitLab PWA",
35-
"pwa_short_name": "GitLab",
36-
"pwa_description": "GitLab as PWA",
37-
"pwa_icon": "/uploads/-/system/appearance/pwa_icon/1/pwa_logo.png",
38-
"logo": "/uploads/-/system/appearance/logo/1/logo.png",
39-
"header_logo": "/uploads/-/system/appearance/header_logo/1/header.png",
40-
"favicon": "/uploads/-/system/appearance/favicon/1/favicon.png",
41-
"new_project_guidelines": "Please read the FAQs for help.",
42-
"profile_image_guidelines": "Custom profile image guidelines",
43-
"header_message": "",
44-
"footer_message": "",
45-
"message_background_color": "#e75e40",
46-
"message_font_color": "#ffffff",
47-
"email_header_and_footer_enabled": false
48-
}`)
32+
"title": "GitLab Test Instance",
33+
"description": "gitlab-test.example.com",
34+
"pwa_name": "GitLab PWA",
35+
"pwa_short_name": "GitLab",
36+
"pwa_description": "GitLab as PWA",
37+
"pwa_icon": "/uploads/-/system/appearance/pwa_icon/1/pwa_logo.png",
38+
"logo": "/uploads/-/system/appearance/logo/1/logo.png",
39+
"header_logo": "/uploads/-/system/appearance/header_logo/1/header.png",
40+
"favicon": "/uploads/-/system/appearance/favicon/1/favicon.png",
41+
"new_project_guidelines": "Please read the FAQs for help.",
42+
"profile_image_guidelines": "Custom profile image guidelines",
43+
"header_message": "",
44+
"footer_message": "",
45+
"message_background_color": "#e75e40",
46+
"message_font_color": "#ffffff",
47+
"email_header_and_footer_enabled": false
48+
}`)
4949
})
5050

5151
appearance, _, err := client.Appearance.GetAppearance()
@@ -56,10 +56,10 @@ func TestGetAppearance(t *testing.T) {
5656
want := &Appearance{
5757
Title: "GitLab Test Instance",
5858
Description: "gitlab-test.example.com",
59-
PwaName: "GitLab PWA",
60-
PwaShortName: "GitLab",
61-
PwaDescription: "GitLab as PWA",
62-
PwaIcon: "/uploads/-/system/appearance/pwa_icon/1/pwa_logo.png",
59+
PWAName: "GitLab PWA",
60+
PWAShortName: "GitLab",
61+
PWADescription: "GitLab as PWA",
62+
PWAIcon: "/uploads/-/system/appearance/pwa_icon/1/pwa_logo.png",
6363
Logo: "/uploads/-/system/appearance/logo/1/logo.png",
6464
HeaderLogo: "/uploads/-/system/appearance/header_logo/1/header.png",
6565
Favicon: "/uploads/-/system/appearance/favicon/1/favicon.png",
@@ -77,62 +77,62 @@ func TestGetAppearance(t *testing.T) {
7777
}
7878
}
7979

80-
func TestPutAppearance(t *testing.T) {
80+
func TestChangeAppearance(t *testing.T) {
8181
mux, client := setup(t)
8282

8383
mux.HandleFunc("/api/v4/application/appearance", func(w http.ResponseWriter, r *http.Request) {
8484
testMethod(t, r, http.MethodPut)
8585
fmt.Fprint(w, `{
86-
"title": "GitLab Test Instance - 001",
87-
"description": "gitlab-test.example.com",
88-
"pwa_name": "GitLab PWA",
89-
"pwa_short_name": "GitLab",
90-
"pwa_description": "GitLab as PWA",
91-
"pwa_icon": "/uploads/-/system/appearance/pwa_icon/1/pwa_logo.png",
92-
"logo": "/uploads/-/system/appearance/logo/1/logo.png",
93-
"header_logo": "/uploads/-/system/appearance/header_logo/1/header.png",
94-
"favicon": "/uploads/-/system/appearance/favicon/1/favicon.png",
95-
"new_project_guidelines": "Please read the FAQs for help.",
96-
"profile_image_guidelines": "Custom profile image guidelines",
97-
"header_message": "",
98-
"footer_message": "",
99-
"message_background_color": "#e75e40",
100-
"message_font_color": "#ffffff",
101-
"email_header_and_footer_enabled": false
102-
}`)
86+
"title": "GitLab Test Instance - 001",
87+
"description": "gitlab-test.example.com",
88+
"pwa_name": "GitLab PWA",
89+
"pwa_short_name": "GitLab",
90+
"pwa_description": "GitLab as PWA",
91+
"pwa_icon": "/uploads/-/system/appearance/pwa_icon/1/pwa_logo.png",
92+
"logo": "/uploads/-/system/appearance/logo/1/logo.png",
93+
"header_logo": "/uploads/-/system/appearance/header_logo/1/header.png",
94+
"favicon": "/uploads/-/system/appearance/favicon/1/favicon.png",
95+
"new_project_guidelines": "Please read the FAQs for help.",
96+
"profile_image_guidelines": "Custom profile image guidelines",
97+
"header_message": "",
98+
"footer_message": "",
99+
"message_background_color": "#e75e40",
100+
"message_font_color": "#ffffff",
101+
"email_header_and_footer_enabled": false
102+
}`)
103103
})
104104

105-
opt := &PutAppearanceRequestOptions{
106-
Title: "GitLab Test Instance - 001",
107-
Description: "gitlab-test.example.com",
108-
PwaName: "GitLab PWA",
109-
PwaShortName: "GitLab",
110-
PwaDescription: "GitLab as PWA",
111-
PwaIcon: "/uploads/-/system/appearance/pwa_icon/1/pwa_logo.png",
112-
Logo: "/uploads/-/system/appearance/logo/1/logo.png",
113-
HeaderLogo: "/uploads/-/system/appearance/header_logo/1/header.png",
114-
Favicon: "/uploads/-/system/appearance/favicon/1/favicon.png",
115-
NewProjectGuidelines: "Please read the FAQs for help.",
116-
ProfileImageGuidelines: "Custom profile image guidelines",
117-
HeaderMessage: "",
118-
FooterMessage: "",
119-
MessageBackgroundColor: "#e75e40",
120-
MessageFontColor: "#ffffff",
121-
EmailHeaderAndFooterEnabled: false,
105+
opt := &ChangeAppearanceOptions{
106+
Title: String("GitLab Test Instance - 001"),
107+
Description: String("gitlab-test.example.com"),
108+
PWAName: String("GitLab PWA"),
109+
PWAShortName: String("GitLab"),
110+
PWADescription: String("GitLab as PWA"),
111+
PWAIcon: String("/uploads/-/system/appearance/pwa_icon/1/pwa_logo.png"),
112+
Logo: String("/uploads/-/system/appearance/logo/1/logo.png"),
113+
HeaderLogo: String("/uploads/-/system/appearance/header_logo/1/header.png"),
114+
Favicon: String("/uploads/-/system/appearance/favicon/1/favicon.png"),
115+
NewProjectGuidelines: String("Please read the FAQs for help."),
116+
ProfileImageGuidelines: String("Custom profile image guidelines"),
117+
HeaderMessage: String(""),
118+
FooterMessage: String(""),
119+
MessageBackgroundColor: String("#e75e40"),
120+
MessageFontColor: String("#ffffff"),
121+
EmailHeaderAndFooterEnabled: Bool(false),
122122
}
123123

124-
appearance, _, err := client.Appearance.PutAppearance(opt)
124+
appearance, _, err := client.Appearance.ChangeAppearance(opt)
125125
if err != nil {
126-
t.Errorf("Appearance.GetAppearance returned error: %v", err)
126+
t.Errorf("Appearance.ChangeAppearance returned error: %v", err)
127127
}
128128

129129
want := &Appearance{
130130
Title: "GitLab Test Instance - 001",
131131
Description: "gitlab-test.example.com",
132-
PwaName: "GitLab PWA",
133-
PwaShortName: "GitLab",
134-
PwaDescription: "GitLab as PWA",
135-
PwaIcon: "/uploads/-/system/appearance/pwa_icon/1/pwa_logo.png",
132+
PWAName: "GitLab PWA",
133+
PWAShortName: "GitLab",
134+
PWADescription: "GitLab as PWA",
135+
PWAIcon: "/uploads/-/system/appearance/pwa_icon/1/pwa_logo.png",
136136
Logo: "/uploads/-/system/appearance/logo/1/logo.png",
137137
HeaderLogo: "/uploads/-/system/appearance/header_logo/1/header.png",
138138
Favicon: "/uploads/-/system/appearance/favicon/1/favicon.png",

0 commit comments

Comments
 (0)