1.1.6 • Published 2 years ago

@humany/serviceclient v1.1.6

Weekly downloads
85
License
SEE LICENSE IN LI...
Repository
-
Last release
2 years ago

@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)
categoryIdLimit 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
phraseGet categories containging guides matching a phrasestring
categoryIdLimit 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.

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.2-alpha.1

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.33

3 years ago

1.0.32

4 years ago

1.0.31

4 years ago

1.0.30

4 years ago

1.0.29

4 years ago

1.0.28

4 years ago

1.0.27

4 years ago

1.0.26

5 years ago

1.0.25

5 years ago

1.0.24

5 years ago

1.0.23

5 years ago

1.0.22

5 years ago

1.0.21

5 years ago

1.0.20

5 years ago

1.0.19

5 years ago

1.0.18

5 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

1.0.0-beta.1

6 years ago