summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorChristian Blättler <blatc2@bfh.ch>2024-04-15 22:41:39 +0200
committerChristian Blättler <blatc2@bfh.ch>2024-04-15 22:41:39 +0200
commitfaaa6c049fe08b36e235d432de3d89d06b3ee029 (patch)
treeffb6ac4a89e6206a2a6313ac56504b923d4970f0 /src/include
parent38972c5e5941133b53695ab5ad1a6c1452c29056 (diff)
downloadmerchant-faaa6c049fe08b36e235d432de3d89d06b3ee029.tar.gz
merchant-faaa6c049fe08b36e235d432de3d89d06b3ee029.tar.bz2
merchant-faaa6c049fe08b36e235d432de3d89d06b3ee029.zip
add token family GET and POST handlers to merchant lib
Diffstat (limited to 'src/include')
-rw-r--r--src/include/taler_merchant_service.h166
1 files changed, 166 insertions, 0 deletions
diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h
index e8c890b1..057c9eff 100644
--- a/src/include/taler_merchant_service.h
+++ b/src/include/taler_merchant_service.h
@@ -1895,6 +1895,172 @@ TALER_MERCHANT_product_delete_cancel (
struct TALER_MERCHANT_ProductDeleteHandle *pdh);
+/* ********************* /tokenfamilies ************************** */
+
+/**
+ * Handle for a GET /tokenfamilies/$SLUG operation.
+ */
+struct TALER_MERCHANT_TokenFamilyGetHandle;
+
+
+/**
+ * Response to GET /tokenfamilies/$SLUG operation.
+ */
+struct TALER_MERCHANT_TokenFamilyGetResponse
+{
+ /**
+ * HTTP response details
+ */
+ struct TALER_MERCHANT_HttpResponse hr;
+
+ /**
+ * Details depending on HTTP status.
+ */
+ union
+ {
+ /**
+ * Details for #MHD_HTTP_OK.
+ */
+ struct
+ {
+
+ /**
+ * Identifier for the token family consisting of unreserved characters
+ * according to RFC 3986.
+ */
+ const char *slug;
+
+ /**
+ * Human-readable name for the token family.
+ */
+ const char *name;
+
+ /**
+ * description of the token family
+ */
+ const char *description;
+
+ /**
+ * Optional map from IETF BCP 47 language tags to localized descriptions.
+ */
+ const json_t *description_i18n;
+
+ /**
+ * Start time of the token family's validity period.
+ */
+ struct GNUNET_TIME_Timestamp valid_after;
+
+ /**
+ * End time of the token family's validity period.
+ */
+ struct GNUNET_TIME_Timestamp valid_before;
+
+ /**
+ * Validity duration of an issued token.
+ */
+ struct GNUNET_TIME_Relative duration;
+
+ /**
+ * Kind of token family, "subscription" or "discount".
+ */
+ const char *kind;
+
+ /**
+ * How many tokens have been issued for this family.
+ */
+ uint64_t issued;
+
+ /**
+ * How many tokens have been redeemed for this family.
+ */
+ uint64_t redeemed;
+ } ok;
+
+ } details;
+
+};
+
+/**
+ * Cancel GET /tokenfamilies/$SLUG operation.
+ *
+ * @param handle operation to cancel
+ */
+void
+TALER_MERCHANT_token_family_get_cancel (
+ struct TALER_MERCHANT_TokenFamilyGetHandle *handle);
+
+
+/**
+ * Function called with the result of the GET /tokenfamilies/$SLUG operation.
+ *
+ * @param cls closure
+ * @param pgr response details
+ */
+typedef void
+(*TALER_MERCHANT_TokenFamilyGetCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_TokenFamilyGetResponse *pgr);
+
+/**
+ * Handle for a POST /tokenfamilies operation.
+ */
+struct TALER_MERCHANT_TokenFamiliesPostHandle;
+
+
+/**
+ * Function called with the result of the POST /tokenfamilies operation.
+ *
+ * @param cls closure
+ * @param hr HTTP response details
+ */
+typedef void
+(*TALER_MERCHANT_TokenFamiliesPostCallback)(
+ void *cls,
+ const struct TALER_MERCHANT_HttpResponse *hr);
+
+
+/**
+ * Make a POST /tokenfamilies request to add a token family to the
+ * merchant instance.
+ *
+ * @param ctx the context
+ * @param backend_url HTTP base URL for the backend
+ * @param slug short, url-safe identifier for the token family
+ * @param name human-readable name for the token family
+ * @param description description of the token family
+ * @param description_i18n Map from IETF BCP 47 language tags to localized descriptions
+ * @param valid_after when the token family becomes valid
+ * @param valid_before when the token family expires
+ * @param duration how long tokens issued by this token family are valid for
+ * @param kind kind of token family, "subscription" or "discount"
+ * @param cb function to call with the backend's result
+ * @param cb_cls closure for @a cb
+ * @return the request handle; NULL upon error
+ */
+struct TALER_MERCHANT_TokenFamiliesPostHandle *
+TALER_MERCHANT_token_families_post (
+ struct GNUNET_CURL_Context *ctx,
+ const char *backend_url,
+ const char *slug,
+ const char *name,
+ const char *description,
+ const json_t *description_i18n,
+ struct GNUNET_TIME_Timestamp valid_after,
+ struct GNUNET_TIME_Timestamp valid_before,
+ struct GNUNET_TIME_Relative duration,
+ const char *kind,
+ TALER_MERCHANT_TokenFamiliesPostCallback cb,
+ void *cb_cls);
+
+/**
+ * Cancel POST /tokenfamilies operation.
+ *
+ * @param handle operation to cancel
+ */
+void
+TALER_MERCHANT_token_families_post_cancel (
+ struct TALER_MERCHANT_TokenFamiliesPostHandle *handle);
+
/* ********************* /orders ************************** */