REST API design for keyword based query - spring-boot

I am trying to architect a REST API design to give the best results to users based on keywords. User will have the option to select keywords (Like 'new', 'top rated', 'open now') and the REST API shall return the best result sets based on the selected keyword.
This is somewhat similar to how Google Maps is implemented. (See the image in the link below for reference) - User can select 'Open now' and 'Top rated', and Google shows the top rated stores that are open.
https://www.reddit.com/r/GoogleMaps/comments/j07cf1/does_anyone_else_find_the_google_maps_search/
I am using Spring as our backend framework and I am lost and not sure where to start. I believe the SQL query should be constructed based on selected user keywords but not sure if this is the right way to do it.
Can anyone familiar with this subject share some ideas on this?

you could use spring boot backed micro services to perform this. you may want to have an api business services (REST endpoint) that interacts with your client and then a core service (REST endpoint) to interact with your DB

You can take the benefit of framework like graphql etc.

Related

Micro-service: How to provide an aggregated documentation?

Here is a simple use case to illustrate my question : imagine a bank mobile app, the features to implement are:
List the beneficiaries
Do a payment
We have one micro-service to handle the payments "PaymentService" and one to deal with the beneficiaries "BeneficiaryService". Both have a documented contract with RAML or OpenAPI.
I think it's not a good idea to let the mobile app call the two micro-services independently: it would expose too much the internal structure of the information system and provide no abstraction and so no mitigation.
So, we need to build a "facade" API that expose the routes of "PaymentService" + "BeneficiaryService" to ease the integration. Let's call it "MyAwesomeMobileApp"
I assume "MyAwesomeMobileApp" can be achieved by writing code (i.e. via an ESB or a dedicated Spring app) or via an API Gateway by configuration.
The thing is how do you provide aggregated documentation to your customer (the people coding the mobile app frontend) ?
By aggregated documentation I mean, a documentation with a set of routes from "PaymentService" and from "BeneficiaryService". A sort of third contract made with a subset of each micro-services.
Thank you
If you're providing (requiring) a gateway API between the application and the other services (which seems like a good choice in your example), you provide documentation only for the gateway API endpoints as the services it consumes are not relevant to the mobile app developer.
The way your facade implements communication with any services behind it could well be different than the services themselves (for example: hiding a field that is for internal use or using different field names) and, as such, the contract even for the service-specific models could well be different.
So, document the facade/gateway API well (and independently) and be on your way. It should internally have brokers or some other separation between the endpoints it exposes and the specific requirements of the services it consumes that allows them to be independently updated without too-tight coupling.
If you are looking for a simple concatenation of the contracts or in other words a "unified" public documentation that contains endpoints from both API specification documents/contracts, then you can give APIMatic's merging feature a try.
A detailed step-by-step walkthrough can be found here: https://docs.apimatic.io/manage-apis/api-merging/#merging-two-api-specifications---a-basic-example . However, in brief, the steps for your scenario can be:
Structure your API contracts in a root directory like shown in an example below:
dir\
payments\
openapi.json
beneficiary\
main.raml
APIMATIC-META.json
Here openapi.json and main.raml can be your OpenAPI and RAML contracts respectively.
A minimalistic APIMATIC-META.json configuration file can look like this to enable merging:
{
"MergeConfiguration": {
"MergedApiName": "My title",
"MergeApis": true
}
}
ZIP the directory, upload it and import it into the APIMatic Dashboard (You will need to sign up first).
Preview your public documentation by doing Generate > Proceed > Preview API Portal. Publish/host it as required.
If you are looking to automate the process, APIMatic has an API too: https://www.apimatic.io/docs/api#/http

integrating third party application with Dynamics CRM

I'm trying to integrate third party application with the dynamics CRM.
Authenticate the Dynamics User > Importing all the users data into third party application is my target.
But I'm unable to find the proper way to do this. I have gone through the developer docs but didn't find the solution. Can anyone please help me with this ?
Thanks for the clarification. You can get the Web API URL from Settings > Customization > Developer Resources > Instance Web API.
It will be something like:
https://myOrg.api.crm.dynamics.com/api/data/v9.1/
Using that URL you can query the system and get JSON results.
Going to the root URL will give you the collection name (a.k.a. EntitySetName) of all the entities in the system (which for users is systemusers).
Generally the EntitySetName will be the plural of the entity (i.e. just add 's'), but there are some quirky rules for making plurals so its best to confirm the entity set name via the API or a tool like XrmToolbox's Metadata Browser.
The most basic query for users would be:
https://myOrg.api.crm.dynamics.com/api/data/v9.1/systemusers
It will return all fields of all users.
To get a set of fields:
https://myOrg.api.crm.dynamics.com/api/data/v9.1/systemusers?$select=salutation,fullname,jobtitle,createdon,internalemailaddress
To add a couple filters:
https://myOrg.api.crm.dynamics.com/api/data/v9.1/systemusers?$select=salutation,fullname,jobtitle,createdon,internalemailaddress&$filter=isdisabled%20eq%20false%20and%20address1_line1%20ne%20null
Of course you have to do this with Java's XmlHttpRequest. When querying data you can use HTTP GET.
To test the above queries quickly you can simply login to the D365 web client then paste a query into the browser's address bar.
You may also want to check out Jason Lattimer's CRMRESTBuilder. While it doesn't build Java, it gives you a UI to create JavaScript XmlHttpRequests, which you can then translate to Java.
And here's some Microsoft documentation on querying the Web API.

SAP Approve and Reject Hours

I am a beginner with ABAP programming and I do not have much experience with SAP GUI...
I am developing a Fiori application to approve and reject absences like the standard application "approve leave request". I wanted to access the "approve leave request" methods to analyze the code to implement my methods..
How can I do that? Which methods / BAPIs do you recommend to use?
In the Fiori Apps Library you can search for Fiori apps delivered by SAP.
With search term “approve leave request” you will find the following 2 apps:
Approve Leave Requests
Approve Leave Requests (Version 2)
Under tab “IMPLEMENTATION INFORMATION” you can expand “Configuration”.
There you will find the corresponding oData Services:
/GBHCM/LEAVEAPPROVAL
HCM_LEAVE_REQ_APPROVE_SRV
With transaction SEGW in the backend, you should be able, to navigate to their corresponding ABAP classes.
It might be, that in SEGW you have to skip the “_SRV” and just search for “HCM_LEAVE_REQ_APPROVE”.

User search in RESTful spring API

So basically, I have a spring API with MySQL database and I need to be able to perform search of a user by his name in front-end web app which is using my API. The trick is that I need a kind of google search so by typing, lets say, 3 letters, list of all users who's name starts from these 3 letters would be returned from the API to the web app. By typing or deleting any letter, list should change dynamically.
My question is how can implement this kind of "dynamic" search in my API. What should requests look like? What should the whole architecture of the process in the API look like?
There are a number of ways to pull this off. Coding this in your API is probably going to be the least efficient. I would recommend using SOLR or Lucene to index the data you want to search on. Your front-end will have some JS that will update your list when characters are entered or deleted in the text field.
JQuery provides a plugin that might be just what you're looking for from the UI.
https://jqueryui.com/autocomplete/

Use Application Insights to view all REST API requests per user

We are developing a WebApi2 application. Users can use the REST API using their specific API key. I am investigating how to setup Application Insights to be able to see the usage of the REST API endpoints per user.
I have been experimenting with using telemetryclient.TrackPageview(endpoint-ID) and telemetryclient.TrackEvent(endpoint-ID), but I am not sure if this is the right way to go. And how should I pass the user-ID (API-key) in the tracking call? As telemetryclient.Context.User.Id? Or using properties or some other way? I would like to be able to use the user-ID to aggregate/segment the pageviews/events that were registered for that particular user. Any ideas are welcome!
I'd suggest using the built in properties, like context.user.id whenever possible, and then custom properties after that.
Currently in the portal, from the search view you can then find an item for any user, then use the "related items" to view "all telemetry for this user" to see all of the items.
Then can use the App Analytics portal to do queries (click the "analytics" button toolbar in the overview blade for your resource azure portal to go to the AA site for that resource), and that service lets you write much richer queries.
in those queries, it's easiest to group/filter on the "built in" properties, for custom properties you have to write a little bit more complicated queries to parse the values out of custom code.

Resources