Create Here API Android Request Id? - android

I'm using the Here API for Android and I'm trying to calculate multiple routes.
I'm using RouteManager's calculateRoute method in order to do this.
The problem is that when using this method for multiple route calculations, the response is async and I want to be able to identify which response is for which request.
I found that for the REST API it's possible to do this by passing RequestId:
"Clients may pass in an arbitrary string to trace request processing through the system. The RequestId is mirrored in the MetaInfo element of the response structure."
Is there something similar for the Android SDK or do I have to compare GeoCoordinates or other route specific data?

The HERE Maps for Android API does not provide this functionality directly but you can write some code on top of the APIs to accomplish this.
As an idea you could implement a class which extends the RouteManager#Listener interface and assign an ID to that class. Then you can use a unique Listener for every request with a different ID value.

Related

How can I retrieve more data from Prestashop API to my flutter app?

I looking for documentation about Prestashop API without success.
I am developing a mobile app with flutter which retrieve data from Prestashop API, the problem is I just can do a couple calls to the api as: list products, list clients, show misc info, etc...
I would like to be able to create a new order, add products to cart, create cart, etc... But I can't find any other solutions.
Should I create my own custom api service?
Edit:
This is the data already have
http://example.com/prestashop/api/products
http://example.com/prestashop/api/images
http://example.com/prestashop/api/customers
And I would like to get the and create the next one (i.e):
http://example.com/prestashop/api/cart/create
http://example.com/prestashop/api/cart/add_product/?id=number
http://example.com/prestashop/api/product/create
Thanks a lot
The lines of documentation you need are here:
https://devdocs.prestashop.com/1.7/webservice/getting-started/#create-a-resource
How to create a new order via Prestashop API?
This process is called create a resource. So, if you want to create a new order, just:
Take all the same XML (or JSON) schema you see in http://example.com/prestashop/api/orders?schema=blank (add "&output_format=JSON" for JSON),
Fill it with your values (with no "id") and send with POST HTTP request back to http://example.com/prestashop/api/orders/
How to edit an order via Prestashop API?
This process is called update a resource. So, if you want to edit an order ID 1, just:
Take all the same XML (or JSON) schema you see in http://example.com/prestashop/api/orders/1 (add "&output_format=JSON" for JSON),
Fill it with your values and send with PUT HTTP request back to http://example.com/prestashop/api/orders/1
The same process is for all entities you see in Prestashop back office > Advanced parameters > Webservice.
Note: Please check if API is enabled and all check boxes are checked for the entity permissions you need. You can find it in Prestashop back office > Advanced parameters > Webservice.

How am I supposed to send my REST Api response from android back to the IBM watson?

I am designing android chatbot using watson. I have a usecase where I need to call external REST api. So I define the function name and parameters in the action tag of JSON editor. I receive those variables in my android code through conversation Api. My question is how am I suppose to send my REST Api response back to the watson? I know I have to use /message api in which I need to set a context. And initially I get the context from the MessageResponse class after the conversation API gets executed. And how are we going to let Watson know about the rest api response. How do we link that response to watson? Help me with some code if you can.
For calling external REST API it is recommended to use Cloud Functions - in the implementation of the cloud function you create the API request you need. Then in Watson Assitant you add the "action" field where you specify what of your cloud function to call and where to store the result (the result will be stored to some variable in the "context" field). More info in the documentation about how to make programatic calls from a dialog node.

time between two places using public transport

Is there some Google Maps API for Android that could return time between two places using public transport (and walking)? Something like Google Maps does when selecting public transit, but I'm interested only in times.
Also, is there way on Android to get list of nearest transit stops (from given location, not necessary phone)?
you can refer google direction API .it provide all types of details. it gives a response based on JSON or xml. if you refer json then pass in url json.
used retrofit for getting direction API response and bind getting data according to google map.
below url is give all data..
https://maps.googleapis.com/maps/api/directions/json?origin=ahmedabad&destination=faizbad&mode=transit&language=gu&key=AIzaSyCMNK9WsbC2vgvMB_trDOjTs2QUvOd7ECw
more information u can refer below link
https://developers.google.com/maps/documentation/directions/intro#TravelModes
Hi below is the link which helps you for which you want
https://developers.google.com/maps/documentation/distance-matrix/intro
Where you find request URL throw which you can find distance or time duration between tow place using different-different parameter
Below is the sample URL for use
https://maps.googleapis.com/maps/api/distancematrix/outputFormat?parameters
You need to pass your API key in parameter compulsory.

Does using Parse Cloud Code is a smart move? altho it's generates more requests?

As simple as it could be.
Example:
I have a Class "A" at Parse that contains 500 "movie ratings". I want to calculate the average of all of them.
I have two options :
Fetch all the results into the user device,and calculate there.(ONE API REQUEST)
Use Cloud Code function to fetch all the results over the cloud, calculate THERE and send to the device "final" answer. (TWO API REQUESTS - one for the cloud code, and one for the fetching.)
What is the right way to handle this? Is there a work around?

How to work with two Parse account in 'one' app

We are creating an Android launcher with several 'pre-installed' apps. These apps are actually part of the same code though to the user and from out perspective these apps are different logical units.
We work with Parse Core and would like to split the data into two different logical 'apps'. Can it be done?
We thought to call 'Parse.initialize' several times with different App & Client keys but then how should we proceed to report to different apps?
Thanks.
I have faced exactly the same issue a few months ago. Atleast, I was not developing a launcher. So, I'm posting my solution to the problem below.
Note: You cannot do it with Parse SDK
So the solution is to do it by having your app expose their own APIs. This has several advantages such as, your parse-apps could be owned by different accounts, while not violating the Parse terms of use.
TL;DR
Create two different apps and expose the API's using cloud code. Use a REST client to transact data back and forth.
Full Solution
The first step is to create two parse-apps, that you think suits individual needs of your launcher software. You can generate express servers for both the apps. Essentially, the result of this step is that, you will have two different apps with your own APIs to be consumed.
Now get rid of the Parse SDKs you might probably be using currently. Select a suitable REST client, in my case it was retrofit. Configure it such a way that it can consume different base-URLs for individual calls. The following is a Retrofit specific example.
A Function that Returns a REST Adapter with a Base URL
public FirstAppApi getFirstAppApi() {
return new RestAdapter.Builder()
.setEndpoint("http://app-one.parseapp.com/")
.build()
.create(FirstAppApi.class);
}
In this example FirstAppApi is essentially a Retrofit interface. Similarly, you can create adapter for the second parse-app as well. Now, to do a data transaction, its just a matter of deciding which app you should use. See a few examples below.
// Get an author from the first Parse app
Author author = getFirstAppApi().getAuthorByName("Shakespeare");
// Get books of the author from the second Parse app
List<Book> books = getSecondAppApi().getBooksByAuthor(author);
A few things needs to be taken care in this implementation. The API is exposed publicly, eventhough the app name, and thus the base-url is known only to you. So, the API should be well secured when completed. You should double confirm with Parse guys that it does not violate their terms of use.
I think you can try to repackage jar-files of Parse SDK with jarjar tool.
Another way is to get source code of Parse SDK(it is opensourced) and refactor it (change package name).
After you do it you can work with two Parse accounts using different classes:
com.parse.Parse.initialized();
com.parse2.Parse.initialized();
If you use Parse's offline storage only second option is available. But you also have to change database name for second Parse instanse (com.parse2.Parse). You need to change com/parse2/OfflineSQLiteOpenHelper.java
/** package */ class OfflineSQLiteOpenHelper extends ParseSQLiteOpenHelper {
// ...
/**
* The SQLite Database name.
*/
private static final String DATABASE_NAME = "ParseOfflineStore2"; // <=====
private static final int DATABASE_VERSION = 4;

Categories

Resources