This package intend to publish common code regarding the Pharmactiv projets
To use an API simply instanciate it const apiCategory = new ApiCategory(config)
.
The Configuration object:
interface IConfiguration {
baseURL: string;
headers: Object;
timeout: number;
}
const configuration: IConfiguration = {
baseURL: "https://www.api.com",
fileMaxSize: 15000000,
headers: {},
timeout: 60000
};
The exported variable API_CONSTANTS
exposes the following set of constants: ACCOUNTS, DISCOUNTS, HIGHLIGHTS, PAGES.
List of endpoints: get, getById, post, patch, delete.
List of endpoints: get, getPostsById, getByType, post, patch, positionByType, delete.
interface IDrugstoreSearch {
nw: string<lat, lng>;
se: string<lat, lng>;
assistances: string<uuid>[];
specializations: string<uuid>[];
}
List of endpoints: get, getBy, getById, search(query: IDrugstoreSearch, config?: IConfiguration), register(), patch.
List of endpoints: get, getById, patch.
List of endpoints: upload(isMultiple: boolean, isBase64: boolean), getFile.
const query = {
url: '<file_url>',
}
const { data } = await apiFile.getFile(query);
List of endpoints: get(contextType?: string, contextId?: string, config?: IConfiguration), getById, getByType(type: integer, contextType?: string, contextId?: string, config?: IConfiguration), getByTypeWithQuery, post, patch, delete.
If necessary, you can send queries from Frontend to filter results like example below :
Method getByTypeWithQuery :
const query = {
env: '<env>' // Integer - Available values : API_CONSTANTS.PHREF_ENVS (For now env parameter works only with Highlight's type API_CONSTANTS.HIGHLIGHTS.HOMEPAGE_CATALOG)
};
const { data } = await apiHighlight.getByTypeWithQuery(
'<highlight_type>', // Integer - Available values : API_CONSTANTS.HIGHLIGHTS.HOMEPAGE_CATALOG
query
);
List of endpoints: patch, delete.
List of endpoints: get, post, patch, delete.
List of endpoints: auth, businesses, organizations, users, categories.
List of endpoints: version, verify, login, register, resendCode, requestResetPassword, resetPassword, me, verifyPhone, verifyPinCode, patch, patchLink, patchPassword, patchPinCode, delete, adelyaGet, adelyaPut, adelyaDelete, epsilonGet, epsilonPut, epsilonDelete, apiCoreGet, apiCorePost, apiCorePatch, apiCorePut, apiCoreDelete, linkGet, linkPost, linkPatch, linkPut, linkDelete.
List of endpoints: categories, ranges.
List of endpoints: get, getById, getBySlug, post, patch, delete.
If necessary, you can send queries from Frontend to filter results like example below :
const query = {
categories: '<category_id>,<category_id>,...', // uuid,uuid,...
level_id: '<level_id>', // uuid
right_id: '<right_id>', // uuid
packs: '<pack_id>,<pack_id>,...', // uuid,uuid,...
min_date: '<min_date>', // Y-m-d H:i:s
max_date: '<max_date>', // Y-m-d H:i:s
search: '<search>', // String
}
const { data } = await apiPost.get(query);
List of endpoints: get, getById, getByCategoryId(categoryId: integer, type: string<(medi|para)>, page?: integer, pharmanityId?: string, config?: IConfiguration), getPostsById, getStock, post, patch, delete.
The endpoint is apiSearch.get(model: string, query: string, type?: number, config?: IConfiguration)
.
Models: product, drugstore, post.
List of endpoints: get, getById, post, patch, delete.
List of endpoints: get, getById, post, patch, delete.
List of endpoints: get, getBySlug, post, patch, delete.
List of endpoints: get, post, delete.
List of endpoints: get, getById, post, patch, delete.
List of endpoints: get, getById, post, patch, delete.
List of endpoints: get, getById, post, patch, delete.
List of endpoints: get, getById, post, patch, delete.
List of endpoints: get, getById, post, patch, position, delete.
List of endpoints: get, getById, exportCsv, post, patch, delete, search, searchAdmin.
If necessary, you can send queries from Frontend to filter results like example below :
Method get (GET method) :
const query = {
category_id: '<category_id>', // uuid
level_id: '<level_id>', // uuid
zone_id: '<zone_id>', // uuid
right_id: '<right_id>', // uuid
packs: '<pack_id>,<pack_id>,...', // uuid,uuid,...
min_date: '<min_date>', // Y-m-d H:i:s
max_date: '<max_date>', // Y-m-d H:i:s
group: '<group>', // Integer - Available values : API_CONSTANTS.PHREF_GROUPS
drugstore_id: '<drugstore_id>', // uuid
}
const { data } = await apiEvent.get(query);
Method search (POST method) :
const query = {
category_id: '<category_id>', // uuid
level_id: '<level_id>', // uuid
zone_id: '<zone_id>', // uuid
right_id: '<right_id>', // uuid
packs: '<pack_id>,<pack_id>,...', // uuid,uuid,...
min_date: '<min_date>', // Y-m-d H:i:s
max_date: '<max_date>', // Y-m-d H:i:s
group: '<group>', // Integer - Available values : API_CONSTANTS.PHREF_GROUPS
drugstore_id: '<drugstore_id>', // uuid
}
const { data } = await apiEvent.search(query);
List of endpoints: get, getById, getPositionsList, post, patch, delete.
List of endpoints: get, getAdmin, post, patch, delete.
If necessary, you can send queries from Frontend to filter results like example below :
const query = {
category_id: '<category_id>', // uuid
level_id: '<level_id>', // uuid
right_id: '<right_id>', // uuid
packs: '<pack_id>,<pack_id>,...', // uuid,uuid,...
type: '<type>', // Integer
search: '<search>', // String
}
const { data } = await apiDocument.get(query);
List of endpoints: get, getByCategory, getBySlug, post, patch, positionByCategory, delete.
List of endpoints: get, getAdmin, post, patch, import, delete.
List of endpoints: get, getAdmin, getMyData, post, patch, import, delete.
If necessary, you can send queries from Frontend to filter results like example below :
const query = {
min_date: '<min_date>', // Y-m-d
max_date: '<max_date>', // Y-m-d
}
const { data } = await apiMydata.get(query);
const query = {
history: '<bool>',
}
const { data } = await apiMydata.getMyData(
'<mydata_id>', // uuid
'<cip>', // String
'<type>', // String - Available types values inside record returned by apiMydata.get()
query
);
List of endpoints: get, getAdmin, getByCategoryId, post, patch, delete.
interface ILog {
email: string;
password: string;
}
interface IResetPassword {
password: string;
confirmation_password: string;
token: string;
}
List of User endpoints: login(logs: ILog, config?: IConfiguration), loginAsAdmin(logs: ILog, config?: IConfiguration), register(), registerPharmacist(), getById, post, patch, sendResetPasswordToken(email: string, config?: IConfiguration), resetPassword(data: IResetPassword, config?: IConfiguration), logout().
List of Account endpoints: logAccount(account: Account, config: IConfiguration), patchAccount.
List of Notifications endpoints: getUnreadNotifications, getReadNotifications, setNotificationAsRead.
apiUser.getUnreadNotifications(
'<user_id>', // uuid
'<type>', // String - Allowed values : 'post', 'document'
);
apiUser.getReadNotifications(
'<user_id>', // uuid
'<type>', // String - Allowed values : 'post', 'document'
);
apiUser.setNotificationAsRead(
'<notification_id>', // uuid
);
- AccountsTypeLabel(type: integer)
- FormatCurrency
- DateFormat(date: Date, format: string)
- DateFormatDistance(date1: Date, date2: Date)
- DateFormatRelative(date1: Date, date2: Date)
For the moment, all dates are set in French.
- EventsDebounce(cb: Function): Function
- HighlightsFilter(highlights: Highlightable[], type: integer)
- HighlightsFilterOne(highlights: Highlightable[], type: integer)
- HihglightsGroup(Highlightable[])
- HighlightsGetDiscountsLabel(discountType: integer)
- HighlightsGetDiscountLabels(discountType: integer)
- HighlightsGetPriceDescription(highlightable: IHighlightable)
- HighlightsConvertCentsToEuro(price: string)
interface INotification {
content: string;
timeout?: integer; // default 5000
}
List of notifications: custom, error, info, success.
- Change package.json version and push it
npm version [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease [--preid=<prerelease-id>] | from-git]
npm publish --access public