[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-merchant] branch master updated: Make /history's arg
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-merchant] branch master updated: Make /history's arguments optional. |
Date: |
Tue, 28 Feb 2017 17:36:51 +0100 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a commit to branch master
in repository merchant.
The following commit(s) were added to refs/heads/master by this push:
new acb8cb3 Make /history's arguments optional.
acb8cb3 is described below
commit acb8cb3d9075879a9deb031352e78b4fde76d1c1
Author: Marcello Stanisci <address@hidden>
AuthorDate: Tue Feb 28 17:36:34 2017 +0100
Make /history's arguments optional.
---
src/backend/taler-merchant-httpd_history.c | 30 ++++++++++++++----------------
src/include/taler_merchant_service.h | 5 +++++
src/lib/merchant_api_history.c | 11 +++++++++--
src/lib/test_merchant_api.c | 2 ++
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 d121114..3fd5f22 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 2e2af85..b1b2520 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 d0dffd6..69d09b8 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 fe596eb..025cd8a 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)))
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [taler-merchant] branch master updated: Make /history's arguments optional.,
gnunet <=