summaryrefslogtreecommitdiff
path: root/src/include/taler_merchant_service.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-06-03 17:54:10 +0200
committerChristian Grothoff <christian@grothoff.org>2023-06-03 17:54:10 +0200
commitcea5867be3735f7c418a456b93ba9a45535f8cbc (patch)
treea73db25bd3ec26b8c2f0d623e55f7dce96639b96 /src/include/taler_merchant_service.h
parent1d8a5e4336304246141e17f4e49e58762348fbd5 (diff)
downloadmerchant-cea5867be3735f7c418a456b93ba9a45535f8cbc.tar.gz
merchant-cea5867be3735f7c418a456b93ba9a45535f8cbc.tar.bz2
merchant-cea5867be3735f7c418a456b93ba9a45535f8cbc.zip
misc style improvements
Diffstat (limited to 'src/include/taler_merchant_service.h')
-rw-r--r--src/include/taler_merchant_service.h263
1 files changed, 207 insertions, 56 deletions
diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h
index 32364fa5..83035455 100644
--- a/src/include/taler_merchant_service.h
+++ b/src/include/taler_merchant_service.h
@@ -303,21 +303,51 @@ struct TALER_MERCHANT_ConfigInformation
};
-// FIXME: change signature!
+/**
+ * Response to /config request.
+ */
+struct TALER_MERCHANT_ConfigResponse
+{
+ /**
+ * HTTP response.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Status-dependent details.
+ */
+ union
+ {
+ /**
+ * Information returned on #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * basic information about the merchant
+ */
+ struct TALER_MERCHANT_ConfigInformation ci;
+
+ /**
+ * protocol compatibility information
+ */
+ enum TALER_MERCHANT_VersionCompatibility compat;
+ } ok;
+ } details;
+};
+
+
/**
* Function called with information about the merchant.
*
* @param cls closure
- * @param hr HTTP response data
- * @param ci basic information about the merchant
- * @param compat protocol compatibility information
+ * @param cr response data
*/
typedef void
(*TALER_MERCHANT_ConfigCallback) (
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- const struct TALER_MERCHANT_ConfigInformation *ci,
- enum TALER_MERCHANT_VersionCompatibility compat);
+ const struct TALER_MERCHANT_ConfigResponse *cr);
/**
@@ -1177,46 +1207,105 @@ TALER_MERCHANT_products_get_cancel (
struct TALER_MERCHANT_ProductGetHandle;
-// FIXME: change signature!
+/**
+ * Response to GET /product/$ID operation.
+ */
+struct TALER_MERCHANT_ProductGetResponse
+{
+ /**
+ * HTTP response details
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on HTTP status.
+ */
+ union
+ {
+ /**
+ * Details for #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * description of the product
+ */
+ const char *description;
+
+ /**
+ * Map from IETF BCP 47 language tags to localized descriptions
+ */
+ const json_t *description_i18n;
+
+ /**
+ * unit in which the product is measured (liters, kilograms, packages, etc.)
+ */
+ const char *unit;
+
+ /**
+ * the price for one @a unit of the product, zero is used to imply that
+ * this product is not sold separately or that the price is
+ * not fixed and must be supplied by the front-end. If
+ * non-zero, price must include applicable taxes.
+ */
+ struct TALER_Amount price;
+
+ /**
+ * base64-encoded product image
+ */
+ const char *image;
+
+ /**
+ * list of taxes paid by the merchant
+ */
+ const json_t *taxes;
+
+ /**
+ * total_stock in @e units, -1 to indicate "infinite" (i.e. electronic
+ * books), does NOT indicate remaining stocks, to get remaining stocks,
+ * subtract @e total_sold and @e total_lost. Note that this still does
+ * not then say how many of the remaining inventory are locked.
+ */
+ int64_t total_stock;
+
+ /**
+ * in @e units, total number of @e unit of product sold
+ */
+ uint64_t total_sold;
+
+ /**
+ * in @e units, total number of @e unit of product lost from inventory
+ */
+ uint64_t total_lost;
+
+ /**
+ * where the product is in stock
+ */
+ const json_t *location;
+
+ /**
+ * when the next restocking is expected to happen, 0 for unknown,
+ * #GNUNET_TIME_UNIT_FOREVER_ABS for 'never'.
+ */
+ struct GNUNET_TIME_Timestamp next_restock;
+ } ok;
+
+ } details;
+
+};
+
+
/**
* Function called with the result of the GET /products operation.
*
* @param cls closure
- * @param hr HTTP response details
- * @param description description of the product
- * @param description_i18n Map from IETF BCP 47 language tags to localized descriptions
- * @param unit unit in which the product is measured (liters, kilograms, packages, etc.)
- * @param price the price for one @a unit of the product, zero is used to imply that
- * this product is not sold separately or that the price is not fixed and
- * must be supplied by the front-end. If non-zero, price must include
- * applicable taxes.
- * @param image base64-encoded product image
- * @param taxes list of taxes paid by the merchant
- * @param total_stock in @a units, -1 to indicate "infinite" (i.e. electronic books),
- * does NOT indicate remaining stocks, to get remaining stocks,
- * subtract @a total_sold and @a total_lost. Note that this still
- * does not then say how many of the remaining inventory are locked.
- * @param total_sold in @a units, total number of @a unit of product sold
- * @param total_lost in @a units, total number of @a unit of product lost from inventory
- * @param location where the product is in stock
- * @param next_restock when the next restocking is expected to happen, 0 for unknown,
- * #GNUNET_TIME_UNIT_FOREVER_ABS for 'never'.
+ * @param pgr response details
*/
typedef void
(*TALER_MERCHANT_ProductGetCallback)(
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- const char *description,
- const json_t *description_i18n,
- const char *unit,
- const struct TALER_Amount *price,
- const char *image,
- const json_t *taxes,
- int64_t total_stock,
- uint64_t total_sold,
- uint64_t total_lost,
- const json_t *location,
- struct GNUNET_TIME_Timestamp next_restock);
+ const struct TALER_MERCHANT_ProductGetResponse *pgr);
/**
@@ -1730,21 +1819,52 @@ struct TALER_MERCHANT_OrderEntry
};
-// FIXME: change signature!
+/**
+ * Response for a GET /private/orders request.
+ */
+struct TALER_MERCHANT_OrdersGetResponse
+{
+ /**
+ * HTTP response details.
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on HTTP status.
+ */
+ union
+ {
+ /**
+ * Details for #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * length of the @e orders array
+ */
+ unsigned int orders_length;
+
+ /**
+ * array of orders the requested instance has made
+ */
+ const struct TALER_MERCHANT_OrderEntry *orders;
+ } ok;
+ } details;
+
+};
+
+
/**
* Function called with the result of the GET /orders operation.
*
* @param cls closure
- * @param hr HTTP response details
- * @param orders_length length of the @a orders array
- * @param orders array of orders the requested instance has made
+ * @param ogr response details
*/
typedef void
(*TALER_MERCHANT_OrdersGetCallback)(
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- unsigned int orders_length,
- const struct TALER_MERCHANT_OrderEntry orders[]);
+ const struct TALER_MERCHANT_OrdersGetResponse *ogr);
/**
@@ -2338,24 +2458,55 @@ TALER_MERCHANT_order_delete_cancel (
struct TALER_MERCHANT_OrderClaimHandle;
-// FIXME: change signature!
+/**
+ * Response to a POST /orders/$ID/claim request.
+ */
+struct TALER_MERCHANT_OrderClaimResponse
+{
+ /**
+ * HTTP response details
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on HTTP status.
+ */
+ union
+ {
+ /**
+ * Details for #MHD_HTTP_OK.
+ */
+ struct
+ {
+ /**
+ * the details of the contract
+ */
+ const json_t *contract_terms;
+
+ /**
+ * merchant's signature over @e contract_terms (already verified)
+ */
+ struct TALER_MerchantSignatureP sig;
+
+ /**
+ * hash over @e contract_terms (computed client-side to verify @e sig)
+ */
+ struct TALER_PrivateContractHashP h_contract_terms;
+ } ok;
+
+ } details;
+};
+
/**
* Callback called to process a POST /orders/$ID/claim response.
*
* @param cls closure
- * @param hr HTTP response details
- * @param contract_terms the details of the contract
- * @param sig merchant's signature over @a contract_terms (already verified)
- * @param h_contract_terms hash over @a contract_terms (computed
- * client-side to verify @a sig)
+ * @param ocr response details
*/
typedef void
(*TALER_MERCHANT_OrderClaimCallback) (
void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- const json_t *contract_terms,
- const struct TALER_MerchantSignatureP *sig,
- const struct TALER_PrivateContractHashP *h_contract_terms);
+ const struct TALER_MERCHANT_OrderClaimResponse *ocr);
/**