-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
af19eb0
commit 587a045
Showing
3 changed files
with
144 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
module Auth0 | ||
module Api | ||
module V2 | ||
# Methods to use the branding endpoints | ||
module Branding | ||
attr_reader :branding_path | ||
|
||
# Retrieve branding settings. | ||
# @see https://auth0.com/docs/api/management/v2/#!/Branding/get_branding | ||
# | ||
# @return [json] Returns branding settings. | ||
def branding() | ||
get(branding_path) | ||
end | ||
alias get_branding branding | ||
|
||
# Update branding settings. | ||
# @see https://auth0.com/docs/api/management/v2/#!/Branding/patch_branding | ||
# @param body [hash] the branding settings to update | ||
# | ||
# @return [json] Returns branding settings. | ||
def patch_branding(body = {}) | ||
patch(branding_path, body) | ||
end | ||
alias update_branding patch_branding | ||
|
||
# Get template for New Universal Login Experience | ||
# @see https://auth0.com/docs/api/management/v2/#!/Branding/get_universal_login | ||
# | ||
# @return [json] Returns branding settings. | ||
def branding_templates_for_universal_login | ||
get(templates_path) | ||
end | ||
alias get_branding_templates_for_universal_login branding_templates_for_universal_login | ||
|
||
# Delete template for New Universal Login Experience | ||
# @see https://auth0.com/docs/api/management/v2/#!/Branding/delete_universal_login | ||
# @param rule_id [string] The id of the rule to delete. | ||
def delete_branding_templates_for_universal_login | ||
delete(templates_path) | ||
end | ||
|
||
# Set template for New Universal Login Experience | ||
# @see https://auth0.com/docs/api/management/v2/#!/Branding/put_universal_login | ||
# @param body [hash] the branding settings to update | ||
# | ||
# @return [json] Returns branding settings. | ||
def put_branding_templates_for_universal_login(body = {}) | ||
put(templates_path, body) | ||
end | ||
alias set_branding_templates_for_universal_login put_branding_templates_for_universal_login | ||
|
||
private | ||
|
||
# Branding API path | ||
def branding_path | ||
@branding_path ||= '/api/v2/branding' | ||
end | ||
|
||
def templates_path | ||
@templates_path ||= "#{branding_path}/templates/universal-login" | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
require 'spec_helper' | ||
describe Auth0::Api::V2::Branding do | ||
before :all do | ||
dummy_instance = DummyClass.new | ||
dummy_instance.extend(Auth0::Api::V2::Branding) | ||
dummy_instance.extend(Auth0::Mixins::Initializer) | ||
@instance = dummy_instance | ||
end | ||
|
||
context '.branding' do | ||
it { expect(@instance).to respond_to(:branding) } | ||
|
||
it 'is expected to call get /api/v2/branding' do | ||
expect(@instance).to receive(:get).with('/api/v2/branding') | ||
expect { @instance.branding }.not_to raise_error | ||
end | ||
|
||
it 'is expected to respond to a get_branding method' do | ||
expect(@instance).to respond_to(:get_branding) | ||
end | ||
end | ||
|
||
context '.patch_branding' do | ||
it { expect(@instance).to respond_to(:patch_branding) } | ||
it 'is expected to call post /api/v2/branding' do | ||
expect(@instance).to receive(:patch).with( | ||
'/api/v2/branding', | ||
template: 'Test' | ||
) | ||
expect { @instance.patch_branding({ template: 'Test' }) }.not_to raise_error | ||
end | ||
|
||
it 'is expected to respond to a get_branding method' do | ||
expect(@instance).to respond_to(:update_branding) | ||
end | ||
end | ||
|
||
context '.branding_templates_for_universal_login' do | ||
it { expect(@instance).to respond_to(:branding) } | ||
|
||
it 'is expected to call get /api/v2/branding/templates/universal-login' do | ||
expect(@instance).to receive(:get).with('/api/v2/branding/templates/universal-login') | ||
expect { @instance.branding_templates_for_universal_login }.not_to raise_error | ||
end | ||
|
||
it 'is expected to respond to a get_branding_templates_for_universal_login method' do | ||
expect(@instance).to respond_to(:get_branding_templates_for_universal_login) | ||
end | ||
end | ||
|
||
context '.put_branding_templates_for_universal_login' do | ||
it { expect(@instance).to respond_to(:put_branding_templates_for_universal_login) } | ||
it 'is expected to call put /api/v2/branding/templates/universal-login' do | ||
expect(@instance).to receive(:put).with( | ||
'/api/v2/branding/templates/universal-login', template: 'Template' | ||
) | ||
expect do | ||
@instance.put_branding_templates_for_universal_login(template: 'Template') | ||
end.not_to raise_error | ||
end | ||
end | ||
|
||
context '.delete_branding_templates_for_universal_login' do | ||
it { expect(@instance).to respond_to(:delete_branding_templates_for_universal_login) } | ||
it 'is expected to call delete /api/v2/branding/templates/universal-login' do | ||
expect(@instance).to receive(:delete).with('/api/v2/branding/templates/universal-login') | ||
expect { @instance.delete_branding_templates_for_universal_login() }.not_to raise_error | ||
end | ||
end | ||
end |