diff options
Diffstat (limited to 'src/backend')
4 files changed, 38 insertions, 118 deletions
diff --git a/src/backend/taler-merchant-httpd_private-get-orders.c b/src/backend/taler-merchant-httpd_private-get-orders.c index 669a2e3b..d2f502f9 100644 --- a/src/backend/taler-merchant-httpd_private-get-orders.c +++ b/src/backend/taler-merchant-httpd_private-get-orders.c @@ -250,12 +250,12 @@ TMH_notify_order_change (const char *instance_id, po = pn) { pn = po->next; - if (! ( ( ((TALER_MERCHANTDB_YNA_YES == po->of.paid) == paid) || - (TALER_MERCHANTDB_YNA_ALL == po->of.paid) ) && - ( ((TALER_MERCHANTDB_YNA_YES == po->of.refunded) == refunded) || - (TALER_MERCHANTDB_YNA_ALL == po->of.refunded) ) && - ( ((TALER_MERCHANTDB_YNA_YES == po->of.wired) == wired) || - (TALER_MERCHANTDB_YNA_ALL == po->of.wired) ) ) ) + if (! ( ( ((TALER_EXCHANGE_YNA_YES == po->of.paid) == paid) || + (TALER_EXCHANGE_YNA_ALL == po->of.paid) ) && + ( ((TALER_EXCHANGE_YNA_YES == po->of.refunded) == refunded) || + (TALER_EXCHANGE_YNA_ALL == po->of.refunded) ) && + ( ((TALER_EXCHANGE_YNA_YES == po->of.wired) == wired) || + (TALER_EXCHANGE_YNA_ALL == po->of.wired) ) ) ) continue; if (0 != strcmp (instance_id, po->instance_id)) @@ -295,48 +295,6 @@ TMH_notify_order_change (const char *instance_id, /** - * Convert query argument to @a yna value. - * - * @param connection connection to take query argument from - * @param arg argument to try for - * @param[out] value to set - * @return true on success, false if the parameter was malformed - */ -static bool -arg_to_yna (struct MHD_Connection *connection, - const char *arg, - enum TALER_MERCHANTDB_YesNoAll *yna) -{ - const char *str; - - str = MHD_lookup_connection_value (connection, - MHD_GET_ARGUMENT_KIND, - arg); - if (NULL == str) - { - *yna = TALER_MERCHANTDB_YNA_ALL; - return true; - } - if (0 == strcasecmp (str, "yes")) - { - *yna = TALER_MERCHANTDB_YNA_YES; - return true; - } - if (0 == strcasecmp (str, "no")) - { - *yna = TALER_MERCHANTDB_YNA_NO; - return true; - } - if (0 == strcasecmp (str, "all")) - { - *yna = TALER_MERCHANTDB_YNA_ALL; - return true; - } - return false; -} - - -/** * Handle a GET "/orders" request. * * @param rh context of the handler @@ -363,23 +321,26 @@ TMH_private_get_orders (const struct TMH_RequestHandler *rh, "orders", hc->ctx); } - if (! (arg_to_yna (connection, - "paid", - &of.paid)) ) + if (! (TALER_arg_to_yna (connection, + "paid", + TALER_EXCHANGE_YNA_ALL, + &of.paid)) ) return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, TALER_EC_PARAMETER_MALFORMED, "paid"); - if (! (arg_to_yna (connection, - "refunded", - &of.refunded)) ) + if (! (TALER_arg_to_yna (connection, + "refunded", + TALER_EXCHANGE_YNA_ALL, + &of.refunded)) ) return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, TALER_EC_PARAMETER_MALFORMED, "refunded"); - if (! (arg_to_yna (connection, - "wired", - &of.wired)) ) + if (! (TALER_arg_to_yna (connection, + "wired", + TALER_EXCHANGE_YNA_ALL, + &of.wired)) ) return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, TALER_EC_PARAMETER_MALFORMED, diff --git a/src/backend/taler-merchant-httpd_private-get-reserves.c b/src/backend/taler-merchant-httpd_private-get-reserves.c index 780f88c8..be607c0e 100644 --- a/src/backend/taler-merchant-httpd_private-get-reserves.c +++ b/src/backend/taler-merchant-httpd_private-get-reserves.c @@ -93,8 +93,8 @@ TMH_private_get_reserves (const struct TMH_RequestHandler *rh, json_t *ra; enum GNUNET_DB_QueryStatus qs; struct GNUNET_TIME_Absolute created_after = { 0 }; - enum TALER_MERCHANTDB_YesNoAll active; - enum TALER_MERCHANTDB_YesNoAll failures; + enum TALER_EXCHANGE_YesNoAll active; + enum TALER_EXCHANGE_YesNoAll failures; { const char *active_s; @@ -104,22 +104,22 @@ TMH_private_get_reserves (const struct TMH_RequestHandler *rh, "active"); if (NULL == active_s) { - active = TALER_MERCHANTDB_YNA_ALL; + active = TALER_EXCHANGE_YNA_ALL; } else if (0 == strcasecmp (active_s, "yes")) { - active = TALER_MERCHANTDB_YNA_YES; + active = TALER_EXCHANGE_YNA_YES; } else if (0 == strcasecmp (active_s, "no")) { - active = TALER_MERCHANTDB_YNA_NO; + active = TALER_EXCHANGE_YNA_NO; } else if (0 == strcasecmp (active_s, "all")) { - active = TALER_MERCHANTDB_YNA_ALL; + active = TALER_EXCHANGE_YNA_ALL; } else return TALER_MHD_reply_with_error (connection, @@ -136,22 +136,22 @@ TMH_private_get_reserves (const struct TMH_RequestHandler *rh, "failures"); if (NULL == failures_s) { - failures = TALER_MERCHANTDB_YNA_ALL; + failures = TALER_EXCHANGE_YNA_ALL; } else if (0 == strcasecmp (failures_s, "yes")) { - failures = TALER_MERCHANTDB_YNA_YES; + failures = TALER_EXCHANGE_YNA_YES; } else if (0 == strcasecmp (failures_s, "no")) { - failures = TALER_MERCHANTDB_YNA_NO; + failures = TALER_EXCHANGE_YNA_NO; } else if (0 == strcasecmp (failures_s, "all")) { - failures = TALER_MERCHANTDB_YNA_ALL; + failures = TALER_EXCHANGE_YNA_ALL; } else return TALER_MHD_reply_with_error (connection, diff --git a/src/backend/taler-merchant-httpd_private-get-tips.c b/src/backend/taler-merchant-httpd_private-get-tips.c index dc4beac0..42651d06 100644 --- a/src/backend/taler-merchant-httpd_private-get-tips.c +++ b/src/backend/taler-merchant-httpd_private-get-tips.c @@ -53,48 +53,6 @@ add_tip (void *cls, /** - * Convert query argument to @a yna value. - * - * @param connection connection to take query argument from - * @param arg argument to try for - * @param[out] value to set - * @return true on success, false if the parameter was malformed - */ -static bool -arg_to_yna (struct MHD_Connection *connection, - const char *arg, - enum TALER_MERCHANTDB_YesNoAll *yna) -{ - const char *str; - - str = MHD_lookup_connection_value (connection, - MHD_GET_ARGUMENT_KIND, - arg); - if (NULL == str) - { - *yna = TALER_MERCHANTDB_YNA_NO; - return true; - } - if (0 == strcasecmp (str, "yes")) - { - *yna = TALER_MERCHANTDB_YNA_YES; - return true; - } - if (0 == strcasecmp (str, "no")) - { - *yna = TALER_MERCHANTDB_YNA_NO; - return true; - } - if (0 == strcasecmp (str, "all")) - { - *yna = TALER_MERCHANTDB_YNA_ALL; - return true; - } - return false; -} - - -/** * Handle a GET "/tips/$ID" request. * * @param rh context of the handler @@ -109,7 +67,7 @@ TMH_private_get_tips (const struct TMH_RequestHandler *rh, { json_t *pa; enum GNUNET_DB_QueryStatus qs; - enum TALER_MERCHANTDB_YesNoAll expired; + enum TALER_EXCHANGE_YesNoAll expired; uint64_t offset; int64_t limit; @@ -117,9 +75,10 @@ TMH_private_get_tips (const struct TMH_RequestHandler *rh, // - also change TALER_MERCHANTDB_YNA to TALER_EXCHANGE_YNA, // - code can go into src/util/ of exchange.git // - please look for other places where the same logic is duplicated to de-dup - if (! (arg_to_yna (connection, /* TODO: put this method in a header somewhere */ - "expired", - &expired)) ) + if (! (TALER_arg_to_yna (connection, /* TODO: put this method in a header somewhere */ + "expired", + TALER_EXCHANGE_YNA_NO, + &expired)) ) return TALER_MHD_reply_with_error (connection, MHD_HTTP_BAD_REQUEST, TALER_EC_PARAMETER_MALFORMED, diff --git a/src/backend/taler-merchant-httpd_private-get-transfers.c b/src/backend/taler-merchant-httpd_private-get-transfers.c index 0bf53f3d..c2f12107 100644 --- a/src/backend/taler-merchant-httpd_private-get-transfers.c +++ b/src/backend/taler-merchant-httpd_private-get-transfers.c @@ -95,7 +95,7 @@ TMH_private_get_transfers (const struct TMH_RequestHandler *rh, struct GNUNET_TIME_Absolute after = GNUNET_TIME_UNIT_ZERO_ABS; int64_t limit = -20; /* FIXME: default? Nothing documented!!? */ uint64_t offset; - enum TALER_MERCHANTDB_YesNoAll verified; + enum TALER_EXCHANGE_YesNoAll verified; payto_uri = MHD_lookup_connection_value (connection, MHD_GET_ARGUMENT_KIND, @@ -191,22 +191,22 @@ TMH_private_get_transfers (const struct TMH_RequestHandler *rh, "verified"); if (NULL == verified_s) { - verified = TALER_MERCHANTDB_YNA_ALL; + verified = TALER_EXCHANGE_YNA_ALL; } else if (0 == strcasecmp (verified_s, "yes")) { - verified = TALER_MERCHANTDB_YNA_YES; + verified = TALER_EXCHANGE_YNA_YES; } else if (0 == strcasecmp (verified_s, "no")) { - verified = TALER_MERCHANTDB_YNA_NO; + verified = TALER_EXCHANGE_YNA_NO; } else if (0 == strcasecmp (verified_s, "all")) { - verified = TALER_MERCHANTDB_YNA_ALL; + verified = TALER_EXCHANGE_YNA_ALL; } else return TALER_MHD_reply_with_error (connection, |