Skip to content

Commit

Permalink
Merge pull request #9 from takenet/feature/129701-custom_common_url
Browse files Browse the repository at this point in the history
Custom common url. #129894
  • Loading branch information
luizguicl authored Feb 12, 2019
2 parents 36db71b + 671cd33 commit 9a3fcac
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ <h1>For connection data tests (*optional)</h1>
.withCustomMessageMetadata({
x: 'y'
})
.withCustomCommonUrl(
'https://hmg-chat.blip.ai/'
)
builder.build()
}

Expand Down
10 changes: 10 additions & 0 deletions src/BlipChat.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ export class BlipChat {
return this
}

withCustomCommonUrl(commonUrl) {
if (!commonUrl.endsWith('/')) {
commonUrl += '/'
}

this.customCommonUrl = commonUrl
return this
}

build() {
this.widget = new BlipChatWidget(
this.appKey,
Expand All @@ -104,6 +113,7 @@ export class BlipChat {
this.environment || process.env.NODE_ENV,
this.customStyle,
this.customMessageMetadata,
this.customCommonUrl,
this.connectionData || {}
)
}
Expand Down
6 changes: 5 additions & 1 deletion src/BlipChatWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class BlipChatWidget {
environment,
customStyle,
customMessageMetadata,
customCommonUrl,
connectionData
) {
self = this
Expand All @@ -55,6 +56,7 @@ export class BlipChatWidget {
self.pendings = []
self.customStyle = customStyle
self.customMessageMetadata = customMessageMetadata
self.customCommonUrl = customCommonUrl
self.connectionData = connectionData

self._setChatUrlEnvironment(environment, authConfig, appKey)
Expand Down Expand Up @@ -103,7 +105,9 @@ export class BlipChatWidget {
}

_setChatUrlEnvironment(environment, authConfig, appKey) {
if (environment === 'homolog') {
if (self.customCommonUrl) {
self.CHAT_URL = self.customCommonUrl
} else if (environment === 'homolog') {
self.CHAT_URL = Constants.CHAT_URL_HMG
} else if (environment === 'production') {
self.CHAT_URL = Constants.CHAT_URL_PROD
Expand Down

0 comments on commit 9a3fcac

Please sign in to comment.