summaryrefslogtreecommitdiff
path: root/src/include/taler_merchant_service.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-10-30 17:13:09 +0100
committerChristian Grothoff <christian@grothoff.org>2020-10-30 17:13:09 +0100
commit09c40af96fa338f6ba57a24df7d43b65384420f9 (patch)
tree59cd6a3b6efec590cb0f3872b08792a7f7387f7f /src/include/taler_merchant_service.h
parentdf8395e9c528a3eed89ce0814bc8b5c37daae267 (diff)
downloadmerchant-09c40af96fa338f6ba57a24df7d43b65384420f9.tar.gz
merchant-09c40af96fa338f6ba57a24df7d43b65384420f9.tar.bz2
merchant-09c40af96fa338f6ba57a24df7d43b65384420f9.zip
properly parse and return out-of-stock reply, fix 2 FIXMEs
Diffstat (limited to 'src/include/taler_merchant_service.h')
-rw-r--r--src/include/taler_merchant_service.h92
1 files changed, 79 insertions, 13 deletions
diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h
index 656ae76e..88a33ba5 100644
--- a/src/include/taler_merchant_service.h
+++ b/src/include/taler_merchant_service.h
@@ -1223,27 +1223,93 @@ TALER_MERCHANT_product_delete_cancel (
/**
- * Handle to a POST /orders operation
+ * Handle to a POST /private/orders operation
*/
-// FIXME: rename: Operation => Handle!
-struct TALER_MERCHANT_PostOrdersOperation;
+struct TALER_MERCHANT_PostOrdersHandle;
+
+
+/**
+ * Possible details from a reply to POST /private/orders.
+ */
+struct TALER_MERCHANT_PostOrdersReply
+{
+
+ /**
+ * HTTP response details. HTTP status code
+ * determines what parts of @e details are valid.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details of the reply, depending on the HTTP
+ * status code.
+ */
+ union {
+
+ /**
+ * Details provided if the @e hr.http_status is
+ * #MHD_HTTP_OK and the order was created.
+ */
+ struct {
+
+ /**
+ * order id of the newly created order
+ */
+ const char *order_id;
+
+ /**
+ * the claim token generated by the merchant,
+ * (NULL if it was NOT generated).
+ */
+ const struct TALER_ClaimTokenP *token;
+
+ } ok;
+
+ /**
+ * Details provided if the @e hr.http_status is
+ * #MHD_HTTP_GONE because a product was out of stock.
+ */
+ struct {
+ /**
+ * ID of the product of the order that is out of
+ * stock.
+ */
+ const char *product_id;
+
+ /**
+ * How many units were requested by the order.
+ */
+ uint64_t requested_quantity;
+
+ /**
+ * How many units are actually still in stock.
+ */
+ uint64_t available_quantity;
+
+ /**
+ * When does the backend expect the stock to be
+ * restocked? 0 for unknown.
+ */
+ struct GNUNET_TIME_Absolute restock_expected;
+
+ } gone;
+
+ } details;
+
+};
+
/**
* Callbacks of this type are used to serve the result of submitting a
* POST /orders request to a merchant.
*
* @param cls closure
- * @param hr HTTP response details
- * @param order_id order id of the newly created order
- * @param token the claim token generated by the merchant (NULL if
- * it wasn't generated).
+ * @param por response details
*/
typedef void
(*TALER_MERCHANT_PostOrdersCallback) (
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- const char *order_id,
- const struct TALER_ClaimTokenP *token);
+ const struct TALER_MERCHANT_PostOrdersReply *por);
/**
@@ -1259,7 +1325,7 @@ typedef void
* @param cb_cls closure for @a cb
* @return a handle for this request, NULL on error
*/
-struct TALER_MERCHANT_PostOrdersOperation *
+struct TALER_MERCHANT_PostOrdersHandle *
TALER_MERCHANT_orders_post (struct GNUNET_CURL_Context *ctx,
const char *backend_url,
const json_t *order,
@@ -1305,7 +1371,7 @@ struct TALER_MERCHANT_InventoryProduct
* @param cb_cls closure for @a cb
* @return a handle for this request, NULL on error
*/
-struct TALER_MERCHANT_PostOrdersOperation *
+struct TALER_MERCHANT_PostOrdersHandle *
TALER_MERCHANT_orders_post2 (
struct GNUNET_CURL_Context *ctx,
const char *backend_url,
@@ -1329,7 +1395,7 @@ TALER_MERCHANT_orders_post2 (
*/
void
TALER_MERCHANT_orders_post_cancel (
- struct TALER_MERCHANT_PostOrdersOperation *po);
+ struct TALER_MERCHANT_PostOrdersHandle *po);
/**