Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for tenant preference overlays #42

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/knock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
MethodOptions,
} from "./common/interfaces";
import { Users } from "./resources/users";
import { Preferences } from "./resources/preferences";
import { Workflows } from "./resources/workflows";
import { TriggerWorkflowProperties } from "./resources/workflows/interfaces";
import { BulkOperations } from "./resources/bulk_operations";
Expand All @@ -35,7 +34,6 @@ class Knock {

// Service accessors
readonly users = new Users(this);
readonly preferences = new Preferences(this);
readonly workflows = new Workflows(this);
readonly bulkOperations = new BulkOperations(this);
readonly objects = new Objects(this);
Expand Down
19 changes: 6 additions & 13 deletions src/resources/objects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { ListMessagesOptions, Message } from "../messages/interfaces";
import { ListSchedulesProps, Schedule } from "../workflows/interfaces";
import {
ChannelTypePreferences,
GetPreferencesOptions,
PreferenceOptions,
PreferenceSet,
SetPreferencesProperties,
Expand Down Expand Up @@ -198,26 +199,18 @@ export class Objects {
return data;
}

/**
* @deprecated Use `objects.getPreferences` instead
*/
async getPrefences(
collection: string,
objectId: string,
options: PreferenceOptions = {},
): Promise<PreferenceSet> {
return this.getPreferences(collection, objectId, options);
}

async getPreferences(
collection: string,
objectId: string,
options: PreferenceOptions = {},
options: GetPreferencesOptions = {},
): Promise<PreferenceSet> {
const preferenceSetId = options.preferenceSet || DEFAULT_PREFERENCE_SET_ID;

const { data } = await this.knock.get(
const {
data,
} = await this.knock.get(
`/v1/objects/${collection}/${objectId}/preferences/${preferenceSetId}`,
{ tenant: options.tenant },
);

return data;
Expand Down
139 changes: 0 additions & 139 deletions src/resources/preferences/index.ts

This file was deleted.

4 changes: 4 additions & 0 deletions src/resources/preferences/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ export interface PreferenceSet {
export interface PreferenceOptions {
preferenceSet?: string;
}

export interface GetPreferencesOptions extends PreferenceOptions {
tenant?: string;
}
18 changes: 6 additions & 12 deletions src/resources/users/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
ChannelTypePreferences,
PreferenceOptions,
PreferenceSet,
GetPreferencesOptions,
SetPreferencesProperties,
WorkflowPreferences,
WorkflowPreferenceSetting,
Expand Down Expand Up @@ -128,24 +129,17 @@ export class Users {
return data;
}

/**
* @deprecated Use `users.getPreferences` instead
*/
async getPrefences(
userId: string,
options: PreferenceOptions = {},
): Promise<PreferenceSet> {
return this.getPreferences(userId, options);
}

async getPreferences(
userId: string,
options: PreferenceOptions = {},
options: GetPreferencesOptions = {},
): Promise<PreferenceSet> {
const preferenceSetId = options.preferenceSet || DEFAULT_PREFERENCE_SET_ID;

const { data } = await this.knock.get(
const {
data,
} = await this.knock.get(
`/v1/users/${userId}/preferences/${preferenceSetId}`,
{ tenant: options.tenant },
);

return data;
Expand Down