Start a new topic

Business Logic : New to Kinvey looking for RESTFUL API sample based on Use Case below

I am new to RESTful APIs and the Kinvey platform 


I have a mobile app that I want to integrate with Kinvey to use Kinvey for the app's business logic


I want to do an API call from the mobile app to Kinvey and then Kinvey must process the business logic request and supply a decision back to the mobile app


Use Case


Forr instance a customer wants to take out a loan the mobile app will call kinvey via an API call and in the API message Body will supply the customer's income and credit score, kinvey must then use this to determine if the customer is successful and can be given the loan, kinvey will in return reply with the loan amount allowed, interest rate per month and the monthly installment and pay back period of the loan.


Is there a example or sample of this somewhere that I can look at to understand how kinvey works as I am not sure where to start 


Regards

Nico


Hi Nico,


Please take a look at following documentation links to get you started with Kinvey Business Logic:


You should be able to implement the sample use case using a custom endpoint.

Regards,
Wani
Kinvey Support

Hi Wani


I had a look at the information you gave me and understand that i need to use the custom endpoint for my Use Case


As I said I am a novice with this and still not sure where to start


How would my endpoint code (javascript) typically look for the use case that i have in mind


Regards

Hi Nico,


Please check following code snippet code:

  

function onRequest(request, response, modules) {
	var body = response.body;
	// body will contain income and credit score values
	// this will contain your custom code to calculate interest rate, loan amount, monthly installment etc
	response.body = {
		// set the values accordingly to above logic
		successful: true,
		interestRate: 5,
		loanAmount: 10000,
		monthlyInstallment: 520,
		paybackPeriod: 20
	};
	response.complete(200);
}

  

I hope this helps. Let me know if you have additional questions.



Regards,

Wani

Hi Wani


Thanks for the sample code 


But how does this sample code fit into the big picture ?


In other words once I insert the sample code into the custom endpoint function on Kinvey console how to do I expose it via API as an endpoint that I can call from POSTMAN to test if its working


I need a 101 guide that will show me all the steps as a getting started


Please advise


regards

Nico

Hi Nico,


Have you checked the documentation on how to get started with Kinvey: 


To develop this use case, you will need to do following things:
  1. Set up development environment for your platform (Angular or otherwise)
  2. Write code to establish a valid user on app startup or before the BL is called
  3. Write code to execute BL


Regards,
Wani

Login or Signup to post a comment