1.3.2 • Published 1 year ago

gpdb-api-client v1.3.2

Weekly downloads
145
License
MIT
Repository
github
Last release
1 year ago

Gpdb Client

The package is a simple wrapper around NameCoach GPDB (General Pronunciation Database) API. It is useful to external developers who wish to add NameCoach services to an application.

For more information on NameCoach GPDB APi, you can visit documentation page.

Installation

Using npm:

npm i --save gpdb-api-client

Configuration:

Specify all needed values through environment variables:

GPDB_API_URL - api url (e.x. https://gpdb.name-coach.com/api/public/v1)
GPDB_ANALYTICS_API_URL - analytics api url (e.x. https://analytics-api-staging.name-coach.com/api/v1)
GPDB_ACCESS_KEY_ID - access key id for your app
GPDB_SECRET_ACCESS_KEY - secret access key for your app

Or pass it manually:

import { Configuration } from "gpdb-client";

const config = new Configuration({
  accessKeyId: 'access key',
  secretAccessKey: 'secret access key',
  apiUrl: 'https://gpdb.name-coach.com/api/public/v1',
  analyticsApiUrl: 'https://analytics-api-staging.name-coach.com/api/v1'
});

Usage

You need to create a client instance to perform requests. Basic example:

import { Client, TargetTypeSig } from "gpdb-client";
// ... configuration

const client = new Client({ instanceSig: 'example.com', typeSig: 'dns' }, config);
const result = await client.pronunciations.simpleSearch({ target: "Sergey", targetTypeSig: TargetTypeSig.FirstName, targetOwnerSig: "sergey" })

You can find detailed information about all possible parameters and the response format on the documentation page. Links to the specific methods are placed at the end of each paragraph.

All parameters should be in camelCase

API

Pronunciations

Simple search

Quick simple request to get pronunciation for a single target.

import { TargetTypeSig } from "gpdb-client";

const result = await client.pronunciations.simpleSearch({ 
  target: "Sergey", 
  targetTypeSig: TargetTypeSig.FirstName, 
  targetOwnerSig: "sergey" 
});

result
  // { target_result: { ... }, meta: { ... } }

Simple search documentation

Complex search

Perform a search in GPDB given between 1 and 10 search targets.

import { TargetTypeSig } from "gpdb-client";

const result =  await client.pronunciations.complexSearch({
  targets: [
    { target: "jack", targetTypeSig: TargetTypeSig.FirstName, targetOwnerContext: { signature: 'uuid' } },
    { target: "pavel", targetTypeSig: TargetTypeSig.FirstName, targetOwnerContext: { signature: 'uuid' } } 
    ],
  userContext: { signature: "uuid" }
});

  result
  // { target_result: { ... }, meta: { ... } }

Search by Sig

Perform a search in GPDB by target owner signature.

  const result =  await client.pronunciations.searchBySig({
    targetOwnerContext: { signature: "uuid" },
    userContext: { signature: "uuid" }
  });

  result
  // { target_result: { ... }, meta: { ... } }

TODO add link to docs after release

Create User Response

Create a user response to a pronunciation if your licensing allows it.

const result = await gpdbClient.pronunciations.userResponse({
  recordingId: "some_id",
  userResponse: "save",
  userContext: { signature: "uuid" },
  targetOwnerSig: "targetOwnerSig"
});

result
// {
//   "response_id": "aGPDBResponseSig",
//   "user_sig": "uuid",
//   "name_owner_sig": "targetOwnerSig",
//   "user_response": "save",
//   "created_at": "timestamp"
// }

Create user response documentation

Create Recording

Creating a recording requires target (name), name owner context(not required but advised), user context and application context - required.

import { TargetTypeSig } from "gpdb-client";

const result = await gpdbClient.pronunciations.createRecording({
  target: 'name',
  targetTypeSig: TargetTypeSig.FirstName,
  audioBase64: 'long_base64_string',
  userContext: { signature: 'userSig' },
  nameOwnerContext: { signature: 'nameOwnerSig' },
});

result
// {
//   "id": "ABCDE",
//   "name_text": "name",
//   "audio_url": "https://a.name-coach.audiourl",
// ...
// }

Create recording documentation

Analytics Events

Create analytics events

Create analytics event:

  await client.analyticsEvents.create({
    customerId: "uuid",
    entityId: "uuid",
    entityType: "playback",
    userId: "uuid"
  });

Create analytics events documentation

Permissions

Load

Quick simple request to get resource permissions for current app.

  const result = await client.permissions.load();

Custom Attributes

Retrieve Config

Quick simple request to retrieve custom attributes config.

  const result = await client.customAttributes.retrieveConfig();

Save Values

Post request to save user input for custom attributes.

  const result = await client.customAttributes.saveValues({ 
    userContext: { signature: 'userSig' },
    targetOwnerContext:  { signature: 'nameOwnerSig' }, 
    customAttributesValues: { some_key: 'value', another_key: true }
  });

Preferred recordings

Save

Save preferred recordings with

await.client.preferredRecordings.save({
  firstNameRecordingId: "123456",
  lastNameRecordingId: "789012",
  userContext: { signature: 'userSig@email.com', signatureType: 'email' }
})

Get

Get saved preferred recordings with

await.client.preferredRecordings.get({
  userContext: { signature: 'userSig@email.com', signatureType: 'email' }
})

Delete

Delete saved preferred recordings with

await.client.preferredRecordings.get({
  firstNameRecordingId: "123456",
  lastNameRecordingId: "789012",
  userContext: { signature: 'userSig@email.com', signatureType: 'email' }
})

Custom attributes documentation

1.3.2

1 year ago

1.2.0

1 year ago

1.2.1

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.1.55

1 year ago

1.1.52

2 years ago

1.1.51

2 years ago

1.1.54

2 years ago

1.1.53

2 years ago

1.1.50

2 years ago

1.1.49

2 years ago

1.1.45

2 years ago

1.1.47

2 years ago

1.1.46

2 years ago

1.1.43

2 years ago

1.1.38

2 years ago

1.1.37

2 years ago

1.1.36

2 years ago

1.1.35

2 years ago

1.1.39

2 years ago

1.1.41

2 years ago

1.1.40

2 years ago

1.1.33

3 years ago

1.1.29

3 years ago

1.1.31

3 years ago

1.1.27

3 years ago

1.1.22

3 years ago

1.1.21

3 years ago

1.1.19

3 years ago

1.1.11

3 years ago

1.1.15

3 years ago

1.1.13

3 years ago

1.1.9

3 years ago

1.1.7

3 years ago

1.1.5

3 years ago

1.1.3

3 years ago

1.1.1

3 years ago

1.0.15

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.10

3 years ago

1.0.12

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.3

3 years ago

1.0.0

3 years ago