Skip to content

Commit

Permalink
Merge pull request #329 from intercom/dan.c/add_api_base
Browse files Browse the repository at this point in the history
Adds access to api_base configuration option
  • Loading branch information
Daniel Carter authored Oct 7, 2020
2 parents 3bd063f + 246cbd4 commit 1ee1fc5
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/intercom-rails/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def self.reset!
config_accessor :enabled_environments, &ARRAY_VALIDATOR
config_accessor :include_for_logged_out_users
config_accessor :hide_default_launcher
config_accessor :api_base
config_accessor :encrypted_mode

def self.api_key=(*)
Expand Down
2 changes: 1 addition & 1 deletion lib/intercom-rails/encrypted_mode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module IntercomRails
class EncryptedMode
attr_reader :secret, :initialization_vector, :enabled

ENCRYPTED_MODE_SETTINGS_WHITELIST = [:app_id, :session_duration, :widget, :custom_launcher_selector, :hide_default_launcher, :alignment, :horizontal_padding, :vertical_padding]
ENCRYPTED_MODE_SETTINGS_WHITELIST = [:app_id, :session_duration, :widget, :custom_launcher_selector, :hide_default_launcher, :api_base, :alignment, :horizontal_padding, :vertical_padding]

def initialize(secret, initialization_vector, options)
@secret = secret
Expand Down
1 change: 1 addition & 0 deletions lib/intercom-rails/script_tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def intercom_settings
hsh[:widget] = widget_options if widget_options.present?
hsh[:company] = company_details if company_details.present?
hsh[:hide_default_launcher] = Config.hide_default_launcher if Config.hide_default_launcher
hsh[:api_base] = Config.api_base if Config.api_base
hsh
end

Expand Down
4 changes: 4 additions & 0 deletions lib/rails/generators/intercom/config/intercom.rb.erb
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,8 @@ IntercomRails.config do |config|
#
# If you'd like to hide default launcher button uncomment this line
# config.hide_default_launcher = true
#
# If you need to route your Messenger requests through a different endpoint than the default, replace the below with your app id, and uncomment below line. Generally speaking, this is not needed.
# config.api_base = https://{app_id}.intercom-messenger.com
#
end
5 changes: 5 additions & 0 deletions spec/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@
expect(IntercomRails.config.hide_default_launcher).to eq(true)
end

it 'gets/sets api_base' do
IntercomRails.config.api_base = "https://abcde1.intercom-messenger.com"
expect(IntercomRails.config.api_base).to eq("https://abcde1.intercom-messenger.com")
end

it 'gets/sets Encrypted Mode' do
IntercomRails.config.encrypted_mode = true
expect(IntercomRails.config.encrypted_mode).to eq(true)
Expand Down
4 changes: 4 additions & 0 deletions spec/script_tag_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ def sha256_hmac(secret, input)
IntercomRails.config.hide_default_launcher = true
expect(ScriptTag.new.intercom_settings['hide_default_launcher']).to eq(true)
end
it 'knows about :api_base' do
IntercomRails.config.api_base = "https://abcde1.intercom-messenger.com"
expect(ScriptTag.new.intercom_settings['api_base']).to eq("https://abcde1.intercom-messenger.com")
end
end

context 'company' do
Expand Down

0 comments on commit 1ee1fc5

Please sign in to comment.