feat: Shows inbox identifier token for API inbox (#2894)

Fixes: #2605
This commit is contained in:
Brandon Wilson
2021-08-27 10:26:45 -04:00
committed by GitHub
parent 9a8cbee470
commit f94abaef5f
5 changed files with 64 additions and 1 deletions

View File

@@ -274,6 +274,8 @@
"AUTO_ASSIGNMENT_SUB_TEXT": "Enable or disable the automatic assignment of new conversations to the agents added to this inbox.",
"HMAC_VERIFICATION": "User Identity Validation",
"HMAC_DESCRIPTION": "Inorder to validate the user's identity, the SDK allows you to pass an `identifier_hash` for each user. You can generate HMAC using 'sha256' with the key shown here.",
"INBOX_IDENTIFIER": "Inbox Identifier",
"INBOX_IDENTIFIER_SUB_TEXT": "Use the `inbox_identifier` token shown here to authentication your API clients.",
"FORWARD_EMAIL_TITLE": "Forward to Email",
"FORWARD_EMAIL_SUB_TEXT": "Start forwarding your emails to the following email address."
},

View File

@@ -279,6 +279,14 @@
</settings-section>
</div>
</div>
<div v-else-if="isAPIInbox" class="settings--content">
<settings-section
:title="$t('INBOX_MGMT.SETTINGS_POPUP.INBOX_IDENTIFIER')"
:sub-title="$t('INBOX_MGMT.SETTINGS_POPUP.INBOX_IDENTIFIER_SUB_TEXT')"
>
<woot-code :script="inbox.inbox_identifier"></woot-code>
</settings-section>
</div>
<div v-else-if="isAnEmailChannel">
<div class="settings--content">
<settings-section
@@ -388,7 +396,7 @@ export default {
];
}
if (this.isATwilioChannel || this.isAnEmailChannel) {
if (this.isATwilioChannel || this.isAPIInbox || this.isAnEmailChannel) {
return [
...visibleToAllChannelTabs,
{

View File

@@ -74,6 +74,10 @@ class Inbox < ApplicationRecord
channel_type == 'Channel::WebWidget'
end
def api?
channel_type == 'Channel::Api'
end
def inbox_type
channel.name
end

View File

@@ -29,3 +29,4 @@ if resource.web_widget?
json.pre_chat_form_enabled resource.channel.try(:pre_chat_form_enabled)
json.pre_chat_form_options resource.channel.try(:pre_chat_form_options)
end
json.inbox_identifier resource.channel.try(:identifier) if resource.api?

View File

@@ -87,4 +87,52 @@ RSpec.describe Inbox do
end
end
end
describe '#web_widget?' do
let(:inbox) do
FactoryBot.build(:inbox, channel: channel_val)
end
context 'when the channel type is Channel::WebWidget' do
let(:channel_val) { Channel::WebWidget.new }
it do
expect(inbox.web_widget?).to eq(true)
expect(inbox.inbox_type).to eq('Website')
end
end
context 'when the channel is not Channel::WebWidget' do
let(:channel_val) { Channel::Api.new }
it do
expect(inbox.web_widget?).to eq(false)
expect(inbox.inbox_type).to eq('API')
end
end
end
describe '#api?' do
let(:inbox) do
FactoryBot.build(:inbox, channel: channel_val)
end
context 'when the channel type is Channel::Api' do
let(:channel_val) { Channel::Api.new }
it do
expect(inbox.api?).to eq(true)
expect(inbox.inbox_type).to eq('API')
end
end
context 'when the channel is not Channel::Api' do
let(:channel_val) { Channel::FacebookPage.new }
it do
expect(inbox.api?).to eq(false)
expect(inbox.inbox_type).to eq('Facebook')
end
end
end
end