Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions packages/api-axios/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ import AvApiCore, {
AvUsers,
AvUserPermissions,
AvWebQL,
AvFeatureManagement,
AvCustomerManagement,
AvUserManagement,
} from '@availity/api-core';

export type { AvApiResponse, RequestConfig, PaginatedData } from '@availity/api-core';
Expand All @@ -53,6 +56,14 @@ export type {
DisclaimersResponse,
Notification,
RouteConfiguration,
UserPermission,
UserPermissionsResponse,
CustomerOrganization,
CustomerOrganizationResponse,
CustomerOrganizationsResponse,
CustomerRegion,
CustomerRegionsResponse,
ManagedUser,
} from '@availity/api-core';

export interface ApiConfig extends AvApiConfig, AxiosRequestConfig {
Expand Down Expand Up @@ -145,6 +156,15 @@ declare const avUserPermissionsApi: AvUserPermissionsApi;
declare class AvWebQLApi extends AvWebQL {}
declare const avWebQLApi: AvWebQLApi;

declare class AvFeatureManagementApi extends AvFeatureManagement {}
declare const avFeatureManagementApi: AvFeatureManagementApi;

declare class AvCustomerManagementApi extends AvCustomerManagement {}
declare const avCustomerManagementApi: AvCustomerManagementApi;

declare class AvUserManagementApi extends AvUserManagement {}
declare const avUserManagementApi: AvUserManagementApi;

export default AvApi;

export {
Expand Down Expand Up @@ -196,4 +216,10 @@ export {
AvUserPermissionsApi,
avWebQLApi,
AvWebQLApi,
avFeatureManagementApi,
AvFeatureManagementApi,
avCustomerManagementApi,
AvCustomerManagementApi,
avUserManagementApi,
AvUserManagementApi,
};
9 changes: 9 additions & 0 deletions packages/api-axios/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ import AvUserApi, { avUserApi } from './resources/user';
import AvUserPermissionsApi, { avUserPermissionsApi } from './resources/userPermissions';
import AvStashApi, { avStashApi } from './resources/stash';
import AvWebQLApi, { avWebQLApi } from './resources/webQL';
import AvFeatureManagementApi, { avFeatureManagementApi } from './resources/featureManagement';
import AvCustomerManagementApi, { avCustomerManagementApi } from './resources/customerManagement';
import AvUserManagementApi, { avUserManagementApi } from './resources/userManagement';

export default AvApi;

Expand Down Expand Up @@ -78,4 +81,10 @@ export {
avStashApi,
AvWebQLApi,
avWebQLApi,
AvFeatureManagementApi,
avFeatureManagementApi,
AvCustomerManagementApi,
avCustomerManagementApi,
AvUserManagementApi,
avUserManagementApi,
};
139 changes: 135 additions & 4 deletions packages/api-axios/src/resources/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ All resources export both a class (for custom configuration) and a ready-to-use
- [AvSettingsApi](#avsettingsapi)
- [AvStashApi](#avstashapi)
- [AvWebQLApi](#avwebqlapi)
- [AvFeatureManagementApi](#avfeaturemanagementapi)
- [AvCustomerManagementApi](#avcustomermanagementapi)
- [AvUserManagementApi](#avusermanagementapi)

## Usage

Expand Down Expand Up @@ -564,10 +567,7 @@ Creates a stash entry with `params`, then opens `linkTo` with `sessionId` append
```js
import { avStashApi } from '@availity/api-axios';

const sessionId = await avStashApi.launch(
{ claimId: '12345', payerId: 'BCBS' },
'/apps/claim-viewer'
);
const sessionId = await avStashApi.launch({ claimId: '12345', payerId: 'BCBS' }, '/apps/claim-viewer');
// Opens: /apps/claim-viewer?sessionId=abc-123
```

Expand All @@ -588,3 +588,134 @@ const response = await avWebQLApi.create({
query: '{ user { id firstName } }',
});
```

---

## AvFeatureManagementApi

Get user permissions with associated authorized organizations from the feature-management service.

**Singleton:** `avFeatureManagementApi`

### Methods

#### `getPermissions(permissionId, region)`

Query user permissions by permission ID(s) and region. Accepts a single ID or an array. Returns `axiUserPermissions[]` via the `afterQuery` hook.

#### `hasPermission(permissionId, region)`

Returns a `boolean` — `true` if the permission exists with at least one authorized organization.

#### `getAuthorizedOrganizations(permissionId, region)`

Returns the organizations array for the matching permission.

#### `afterQuery(response)`

Hook that unwraps `axiUserPermissions` from the response, returning `[]` if absent.

```js
import { avFeatureManagementApi } from '@availity/api-axios';

const perms = await avFeatureManagementApi.getPermissions(['7777', '8888'], 'FL');
const canAccess = await avFeatureManagementApi.hasPermission('7777', 'FL');
const orgs = await avFeatureManagementApi.getAuthorizedOrganizations('7777', 'FL');
```

---

## AvCustomerManagementApi

Look up organizations and regions from the customer-management service.

**Singleton:** `avCustomerManagementApi`

### Methods

#### `getOrganization(customerId)`

GET an organization by ID. Returns `{ status, organization }`.

#### `getOrganizations(config)`

Collection query for organizations.

#### `getOrganizationData(customerId)`

Convenience method — unwraps and returns just the `organization` object.

#### `searchByName(name, config)`

Query organizations with a `{ name }` param.

#### `searchByTaxId(taxId, config)`

Query organizations with a `{ taxId }` param.

#### `getRegions(config)`

List all regions. Supports `{ sortBy, sortDirection }` params.

#### `getRegion(regionCode)`

GET a region by code (e.g. `'FL'`).

#### `getCurrentRegion()`

GET the region with `currentlySelected=true`.

#### `setCurrentRegion(regionCode, akaName)`

PUT to switch the active region for a user.

```js
import { avCustomerManagementApi } from '@availity/api-axios';

const org = await avCustomerManagementApi.getOrganizationData('12345');
const results = await avCustomerManagementApi.searchByName('Acme Health');
const regions = await avCustomerManagementApi.getRegions({ params: { sortBy: 'name' } });
await avCustomerManagementApi.setCurrentRegion('FL', 'my-aka-name');
```

---

## AvUserManagementApi

Get the current user's profile and identity details from the user-management service.

**Singleton:** `avUserManagementApi`

### Methods

#### `me()`

GET the current user's full profile response.

#### `getUser(akaName)`

GET a user by `akaName`.

#### `getMe()`

Convenience method — returns `response.data` directly.

#### `getUserId()`

Returns `user.id`.

#### `getAkaName()`

Returns `user.akaname`.

#### `getCurrentRegion()`

Returns `user.currentRegion`.

```js
import { avUserManagementApi } from '@availity/api-axios';

const profile = await avUserManagementApi.getMe();
const userId = await avUserManagementApi.getUserId();
const region = await avUserManagementApi.getCurrentRegion();
```
123 changes: 123 additions & 0 deletions packages/api-axios/src/resources/customerManagement.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import AvApi from '../api';

export default class AvCustomerManagementApi extends AvApi {
constructor(config) {
super({
path: 'cloud/web/appl/customer-management',
version: '',
...config,
});
}

orgsConfig(id = '', extraConfig = {}) {
const cfg = this.config({ ...extraConfig, name: 'legacy/v1/organizations' });
cfg.url = this.getUrl(cfg, id);
return cfg;
}

regionsConfig(id = '', extraConfig = {}) {
const cfg = this.config({ ...extraConfig, name: 'legacy/sdk/platform/v1/regions' });
cfg.url = this.getUrl(cfg, id);
return cfg;
}

// --- Organizations ---

/**
* Get a single organization by its numeric customer ID.
* Returns `{ status, organization }`.
* @param {string|number} customerId
*/
async getOrganization(customerId) {
const cfg = this.orgsConfig(customerId);
cfg.method = 'GET';
return this.request(cfg, this.afterGet);
}

/**
* Query organizations with optional filter params (e.g. customerId, name).
* @param {object} [config]
*/
async getOrganizations(config) {
const cfg = this.orgsConfig('', config);
cfg.method = 'GET';
return this.request(cfg, this.afterQuery);
}

/**
* Get a single organization and return just the organization object (unwrapped).
* @param {string|number} customerId
*/
async getOrganizationData(customerId) {
const response = await this.getOrganization(customerId);
return response?.data?.organization;
}

/**
* Search organizations by customer name.
* @param {string} name
* @param {object} [config]
*/
async searchByName(name, config) {
return this.getOrganizations({
...config,
params: { name, ...config?.params },
});
}

/**
* Search organizations by tax ID.
* @param {string} taxId
* @param {object} [config]
*/
async searchByTaxId(taxId, config) {
return this.getOrganizations({
...config,
params: { taxId, ...config?.params },
});
}

// --- Regions ---

/**
* Get all regions. Supports optional params: { sortBy, sortDirection }.
* @param {object} [config]
*/
async getRegions(config) {
const cfg = this.regionsConfig('', config);
cfg.method = 'GET';
return this.request(cfg);
}

/**
* Get a specific region by its code (e.g. 'FL', 'AZ').
* @param {string} regionCode
*/
async getRegion(regionCode) {
const cfg = this.regionsConfig(regionCode);
cfg.method = 'GET';
return this.request(cfg);
}

/**
* Get the currently selected region for the authenticated user.
*/
async getCurrentRegion() {
const cfg = this.regionsConfig('', { params: { currentlySelected: true } });
cfg.method = 'GET';
return this.request(cfg);
}

/**
* Set the current region for a user by akaName.
* @param {string} regionCode - Region code to switch to (e.g. 'AZ')
* @param {string} akaName - The user's akaName
*/
async setCurrentRegion(regionCode, akaName) {
const cfg = this.regionsConfig(regionCode, { params: { akaName } });
cfg.method = 'PUT';
return this.request(cfg, this.afterUpdate);
}
}

export const avCustomerManagementApi = new AvCustomerManagementApi();
Loading
Loading