Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hull-client

Package Overview
Dependencies
Maintainers
3
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hull-client - npm Package Compare versions

Comparing version 2.0.2 to 2.0.4

6

CHANGELOG.md
# CHANGELOG
## 2.0.4
* add support for account aliases identity claim
## 2.0.3
* unpublished
## 2.0.2

@@ -4,0 +10,0 @@ * add unalias method for users and accounts

2

lib/lib/configuration.js

@@ -71,3 +71,3 @@ // @flow

*/
const ACCOUNT_CLAIMS /*: Array<string>*/ = ["id", "external_id", "domain", "anonymous_id"];
const ACCOUNT_CLAIMS /*: Array<string>*/ = ["id", "external_id", "domain", "anonymous_id", "aliases"];

@@ -74,0 +74,0 @@ /**

{
"name": "hull-client",
"version": "2.0.2",
"version": "2.0.4",
"description": "A barebones Node.js API client for hull.io",

@@ -5,0 +5,0 @@ "main": "lib",

@@ -80,18 +80,19 @@ # Overview

A common use case is to interact with the API identified as a User or Account. To get a scoped HullClient use `asUser` or `asAccount` methods just like below:
A common use case is to interact with the API identified as a User or Account. To get a scoped HullClient use `asUser` or `asAccount` methods, you pass Claims to it just like below:
```js
// if you have a user id from your database, use the `external_id` field
const user = hullClient.asUser({ external_id: "dkjf565wd654e" });
const claims = { external_id: "dkjf565wd654e" }
const userClient = hullClient.asUser(claims);
// if you have a Hull Internal User Id:
const user = hullClient.asUser({ id: "5718b59b7a85ebf20e000169" });
// or just as a string:
const user = hullClient.asUser("5718b59b7a85ebf20e000169");
const userClient = hullClient.asUser({ id: "5718b59b7a85ebf20e000169" });
// if you have the ID from a 3rd party service. The convention is to prefix with `:`:
const userClient = hullClient.asUser({ anonymous_id: "intercom:5718b59b7a85ebf20e000169" });
// Constant `user` is an instance of HullClient, scoped to a specific user
// perform an API call with the user access token
user.get("/me").then((me) => {
console.log(me);
});
const userData = await user.get("/me/user_report", { create: false });
console.log(userData)

@@ -101,3 +102,2 @@ // store attributes on this user identity

// get the access token value

@@ -107,9 +107,11 @@ user.token();

// client for an account identified by its domain name
const account = hullClient.asAccount({ domain: 'hull.io' });
account.traits({ name: "Hull inc" });
const accountClient = hullClient.asAccount({ domain: 'hull.io' });
accountClient.traits({ name: "Hull inc" });
```
### Supported Claims
To identify a User, you can use an internal Hull `id`, an ID from your own system of records or database that we call `external_id`, an `email` address or `anonymous_id`. See more examples of picking and using different User claims below.
To identify an account, you can use a Hull `id`, an `external_id` or a `domain`.
To identify an account, you can use a Hull `id`, an `external_id`, a `domain`, `anonymous_id` or an array of `aliases`.

@@ -122,6 +124,6 @@ Using `asUser` and `asAccount` methods doesn't make an API call, it just returns scoped instance of `HullClient` which comes with additional methods (see [API REFERENCE](./API.md#scopedhullclient)).

> Return a `HullClient` scoped to the user identified by its Hull ID. Not lazily created. Needs an existing User.
> Return a `HullClient` scoped to the user identified by its Hull ID. Not lazily created. Needs an existing User. Will throw an error if no user with these claims was found
```js
hullClient.asUser(userId, { create: false });
hullClient.asUser(claims, { create: false });
```

@@ -159,3 +161,2 @@

const anonymousId = "44564-EJVWE-1CE56SE-SDVE879VW8D4";
const user = client.asUser({ external_id: externalId, anonymous_id: anonymousId });

@@ -192,8 +193,3 @@ ```

```js
user.traits({
opened_tickets: 12
}, { source: "zendesk" });
// 'source' is optional. Will store the traits grouped under the source name.
// Alternatively, you can send properties for multiple groups with the flat syntax:
// you can send properties for multiple groups with the flat syntax.
user.traits({ "zendesk/opened_tickets": 12, "clearbit/name": "foo" });

@@ -200,0 +196,0 @@ ```

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc