[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-donau] branch master updated: [lib] adjust charity get API
From: |
gnunet |
Subject: |
[taler-donau] branch master updated: [lib] adjust charity get API |
Date: |
Tue, 16 Jan 2024 14:55:43 +0100 |
This is an automated email from the git hooks/post-receive script.
lukas-matyja pushed a commit to branch master
in repository donau.
The following commit(s) were added to refs/heads/master by this push:
new 18a7b7f [lib] adjust charity get API
new 3045c0f Merge remote-tracking branch 'refs/remotes/origin/master'
18a7b7f is described below
commit 18a7b7fe003abc65b9f03e23a8998f3dfb6148b6
Author: Matyja Lukas Adam <lukas.matyja@students.bfh.ch>
AuthorDate: Tue Jan 16 14:45:06 2024 +0100
[lib] adjust charity get API
---
...api_charity_get.c => donau_api_charities_get.c} | 84 +++++++++++-----------
src/lib/donau_api_charity_get.c | 71 +++++++++---------
2 files changed, 77 insertions(+), 78 deletions(-)
diff --git a/src/lib/donau_api_charity_get.c b/src/lib/donau_api_charities_get.c
similarity index 80%
copy from src/lib/donau_api_charity_get.c
copy to src/lib/donau_api_charities_get.c
index ed9b111..d382fe6 100644
--- a/src/lib/donau_api_charity_get.c
+++ b/src/lib/donau_api_charities_get.c
@@ -18,7 +18,7 @@
*/
/**
- * @file lib/donau_api_charity_get.c
+ * @file lib/donau_api_charities_get.c
* @brief Implementation of the "handle" component of the donau's HTTP API
* @author Lukas Matyja
*/
@@ -32,7 +32,7 @@
/**
* Handle for a GET /charities/$CHARITY_ID request.
*/
-struct DONAU_CharityGetHandle
+struct DONAU_CharitiesGetHandle
{
/**
* The url for the /charities/$CHARITY_ID request.
@@ -47,7 +47,7 @@ struct DONAU_CharityGetHandle
/**
* Function to call with the result.
*/
- DONAU_GetCharityResponseCallback cb;
+ DONAU_GetCharitiesResponseCallback cb;
/**
* Charity id we are querying.
@@ -71,7 +71,7 @@ struct DONAU_CharityGetHandle
* (malformed JSON)
*/
static enum GNUNET_GenericReturnValue
-handle_charity_get_ok (const json_t *resp_obj,
+handle_charities_get_ok (const json_t *resp_obj,
struct DONAU_CharityGetHandle *cgh)
{
const json_t *charity_hist_array;
@@ -88,14 +88,14 @@ handle_charity_get_ok (const json_t *resp_obj,
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_string ("name",
&name),
- GNUNET_JSON_spec_fixed_auto ("pub_key",
- &charity_resp.details.ok.charity->pub_key),
+ GNUNET_JSON_spec_fixed_auto ("charity_pub",
+
&charity_resp.details.ok.charity->charity_pub),
TALER_JSON_spec_amount_any ("max_per_year",
&charity_resp.details.ok.charity->max_per_year),
- GNUNET_JSON_spec_array_const ("donation_history",
- &charity_hist_array),
- GNUNET_JSON_spec_uint32 ("num_hist",
- &charity_resp.details.ok.charity->num_hist),
+ TALER_JSON_spec_amount_any ("receipts_to_date",
+ &charty_resp.details.ok.charity->receipts_to_date),
+ GNUNET_JSON_spec_uint32 ("current_year",
+ &charity_resp.details.ok.charity->current_year),
GNUNET_JSON_spec_end ()
};
@@ -110,37 +110,37 @@ handle_charity_get_ok (const json_t *resp_obj,
}
charity_resp.details.ok.charity->name = GNUNET_strdup (name);
- /* parse the charity history data */
- charity_resp.details.ok.charity->num_hist
- = json_array_size (charity_hist_array);
- if (0 != charity_resp.details.ok.charity->num_hist)
- {
- json_t *charity_history_obj;
- unsigned int index;
+ // /* parse the charity history data */
+ // charity_resp.details.ok.charity->num_hist
+ // = json_array_size (charity_hist_array);
+ // if (0 != charity_resp.details.ok.charity->num_hist)
+ // {
+ // json_t *charity_history_obj;
+ // unsigned int index;
- charity_resp.details.ok.charity->donation_history
- = GNUNET_new_array (charity_resp.details.ok.charity->num_hist,
- struct DONAU_CharityHistoryYear);
- json_array_foreach (charity_hist_array, index, charity_history_obj) {
- struct DONAU_CharityHistoryYear *donation_history =
&charity_resp.details.ok.charity->donation_history[index];
- struct GNUNET_JSON_Specification history_spec[] = {
- TALER_JSON_spec_amount_any ("final_amount",
- &donation_history->final_amount),
- GNUNET_JSON_spec_uint32 ("year",
- &donation_history->year),
- GNUNET_JSON_spec_end ()
- };
+ // charity_resp.details.ok.charity->donation_history
+ // = GNUNET_new_array (charity_resp.details.ok.charity->num_hist,
+ // struct DONAU_CharityHistoryYear);
+ // json_array_foreach (charity_hist_array, index, charity_history_obj) {
+ // struct DONAU_CharityHistoryYear *donation_history =
&charity_resp.details.ok.charity->donation_history[index];
+ // struct GNUNET_JSON_Specification history_spec[] = {
+ // TALER_JSON_spec_amount_any ("final_amount",
+ // &donation_history->final_amount),
+ // GNUNET_JSON_spec_uint32 ("year",
+ // &donation_history->year),
+ // GNUNET_JSON_spec_end ()
+ // };
- if (GNUNET_OK !=
- GNUNET_JSON_parse (charity_history_obj,
- history_spec,
- NULL, NULL))
- {
- GNUNET_break_op (0);
- return GNUNET_SYSERR;
- }
- }
- }
+ // if (GNUNET_OK !=
+ // GNUNET_JSON_parse (charity_history_obj,
+ // history_spec,
+ // NULL, NULL))
+ // {
+ // GNUNET_break_op (0);
+ // return GNUNET_SYSERR;
+ // }
+ // }
+ // }
cgh->cb (cgh->cb_cls,
&charity_resp);
@@ -158,7 +158,7 @@ handle_charity_get_ok (const json_t *resp_obj,
* @param resp_obj parsed JSON result, NULL on error
*/
static void
-handle_charity_get_finished (void *cls,
+handle_charities_get_finished (void *cls,
long response_code,
const void *resp_obj)
{
@@ -226,7 +226,7 @@ handle_charity_get_finished (void *cls,
}
struct DONAU_CharityGetHandle *
-DONAU_charity_get (
+DONAU_charities_get (
struct GNUNET_CURL_Context *ctx,
const char *url,
const uint64_t id,
@@ -292,7 +292,7 @@ DONAU_charity_get (
}
void
-DONAU_charity_get_cancel (
+DONAU_charities_get_cancel (
struct DONAU_CharityGetHandle *cgh)
{
if (NULL != cgh->job)
diff --git a/src/lib/donau_api_charity_get.c b/src/lib/donau_api_charity_get.c
index ed9b111..26b0042 100644
--- a/src/lib/donau_api_charity_get.c
+++ b/src/lib/donau_api_charity_get.c
@@ -74,7 +74,7 @@ static enum GNUNET_GenericReturnValue
handle_charity_get_ok (const json_t *resp_obj,
struct DONAU_CharityGetHandle *cgh)
{
- const json_t *charity_hist_array;
+ //const json_t *charity_hist_array;
const char *name;
if (JSON_OBJECT != json_typeof (resp_obj))
{
@@ -88,17 +88,16 @@ handle_charity_get_ok (const json_t *resp_obj,
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_string ("name",
&name),
- GNUNET_JSON_spec_fixed_auto ("pub_key",
- &charity_resp.details.ok.charity->pub_key),
+ GNUNET_JSON_spec_fixed_auto ("charity_pub",
+
&charity_resp.details.ok.charity->charity_pub),
TALER_JSON_spec_amount_any ("max_per_year",
&charity_resp.details.ok.charity->max_per_year),
- GNUNET_JSON_spec_array_const ("donation_history",
- &charity_hist_array),
- GNUNET_JSON_spec_uint32 ("num_hist",
- &charity_resp.details.ok.charity->num_hist),
+ TALER_JSON_spec_amount_any ("receipts_to_date",
+
&charity_resp.details.ok.charity->receipts_to_date),
+ GNUNET_JSON_spec_uint32 ("current_year",
+ &charity_resp.details.ok.charity->current_year),
GNUNET_JSON_spec_end ()
};
-
if (GNUNET_OK !=
GNUNET_JSON_parse (resp_obj,
spec,
@@ -111,36 +110,36 @@ handle_charity_get_ok (const json_t *resp_obj,
charity_resp.details.ok.charity->name = GNUNET_strdup (name);
/* parse the charity history data */
- charity_resp.details.ok.charity->num_hist
- = json_array_size (charity_hist_array);
- if (0 != charity_resp.details.ok.charity->num_hist)
- {
- json_t *charity_history_obj;
- unsigned int index;
+ // charity_resp.details.ok.charity->num_hist
+ // = json_array_size (charity_hist_array);
+ // if (0 != charity_resp.details.ok.charity->num_hist)
+ // {
+ // json_t *charity_history_obj;
+ // unsigned int index;
- charity_resp.details.ok.charity->donation_history
- = GNUNET_new_array (charity_resp.details.ok.charity->num_hist,
- struct DONAU_CharityHistoryYear);
- json_array_foreach (charity_hist_array, index, charity_history_obj) {
- struct DONAU_CharityHistoryYear *donation_history =
&charity_resp.details.ok.charity->donation_history[index];
- struct GNUNET_JSON_Specification history_spec[] = {
- TALER_JSON_spec_amount_any ("final_amount",
- &donation_history->final_amount),
- GNUNET_JSON_spec_uint32 ("year",
- &donation_history->year),
- GNUNET_JSON_spec_end ()
- };
+ // charity_resp.details.ok.charity->donation_history
+ // = GNUNET_new_array (charity_resp.details.ok.charity->num_hist,
+ // struct DONAU_CharityHistoryYear);
+ // json_array_foreach (charity_hist_array, index, charity_history_obj) {
+ // struct DONAU_CharityHistoryYear *donation_history =
&charity_resp.details.ok.charity->donation_history[index];
+ // struct GNUNET_JSON_Specification history_spec[] = {
+ // TALER_JSON_spec_amount_any ("final_amount",
+ // &donation_history->final_amount),
+ // GNUNET_JSON_spec_uint32 ("year",
+ // &donation_history->year),
+ // GNUNET_JSON_spec_end ()
+ // };
- if (GNUNET_OK !=
- GNUNET_JSON_parse (charity_history_obj,
- history_spec,
- NULL, NULL))
- {
- GNUNET_break_op (0);
- return GNUNET_SYSERR;
- }
- }
- }
+ // if (GNUNET_OK !=
+ // GNUNET_JSON_parse (charity_history_obj,
+ // history_spec,
+ // NULL, NULL))
+ // {
+ // GNUNET_break_op (0);
+ // return GNUNET_SYSERR;
+ // }
+ // }
+ //}
cgh->cb (cgh->cb_cls,
&charity_resp);
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-donau] branch master updated: [lib] adjust charity get API,
gnunet <=