API Configuration

Overview

When you go “Web service List” from Navigation, you will  see below default screen.

It allows you to configure web services based on modules and database.

You can see default web service “admin_list” also there. First, we will take review of default screen and then move on to “Details | Configuration” part of web service.

Details of Button Bar

  1. Add New : allows you to add new web service. (See in brief later)
  2. Delete : allows you to delete web service.
  3. Active : allows you to change status (Active) of selected web service.
  4. Inactive : allows you to change status (Inactive) of selected web service.
  5. Show All : shows you all web services in listing.
  6. Copy WS : allows you to copy web service from same or other projects. When you select any web service, it will show you details of flow which is used in specific web service.

If you copy  from different project, the corresponding tables also get copied along with the WS.

Quick CRUD Add→ allows you to create 5 default CRUD WS  automatically based on already created module settings.  (You will get idea for WS in “Add New  WS & Configure It”  section in brief) .

It allows you to set Input and Output parameters. Based on these  parameter settings , it will create WS. So if you want to create CRUD WS then it will automatically generate WS in one click.

5 Default CRUD Web Services

  1. CRUD_select_tablename : It will create SELECT WS WITHOUT INPUT PARAMS.
  2. CRUD_sel_id_tablename : It will create SELECT WS WITH  INPUT PARAMS.
  3. CRUD_insert_tablename : It will create INSERT  WS.
  4. CRUD_update_tablename : It will create UPDATE  WS.
  5. CRUD_delete_tablename : It will create DELETE  WS.

Just select table and select module.

When you select module , its related tables defined in module will be reflected here with applied configuration.

For example : There is a module named 'admin' with the table 'mod_admin' with 'mod_group_master' being a relational module. Fields that have been used from the tabel 'mod_group_master' will be selected in params. If you have set any field as default sorting, it will be reflected here.

If you have set any "Unique field" , "Group By condition" , "Validations" , settings for image file and more in your "Admin" module , then it will create WS based on this settings.

You can also modify this settings further.

See below screen of Admin module & Quick CRUD ADD after selecting "Product" module.

Now, “Generate” CRUD ws and see web service list. You will see 5 default WS generated by CRUD. You can modify these WS further. (You will get idea for WS in “Add New WS & Configure It”  section).

See “crud_insert_product”,

Detail screen

Configuration screen

See settings for “Unique Field” in Admin

Now , go Quick CRUD Add” list, It will show you numbers of WS with specific table.

For example : we have created 5 default WS for “Product” table. Then you can show “Table name with numbers of WS generated” in table list on Quick CRUD add page.

If you want to generate WS for “Product” table again then you can do it.

Name of the WS will be appended with Version number like “crud_insert_product_v1”.

Now, See below screen where we have selected  “crud_insert_product” WS for Overwriting.  So it will be overwritten by exist one.

We have disabled checkboxes for “Update & Delete”. So again , it will not create WS for update and delete.

It will show you new generated WS for “Select and Sel_id” ws with version no and also existing one.

Now, click on “generate” button for generating new WS again.

See webservice list now,

Now , go to “Quick CRUD Add” page ,

you can see  change in “Table name with numbers of WS generated” in table list on Quick CRUD add page.

  1. Upload On FTP : If you have added any remote server details and marked it as “default” server (from project management → Remote Server List ) , then you will get option to upload code of all web services directly on default remote  server.

If you don’t make any remote server as “default” server , then it will not show you this upload feature.

  1. Download Code : download code of all web services  with latest configuration in zip file.
  2. Update Code : update all web service  with latest configuration & open new window  where you can see all web services of your project. (One type of console).

  1. Search By : allows you to search any web service.

Listing Grid

  1. Web Service Name : shows you web service name.
  2. WS Management : allows you to add details in WS and configure it. (Describe it later in Add New WS section).
  1. FTP : If you have added any remote server details and marked it as “default” server (from project management → Remote Server List ) , then you will get option to upload specific web service code directly on default remote  server.

If you don’t make any remote server as “default” server , then it will not show you this upload feature.

  1. Download : allows you to download WS code.
  2. Update : update web service  with latest configuration.
  3. Status : shows you WS status.

Now we will see how to add new WS & its configurations.

How to add new API?

Add New  WS & Configure It

Detail Page

See below default screen for Add New WS (Detail Page)

  1. Web service Name : allows you to specify WS name.
  2. WS Function : automatically takes function name based on WS name.
  3. Main Operation : allows you to select main operation of your WS (Select / Insert / Update / Delete).
  4. WS Method : allows you to select method (GET / POST / BOTH).
  5. Input Parameters : allows you to add multiple parameters in your web service

For Example : You want to create Web service for getting category details.

Configuration Page

Next page  → Configuration Page

  1. Now you will be redirected on configuration page of WS. You just need to configure WS using flow chart structure.
  2. It will show your WS URL on configuration page. you can execute WS and  also debug it.
  3. It provides different controllers to create flow chart of WS.
    • It allows you to start flow ,add Query , Push notification , Notification mail ,  multiple conditions , allow to start loop , allow to end loop , allow to add custom PHP function and end flow.  Just click on this button and specific flow tag will be added in your WS then , configure it and save settings. It will be done.
  4. It provides flow checker as bulb icon that gives you green signal when flow is correct. It checks WS is ready to execute or not. If flow has any error then it will show you with the help of ‘help text’ .
  5. You can add any web service (whole WS / its specific flow used in it)  in another WS. So it allows you to copy specific block.
  6. See below default configuration screen

Examples for more understanding

Select WS without params

Configuration for getting category details WS (Select WS without params)

Just prepare your steps (flow) to get category data. we will see the use of Start (set by default), Query , Add conditions & finish controller here

  1. Start the flow. (Set by default)
  2. Add query and configure it.
  3. Check if data is null or exist.
  4. Finish the flow
    • if data is null then no records.
    • if data is exist then success.

Start from 2nd step (Add query)

After configuring  this block, you must have to save settings and go to next block “Select table fields” where you can select fields that you want to send in response.

Save settings and go to next block “where condition tables” where you can specify extra condition which is applicable for ‘where’.

For example : we want to get data for ‘Active’ category only.

Save settings and go to next block “Group By Fields” where you can select multiple fields as Group By fields.

Save settings and go to next block “Having Condition Tables” where you can add having condition for calculation (COUNT , SUM , AVG , MIN , MAX).

Save settings and go to next block “Order By Tables” where you can add order by field and set order ASC/DESC.

Save settings and go to next step “Add condition” for checking data is exist or null.

Start 3rd step (Add Condition)

So click on “Add condition” controller  OR right click on query controller , you will find controller options for insert before / after , shift before / after.

Now , Configure condition. It allows you to add multiple AND / OR conditions by Flow / Variable / Static value.

If flow is selected then it will populate all flow labels that we have defined

If Variable is selected then it will populate all table fields  that we have chosen.

Now you have to use finish controller for setting “Success / Failure” message and ending  the flow as well if condition is “true (1)  / false (0)”.

Start 4th  step (Finish flow , just double click for configuration)

Finish controller when data exists (On success).

Finish controller when data is null - No records (On failure)

Now ,Save settings. Your WS is ready to execute. You can check it by web service flow status (Blinking bulb). Then execute your web service and it opens new window and shows you json formatted response.

Select WS with params

Configuration for getting country details by ID WS (Select WS with params)

Go to configuration page and add “Query” controller and configure it.

Now add “Finish” controller to finish the flow

Note : If you don’t enter ID and execute WS , then you will get all data of countries.

Select WS with Start-End loop & Custom function

Configuration for getting Country-wise States by multiple Country ID WS (Start Loop and End Loop , Custom function)

Create WS for getting  country-wise states.

Configuration of WS

We are creating WS for passing multiple comma separated values in parameter. So we have created function to convert comma separated values in array.

Now, we use this function in our WS. Add “Custom function” and configure it

How can we use “Custom Function”?

Custom Function has 2 types>

  1. Existing Web Service
    • for using existing WS

  2. General Function
    • for using custom PHP function. It will show you syntax help text too.

We have used “General function” to use Custom PHP Function that we have created.

It allows you to set multiple OUTPUT parameters using “Existing WS / Custom PHP function” accordingly which can be used in our WS.

After adding “Custom Function” , we will add “Start Loop” Controller

How can we use “Start Loop”?

It allows you to add label for start loop. Then you must specify "Flow Label" of any of the above flows as Loop Name.

NOTE : Please do not specify the current or below flow label as Loop Name.

Here , we have above used “convert_in_array” labeled custom function controller. So we have selected it to use its output parameters.

Now we will add “Query” controller to get data (Configure it)

Now , in “where” condition , we need to add condition for mapping  “country id” with country id which we have passed in Input Params and converted in array using function. In custom function , we have specified it as “cid” . So here “cid” is selected.

Now save settings. Query controller is configured now.

Add “End Loop” and configure it

How can we use “End Loop”?

It allows you to end started loop. You just need to select started loop that you want to end.

Add “Finish” and configure it

Select params for success and specify your message.

Now , You can check WS Flow Status.It is ready to execute or not.

After that, you can pass input multiple comma separated values as input  parameter “country ID” and  execute WS.

Select WS with Notification Email

Configuration for sending email notification for forgot password  WS (Notification Email)

Create WS for sending email notification (login details) in forgot password

Configuration of WS

We get user data from email and send notification email with login details to user

Now we will add “Query” controller to get user data (Configure it)

Save settings and now add “Notification Email” controller.

Before using “Notification Email” controller , you need to define variables in your template.

We are going to use system email “Forgot Password” template.

(From Admin panel → Resources → System Emails → Select template ) OR

(Go to Navigation menu → System Emails → Select template )

Now we will add “Notification Email” controller and Configure it

It allows you to specify fields for TO , Add Cc , Add Bcc , From , Subject , allow to select Email template (content).

It will show you variables which you have defined in Email Template. Just need to map with fields.

Add “Finish” and configure it

Select params for success and specify your message.

Now , You can check WS Flow Status.It is ready to execute or not.

You will get Notification Email with your login details

WS with Push Notification

Configuration for sending push notification (Push Notification)

Configuration for Push Notification

You just need to map field for device Id and specify content/message.

Response parameters should be preceded and followed by "#" symbol.

Example:     #variable_name#

So you have to get device ID and map with input params. If it matches then send  push notification.

WS with INSERT

Configuration for Sign Up WS (INSERT)

Create WS for user signing up

Configuration of WS

Now we will add “Query” controller to insert  user data (Configure it)

You can also check data for user before INSERT query. You can use “Add condition” controller for checking user existence. If user doesn’t exist then “INSERT” otherwise show failure message.

Add “Finish” and configure it

Select params for success and specify your message.

Now , You can check WS Flow Status. It is ready to execute or not.

WS with UPDATE

Configuration for Change Password  WS (UPDATE)

Create WS for changing password

Configuration of WS

Now we will add “Query” controller to update change password (Configure it)

Add “Finish” and configure it

Select params for success and specify your message.

Now , you can check WS Flow Status.It is ready to execute or not.

WS with DELETE

Configuration for delete user WS (DELETE)

Create WS for deleting user

Configuration of WS

Now we will add “Query” controller to delete user (Configure it)

Add “Finish” and configure it

Select params for success and specify your message.

Now , you can check WS Flow Status.It is ready to execute or not.