<<

NAME

ProductOpener::APIProductServices - Microservices to enrich a product object

DESCRIPTION

This module implements a microservice API for operations done on an product object.

Applications can send product data (for instance a nested list of ingredients), ask for one or more services to be executed on the input product data (for instance computing the min, max and estimated percentages of each ingredient), and get back resulting product data (possibly filtered to get only specific fields back).

INTERFACE

Request

The Routing.pm and API.pm module offer an HTTP interface of this form: POST /api/v3/product_services

The POST body is a JSON object with those fields:

services

An array list of services to perform.

Currently implemented services:

- echo : does nothing, mostly for testing - estimate_ingredients_percent : compute percent_min, percent_max, percent_estimate for each ingredient in the ingredients object

product

A product object

fields

An array list of fields to return. If empty, only fields that can be created or updated by the service are returned. e.g. a service to parse the ingredients text list will return the "ingredients" object.

Response

The response is in the JSON API v3 response format, with a resulting product object.

echo_service ($product_ref)

Echo service that returns the input product unchanged.

product_services_api($request_ref)

Process API v3 product services requests.

<<