@scout9/admin 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/build/api-openai.d.ts +2992 -0
- package/build/api-openai.js +1968 -0
- package/build/api.d.ts +78 -0
- package/build/api.js +90 -0
- package/build/base.d.ts +43 -0
- package/build/base.js +52 -0
- package/build/common.d.ts +54 -0
- package/build/common.js +132 -0
- package/build/configuration.d.ts +84 -0
- package/build/configuration.js +106 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +18 -0
- package/build/schemas/common/algolia.d.ts +20 -0
- package/build/schemas/common/algolia.js +2 -0
- package/build/schemas/common/contact-map.d.ts +33 -0
- package/build/schemas/common/contact-map.js +2 -0
- package/build/schemas/common/currency.d.ts +1 -0
- package/build/schemas/common/currency.js +2 -0
- package/build/schemas/common/index.d.ts +6 -0
- package/build/schemas/common/index.js +22 -0
- package/build/schemas/common/location.d.ts +5 -0
- package/build/schemas/common/location.js +2 -0
- package/build/schemas/common/task.d.ts +20 -0
- package/build/schemas/common/task.js +2 -0
- package/build/schemas/common/time.d.ts +14 -0
- package/build/schemas/common/time.js +2 -0
- package/build/schemas/common.d.ts +77 -0
- package/build/schemas/common.js +8 -0
- package/build/schemas/conversations/context.d.ts +55 -0
- package/build/schemas/conversations/context.js +2 -0
- package/build/schemas/conversations/conversation.d.ts +53 -0
- package/build/schemas/conversations/conversation.js +2 -0
- package/build/schemas/conversations/index.d.ts +6 -0
- package/build/schemas/conversations/index.js +22 -0
- package/build/schemas/conversations/message.d.ts +62 -0
- package/build/schemas/conversations/message.js +2 -0
- package/build/schemas/conversations/parsed.d.ts +7 -0
- package/build/schemas/conversations/parsed.js +2 -0
- package/build/schemas/conversations/scheduled-conversation.d.ts +31 -0
- package/build/schemas/conversations/scheduled-conversation.js +2 -0
- package/build/schemas/conversations/webhook.d.ts +8 -0
- package/build/schemas/conversations/webhook.js +2 -0
- package/build/schemas/index.d.ts +3 -0
- package/build/schemas/index.js +19 -0
- package/build/schemas/users/businesses/agents/agent.d.ts +76 -0
- package/build/schemas/users/businesses/agents/agent.js +2 -0
- package/build/schemas/users/businesses/agents/auth.d.ts +7 -0
- package/build/schemas/users/businesses/agents/auth.js +2 -0
- package/build/schemas/users/businesses/agents/index.d.ts +2 -0
- package/build/schemas/users/businesses/agents/index.js +18 -0
- package/build/schemas/users/businesses/business-location.d.ts +10 -0
- package/build/schemas/users/businesses/business-location.js +2 -0
- package/build/schemas/users/businesses/business.d.ts +32 -0
- package/build/schemas/users/businesses/business.js +2 -0
- package/build/schemas/users/businesses/context/context-indexed.d.ts +9 -0
- package/build/schemas/users/businesses/context/context-indexed.js +2 -0
- package/build/schemas/users/businesses/context/context-saves.d.ts +12 -0
- package/build/schemas/users/businesses/context/context-saves.js +2 -0
- package/build/schemas/users/businesses/context/context.d.ts +64 -0
- package/build/schemas/users/businesses/context/context.js +2 -0
- package/build/schemas/users/businesses/context/index.d.ts +2 -0
- package/build/schemas/users/businesses/context/index.js +18 -0
- package/build/schemas/users/businesses/index.d.ts +5 -0
- package/build/schemas/users/businesses/index.js +21 -0
- package/build/schemas/users/businesses/notifications.d.ts +7 -0
- package/build/schemas/users/businesses/notifications.js +2 -0
- package/build/schemas/users/businesses/offerings/index.d.ts +2 -0
- package/build/schemas/users/businesses/offerings/index.js +18 -0
- package/build/schemas/users/businesses/offerings/offer-indexed.d.ts +34 -0
- package/build/schemas/users/businesses/offerings/offer-indexed.js +2 -0
- package/build/schemas/users/businesses/offerings/offer.d.ts +29 -0
- package/build/schemas/users/businesses/offerings/offer.js +2 -0
- package/build/schemas/users/businesses/thread.d.ts +44 -0
- package/build/schemas/users/businesses/thread.js +2 -0
- package/build/schemas/users/customers/customer.d.ts +35 -0
- package/build/schemas/users/customers/customer.js +2 -0
- package/build/schemas/users/customers/index.d.ts +1 -0
- package/build/schemas/users/customers/index.js +17 -0
- package/build/schemas/users/index.d.ts +2 -0
- package/build/schemas/users/index.js +18 -0
- package/package.json +33 -0
- package/src/api-openai.txt +4117 -0
- package/src/api.ts +141 -0
- package/src/base.ts +55 -0
- package/src/common.ts +136 -0
- package/src/configuration.ts +124 -0
- package/src/index.ts +2 -0
- package/src/schemas/common/algolia.ts +24 -0
- package/src/schemas/common/contact-map.ts +35 -0
- package/src/schemas/common/currency.ts +1 -0
- package/src/schemas/common/index.ts +6 -0
- package/src/schemas/common/location.ts +6 -0
- package/src/schemas/common/task.ts +26 -0
- package/src/schemas/common/time.ts +15 -0
- package/src/schemas/common.ts +94 -0
- package/src/schemas/conversations/context.ts +64 -0
- package/src/schemas/conversations/conversation.ts +68 -0
- package/src/schemas/conversations/index.ts +6 -0
- package/src/schemas/conversations/message.ts +78 -0
- package/src/schemas/conversations/parsed.ts +5 -0
- package/src/schemas/conversations/scheduled-conversation.ts +35 -0
- package/src/schemas/conversations/webhook.ts +10 -0
- package/src/schemas/index.ts +3 -0
- package/src/schemas/users/businesses/agents/agent.ts +107 -0
- package/src/schemas/users/businesses/agents/auth.ts +8 -0
- package/src/schemas/users/businesses/agents/index.ts +2 -0
- package/src/schemas/users/businesses/business-location.ts +15 -0
- package/src/schemas/users/businesses/business.ts +43 -0
- package/src/schemas/users/businesses/context/context-indexed.ts +11 -0
- package/src/schemas/users/businesses/context/context-saves.ts +14 -0
- package/src/schemas/users/businesses/context/context.ts +76 -0
- package/src/schemas/users/businesses/context/index.ts +2 -0
- package/src/schemas/users/businesses/index.ts +6 -0
- package/src/schemas/users/businesses/notifications.ts +12 -0
- package/src/schemas/users/businesses/offerings/index.ts +2 -0
- package/src/schemas/users/businesses/offerings/offer-indexed.ts +42 -0
- package/src/schemas/users/businesses/offerings/offer.ts +39 -0
- package/src/schemas/users/businesses/thread.ts +55 -0
- package/src/schemas/users/customers/customer.ts +46 -0
- package/src/schemas/users/customers/index.ts +1 -0
- package/src/schemas/users/index.ts +2 -0
- package/tsconfig.json +16 -0
- package/tsconfig.tsbuildinfo +1 -0
package/src/api.ts
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type { Configuration } from './configuration';
|
|
2
|
+
import type { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
3
|
+
import globalAxios from 'axios';
|
|
4
|
+
// Some imports not used depending on template conditions
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from './common';
|
|
7
|
+
import type { RequestArgs } from './base';
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
import { BASE_PATH, COLLECTION_FORMATS, BaseAPI, RequiredError, API_VERSION } from './base';
|
|
10
|
+
import { ICustomer } from './schemas';
|
|
11
|
+
|
|
12
|
+
export type ICustomerCreateRequest = ICustomer;
|
|
13
|
+
|
|
14
|
+
export interface ICustomerCreateResponse {
|
|
15
|
+
success: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type ICustomerUpdateRequest = Partial<ICustomer>;
|
|
19
|
+
|
|
20
|
+
export interface ICustomerUpdateResponse {
|
|
21
|
+
success: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface ICustomerRemoveRequest {
|
|
25
|
+
customer: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface ICustomerRemoveResponse {
|
|
29
|
+
success: boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface ICustomerCreateBulkRequest {
|
|
33
|
+
customers: ICustomer[];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface ICustomerCreateBulkResponse {
|
|
37
|
+
success: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface ICustomerRemoveBulkRequest {
|
|
41
|
+
customers: string[];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface ICustomerRemoveBulkResponse {
|
|
45
|
+
success: boolean;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface ICustomerUpdateBulkRequest {
|
|
49
|
+
customers: Partial<ICustomer>[];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface ICustomerUpdateBulkResponse {
|
|
53
|
+
success: boolean;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const Scout9ApiAxiosParamCreator = function (configuration?: Configuration) {
|
|
57
|
+
return {
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
*
|
|
61
|
+
* @summary Creates a model response for the given chat conversation.
|
|
62
|
+
* @param {ICustomerCreateRequest} createCustomerRequest
|
|
63
|
+
* @param {*} [options] Override http request option.
|
|
64
|
+
* @throws {RequiredError}
|
|
65
|
+
*/
|
|
66
|
+
createCustomer: async (createCustomerRequest: ICustomerCreateRequest, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
|
67
|
+
// verify required parameter 'createChatCompletionRequest' is not null or undefined
|
|
68
|
+
assertParamExists('createCustomer', 'createCustomerRequest', createCustomerRequest);
|
|
69
|
+
const localVarPath = `${configuration?.apiVersion || ''}-customers-customer-create`;
|
|
70
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
71
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
72
|
+
let baseOptions;
|
|
73
|
+
if (configuration) {
|
|
74
|
+
baseOptions = configuration.baseOptions;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const localVarRequestOptions = {method: 'POST', ...baseOptions, ...options};
|
|
78
|
+
const localVarHeaderParameter = {} as any;
|
|
79
|
+
const localVarQueryParameter = {} as any;
|
|
80
|
+
|
|
81
|
+
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
82
|
+
|
|
83
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
84
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
85
|
+
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
|
86
|
+
localVarRequestOptions.data = serializeDataIfNeeded(createCustomerRequest, localVarRequestOptions, configuration);
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
url: toPathString(localVarUrlObj),
|
|
90
|
+
options: localVarRequestOptions,
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Scout9Api - functional programming interface
|
|
100
|
+
* @export
|
|
101
|
+
*/
|
|
102
|
+
export const Scout9ApiFp = function (configuration?: Configuration) {
|
|
103
|
+
const localVarAxiosParamCreator = Scout9ApiAxiosParamCreator(configuration);
|
|
104
|
+
return {
|
|
105
|
+
/**
|
|
106
|
+
*
|
|
107
|
+
* @summary Creates a model response for the given chat conversation.
|
|
108
|
+
* @param {ICustomerCreateRequest} createCustomerRequest
|
|
109
|
+
* @param {*} [options] Override http request option.
|
|
110
|
+
* @throws {RequiredError}
|
|
111
|
+
*/
|
|
112
|
+
async createCustomer(createCustomerRequest: ICustomerCreateRequest, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ICustomerCreateResponse>> {
|
|
113
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.createCustomer(createCustomerRequest, options);
|
|
114
|
+
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Scout9Api - object-oriented interface
|
|
121
|
+
* @export
|
|
122
|
+
* @class Scout9Api
|
|
123
|
+
* @extends {BaseAPI}
|
|
124
|
+
*/
|
|
125
|
+
export class Scout9Api extends BaseAPI {
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
*
|
|
129
|
+
* @summary Creates a model response for the given chat conversation.
|
|
130
|
+
* @param {ICustomerCreateRequest} createCustomerRequest
|
|
131
|
+
* @param {*} [options] Override http request option.
|
|
132
|
+
* @throws {RequiredError}
|
|
133
|
+
* @memberof Scout9Api
|
|
134
|
+
*/
|
|
135
|
+
public createCustomer(createCustomerRequest: ICustomerCreateRequest, options?: AxiosRequestConfig) {
|
|
136
|
+
return Scout9ApiFp(this.configuration)
|
|
137
|
+
.createCustomer(createCustomerRequest, options)
|
|
138
|
+
.then((request) => request(this.axios, this.basePath));
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
}
|
package/src/base.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Configuration } from './configuration';
|
|
2
|
+
import type { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
3
|
+
import globalAxios from 'axios';
|
|
4
|
+
|
|
5
|
+
export const BASE_PATH = "https://us-central1-jumpstart.cloudfunctions.net".replace(/\/+$/, "");
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @export
|
|
10
|
+
*/
|
|
11
|
+
export const COLLECTION_FORMATS = {
|
|
12
|
+
csv: ",",
|
|
13
|
+
ssv: " ",
|
|
14
|
+
tsv: "\t",
|
|
15
|
+
pipes: "|",
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @export
|
|
21
|
+
* @interface RequestArgs
|
|
22
|
+
*/
|
|
23
|
+
export interface RequestArgs {
|
|
24
|
+
url: string;
|
|
25
|
+
options: AxiosRequestConfig;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @export
|
|
31
|
+
* @class BaseAPI
|
|
32
|
+
*/
|
|
33
|
+
export class BaseAPI {
|
|
34
|
+
protected configuration: Configuration | undefined;
|
|
35
|
+
|
|
36
|
+
constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) {
|
|
37
|
+
if (configuration) {
|
|
38
|
+
this.configuration = configuration;
|
|
39
|
+
this.basePath = configuration.basePath || this.basePath;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
*
|
|
46
|
+
* @export
|
|
47
|
+
* @class RequiredError
|
|
48
|
+
* @extends {Error}
|
|
49
|
+
*/
|
|
50
|
+
export class RequiredError extends Error {
|
|
51
|
+
constructor(public field: string, msg?: string) {
|
|
52
|
+
super(msg as string);
|
|
53
|
+
this.name = "RequiredError"
|
|
54
|
+
}
|
|
55
|
+
}
|
package/src/common.ts
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import type { Configuration } from "./configuration";
|
|
3
|
+
import type { RequestArgs, } from "./base";
|
|
4
|
+
import type { AxiosInstance, AxiosResponse } from 'axios';
|
|
5
|
+
import {RequiredError} from './base';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @export
|
|
10
|
+
*/
|
|
11
|
+
export const DUMMY_BASE_URL = 'https://example.com'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @throws {RequiredError}
|
|
16
|
+
* @export
|
|
17
|
+
*/
|
|
18
|
+
export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) {
|
|
19
|
+
if (paramValue === null || paramValue === undefined) {
|
|
20
|
+
throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @export
|
|
27
|
+
*/
|
|
28
|
+
export const setApiKeyToObject = async function (object: any, keyParamName: string, configuration?: Configuration) {
|
|
29
|
+
if (configuration && configuration.apiKey) {
|
|
30
|
+
const localVarApiKeyValue = typeof configuration.apiKey === 'function'
|
|
31
|
+
? await configuration.apiKey(keyParamName)
|
|
32
|
+
: await configuration.apiKey;
|
|
33
|
+
object[keyParamName] = localVarApiKeyValue;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
* @export
|
|
40
|
+
*/
|
|
41
|
+
export const setBasicAuthToObject = function (object: any, configuration?: Configuration) {
|
|
42
|
+
if (configuration && (configuration.username || configuration.password)) {
|
|
43
|
+
object["auth"] = { username: configuration.username, password: configuration.password };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
*
|
|
49
|
+
* @export
|
|
50
|
+
*/
|
|
51
|
+
export const setBearerAuthToObject = async function (object: any, configuration?: Configuration) {
|
|
52
|
+
if (configuration && configuration.accessToken) {
|
|
53
|
+
const accessToken = typeof configuration.accessToken === 'function'
|
|
54
|
+
? await configuration.accessToken()
|
|
55
|
+
: await configuration.accessToken;
|
|
56
|
+
object["Authorization"] = "Bearer " + accessToken;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
*
|
|
62
|
+
* @export
|
|
63
|
+
*/
|
|
64
|
+
export const setOAuthToObject = async function (object: any, name: string, scopes: string[], configuration?: Configuration) {
|
|
65
|
+
if (configuration && configuration.accessToken) {
|
|
66
|
+
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
|
|
67
|
+
? await configuration.accessToken(name, scopes)
|
|
68
|
+
: await configuration.accessToken;
|
|
69
|
+
object["Authorization"] = "Bearer " + localVarAccessTokenValue;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void {
|
|
74
|
+
if (parameter == null) return;
|
|
75
|
+
if (typeof parameter === "object") {
|
|
76
|
+
if (Array.isArray(parameter)) {
|
|
77
|
+
(parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
Object.keys(parameter).forEach(currentKey =>
|
|
81
|
+
setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`)
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
if (urlSearchParams.has(key)) {
|
|
87
|
+
urlSearchParams.append(key, parameter);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
urlSearchParams.set(key, parameter);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
*
|
|
97
|
+
* @export
|
|
98
|
+
*/
|
|
99
|
+
export const setSearchParams = function (url: URL, ...objects: any[]) {
|
|
100
|
+
const searchParams = new URLSearchParams(url.search);
|
|
101
|
+
setFlattenedQueryParams(searchParams, objects);
|
|
102
|
+
url.search = searchParams.toString();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
*
|
|
107
|
+
* @export
|
|
108
|
+
*/
|
|
109
|
+
export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) {
|
|
110
|
+
const nonString = typeof value !== 'string';
|
|
111
|
+
const needsSerialization = nonString && configuration && configuration.isJsonMime
|
|
112
|
+
? configuration.isJsonMime(requestOptions.headers['Content-Type'])
|
|
113
|
+
: nonString;
|
|
114
|
+
return needsSerialization
|
|
115
|
+
? JSON.stringify(value !== undefined ? value : {})
|
|
116
|
+
: (value || "");
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
*
|
|
121
|
+
* @export
|
|
122
|
+
*/
|
|
123
|
+
export const toPathString = function (url: URL) {
|
|
124
|
+
return url.pathname + url.search + url.hash
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
*
|
|
129
|
+
* @export
|
|
130
|
+
*/
|
|
131
|
+
export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) {
|
|
132
|
+
return <T = unknown, R = AxiosResponse<T>>(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
|
|
133
|
+
const axiosRequestArgs: AxiosRequestConfig<any> = {...axiosArgs.options, url: (configuration?.basePath || basePath) + axiosArgs.url};
|
|
134
|
+
return axios.request<T, R>(axiosRequestArgs);
|
|
135
|
+
};
|
|
136
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
const packageJson = require("../package.json");
|
|
2
|
+
|
|
3
|
+
export interface ConfigurationParameters {
|
|
4
|
+
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
|
5
|
+
organization?: string;
|
|
6
|
+
username?: string;
|
|
7
|
+
password?: string;
|
|
8
|
+
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
|
|
9
|
+
basePath?: string;
|
|
10
|
+
baseOptions?: any;
|
|
11
|
+
formDataCtor?: new () => any;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class Configuration {
|
|
15
|
+
/**
|
|
16
|
+
* parameter for apiKey security
|
|
17
|
+
* @param name security name
|
|
18
|
+
* @memberof Configuration
|
|
19
|
+
*/
|
|
20
|
+
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Scout9 organization id
|
|
24
|
+
*
|
|
25
|
+
* @type {string}
|
|
26
|
+
* @memberof Configuration
|
|
27
|
+
*/
|
|
28
|
+
organization?: string;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* parameter for basic security
|
|
32
|
+
*
|
|
33
|
+
* @type {string}
|
|
34
|
+
* @memberof Configuration
|
|
35
|
+
*/
|
|
36
|
+
username?: string;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* parameter for basic security
|
|
40
|
+
*
|
|
41
|
+
* @type {string}
|
|
42
|
+
* @memberof Configuration
|
|
43
|
+
*/
|
|
44
|
+
password?: string;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* parameter for oauth2 security
|
|
48
|
+
* @param name security name
|
|
49
|
+
* @param scopes oauth2 scope
|
|
50
|
+
* @memberof Configuration
|
|
51
|
+
*/
|
|
52
|
+
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* override base path
|
|
56
|
+
*
|
|
57
|
+
* @type {string}
|
|
58
|
+
* @memberof Configuration
|
|
59
|
+
*/
|
|
60
|
+
basePath?: string;
|
|
61
|
+
/**
|
|
62
|
+
* base options for axios calls
|
|
63
|
+
*
|
|
64
|
+
* @type {any}
|
|
65
|
+
* @memberof Configuration
|
|
66
|
+
*/
|
|
67
|
+
baseOptions?: any;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The FormData constructor that will be used to create multipart form data
|
|
71
|
+
* requests. You can inject this here so that execution environments that
|
|
72
|
+
* do not support the FormData class can still run the generated client.
|
|
73
|
+
*
|
|
74
|
+
* @type {new () => FormData}
|
|
75
|
+
*/
|
|
76
|
+
formDataCtor?: new () => any;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The version of the Scout9 API that this client library version is
|
|
80
|
+
*/
|
|
81
|
+
apiVersion?: string;
|
|
82
|
+
|
|
83
|
+
constructor(param: ConfigurationParameters = {}) {
|
|
84
|
+
this.apiKey = param.apiKey;
|
|
85
|
+
this.organization = param.organization;
|
|
86
|
+
this.username = param.username;
|
|
87
|
+
this.password = param.password;
|
|
88
|
+
this.accessToken = param.accessToken;
|
|
89
|
+
this.basePath = param.basePath;
|
|
90
|
+
this.baseOptions = param.baseOptions;
|
|
91
|
+
this.formDataCtor = param.formDataCtor;
|
|
92
|
+
this.apiVersion = 'v' + packageJson.version.split(".")[0];
|
|
93
|
+
|
|
94
|
+
if (!this.baseOptions) {
|
|
95
|
+
this.baseOptions = {};
|
|
96
|
+
}
|
|
97
|
+
this.baseOptions.headers = {
|
|
98
|
+
'User-Agent': `Scout9/NodeJS/${packageJson.version}`,
|
|
99
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
100
|
+
...this.baseOptions.headers,
|
|
101
|
+
}
|
|
102
|
+
if (this.organization) {
|
|
103
|
+
this.baseOptions.headers['Scout9-Organization'] = this.organization;
|
|
104
|
+
}
|
|
105
|
+
if (!this.formDataCtor) {
|
|
106
|
+
this.formDataCtor = require("form-data");
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Check if the given MIME is a JSON MIME.
|
|
112
|
+
* JSON MIME examples:
|
|
113
|
+
* application/json
|
|
114
|
+
* application/json; charset=UTF8
|
|
115
|
+
* APPLICATION/JSON
|
|
116
|
+
* application/vnd.company+json
|
|
117
|
+
* @param mime - MIME (Multipurpose Internet Mail Extensions)
|
|
118
|
+
* @return True if the given MIME is JSON, false otherwise.
|
|
119
|
+
*/
|
|
120
|
+
public isJsonMime(mime: string): boolean {
|
|
121
|
+
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
|
|
122
|
+
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
|
|
123
|
+
}
|
|
124
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper schedule to bridge algolia records with internal db
|
|
3
|
+
*/
|
|
4
|
+
export interface IAlgoliaIndexedObject {
|
|
5
|
+
/**
|
|
6
|
+
* Where this object is stored in the database
|
|
7
|
+
*/
|
|
8
|
+
parent: string;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Algolia objectID required
|
|
12
|
+
*/
|
|
13
|
+
objectID: string;
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Algolia geolocation for a given object
|
|
18
|
+
*/
|
|
19
|
+
_geoloc?: {
|
|
20
|
+
lat: number;
|
|
21
|
+
lng: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { EmailServiceType } from '../users';
|
|
2
|
+
|
|
3
|
+
export interface IContactPath {
|
|
4
|
+
id: string;
|
|
5
|
+
path: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A utility helper collection to map contact information to a common format.
|
|
9
|
+
*
|
|
10
|
+
* scout9-contact-map/{contact}
|
|
11
|
+
*/
|
|
12
|
+
export interface IContactMap {
|
|
13
|
+
/**
|
|
14
|
+
* Can either be the formatted phone number or email address.
|
|
15
|
+
*/
|
|
16
|
+
contact: string;
|
|
17
|
+
agentPaths: {
|
|
18
|
+
businessId: string;
|
|
19
|
+
agentId: string;
|
|
20
|
+
}[];
|
|
21
|
+
customerPaths: {
|
|
22
|
+
businessId: string;
|
|
23
|
+
customerId: string;
|
|
24
|
+
}[];
|
|
25
|
+
|
|
26
|
+
programmableEmailProps?: {
|
|
27
|
+
type: EmailServiceType;
|
|
28
|
+
/**
|
|
29
|
+
* If this email is a gmail email, then we can store the refresh token (after they O-Auth) here so that we can run gmail.contacts.watch
|
|
30
|
+
* @TODO - create a O-Auth flow for this, see scripts/gmail/generate-refresh-token for an example
|
|
31
|
+
*/
|
|
32
|
+
gmailRefreshToken?: string;
|
|
33
|
+
gmailWatchExpiration?: string;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Currency = 'usd' | 'cad';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Timestamp } from '../common';
|
|
2
|
+
|
|
3
|
+
export interface ITask {
|
|
4
|
+
/**
|
|
5
|
+
* Unique token for processing
|
|
6
|
+
*/
|
|
7
|
+
token?: string;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Time when the task was created
|
|
11
|
+
*/
|
|
12
|
+
time: Timestamp;
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* When was the task completed
|
|
17
|
+
*/
|
|
18
|
+
completed?: Timestamp;
|
|
19
|
+
|
|
20
|
+
retries?: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface IQueueTask {
|
|
24
|
+
token: string;
|
|
25
|
+
taskPath: string;
|
|
26
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import moment from 'moment';
|
|
2
|
+
import { ISOString, Timestamp } from '../common';
|
|
3
|
+
|
|
4
|
+
export interface ITimeRange {
|
|
5
|
+
from: ISOString;
|
|
6
|
+
to: ISOString;
|
|
7
|
+
}
|
|
8
|
+
export interface ITimeRangeTimestamp {
|
|
9
|
+
from: Timestamp;
|
|
10
|
+
to: Timestamp;
|
|
11
|
+
}
|
|
12
|
+
export interface ITimeRangeMoment {
|
|
13
|
+
from: moment.Moment;
|
|
14
|
+
to: moment.Moment;
|
|
15
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export type Timestamp = any;
|
|
2
|
+
export type ISOString = string;
|
|
3
|
+
|
|
4
|
+
export type MessageStatus = 'queued'|'sending'|'sent'|'failed'|'delivered'|'undelivered'|'receiving'|'received'|'accepted'|'scheduled'|'read'|'partially_delivered'|'canceled';
|
|
5
|
+
|
|
6
|
+
export const ChatCompletionRequestMessageRoleEnum = {
|
|
7
|
+
System: 'system',
|
|
8
|
+
User: 'user',
|
|
9
|
+
Assistant: 'assistant'
|
|
10
|
+
} as const;
|
|
11
|
+
|
|
12
|
+
export type ChatCompletionRequestMessageRoleEnum = typeof ChatCompletionRequestMessageRoleEnum[keyof typeof ChatCompletionRequestMessageRoleEnum];
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
export interface ChatCompletionRequestMessage {
|
|
16
|
+
/**
|
|
17
|
+
* The role of the author of this message.
|
|
18
|
+
* @type {string}
|
|
19
|
+
* @memberof ChatCompletionRequestMessage
|
|
20
|
+
*/
|
|
21
|
+
'role': ChatCompletionRequestMessageRoleEnum;
|
|
22
|
+
/**
|
|
23
|
+
* The contents of the message
|
|
24
|
+
* @type {string}
|
|
25
|
+
* @memberof ChatCompletionRequestMessage
|
|
26
|
+
*/
|
|
27
|
+
'content': string;
|
|
28
|
+
/**
|
|
29
|
+
* The name of the user in a multi-user chat
|
|
30
|
+
* @type {string}
|
|
31
|
+
* @memberof ChatCompletionRequestMessage
|
|
32
|
+
*/
|
|
33
|
+
'name'?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
export module Stripe {
|
|
38
|
+
export interface Address {
|
|
39
|
+
/**
|
|
40
|
+
* City/District/Suburb/Town/Village.
|
|
41
|
+
*/
|
|
42
|
+
city: string | null;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 2-letter country code.
|
|
46
|
+
*/
|
|
47
|
+
country: string | null;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Address line 1 (Street address/PO Box/Company name).
|
|
51
|
+
*/
|
|
52
|
+
line1: string | null;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Address line 2 (Apartment/Suite/Unit/Building).
|
|
56
|
+
*/
|
|
57
|
+
line2: string | null;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* ZIP or postal code.
|
|
61
|
+
*/
|
|
62
|
+
postal_code: string | null;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* State/County/Province/Region.
|
|
66
|
+
*/
|
|
67
|
+
state: string | null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Helper schedule to bridge algolia records with internal db
|
|
73
|
+
*/
|
|
74
|
+
export interface IAlgoliaIndexedObject {
|
|
75
|
+
/**
|
|
76
|
+
* Where this object is stored in the database
|
|
77
|
+
*/
|
|
78
|
+
parent: string;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Algolia objectID required
|
|
82
|
+
*/
|
|
83
|
+
objectID: string;
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Algolia geolocation for a given object
|
|
88
|
+
*/
|
|
89
|
+
_geoloc?: {
|
|
90
|
+
lat: number;
|
|
91
|
+
lng: number;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
}
|