Namely is an all in one human resource information system. Its offer HRIS, payroll, benefits administration & management, and performance reviews.
If any organization have the central system of namely that contains all employee information, there is a situation where the organization has a different application that requires accessing namely employee’s data. So that this blog is more specific to how to integrate existing Namely Employee data to other software.
Prerequisite:
Authorize namely software with Administrator access rights.
Authorization with Namely System:
Once you do, you will see a form to create an API client and/or a form to create an Access Token, depending on which permissions you have. There are two ways to integrate one is API Client and other is Access Token object.
Access Token object:
Creating a Permanent Access Token is a way to bypass the OAuth flow. A Permanent Access Token is significantly longer lived, lasting 2 years. Anyone who has this Access Token is able to access Namely with it alone, which represents a significant security risk. While this access method may be convenient for your purposes.
Permanent Access Tokens:
If you decide to use Permanent Access Tokens, the interface is located alongside API Client creation and will be visible with the proper permission. Please consult your company's Namely or Namely Client Success Representative to have your permissions properly set up.
Namely also provides an interface to create long-lived Access Tokens. While these can be useful for server processes, we urge you to be cautious. Anyone with access to the Access Token can access your system. Avoid placing such tokens in shared code bases, etc.
Namely API request:
You need to include your Access Token in your request headers; you should place them in the "Authorization" element in your headers in the format 'Bearer [Access Token]'.
Below are the code snippets from C# - it passes two parameter – Namely API URL & Authentication Token.
public ApiResult<bool> SyncNamelyProfiles(long userId)
{
NamelyProfileEntity namelyProfileEntity = new NamelyProfileEntity();
var url = AppConfiguration.NamelyApiURL + "profiles";
var pageNumber = 1;
namelyProfileEntity = GetNamelyProfilesByPagination(AppConfiguration.NamelyApiURL, AppConfiguration.NamelyBearerAuthenticationToken, AppConfiguration.NamelyPageSize, pageNumber);
while (namelyProfileEntity.meta.Count > (AppConfiguration.NamelyPageSize * pageNumber))
{
pageNumber = pageNumber + 1;
namelyProfileEntity.Profiles.AddRange((GetNamelyProfilesByPagination(AppConfiguration.NamelyApiURL, AppConfiguration.NamelyBearerAuthenticationToken, AppConfiguration.NamelyPageSize, pageNumber).Profiles));
}
var result = iNamely.SyncNamelyProfiles(namelyProfileEntity, userId);
return HttpStatusCode.OK.SuccessResponse<bool>(result);
}
{
NamelyProfileEntity namelyProfileEntity = new NamelyProfileEntity();
var url = AppConfiguration.NamelyApiURL + "profiles";
var pageNumber = 1;
namelyProfileEntity = GetNamelyProfilesByPagination(AppConfiguration.NamelyApiURL, AppConfiguration.NamelyBearerAuthenticationToken, AppConfiguration.NamelyPageSize, pageNumber);
while (namelyProfileEntity.meta.Count > (AppConfiguration.NamelyPageSize * pageNumber))
{
pageNumber = pageNumber + 1;
namelyProfileEntity.Profiles.AddRange((GetNamelyProfilesByPagination(AppConfiguration.NamelyApiURL, AppConfiguration.NamelyBearerAuthenticationToken, AppConfiguration.NamelyPageSize, pageNumber).Profiles));
}
var result = iNamely.SyncNamelyProfiles(namelyProfileEntity, userId);
return HttpStatusCode.OK.SuccessResponse<bool>(result);
}
private NamelyProfileEntity GetNamelyProfilesByPagination(string namelyURL, string token, int pageSize, int pageNumber)
{
var url = namelyURL + "profiles";
var queryString = "?" + "per_page=" + pageSize + "&page=" + pageNumber;
var client = new RestClient(url + queryString);
var request = new RestRequest(Method.GET);
request.AddHeader("authorization", "Bearer " + token);
request.AddParameter("undefined", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
var result = Converter.Deserialize<NamelyProfileEntity>(response.Content);
return result;
}
It will return employee basic information and store it in individual database/store for an organization level different application usages.
It will return employee basic information and store it in individual database/store for an organization level different application usages.
No comments:
Post a Comment