Get contents

Once you have integrated Dialogue Wise, you can easily retrieve the contents of a Dialogue and display it on your app. To do that you need to first prepare the payload.

var request = new GetDialogueRequest();
request.slug = '[Your Slug]';
request.apiKey = '[Your API Key]';
request.emailHash='[The hash of your email]';

//In case you need to pass variables. This is optional parameter.
request.variables = new Map<String, dynamic>(); 
request.variables ={
//Your variables and corresponding values.
};

//In order to get paginated data. These are optional parameters.
request.pageIndex=1;
request.pageSize=5;

//To get Piloted version. This is optional parameter.
request.isPilot=true;

Now that you have the payload ready, all you need to do is to call the service with the payload.

var dialogueWiseService = new DialogueWiseService(); 
Map response = await dialogueWiseService.getDialogue(request);

If the contents are retrieved successfully, it will return you a response of type DialogueWiseResponse which will contain a status code, reason phrase and response. The status code indicates the standard HTTP response status codes and the reason phrase will contain the corresponding reason for the status code. The response will have the content which can be displayed on your app.

A sample response would look like the one below.

{
   "statusCode":200,
   "reasonPhrase":"OK",
   "response":{
      "dialogue":[
         {
            "dish-name":"Chicken Hot Dog",
            "dish-photo":"hotdog.jpg",
            "is-available":"true",
            "long-description":"Chicken Hot Dog with mayonnaise.",
            "price":"$7",
            "short-description":"Chicken Hot Dog with mayonnaise.",
            "id":"D82D0CA45C6044FAB4BDD6B9E0F5B31B",
            "isSourceAPI":"false"
         }
      ],
      "totalRecords":1,
      "error":""
   }
}

Every record will contain an id and isSourceAPI field. The id field is a unique identifier that can be used to update or delete the record. The isSourceAPI field indicates if the record was added through the API or manually through the portal.