Creating a catalog from the client

Hi there,

I am trying to send a Volley request from the terminal to the cloud api with a JSON payload that defines a catalogue. The idea being that the user logs in through our Poynt app and any menus the user has on our server are automatically retrieved and pushed up to Poynts servers, saving them the need to manually rebuild their menu via the Poynt web portal.

I am running into authentication issues regarding the .pem certificate issued while attempting to send the JSON catalogue object.

Do you have any examples or advice on how to populate a catalogue from the terminal or sdk?

Thanks in advance!

Hi there,

We do have an aidl service to work with the catalog but at the moment it only exposes read operations (IPoyntProductService). Hopefully we will add write operations soon.

For now, consider using our cloud API interface to create catalog from your server.
Step 1 would be to create products. Here’s an example:

OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n  \"ean\":\"EAN-a42929fc-56a4-be05-6a60-e0b9f9f41974\",\n  \"upc\":\"UPC-a42929fc-56a4-be05-6a60-e0b9f9f41974\",\n  \"isbn\":\"ISBN-a42929fc-56a4-be05-6a60-e0b9f9f41974\",\n  \"plu\":\"PLU-a42929fc-56a4-be05-6a60-e0b9f9f41974\",\n  \"asin\":\"ASIN-a42929fc-56a4-be05-6a60-e0b9f9f41974\",\n  \"name\":\"Cheetos Crunch 843\",\n  \"description\":\"A bag of Cheetos\",\n  \"specification\":\"Total Fat: 16%DV, Sodium:10%DV,, Carb: 4%DV\",\n  \"releaseDate\":\"2014-01-01T00:00:00Z\",\n  \"brand\":\"Cheetos\",\n  \"manufacturer\":\"FritoLay\",\n  \"publisher\":\"FritoLay\",\n  \"studio\":\"www.cheetos.com\",\n  \"designer\":\"John Doe\",\n  \"author\":\"John Doe\",\n  \"artist\":\"\",\n  \"msrp\":{\"amount\":142, \"currency\":\"USD\"},\n  \"tags\":\"chips cheetas\",\n  \"sku\":\"SK-a42929fc-56a4-be05-6a60-e0b9f9f41974\",\n  \"mpn\":\"FRTLY1\",\n  \"styleNumber\":\"Flaming\",\n  \"modelNumber\":\"BAG-O-CHIP\",\n  \"type\":\"SIMPLE\",\n  \"imageUrl\":[\"http://i.onionstatic.com/avclub/4425/01/16x9/1200.jpg\"],\n  \"price\":{\"amount\":142, \"currency\":\"USD\"},\n  \"unitOfMeasure\":\"EACH\",\n  \"status\":\"ACTIVE\",\n  \"shortCode\":\"BOC\"\n}\n");
Request request = new Request.Builder()
  .url("https://services.poynt.net/businesses/<business id>/products")
  .post(body)
  .addHeader("content-type", "application/json")
  .addHeader("authorization", "Bearer  <token>")
  .addHeader("poynt-request-id", "<unique id>")
  .addHeader("api-version", "1.2")
  .addHeader("cache-control", "no-cache")
  .build();

Response response = client.newCall(request).execute();

Step 2: Create catalog with array of CatalogItems which would have the ids of products you created in Step 1. Or create catalog with array of categories with corresponding arrays of CatalogItems.

Thanks for the great code snippet!

The trouble I am having is around retrieving a token. I understand that I need to create a JWT using my certificate that I downloaded when creating my Poynt cloud application, however implementing this using the Android framework has proved less than straight forward.

Do you have any advice on how to build the request to receive the token in order to upload a menu on the cusers behalf?

Do you absolutely have to perform this action from the terminal directly or can this be done from your backend server?