commit 73baafbebdb17642fc9efae63aac089857a1ccb3
parent d02801a9e19b9376bd05ac4625f5da4932f34557
Author: Matyja Lukas Adam <lukas.matyja@students.bfh.ch>
Date: Sun, 22 Oct 2023 23:00:52 +0200
[header] add bearer tokens, a charityRequest data type
Diffstat:
1 file changed, 52 insertions(+), 46 deletions(-)
diff --git a/src/include/taler_donau_service.h b/src/include/taler_donau_service.h
@@ -955,12 +955,11 @@ typedef void
/**
* Submit a request to obtain the transaction history of a charity
- * from the donau. Note that while we return the full response to the
+ * from the donau. Note that while we return the full response to the
* caller for further processing, we do already verify that the
* response is well-formed (i.e. that signatures included in the
- * response are all valid and add up to the balance). If the donau's
- * reply is not well-formed, we return an HTTP status code of zero to
- * @a cb.
+ * response are all valid). If the donau's reply is not well-formed,
+ * we return an HTTP status code of zero to @a cb.
*
* @param ctx curl context
* @param url donau base URL
@@ -970,7 +969,7 @@ typedef void
* @param cb the callback to call when a reply for this request is available
* @param cb_cls closure for the above callback
* @return a handle for this request; NULL if the inputs are invalid (i.e.
- * signatures fail to verify). In this case, the callback is not called.
+ * signatures fail to verify). In this case, the callback is not called.
*/
struct TALER_DONAU_CharitiesGetHandle *
TALER_DONAU_charities_get (
@@ -1097,19 +1096,15 @@ typedef void
/**
- * Submit a request to obtain the transaction history of a charity
- * from the donau. Note that while we return the full response to the
+ * Submit a GET request to obtain the informations about a single charity
+ * from the donau. Note that while we return the full response to the
* caller for further processing, we do already verify that the
* response is well-formed (i.e. that signatures included in the
- * response are all valid and add up to the balance). If the donau's
- * reply is not well-formed, we return an HTTP status code of zero to
- * @a cb.
+ * response are all valid). If the donau's reply is not well-formed,
+ * we return an HTTP status code of zero to @a cb.
*
* @param ctx curl context
* @param url donau base URL
- * @param charity_pub public key of the charity to inspect
- * @param timeout how long to wait for an affirmative reply
- * (enables long polling if the charity does not yet exist)
* @param cb the callback to call when a reply for this request is available
* @param cb_cls closure for the above callback
* @return a handle for this request; NULL if the inputs are invalid (i.e.
@@ -1119,7 +1114,6 @@ struct TALER_DONAU_CharityGetHandle *
TALER_DONAU_charity_get (
struct GNUNET_CURL_Context *ctx,
const char *url,
- const struct TALER_charityPublicKeyP *charity_pub,
TALER_DONAU_GetCharityResponseCallback cb,
void *cb_cls);
@@ -1138,6 +1132,27 @@ TALER_DONAU_charity_get_cancel (
/* ********************* POST /charities/ *********************** */
/**
+ * add or change charity request
+ */
+struct charityRequest
+{
+ /**
+ * name of the charity
+ */
+ char *name;
+
+ /**
+ * max donation amount per year
+ */
+ struct TALER_Amount amount;
+
+ /**
+ * public key of the charity
+ */
+ struct TALER_DONAU_EddsaPublicKeyP charity_pub;
+
+};
+/**
* @brief A /charities Post Handle
*/
struct TALER_DONAU_CharityPostHandle;
@@ -1194,19 +1209,17 @@ typedef void
/**
- * Submit a request to obtain the transaction history of a charity
- * from the donau. Note that while we return the full response to the
- * caller for further processing, we do already verify that the
- * response is well-formed (i.e. that signatures included in the
- * response are all valid and add up to the balance). If the donau's
+ * Submit a POST request to add a new charity to the donau. Note that
+ * while we return the full response to the caller for further processing,
+ * we do already verify that the response is well-formed (i.e. that
+ * signatures included in the response are all valid). If the donau's
* reply is not well-formed, we return an HTTP status code of zero to
* @a cb.
*
* @param ctx curl context
* @param url donau base URL
- * @param name name of the charity
- * @param amount Max donation amout for this charitiy and year.
- * @param charity_pub public key of the charity
+ * @param charity_req contains the name, public key and the max donation amount
+ * @param bearer for authentication
* @param cb the callback to call when a reply for this request is available
* @param cb_cls closure for the above callback
* @return a handle for this request; NULL if the inputs are invalid (i.e.
@@ -1216,9 +1229,8 @@ struct TALER_DONAU_CharityPostHandle *
TALER_DONAU_charity_post (
struct GNUNET_CURL_Context *ctx,
const char *url,
- const char *name,
- const struct TALER_Amount amount,
- const struct TALER_DONAU_EddsaPublicKeyP charity_pub,
+ const charityRequest charity_req,
+ const struct TALER_DONAU_BearerToken bearer,
TALER_DONAU_PostCharityResponseCallback cb,
void *cb_cls);
@@ -1268,19 +1280,16 @@ typedef void
/**
- * Submit a request to obtain the transaction history of a charity
- * from the donau. Note that while we return the full response to the
+ * Submit a PATCH request to change data about a charity
+ * from the donau. Note that while we return the full response to the
* caller for further processing, we do already verify that the
* response is well-formed (i.e. that signatures included in the
- * response are all valid and add up to the balance). If the donau's
- * reply is not well-formed, we return an HTTP status code of zero to
- * @a cb.
+ * response are all valid). If the donau's reply is not well-formed,
+ * we return an HTTP status code of zero to @a cb.
*
* @param ctx curl context
* @param url donau base URL
- * @param name name of the charity
- * @param amount Max donation amout for this charitiy and year.
- * @param charity_pub public key of the charity
+ * @param charity_req contains the name, public key and the max donation amount
* @param cb the callback to call when a reply for this request is available
* @param cb_cls closure for the above callback
* @return a handle for this request; NULL if the inputs are invalid (i.e.
@@ -1290,9 +1299,8 @@ struct TALER_DONAU_CharityPatchHandle *
TALER_DONAU_charity_patch (
struct GNUNET_CURL_Context *ctx,
const char *url,
- const char *name,
- const struct TALER_Amount amount,
- const struct TALER_DONAU_EddsaPublicKeyP charity_pub,
+ const struct charityRequest charity_req,
+ const struct TALER_DONAU_BearerToken bearer,
TALER_DONAU_PatchCharityResponseCallback cb,
void *cb_cls);
@@ -1343,28 +1351,26 @@ typedef void
/**
- * Submit a request to obtain the transaction history of a charity
- * from the donau. Note that while we return the full response to the
+ * Submit a DELETE request to delete a charity
+ * from the donau. Note that while we return the full response to the
* caller for further processing, we do already verify that the
* response is well-formed (i.e. that signatures included in the
- * response are all valid and add up to the balance). If the donau's
- * reply is not well-formed, we return an HTTP status code of zero to
- * @a cb.
+ * response are all valid). If the donau's reply is not well-formed,
+ * we return an HTTP status code of zero to @a cb.
*
* @param ctx curl context
* @param url donau base URL
- * @param name name of the charity
- * @param amount Max donation amout for this charitiy and year.
- * @param charity_pub public key of the charity
+ * @param bearer for authentication
* @param cb the callback to call when a reply for this request is available
* @param cb_cls closure for the above callback
* @return a handle for this request; NULL if the inputs are invalid (i.e.
- * signatures fail to verify). In this case, the callback is not called.
+ * signatures fail to verify). In this case, the callback is not called.
*/
-struct TALER_DONAU_CharityPostHandle *
+struct TALER_DONAU_CharityDeleteHandle *
TALER_DONAU_charity_delete (
struct GNUNET_CURL_Context *ctx,
const char *url,
+ const struct TALER_DONAU_BearerToken bearer,
TALER_DONAU_DeleteCharityResponseCallback cb,
void *cb_cls);