Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
@trycourier/client-graphql
Advanced tools
Courier GraqphQl Client for usage in the browser.
Courier GraqphQl Client for usage in the browser.
You can initialize each module with either an object containing:
{
clientKey: string;
userId: string;
userSignature?: string,
}
Or alternately, you can use an issued authorization token.
{
authorization: string;
}
You can also create the client separately and pass the client in:
import { createCourierClient } from "@trycourier/client-graphql";
const courierClient = createCourierClient({
clientKey: "abc123",
userId: "@me",
userSignature: "SUPER_SECRET",
});
const messages = Messages({ client: courierClient })
const events = Events({ events: courierClient })
const events = Brands({ events: courierClient })
import { Messages } from "@trycourier/client-graphql";
const messagesApi = Messages({ authorization: "abc123" });
const getMessageCount = async (params?: {
isRead?: boolean,
from?: number,
tags?: string[],
}) => {
const messageCount = await messagesApi.getMessageCount(params);
return messageCount;
};
const getMessages = async (
params?: {
isRead?: boolean,
from?: number,
tags?: string[],
},
after?: string
) => {
const { startCursor, messages } = await messagesApi.getMessages(params);
return {
startCursor,
messages,
};
};
import { Events } from "@trycourier/client-graphql";
const eventsApi = Events({
clientKey: "abc123",
userId: "@me",
userSignature: "SUPER_SECRET",
});
const trackEvent = async (trackingId: string) => {
await eventsApi.trackEvent(trackingId);
};
import { Brands } from "@trycourier/client-graphql";
const brandsApi = Brands({
clientKey: "abc123",
userId: "@me",
userSignature: "SUPER_SECRET",
});
const getBrand = async (brandId?: string) => {
const myBrand = await brandsApi.getBrand(brandId);
return myBrand;
};
You can use our GraphQL endpoints to read and write advanced user preferences and see draft preferences. This API has getRecipientPreferences, getPreferencePage, getDraftPreferencePage, and updateRecipientPreferences methods. You can see the response payloads in action on User Preference Tester
import { Preferences } from "@trycourier/client-graphql";
const preferencesApi = Preferences({
clientKey: "abc123",
userId: "@me",
userSignature: "SUPER_SECRET",
});
const getRecipientPreferences = async (tenantId?: string) => {
const user_preferences = await preferencesApi.getRecipientPreferences(
tenantId
);
return user_preferences;
};
const getPreferencePage = async (tenantId?: string) => {
const page_with_defaults = await preferencesApi.getPreferencePage(tenantId);
return page_with_defaults;
};
const getDraftPreferencePage = async (tenantId?: string) => {
const draft_page_with_defaults = await preferencesApi.getDraftPreferencePage(
tenantId
);
return draft_page_with_defaults;
};
const updateRecipientPreferences = async (
payload: UpdateRecipientPreferencesPayload
) => {
const update_preferences = await preferencesApi.updateRecipientPreferences(
payload
);
return update_preferences;
};
interface UpdateRecipientPreferencesPayload {
templateId: string;
status: string;
hasCustomRouting: boolean;
routingPreferences: Array<string>;
digestSchedule: string;
tenantId?: string;
}
This will instantiate the client required to query the Courier GraphQL. getBanners will grab all banners for that user
import { Banner } from "@trycourier/client-graphql";
const bannerApi = Banner({
clientKey: "abc123",
userId: "@me",
userSignature: "SUPER_SECRET", //optional
});
const getBanners = async (params?: IGetBannerParams) => {
const myBanners = await bannerApi.getBanners(params);
return myBanners;
};
The following code will archive the selected banner for that user. After receiving and processing in Courier, getBanners will no longer return the banner. Archiving is an asynchronous process; there will be a slight delay before the banner is removed in the getBanners API call.
const config = {
clientKey: "abc123",
userId: "@me",
userSignature: "SUPER_SECRET", //optional
}
const bannerApi = Banner(config);
const eventsApi = Events(config);
const getBanners = async (params?: IGetBannerParams) => {
const myBanners = await bannerApi.getBanners(params);
return myBanners;
};
const banners = await getBanner();
await eventsApi.trackEvent(
banners.content.trackingIds.archiveTrackingId
);
interface IGetBannerParams {
from?: number;
limit?: number;
locale?: string;
tags?: string[];
trackingIds?: boolean;
}
import { Banner } from "@trycourier/client-graphql";
const bannerApi = Banner({ authorization: "MY JWT TOKEN" });
const getBanners = async (params?: { tags?: string[], locale?: string }) => {
const myBanners = await bannerApi.getBanners(params);
return myBanners;
};
FAQs
Courier GraqphQl Client for usage in the browser.
We found that @trycourier/client-graphql demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.