Showing posts with label API. Show all posts
Showing posts with label API. Show all posts

Friday, 31 August 2018

Microsoft Azure Search Service


Microsoft Azure search provides powerful, scalable and stable search experience over data in web and mobile applications.

It provides an easy way to scale up and scale down based on user traffic/workload over the application. As per Microsoft SLA – it is highly available infrastructure with 99.95% uptime. There are some of the key features like auto-complete, auto-correct, geo-search and facet navigation filters.

There are two ways to configure search index from data source either though azure portal or Azure Search SDK.

The SDK provides client libraries that enable us to manage search indexes, data sources, indexers and execute queries. All the search API are available over HTTP with JSON response.

Azure Search Configuration Steps:

We would configure azure search service using Azure portal, the first login to the portal and create new search service with resource group, location, and pricing tier. Now we would follow the below steps with sample screen for further:

1.    Import Data- Choose Data source

Click on top bar – Import Data for data source section




Azure search would provide below data source as an input:

The pull model retrieves data from external data sources. It's supported through indexers that streamline and automate aspects of data ingestion, such as connecting to, reading, and serializing data. Indexers are available for Azure Cosmos DB, Azure SQL Database, Azure Blob Storage, and SQL Server hosted in an Azure VM. You can configure an indexer for on-demand or scheduled data refresh.



2. Create Index 

Here during index creation need to select Fields that defines the searchable data in your index. A Fields collection includes required and optional fields, named and typed, with index attributes that determine how the field can be used.



Attribute Description
searchable   Full-text searchable, subject to lexical analysis such as word-breaking during indexing. 
filterableReferenced in $filter queries. Filterable fields of type Edm.String or Collection(Edm.String) do not undergo word-breaking, so comparisons are for exact matches only. For example, if you set such a field f to "good day", $filter=f eq 'test' will find no matches, but $filter=f eq 'good day' will.
sortableBy default the system sorts results by score, but you can configure sort based on fields in the documents. Fields of type Collection(Edm.String) cannot be sortable.
facetableTypically used in a presentation of search results that includes a hit count by category (for example, restaurant in a specific city). This option cannot be used with fields of type Edm.GeographyPoint
keyUnique identifier for documents within the index. 
retrievableDetermines whether the field can be returned in a search result.

3. Customization Target Index

 Configuration database schedule for record synchronization.


4. Data Source Synchronization

5. Search Explore as an Output – Search APIs

 Here is the sample of suggestion search 

Here in left side you can see the facetable output using Azure search  APIs.

Key benefits:

  1. Enrich and extract insights through cognitive skills
  2. Get your search indices up and running quickly
  3. Easily scale up and down
  4. Connect search results to business goals with great control over search ranking
  5. Take advantage of Microsoft’s deep knowledge of natural language processing
  6.  Easily add geospatial search to your app

  

Service Limitation: every service has some of the limitation based on the resource which
We opt to create service indexes.

For more service quotas limitation please refer below URL.

Thursday, 26 April 2018

Namely API - Integration with .NET Web application


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:

In order to use the Namely API, the user must have permission within the system to generate either an API Client or Access Token object.




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);
        }


        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.

Xamarin - Cross Platform Mobile Development

Xamarin - Cross Platform Mobile Development Xamarin is one of the most popular cross-platform frameworks at the moment. Xamarin devel...