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

@humany/serviceclient

Package Overview
Dependencies
Maintainers
4
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@humany/serviceclient

Service client for communication with classical Humany projections.

  • 1.0.25
  • npm
  • Socket score

Version published
Weekly downloads
7
decreased by-36.36%
Maintainers
4
Weekly downloads
 
Created
Source

@humany/serviceclient

The Service Client provides an API for interacting with classic Humany projections. A projection is a URL representing a subset of content (guides, categories, contact methods etc) in a Humany application.

Projection URL Format

The standard format of a Projection URL consists of the root application url followed by the projection name.

https://[application].humany.net/[projection-name]

Create an instance of Service Client

Create an instance by passing the Projection URL as the first constructor argument.

import { ServiceClient } from '@humany/serviceclient';

const projection = '[projection-url]';
const serviceClient = new ServiceClient(projection);

Passing additional options

The second constructor argument can be used to pass additional ServiceClientOptions.

ServiceClientOptions
ArgumentDescriptionType
funnelFunnel to report statistics on.string
clientUnique ID for the clientstring
siteSite (URI) to report statistics on.string
pagingDefault paging optionsobject

Comments

  • Funnel, Client and Site can be overriden by using the options parameter on specific API calls.

Match

Match guides based on a search phrase.

match(phrase, success, [error])

ArgumentDescriptionType
phraseThe phrase to match.string
successCallback returning the result.function
errorCallback returning a description of the error.function

match(phrase, options, success, [error])

ArgumentDescriptionType
phraseThe phrase to match.string
optionsAdditional matching optionsMatchingOptions
successCallback returning the result.function
errorCallback returning a description of the error.function
MatchingOptions
ArgumentDescriptionType
statisticsDisabledWhether statistics should be reported for the request.boolean (default: false)
categoryId Limit the matching to the specified categorynumber

Example

serviceClient.match('hello world', (matchResult) => {
  console.log('matched guides:', matchResult.Matches);
});

Get categories

getCategories(success, [error])

ArgumentDescriptionType
successCallback returning the result.function
errorCallback returning a description of the error.function

getCategories(options, success, [error])

ArgumentDescriptionType
optionsAdditional matching optionsCategoriesOptions
successCallback returning the result.function
errorCallback returning a description of the error.function
CategoriesOptions
ArgumentDescriptionType
phrase Get categories containging guides matching a phrasestring
categoryId Limit the matching to the specified categorynumber
expandPossible values: 'none', 'children', 'descendants'string

Example

serviceClient.getCategories((categoryResult) => {
  console.log('all categories:', categoryResult.Children);
});

Get guide

getGuide(id, success, [error])

ArgumentDescriptionType
idGuide ID.number
successCallback returning the result.function
errorCallback returning a description of the error.function

getGuide(id, options, success, [error])

ArgumentDescriptionType
idGuide ID.number
optionsAdditional guide options.GuideOptions
successCallback returning the result.function
errorCallback returning a description of the error.function

getGuide(id, connectionKey, success, [error])

ArgumentDescriptionType
idGuide ID.number
connectionKeyA connection key (part of dialog) to get.string
successCallback returning the result.function
errorCallback returning a description of the error.function

getGuide(id, connectionKey, options, success, [error])

ArgumentDescriptionType
idGuide ID.number
connectionKeyA connection key (part of dialog) to get.string
optionsAdditional guide options.GuideOptions
successCallback returning the result.function
errorCallback returning a description of the error.function
GuideOptions
ArgumentDescriptionType
statisticsDisabledWhether statistics should be reported for the request.boolean (default: false)

Comments

  • If the Guide is not intended to be displayed as a result of a previous match statistics should be disabled.

Give feedback on guide

giveFeedback(id, connectionKey, feedbackType, [success, error])

ArgumentDescriptionType
idGuide ID.number
connectionKeyA connection key (part of dialog) to give feedback on.string
feedbackTypeType of feedback to give (Positive or Negative).string

Accessing the Service Client from a plugin

For implementations running version 4 you can author a plugin and access the current Service Client through the container under the key 'matchingClient'. The value must be resolved asynchronously as in the example below.

import { Plugin } from '@humany/widget-core';

class MyPlugin extends Plugin {
  initialize() {
    this.container.getAsync('matchingClient').then((matchingClient) => {
      // use 'matchingClient' here
    });  
  }
}

See the Skeleton Plugin repository for an example on how to author a Webprovisions plugin.

Keywords

FAQs

Package last updated on 18 Jun 2019

Did you know?

Socket

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.

Install

Related posts

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