@knocklabs/client
Advanced tools
Comparing version 0.9.3 to 0.9.4
# Changelog | ||
## 0.9.4 | ||
### Patch Changes | ||
- f58371c: Added user get and identify methods | ||
## 0.9.3 | ||
@@ -4,0 +10,0 @@ |
@@ -1,2 +0,2 @@ | ||
"use strict";var i=Object.defineProperty;var u=(s,e,t)=>e in s?i(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var a=(s,e,t)=>(u(s,typeof e!="symbol"?e+"":e,t),t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r="default";class l{constructor(e){a(this,"instance");this.instance=e}async getAllPreferences(){const e=await this.instance.client().makeRequest({method:"GET",url:`/v1/users/${this.instance.userId}/preferences`});return this.handleResponse(e)}async getPreferences(e={}){const t=e.preferenceSet||r,n=await this.instance.client().makeRequest({method:"GET",url:`/v1/users/${this.instance.userId}/preferences/${t}`,params:{tenant:e.tenant}});return this.handleResponse(n)}async setPreferences(e,t={}){const n=t.preferenceSet||r,c=await this.instance.client().makeRequest({method:"PUT",url:`/v1/users/${this.instance.userId}/preferences/${n}`,data:e});return this.handleResponse(c)}async getChannelData(e){const t=await this.instance.client().makeRequest({method:"GET",url:`/v1/users/${this.instance.userId}/channel_data/${e.channelId}`});return this.handleResponse(t)}async setChannelData({channelId:e,channelData:t}){const n=await this.instance.client().makeRequest({method:"PUT",url:`/v1/users/${this.instance.userId}/channel_data/${e}`,data:{data:t}});return this.handleResponse(n)}handleResponse(e){if(e.statusCode==="error")throw new Error(e.error||e.body);return e.body}}exports.default=l; | ||
"use strict";var c=Object.defineProperty;var u=(s,e,t)=>e in s?c(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var a=(s,e,t)=>(u(s,typeof e!="symbol"?e+"":e,t),t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r="default";class l{constructor(e){a(this,"instance");this.instance=e}async get(){const e=await this.instance.client().makeRequest({method:"GET",url:`/v1/users/${this.instance.userId}`});return this.handleResponse(e)}async identify(e={}){const t=await this.instance.client().makeRequest({method:"PUT",url:`/v1/users/${this.instance.userId}`,params:e});return this.handleResponse(t)}async getAllPreferences(){const e=await this.instance.client().makeRequest({method:"GET",url:`/v1/users/${this.instance.userId}/preferences`});return this.handleResponse(e)}async getPreferences(e={}){const t=e.preferenceSet||r,n=await this.instance.client().makeRequest({method:"GET",url:`/v1/users/${this.instance.userId}/preferences/${t}`,params:{tenant:e.tenant}});return this.handleResponse(n)}async setPreferences(e,t={}){const n=t.preferenceSet||r,i=await this.instance.client().makeRequest({method:"PUT",url:`/v1/users/${this.instance.userId}/preferences/${n}`,data:e});return this.handleResponse(i)}async getChannelData(e){const t=await this.instance.client().makeRequest({method:"GET",url:`/v1/users/${this.instance.userId}/channel_data/${e.channelId}`});return this.handleResponse(t)}async setChannelData({channelId:e,channelData:t}){const n=await this.instance.client().makeRequest({method:"PUT",url:`/v1/users/${this.instance.userId}/channel_data/${e}`,data:{data:t}});return this.handleResponse(n)}handleResponse(e){if(e.statusCode==="error")throw new Error(e.error||e.body);return e.body}}exports.default=l; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import { ChannelData } from "../../interfaces"; | ||
import { ChannelData, User } from "../../interfaces"; | ||
import Knock from "../../knock"; | ||
@@ -8,2 +8,4 @@ import { GetPreferencesOptions, PreferenceOptions, PreferenceSet, SetPreferencesProperties } from "../preferences/interfaces"; | ||
constructor(instance: Knock); | ||
get(): Promise<User>; | ||
identify(props?: Record<string, any>): Promise<User>; | ||
getAllPreferences(): Promise<PreferenceSet[]>; | ||
@@ -10,0 +12,0 @@ getPreferences(options?: GetPreferencesOptions): Promise<PreferenceSet>; |
{ | ||
"name": "@knocklabs/client", | ||
"version": "0.9.3", | ||
"version": "0.9.4", | ||
"description": "The clientside library for interacting with Knock", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/knocklabs/javascript/tree/main/packages/client", |
import { ApiResponse } from "../../api"; | ||
import { ChannelData } from "../../interfaces"; | ||
import { ChannelData, User } from "../../interfaces"; | ||
import Knock from "../../knock"; | ||
@@ -10,2 +10,3 @@ import { | ||
} from "../preferences/interfaces"; | ||
import { GetChannelDataInput, SetChannelDataInput } from "./interfaces"; | ||
@@ -22,2 +23,21 @@ | ||
async get() { | ||
const result = await this.instance.client().makeRequest({ | ||
method: "GET", | ||
url: `/v1/users/${this.instance.userId}`, | ||
}); | ||
return this.handleResponse<User>(result); | ||
} | ||
async identify(props: Record<string, any> = {}) { | ||
const result = await this.instance.client().makeRequest({ | ||
method: "PUT", | ||
url: `/v1/users/${this.instance.userId}`, | ||
params: props, | ||
}); | ||
return this.handleResponse<User>(result); | ||
} | ||
async getAllPreferences() { | ||
@@ -24,0 +44,0 @@ const result = await this.instance.client().makeRequest({ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
307855
3207