Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 245a081

Browse files
authored
Add branding theme endpoints (auth0#477)
2 parents 1a1b975 + 4a0cf84 commit 245a081

File tree

2 files changed

+115
-0
lines changed

2 files changed

+115
-0
lines changed

auth0/management/branding.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,56 @@ def update_template_universal_login(self, body):
9393
self._url("templates", "universal-login"),
9494
body={"template": body},
9595
)
96+
97+
def get_default_branding_theme(self):
98+
"""Retrieve default branding theme.
99+
100+
See: https://auth0.com/docs/api/management/v2#!/Branding/get_default_branding_theme
101+
"""
102+
103+
return self.client.get(self._url("themes", "default"))
104+
105+
def get_branding_theme(self, theme_id):
106+
"""Retrieve branding theme.
107+
108+
Args:
109+
theme_id (str): The theme_id to retrieve branding theme for.
110+
111+
See: https://auth0.com/docs/api/management/v2#!/Branding/get_branding_theme
112+
"""
113+
114+
return self.client.get(self._url("themes", theme_id))
115+
116+
def delete_branding_theme(self, theme_id):
117+
"""Delete branding theme.
118+
119+
Args:
120+
theme_id (str): The theme_id to delete branding theme for.
121+
122+
See: https://auth0.com/docs/api/management/v2#!/Branding/delete_branding_theme
123+
"""
124+
125+
return self.client.delete(self._url("themes", theme_id))
126+
127+
def update_branding_theme(self, theme_id, body):
128+
"""Update branding theme.
129+
130+
Args:
131+
theme_id (str): The theme_id to update branding theme for.
132+
body (dict): The attributes to set on the theme.
133+
134+
See: https://auth0.com/docs/api/management/v2#!/Branding/patch_branding_theme
135+
"""
136+
137+
return self.client.patch(self._url("themes", theme_id), data=body)
138+
139+
def create_branding_theme(self, body):
140+
"""Create branding theme.
141+
142+
Args:
143+
body (dict): The attributes to set on the theme.
144+
145+
See: https://auth0.com/docs/api/management/v2#!/Branding/post_branding_theme
146+
"""
147+
148+
return self.client.post(self._url("themes"), data=body)

auth0/test/management/test_branding.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,65 @@ def test_update_template_universal_login(self, mock_rc):
7171
"https://domain/api/v2/branding/templates/universal-login",
7272
body={"template": {"a": "b", "c": "d"}},
7373
)
74+
75+
@mock.patch("auth0.management.branding.RestClient")
76+
def test_get_default_branding_theme(self, mock_rc):
77+
api = mock_rc.return_value
78+
api.get.return_value = {}
79+
80+
branding = Branding(domain="domain", token="jwttoken")
81+
branding.get_default_branding_theme()
82+
83+
api.get.assert_called_with(
84+
"https://domain/api/v2/branding/themes/default",
85+
)
86+
87+
@mock.patch("auth0.management.branding.RestClient")
88+
def test_get_branding_theme(self, mock_rc):
89+
api = mock_rc.return_value
90+
api.get.return_value = {}
91+
92+
branding = Branding(domain="domain", token="jwttoken")
93+
branding.get_branding_theme("theme_id")
94+
95+
api.get.assert_called_with(
96+
"https://domain/api/v2/branding/themes/theme_id",
97+
)
98+
99+
@mock.patch("auth0.management.branding.RestClient")
100+
def test_delete_branding_theme(self, mock_rc):
101+
api = mock_rc.return_value
102+
api.delete.return_value = {}
103+
104+
branding = Branding(domain="domain", token="jwttoken")
105+
branding.delete_branding_theme("theme_id")
106+
107+
api.delete.assert_called_with(
108+
"https://domain/api/v2/branding/themes/theme_id",
109+
)
110+
111+
@mock.patch("auth0.management.branding.RestClient")
112+
def test_update_branding_theme(self, mock_rc):
113+
api = mock_rc.return_value
114+
api.patch.return_value = {}
115+
116+
branding = Branding(domain="domain", token="jwttoken")
117+
branding.update_branding_theme("theme_id", {})
118+
119+
api.patch.assert_called_with(
120+
"https://domain/api/v2/branding/themes/theme_id",
121+
data={},
122+
)
123+
124+
@mock.patch("auth0.management.branding.RestClient")
125+
def test_create_branding_theme(self, mock_rc):
126+
api = mock_rc.return_value
127+
api.post.return_value = {}
128+
129+
branding = Branding(domain="domain", token="jwttoken")
130+
branding.create_branding_theme({})
131+
132+
api.post.assert_called_with(
133+
"https://domain/api/v2/branding/themes",
134+
data={},
135+
)

0 commit comments

Comments
 (0)