Skip to content

Commit

Permalink
Remove searchAccounts method
Browse files Browse the repository at this point in the history
  • Loading branch information
FranciscoGileno committed Jul 5, 2024
1 parent b4fa940 commit dca5cfb
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 97 deletions.
14 changes: 0 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,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:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@incognia/api",
"author": "Incognia (https://us.incognia.com)",
"author": "Incognia (https://incognia.com)",
"repository": "https://github.com/inloco/incognia-node",
"version": "5.0.0",
"license": "MIT",
Expand Down
23 changes: 1 addition & 22 deletions src/incogniaApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import {
RegisterTransactionProps,
RegisterWebLoginProps,
RegisterWebSignupProps,
SearchAccountsBodyProps,
SearchAccountsResponse,
SignupResponse,
TransactionResponse,
TransactionType,
Expand All @@ -46,7 +44,6 @@ type ApiEndpoints = {
SIGNUPS: string
TRANSACTIONS: string
FEEDBACKS: string
ACCOUNTS: string
}

const BASE_ENDPOINT = 'https://api.incognia.com/api'
Expand All @@ -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 {
Expand Down Expand Up @@ -170,23 +166,6 @@ export class IncogniaApi {
})
}

// Search Accounts
async searchAccounts(
props: SearchAccountsBodyProps
): Promise<SearchAccountsResponse> {
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 {
Expand Down
15 changes: 0 additions & 15 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,18 +472,3 @@ export enum FeedbackEvent {
SignupDeclined = 'signup_declined',
Verified = 'verified'
}

export type SearchAccountsBodyProps = {
installationId: string
}

export type SearchAccountsResponse = {
count: number
data: Array<AccountData>
}

type AccountData = {
accountId: string
firstEventAt: string
lastEventAt: string
}
45 changes: 0 additions & 45 deletions test/incogniaApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,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', () => {
Expand Down

0 comments on commit dca5cfb

Please sign in to comment.