@trycourier/client-graphql
Advanced tools
Comparing version 4.8.1-internal.bba30b1.0 to 4.9.0
@@ -8,3 +8,3 @@ "use strict"; | ||
}); | ||
exports["default"] = exports.getBanners = exports.QUERY_BANNER = void 0; | ||
exports["default"] = exports.getBanners = exports.QUERY_BANNER_WITH_TRACKING = exports.QUERY_BANNER = void 0; | ||
@@ -21,2 +21,4 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); | ||
exports.QUERY_BANNER = QUERY_BANNER; | ||
var QUERY_BANNER_WITH_TRACKING = "\n query GetBanners($params: BannerParamsInput, $limit: Int = 10, $after: String){\n banners(params: $params, limit: $limit, after: $after) {\n totalCount\n pageInfo {\n startCursor\n hasNextPage\n }\n nodes {\n id\n userId\n messageId\n created\n tags\n content {\n title\n body\n blocks {\n ... on TextBlock {\n type\n text\n }\n ... on ActionBlock {\n type\n text\n url\n }\n }\n data\n trackingIds {\n archiveTrackingId\n }\n }\n }\n }\n }\n"; | ||
exports.QUERY_BANNER_WITH_TRACKING = QUERY_BANNER_WITH_TRACKING; | ||
@@ -28,3 +30,3 @@ var getBanners = function getBanners(client) { | ||
var _ref2, limit, restParams, results, banners, startCursor; | ||
var _ref2, limit, getTrackindIds, restParams, results, banners, startCursor; | ||
@@ -43,5 +45,5 @@ return _regenerator["default"].wrap(function _callee$(_context) { | ||
case 2: | ||
_ref2 = params !== null && params !== void 0 ? params : {}, limit = _ref2.limit, restParams = (0, _objectWithoutProperties2["default"])(_ref2, ["limit"]); | ||
_ref2 = params !== null && params !== void 0 ? params : {}, limit = _ref2.limit, getTrackindIds = _ref2.getTrackindIds, restParams = (0, _objectWithoutProperties2["default"])(_ref2, ["limit", "getTrackindIds"]); | ||
_context.next = 5; | ||
return client.query(QUERY_BANNER, { | ||
return client.query(getTrackindIds ? QUERY_BANNER_WITH_TRACKING : QUERY_BANNER, { | ||
after: after, | ||
@@ -48,0 +50,0 @@ limit: limit, |
{ | ||
"name": "@trycourier/client-graphql", | ||
"version": "4.8.1-internal.bba30b1.0+bba30b1", | ||
"version": "4.9.0", | ||
"description": "", | ||
@@ -27,3 +27,3 @@ "main": "dist/index.js", | ||
], | ||
"gitHead": "bba30b170671230f8ea901e4fc1fc0c7d96f3073" | ||
"gitHead": "6ae0019ccbe22a4aef4bed04dc75ba6b66250f5e" | ||
} |
@@ -151,2 +151,4 @@ ## Courier Client GraphQl | ||
This will instantiate the client required to query the Courier GraphQL. getBanners will grab all banners for that user | ||
```js | ||
@@ -159,3 +161,3 @@ import { Banner } from "@trycourier/client-graphql"; | ||
}); | ||
const getBanners = async (params?: { tags?: string[], locale?: string }) => { | ||
const getBanners = async (params?: IGetBannerParams) => { | ||
const myBanners = await bannerApi.getBanners(params); | ||
@@ -166,2 +168,37 @@ return myBanners; | ||
#### Archive a banner | ||
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 | ||
); | ||
``` | ||
#### Banner Params | ||
```typescript | ||
interface IGetBannerParams { | ||
from?: number; | ||
limit?: number; | ||
locale?: string; | ||
tags?: string[]; | ||
trackingIds?: boolean; | ||
} | ||
``` | ||
#### With JWT (Supports multiple users) | ||
@@ -168,0 +205,0 @@ |
@@ -8,4 +8,6 @@ import { Client } from "urql"; | ||
tags?: string[]; | ||
getTrackindIds?: boolean; | ||
} | ||
export declare const QUERY_BANNER = "\n query GetBanners($params: BannerParamsInput, $limit: Int = 10, $after: String){\n banners(params: $params, limit: $limit, after: $after) {\n totalCount\n pageInfo {\n startCursor\n hasNextPage\n }\n nodes {\n id\n userId\n messageId\n created\n tags\n content {\n title\n body\n blocks {\n ... on TextBlock {\n type\n text\n }\n ... on ActionBlock {\n type\n text\n url\n }\n }\n data\n }\n }\n }\n }\n"; | ||
export declare const QUERY_BANNER_WITH_TRACKING = "\n query GetBanners($params: BannerParamsInput, $limit: Int = 10, $after: String){\n banners(params: $params, limit: $limit, after: $after) {\n totalCount\n pageInfo {\n startCursor\n hasNextPage\n }\n nodes {\n id\n userId\n messageId\n created\n tags\n content {\n title\n body\n blocks {\n ... on TextBlock {\n type\n text\n }\n ... on ActionBlock {\n type\n text\n url\n }\n }\n data\n trackingIds {\n archiveTrackingId\n }\n }\n }\n }\n }\n"; | ||
declare type GetBanners = (params?: IGetBannerParams, after?: string) => Promise<{ | ||
@@ -12,0 +14,0 @@ startCursor: string; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
159185
1442
1
211
0