NeedInfo
NeedInfo
Needinfos are a hypermedia control that prevent a resource from changing its state until a set of conditions are satisfied. Needinfos are generally used to control a button's enabled state on the user interface.
NeedInfo Example: Completing a Purchase
The purchase form resource creates a purchase. The submitorderaction link appears on the purchase form when the purchases preconditions are satisfied and a purchase can be placed. Below is a purchase form with its preconditions satisfied.
{ "self": { "type": "elasticpath.purchases.purchase", "uri": "/commerce-legacy/purchases/orders/mobee/mu3=/form", "href": "http://api.elasticpath.net/cortex/purchases/orders/mobee/mu3=/form" } "links": [ { "rel": "submitorderaction", "uri": "/commerce-legacy/purchases/orders/mobee/mu3=", "href": "http://api.elasticpath.net/cortex/purchases/orders/mobee/mu3=" } ] }
If a purchases preconditions are not satisfied and more information is required from the shopper, needinfo links appear instead of the submitorderaction link for each piece of missing information. needinfos points to an info resource that allows the shopper to select or create the missing data. The example below shows needinfos appearing on a purchase form.
{ "self": { "type": "elasticpath.purchases.purchase", "uri": "/commerce-legacy/purchases/orders/mobee/mu3=/form", "href": "http://api.elasticpath.net/cortex/purchases/orders/mobee/mu3=/form" } "links": [ { "rel": "needinfo", "type": "elasticpath.controls.info", "uri": "/commerce-legacy/orders/mobee/grr=/billingaddressinfo", "href": "http://api.elasticpath.net/cortex/orders/mobee/grr=/billingaddressinfo" }, { "rel": "needinfo", "type": "elasticpath.controls.info", "uri": "/commerce-legacy/orders/mobee/grr=/emailinfo", "href": "http://api.elasticpath.net/cortex/orders/mobee/grr=/emailinfo" } ] }