summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcello Stanisci <marcello.stanisci@inria.fr>2017-02-28 17:36:34 +0100
committerMarcello Stanisci <marcello.stanisci@inria.fr>2017-02-28 17:36:34 +0100
commitacb8cb3d9075879a9deb031352e78b4fde76d1c1 (patch)
treea93cc70b29ae1b1e024caede0108214a954dad79
parentb494f35d37731d0a301f95d0cb6c9ff44b9a828a (diff)
downloadmerchant-acb8cb3d9075879a9deb031352e78b4fde76d1c1.tar.gz
merchant-acb8cb3d9075879a9deb031352e78b4fde76d1c1.tar.bz2
merchant-acb8cb3d9075879a9deb031352e78b4fde76d1c1.zip
Make /history's arguments optional.
-rw-r--r--src/backend/taler-merchant-httpd_history.c30
-rw-r--r--src/include/taler_merchant_service.h5
-rw-r--r--src/lib/merchant_api_history.c11
-rw-r--r--src/lib/test_merchant_api.c2
4 files changed, 30 insertions, 18 deletions
diff --git a/src/backend/taler-merchant-httpd_history.c b/src/backend/taler-merchant-httpd_history.c
index d121114b..3fd5f220 100644
--- a/src/backend/taler-merchant-httpd_history.c
+++ b/src/backend/taler-merchant-httpd_history.c
@@ -91,29 +91,27 @@ MH_handler_history (struct TMH_RequestHandler *rh,
MHD_GET_ARGUMENT_KIND,
"date");
- if (NULL == str)
- return TMH_RESPONSE_reply_arg_missing (connection,
- TALER_EC_PARAMETER_MISSING,
- "date");
-
- if (1 != sscanf (str, "%llu", &seconds))
+ seconds = 0;
+ if (NULL != str)
+ {
+ if (1 != sscanf (str, "%llu", &seconds))
return TMH_RESPONSE_reply_arg_invalid (connection,
TALER_EC_PARAMETER_MALFORMED,
"date");
- date.abs_value_us = seconds * 1000LL * 1000LL;
- if (date.abs_value_us / 1000LL / 1000LL != seconds)
- return TMH_RESPONSE_reply_bad_request (connection,
- TALER_EC_HISTORY_TIMESTAMP_OVERFLOW,
- "Timestamp overflowed");
+ date.abs_value_us = seconds * 1000LL * 1000LL;
+ if (date.abs_value_us / 1000LL / 1000LL != seconds)
+ return TMH_RESPONSE_reply_bad_request (connection,
+ TALER_EC_HISTORY_TIMESTAMP_OVERFLOW,
+ "Timestamp overflowed");
+
+ }
+ mi = TMH_lookup_instance ("default");
str = MHD_lookup_connection_value (connection,
MHD_GET_ARGUMENT_KIND,
"instance");
- if (NULL == str)
- return TMH_RESPONSE_reply_arg_missing (connection,
- TALER_EC_PARAMETER_MISSING,
- "instance");
- mi = TMH_lookup_instance (str);
+ if (NULL != str)
+ mi = TMH_lookup_instance (str);
if (NULL == mi)
return TMH_RESPONSE_reply_not_found (connection,
diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h
index 2e2af851..b1b25206 100644
--- a/src/include/taler_merchant_service.h
+++ b/src/include/taler_merchant_service.h
@@ -552,6 +552,9 @@ typedef void
*
* @param ctx execution context
* @param backend_uri base URL of the merchant backend
+ * @param instance which merchant instance is performing this call
+ * @param start return `delta` records starting from position `start`
+ * @param delta return `delta` records starting from position `start`
* @param date only transactions younger than/equals to date will be returned
* @param history_cb callback which will work the response gotten from the backend
* @param history_cb_cls closure to pass to history_cb
@@ -561,6 +564,8 @@ struct TALER_MERCHANT_HistoryOperation *
TALER_MERCHANT_history (struct GNUNET_CURL_Context *ctx,
const char *backend_uri,
const char *instance,
+ unsigned int start,
+ unsigned int delta,
struct GNUNET_TIME_Absolute date,
TALER_MERCHANT_HistoryOperationCallback history_cb,
void *history_cb_cls);
diff --git a/src/lib/merchant_api_history.c b/src/lib/merchant_api_history.c
index d0dffd66..69d09b8e 100644
--- a/src/lib/merchant_api_history.c
+++ b/src/lib/merchant_api_history.c
@@ -136,6 +136,9 @@ history_raw_cb (void *cls,
*
* @param ctx execution context
* @param backend_uri base URL of the merchant backend
+ * @param instance which merchant instance is performing this call
+ * @param start return `delta` records starting from position `start`
+ * @param delta return `delta` records starting from position `start`
* @param date only transactions younger than/equals to date will be returned
* @param history_cb callback which will work the response gotten from the backend
* @param history_cb_cls closure to pass to @a history_cb
@@ -145,6 +148,8 @@ struct TALER_MERCHANT_HistoryOperation *
TALER_MERCHANT_history (struct GNUNET_CURL_Context *ctx,
const char *backend_uri,
const char *instance,
+ unsigned int start,
+ unsigned int delta,
struct GNUNET_TIME_Absolute date,
TALER_MERCHANT_HistoryOperationCallback history_cb,
void *history_cb_cls)
@@ -159,10 +164,12 @@ TALER_MERCHANT_history (struct GNUNET_CURL_Context *ctx,
ho->cb_cls = history_cb_cls;
seconds = date.abs_value_us / 1000LL / 1000LL;
GNUNET_asprintf (&ho->url,
- "%s/history?date=%llu&instance=%s",
+ "%s/history?date=%llu&instance=%s&start=%d&delta=%d",
backend_uri,
seconds,
- instance);
+ instance,
+ start,
+ delta);
eh = curl_easy_init ();
if (CURLE_OK != curl_easy_setopt (eh,
CURLOPT_URL,
diff --git a/src/lib/test_merchant_api.c b/src/lib/test_merchant_api.c
index fe596ebd..025cd8a2 100644
--- a/src/lib/test_merchant_api.c
+++ b/src/lib/test_merchant_api.c
@@ -1980,6 +1980,8 @@ interpreter_run (void *cls)
(cmd->details.history.ho = TALER_MERCHANT_history (ctx,
MERCHANT_URI,
instance,
+ 0,
+ 20,
cmd->details.history.date,
history_cb,
is)))