Skip to content

Commit

Permalink
update endpoint (#26)
Browse files Browse the repository at this point in the history
update endpoint from `liveapi.yext.com` to `cdn.yextapis.com` for PROD and SANDBOX in US region.

J=CLIP-539
TEST=manual

see that I get successful responses using bots from prod and sandbox account:
![Screenshot 2023-10-12 at 2 27 45 PM](https://github.com/yext/chat-core/assets/36055303/4cf7d11c-4426-4ca2-8043-27366c16e152)
![Screenshot 2023-10-12 at 2 28 18 PM](https://github.com/yext/chat-core/assets/36055303/51ad5b4c-95f8-42b3-90d8-81f17471c968)
  • Loading branch information
yen-tt authored Oct 12, 2023
1 parent 5b0d76b commit a6069ce
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yext/chat-core",
"version": "0.7.2",
"version": "0.7.3",
"description": "Typescript Networking Library for the Yext Chat API",
"main": "./dist/commonjs/index.js",
"module": "./dist/esm/index.mjs",
Expand Down
4 changes: 2 additions & 2 deletions src/infra/EndpointsFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ export class EndpointsFactory {
case Region.US:
switch (env) {
case Environment.SANDBOX:
return "liveapi-sandbox.yext.com";
return "sbx-cdn.yextapis.com";
default:
return "liveapi.yext.com";
return "cdn.yextapis.com";
}
case Region.EU:
if (env === Environment.PRODUCTION) {
Expand Down
8 changes: 4 additions & 4 deletions tests/ChatCore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe("URL and http request construction", () => {
const chatCore = provideChatCore(defaultConfig);
await chatCore.getNextMessage(mockedMessageRequest);
expect(httpServiceSpy).toHaveBeenCalledWith(
"https://liveapi.yext.com/v2/accounts/me/chat/my-bot/message",
"https://cdn.yextapis.com/v2/accounts/me/chat/my-bot/message",
{ v: defaultApiVersion },
mockedMessageRequest,
"my-api-key"
Expand All @@ -102,7 +102,7 @@ describe("URL and http request construction", () => {
const chatCore = provideChatCore(defaultConfig);
await chatCore.streamNextMessage(mockedMessageRequest);
expect(httpServiceSpy).toHaveBeenCalledWith(
"https://liveapi.yext.com/v2/accounts/me/chat/my-bot/message/streaming",
"https://cdn.yextapis.com/v2/accounts/me/chat/my-bot/message/streaming",
{ v: defaultApiVersion },
mockedMessageRequest,
"my-api-key"
Expand Down Expand Up @@ -164,7 +164,7 @@ describe("URL and http request construction", () => {
const chatCore = provideChatCore(configWithVersion);
await chatCore.getNextMessage(mockedMessageRequest);
expect(httpServiceSpy).toHaveBeenCalledWith(
"https://liveapi.yext.com/v2/accounts/me/chat/my-bot/message",
"https://cdn.yextapis.com/v2/accounts/me/chat/my-bot/message",
{ v: defaultApiVersion },
{
version: '42',
Expand All @@ -183,7 +183,7 @@ describe("URL and http request construction", () => {
const chatCore = provideChatCore(configWithVersion);
await chatCore.streamNextMessage(mockedMessageRequest);
expect(httpServiceSpy).toHaveBeenCalledWith(
"https://liveapi.yext.com/v2/accounts/me/chat/my-bot/message/streaming",
"https://cdn.yextapis.com/v2/accounts/me/chat/my-bot/message/streaming",
{ v: defaultApiVersion },
{
version: '42',
Expand Down
12 changes: 6 additions & 6 deletions tests/infra/EndPointFactory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ it("provides proper endpoint for default env, region, and businessId", () => {
botId: "my-bot",
});
expect(endpoints).toEqual({
chat: `https://liveapi.yext.com/v2/accounts/me/chat/my-bot/message`,
chatStream: `https://liveapi.yext.com/v2/accounts/me/chat/my-bot/message/streaming`,
chat: `https://cdn.yextapis.com/v2/accounts/me/chat/my-bot/message`,
chatStream: `https://cdn.yextapis.com/v2/accounts/me/chat/my-bot/message/streaming`,
});
});

Expand All @@ -16,8 +16,8 @@ it("provides proper endpoint for custom env", () => {
env: "SANDBOX",
});
expect(endpoints).toEqual({
chat: `https://liveapi-sandbox.yext.com/v2/accounts/me/chat/my-bot/message`,
chatStream: `https://liveapi-sandbox.yext.com/v2/accounts/me/chat/my-bot/message/streaming`,
chat: `https://sbx-cdn.yextapis.com/v2/accounts/me/chat/my-bot/message`,
chatStream: `https://sbx-cdn.yextapis.com/v2/accounts/me/chat/my-bot/message/streaming`,
});
});

Expand All @@ -38,8 +38,8 @@ it("provides proper endpoint for custom businessId", () => {
businessId: 123,
});
expect(endpoints).toEqual({
chat: `https://liveapi.yext.com/v2/accounts/123/chat/my-bot/message`,
chatStream: `https://liveapi.yext.com/v2/accounts/123/chat/my-bot/message/streaming`,
chat: `https://cdn.yextapis.com/v2/accounts/123/chat/my-bot/message`,
chatStream: `https://cdn.yextapis.com/v2/accounts/123/chat/my-bot/message/streaming`,
});
});

Expand Down

0 comments on commit a6069ce

Please sign in to comment.