Skip to content

Commit

Permalink
Branding (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidpatrick authored Apr 9, 2021
1 parent af19eb0 commit 587a045
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/auth0/api/v2.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
require 'auth0/api/v2/anomaly'
require 'auth0/api/v2/blacklists'
require 'auth0/api/v2/branding'
require 'auth0/api/v2/clients'
require 'auth0/api/v2/client_grants'
require 'auth0/api/v2/connections'
require 'auth0/api/v2/device_credentials'
require 'auth0/api/v2/emails'
require 'auth0/api/v2/jobs'
require 'auth0/api/v2/prompts'
require 'auth0/api/v2/organizations'
require 'auth0/api/v2/rules'
require 'auth0/api/v2/roles'
require 'auth0/api/v2/stats'
Expand All @@ -19,34 +21,34 @@
require 'auth0/api/v2/log_streams'
require 'auth0/api/v2/resource_servers'
require 'auth0/api/v2/guardian'
require 'auth0/api/v2/organizations'

module Auth0
module Api
# https://auth0.com/docs/apiv2
module V2
include Auth0::Api::V2::Anomaly
include Auth0::Api::V2::Blacklists
include Auth0::Api::V2::Branding
include Auth0::Api::V2::Clients
include Auth0::Api::V2::ClientGrants
include Auth0::Api::V2::Connections
include Auth0::Api::V2::DeviceCredentials
include Auth0::Api::V2::Emails
include Auth0::Api::V2::Guardian
include Auth0::Api::V2::Jobs
include Auth0::Api::V2::Logs
include Auth0::Api::V2::LogStreams
include Auth0::Api::V2::Prompts
include Auth0::Api::V2::Organizations
include Auth0::Api::V2::Rules
include Auth0::Api::V2::Roles
include Auth0::Api::V2::Stats
include Auth0::Api::V2::Users
include Auth0::Api::V2::UsersByEmail
include Auth0::Api::V2::UserBlocks
include Auth0::Api::V2::ResourceServers
include Auth0::Api::V2::Tenants
include Auth0::Api::V2::Tickets
include Auth0::Api::V2::Logs
include Auth0::Api::V2::LogStreams
include Auth0::Api::V2::ResourceServers
include Auth0::Api::V2::Guardian
include Auth0::Api::V2::Organizations
end
end
end
66 changes: 66 additions & 0 deletions lib/auth0/api/v2/branding.rb
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
70 changes: 70 additions & 0 deletions spec/lib/auth0/api/v2/branding_spec.rb
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

0 comments on commit 587a045

Please sign in to comment.