diff --git a/README.md b/README.md index 865c211..865d367 100644 --- a/README.md +++ b/README.md @@ -78,19 +78,6 @@ try { } ``` - -### Getting a Mobile Signup - -This method allows you to retrieve the latest assessment for a given signup event, returning a signup assessment, containing the risk assessment and supporting evidence: - -```js -try { - const signupAssessment = await incogniaApi.getSignupAssessment(signupId) -} catch (error) { - console.log(error.message) -} -``` - ### Registering a Mobile Login This method registers a new mobile login for the given installation and account, returning a transaction assessment, containing the risk assessment and supporting evidence. @@ -177,20 +164,6 @@ try { } ``` -### Searching for accounts - -This method fetches every account associated with a specific installation, returning the number of accounts and an array containing the account IDs and related timestamps. Use this API to map the relationship between user accounts and devices. - -```js -try { - const accounts = await incogniaApi.searchAccounts({ - installationId: 'installation_id' - }) -} catch (error) { - console.log(error.message) -} -``` - ## Typescript enabled Thanks to Typescript, all methods attributes and data response are typed, meaning any typescript-enabled editor can take advantage of intellisense and auto-complete: diff --git a/package.json b/package.json index 5e80a10..3c255a7 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "@incognia/api", - "author": "Incognia (https://us.incognia.com)", + "author": "Incognia (https://incognia.com)", "repository": "https://github.com/inloco/incognia-node", - "version": "4.5.1", + "version": "5.0.0", "license": "MIT", "type": "module", "main": "dist/index.cjs.js", diff --git a/src/incogniaApi.ts b/src/incogniaApi.ts index 55e21b1..f3b8239 100644 --- a/src/incogniaApi.ts +++ b/src/incogniaApi.ts @@ -19,8 +19,6 @@ import { RegisterTransactionProps, RegisterWebLoginProps, RegisterWebSignupProps, - SearchAccountsBodyProps, - SearchAccountsResponse, SignupResponse, TransactionResponse, TransactionType, @@ -46,7 +44,6 @@ type ApiEndpoints = { SIGNUPS: string TRANSACTIONS: string FEEDBACKS: string - ACCOUNTS: string } const BASE_ENDPOINT = 'https://api.incognia.com/api' @@ -55,8 +52,7 @@ export const apiEndpoints: ApiEndpoints = { TOKEN: `${BASE_ENDPOINT}/v2/token`, SIGNUPS: `${BASE_ENDPOINT}/v2/onboarding/signups`, TRANSACTIONS: `${BASE_ENDPOINT}/v2/authentication/transactions`, - FEEDBACKS: `${BASE_ENDPOINT}/v2/feedbacks`, - ACCOUNTS: `${BASE_ENDPOINT}/v2/accounts/search` + FEEDBACKS: `${BASE_ENDPOINT}/v2/feedbacks` } export class IncogniaApi { @@ -77,17 +73,6 @@ export class IncogniaApi { /* ** Resources */ - async getSignupAssessment(signupId: string): Promise { - if (!signupId) { - throw new IncogniaError('No signupId provided') - } - - return this.resourceRequest({ - url: `${apiEndpoints.SIGNUPS}/${signupId}`, - method: Method.Get - }) - } - async registerSignup(props: RegisterSignupProps): Promise { const { installationId } = props || {} if (!installationId) { @@ -181,23 +166,6 @@ export class IncogniaApi { }) } - // Search Accounts - async searchAccounts( - props: SearchAccountsBodyProps - ): Promise { - const { installationId } = props || {} - if (!installationId) { - throw new IncogniaError('No installationId provided') - } - const data = convertObjectToSnakeCase(props) - - return this.resourceRequest({ - url: apiEndpoints.ACCOUNTS, - method: Method.Post, - data - }) - } - async resourceRequest(options: AxiosRequestConfig) { await this.updateAccessToken() try { diff --git a/src/types.ts b/src/types.ts index eabd945..c466ab4 100644 --- a/src/types.ts +++ b/src/types.ts @@ -472,18 +472,3 @@ export enum FeedbackEvent { SignupDeclined = 'signup_declined', Verified = 'verified' } - -export type SearchAccountsBodyProps = { - installationId: string -} - -export type SearchAccountsResponse = { - count: number - data: Array -} - -type AccountData = { - accountId: string - firstEventAt: string - lastEventAt: string -} diff --git a/src/version.ts b/src/version.ts index 4b8fe3b..aa8cf9b 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1,2 +1,2 @@ // Generated by genversion. -export const version = '4.5.1' +export const version = '5.0.0' diff --git a/test/incogniaApi.test.ts b/test/incogniaApi.test.ts index 1bbead8..5e9597c 100644 --- a/test/incogniaApi.test.ts +++ b/test/incogniaApi.test.ts @@ -75,30 +75,6 @@ describe('API', () => { }) }) - it('gets signup assessment', async () => { - const apiResponse = { - id: '5e76a7ca-577c-4f47-a752-9e1e0cee9e49', - request_id: '8afc84a7-f1d4-488d-bd69-36d9a37168b7', - risk_assessment: 'low_risk' - } - - const expectedResponse = { - id: '5e76a7ca-577c-4f47-a752-9e1e0cee9e49', - requestId: '8afc84a7-f1d4-488d-bd69-36d9a37168b7', - riskAssessment: 'low_risk' - } - - nock(BASE_ENDPOINT_URL) - .get(`/v2/onboarding/signups/${apiResponse.id}`) - .reply(200, apiResponse) - - const signupAssessment = await incogniaApi.getSignupAssessment( - apiResponse.id - ) - - expect(signupAssessment).toEqual(expectedResponse) - }) - it('registers signup', async () => { const apiResponse = { id: '5e76a7ca-577c-4f47-a752-9e1e0cee9e49', @@ -281,51 +257,6 @@ describe('API', () => { }) }) }) - - it('retrieves accounts', async () => { - const timestamp = '2022-06-02T22:25:30.885104Z' - - const apiResponse = { - count: 2, - data: [ - { - account_id: '1', - first_event_at: timestamp, - last_event_at: timestamp - }, - { - account_id: '2', - first_event_at: timestamp, - last_event_at: timestamp - } - ] - } - - const expectedResponse = { - count: 2, - data: [ - { - accountId: '1', - firstEventAt: timestamp, - lastEventAt: timestamp - }, - { - accountId: '2', - firstEventAt: timestamp, - lastEventAt: timestamp - } - ] - } - - nock(BASE_ENDPOINT_URL) - .post(`/v2/accounts/search`) - .reply(200, apiResponse) - - const accounts = await incogniaApi.searchAccounts({ - installationId: 'installation_id' - }) - expect(accounts).toEqual(expectedResponse) - }) }) describe('Access token managament', () => { @@ -366,25 +297,29 @@ describe('API', () => { describe('when calling the api ', () => { it('calls access token endpoint only at the first time', async () => { - const signupId = '123' const accessTokenEndpointFirstCall = nock(BASE_ENDPOINT_URL) .post('/v2/token') .reply(200, accessTokenExample) - const signupEndpointGet = nock(BASE_ENDPOINT_URL) + const signupEndpointRegister = nock(BASE_ENDPOINT_URL) .persist() - .get(`/v2/onboarding/signups/${signupId}`) + .post(`/v2/onboarding/signups`) .reply(200) const accessTokenEndpointSecondCall = nock(BASE_ENDPOINT_URL) .post('/v2/token') .reply(200, accessTokenExample) + const payload = { + installationId: 'installation_id', + policyId: 'policy_id' + } + //call resource for the first time - await incogniaApi.getSignupAssessment(signupId) + await incogniaApi.registerSignup(payload) expect(accessTokenEndpointFirstCall.isDone()).toBeTruthy() - expect(signupEndpointGet.isDone()).toBeTruthy() + expect(signupEndpointRegister.isDone()).toBeTruthy() //call resource for the second time - await incogniaApi.getSignupAssessment(signupId) + await incogniaApi.registerSignup(payload) expect(accessTokenEndpointSecondCall.isDone()).toBeFalsy() }) })