[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-merchant] 46/277: improve API
From: |
gnunet |
Subject: |
[taler-merchant] 46/277: improve API |
Date: |
Sun, 05 Jul 2020 20:49:19 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository merchant.
commit 0fa2888bc7d1095a2341e16eda59cb5085b78b67
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Fri Apr 24 19:54:50 2020 +0200
improve API
---
src/include/taler_merchant_testing_lib.h | 12 ++++-----
src/testing/test_merchant_api.c | 40 ++++++++++++++++++++++++++++
src/testing/testing_api_cmd_patch_instance.c | 12 ++++++---
src/testing/testing_api_cmd_patch_product.c | 6 +++--
src/testing/testing_api_cmd_post_instances.c | 29 ++++++++++----------
src/testing/testing_api_cmd_post_products.c | 13 ++++-----
6 files changed, 78 insertions(+), 34 deletions(-)
diff --git a/src/include/taler_merchant_testing_lib.h
b/src/include/taler_merchant_testing_lib.h
index d9d3c8e..bba80d3 100644
--- a/src/include/taler_merchant_testing_lib.h
+++ b/src/include/taler_merchant_testing_lib.h
@@ -147,9 +147,9 @@ TALER_TESTING_cmd_merchant_post_instances2 (
const char *name,
json_t *address,
json_t *jurisdiction,
- const struct TALER_Amount *default_max_wire_fee,
+ const char *default_max_wire_fee,
uint32_t default_wire_fee_amortization,
- const struct TALER_Amount *default_max_deposit_fee,
+ const char *default_max_deposit_fee,
struct GNUNET_TIME_Relative default_wire_transfer_delay,
struct GNUNET_TIME_Relative default_pay_delay,
unsigned int http_status);
@@ -185,9 +185,9 @@ TALER_TESTING_cmd_merchant_patch_instance (
const char *name,
json_t *address,
json_t *jurisdiction,
- const struct TALER_Amount *default_max_wire_fee,
+ const char *default_max_wire_fee,
uint32_t default_wire_fee_amortization,
- const struct TALER_Amount *default_max_deposit_fee,
+ const char *default_max_deposit_fee,
struct GNUNET_TIME_Relative default_wire_transfer_delay,
struct GNUNET_TIME_Relative default_pay_delay,
unsigned int http_status);
@@ -281,7 +281,7 @@ TALER_TESTING_cmd_merchant_post_products2 (
const char *description,
json_t *description_i18n,
const char *unit,
- const struct TALER_Amount *price,
+ const char *price,
json_t *image,
json_t *taxes,
int64_t total_stocked,
@@ -345,7 +345,7 @@ TALER_TESTING_cmd_merchant_patch_product (
const char *description,
json_t *description_i18n,
const char *unit,
- const struct TALER_Amount *price,
+ const char *price,
json_t *image,
json_t *taxes,
int64_t total_stocked,
diff --git a/src/testing/test_merchant_api.c b/src/testing/test_merchant_api.c
index 3a203fc..76fbb43 100644
--- a/src/testing/test_merchant_api.c
+++ b/src/testing/test_merchant_api.c
@@ -42,6 +42,8 @@
*/
#define CONFIG_FILE "test_merchant_api.conf"
+#define PAYTO_I1 "payto://taler-bank/localhost/3"
+
/**
* Exchange base URL. Could also be taken from config.
*/
@@ -895,10 +897,48 @@ run (void *cls,
TALER_TESTING_cmd_end ()
};
+ const char *payto_uris[] = {
+ PAYTO_I1
+ };
struct TALER_TESTING_Command commands[] = {
TALER_TESTING_cmd_config ("config",
merchant_url,
MHD_HTTP_OK),
+ TALER_TESTING_cmd_merchant_get_instances ("instances-empty",
+ merchant_url,
+ MHD_HTTP_OK),
+ TALER_TESTING_cmd_merchant_post_instances ("instance-create-i1",
+ merchant_url,
+ "i1",
+ PAYTO_I1,
+ "EUR",
+ MHD_HTTP_NO_CONTENT),
+ TALER_TESTING_cmd_merchant_get_instances ("instances-get-i1",
+ merchant_url,
+ MHD_HTTP_OK),
+ TALER_TESTING_cmd_merchant_get_instance ("instances-get-i1",
+ merchant_url,
+ "i1",
+ MHD_HTTP_OK,
+ "instance-create-i1"),
+ TALER_TESTING_cmd_merchant_patch_instance ("instance-create-i1",
+ merchant_url,
+ "i1",
+ 1,
+ payto_uris,
+ "bob-the-merchant",
+ json_pack ("{s:s}",
+ "street",
+ "bobstreet"),
+ json_pack ("{s:s}",
+ "street",
+ "bobjuryst"),
+ "EUR:0.1",
+ 4,
+ "EUR:0.5",
+ GNUNET_TIME_UNIT_MINUTES,
+ GNUNET_TIME_UNIT_MINUTES,
+ MHD_HTTP_NO_CONTENT),
#if 0
TALER_TESTING_cmd_batch ("pay",
pay),
diff --git a/src/testing/testing_api_cmd_patch_instance.c
b/src/testing/testing_api_cmd_patch_instance.c
index 0d589bb..a198829 100644
--- a/src/testing/testing_api_cmd_patch_instance.c
+++ b/src/testing/testing_api_cmd_patch_instance.c
@@ -237,9 +237,9 @@ TALER_TESTING_cmd_merchant_patch_instance (
const char *name,
json_t *address,
json_t *jurisdiction,
- const struct TALER_Amount *default_max_wire_fee,
+ const char *default_max_wire_fee,
uint32_t default_wire_fee_amortization,
- const struct TALER_Amount *default_max_deposit_fee,
+ const char *default_max_deposit_fee,
struct GNUNET_TIME_Relative default_wire_transfer_delay,
struct GNUNET_TIME_Relative default_pay_delay,
unsigned int http_status)
@@ -255,9 +255,13 @@ TALER_TESTING_cmd_merchant_patch_instance (
pis->name = name;
pis->address = address; /* ownership transfer! */
pis->jurisdiction = jurisdiction; /* ownership transfer! */
- pis->default_max_wire_fee = *default_max_wire_fee;
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (default_max_wire_fee,
+ &pis->default_max_wire_fee));
pis->default_wire_fee_amortization = default_wire_fee_amortization;
- pis->default_max_deposit_fee = *default_max_deposit_fee;
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (default_max_deposit_fee,
+ &pis->default_max_deposit_fee));
pis->default_wire_transfer_delay = default_wire_transfer_delay;
pis->default_pay_delay = default_pay_delay;
{
diff --git a/src/testing/testing_api_cmd_patch_product.c
b/src/testing/testing_api_cmd_patch_product.c
index 8088932..ec4bb4c 100644
--- a/src/testing/testing_api_cmd_patch_product.c
+++ b/src/testing/testing_api_cmd_patch_product.c
@@ -243,7 +243,7 @@ TALER_TESTING_cmd_merchant_patch_product (
const char *description,
json_t *description_i18n,
const char *unit,
- const struct TALER_Amount *price,
+ const char *price,
json_t *image,
json_t *taxes,
int64_t total_stocked,
@@ -261,7 +261,9 @@ TALER_TESTING_cmd_merchant_patch_product (
pis->description = description;
pis->description_i18n = description_i18n; /* ownership taken */
pis->unit = unit;
- pis->price = *price;
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (price,
+ &pis->price));
pis->image = image; /* ownership taken */
pis->taxes = taxes; /* ownership taken */
pis->total_stocked = total_stocked;
diff --git a/src/testing/testing_api_cmd_post_instances.c
b/src/testing/testing_api_cmd_post_instances.c
index f9da2da..26efd0b 100644
--- a/src/testing/testing_api_cmd_post_instances.c
+++ b/src/testing/testing_api_cmd_post_instances.c
@@ -237,9 +237,9 @@ TALER_TESTING_cmd_merchant_post_instances2 (
const char *name,
json_t *address,
json_t *jurisdiction,
- const struct TALER_Amount *default_max_wire_fee,
+ const char *default_max_wire_fee,
uint32_t default_wire_fee_amortization,
- const struct TALER_Amount *default_max_deposit_fee,
+ const char *default_max_deposit_fee,
struct GNUNET_TIME_Relative default_wire_transfer_delay,
struct GNUNET_TIME_Relative default_pay_delay,
unsigned int http_status)
@@ -255,9 +255,13 @@ TALER_TESTING_cmd_merchant_post_instances2 (
pis->name = name;
pis->address = address; /* ownership transfer! */
pis->jurisdiction = jurisdiction; /* ownership transfer! */
- pis->default_max_wire_fee = *default_max_wire_fee;
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (default_max_wire_fee,
+ &pis->default_max_wire_fee));
pis->default_wire_fee_amortization = default_wire_fee_amortization;
- pis->default_max_deposit_fee = *default_max_deposit_fee;
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (default_max_deposit_fee,
+ &pis->default_max_deposit_fee));
pis->default_wire_transfer_delay = default_wire_transfer_delay;
pis->default_pay_delay = default_pay_delay;
{
@@ -296,17 +300,14 @@ TALER_TESTING_cmd_merchant_post_instances (const char
*label,
const char *payto_uris[] = {
payto_uri
};
- struct TALER_Amount default_max_wire_fee;
- struct TALER_Amount default_max_deposit_fee;
+ struct TALER_Amount default_max_fee;
+ const char *default_max_fee_s;
GNUNET_assert (GNUNET_OK ==
TALER_amount_get_zero (currency,
- &default_max_wire_fee));
- GNUNET_assert (GNUNET_OK ==
- TALER_amount_get_zero (currency,
- &default_max_deposit_fee));
- default_max_wire_fee.value = 1;
- default_max_deposit_fee.value = 1;
+ &default_max_fee));
+ default_max_fee.value = 1;
+ default_max_fee_s = TALER_amount2s (&default_max_fee);
return TALER_TESTING_cmd_merchant_post_instances2 (
label,
@@ -317,9 +318,9 @@ TALER_TESTING_cmd_merchant_post_instances (const char
*label,
instance_id,
json_pack ("{s:s}", "city", "shopcity"),
json_pack ("{s:s}", "city", "lawyercity"),
- &default_max_wire_fee,
+ default_max_fee_s,
10,
- &default_max_deposit_fee,
+ default_max_fee_s,
GNUNET_TIME_UNIT_MINUTES,
GNUNET_TIME_UNIT_MINUTES,
http_status);
diff --git a/src/testing/testing_api_cmd_post_products.c
b/src/testing/testing_api_cmd_post_products.c
index f5fed27..8f787bc 100644
--- a/src/testing/testing_api_cmd_post_products.c
+++ b/src/testing/testing_api_cmd_post_products.c
@@ -234,7 +234,7 @@ TALER_TESTING_cmd_merchant_post_products2 (
const char *description,
json_t *description_i18n,
const char *unit,
- const struct TALER_Amount *price,
+ const char *price,
json_t *image,
json_t *taxes,
int64_t total_stocked,
@@ -251,7 +251,9 @@ TALER_TESTING_cmd_merchant_post_products2 (
pis->description = description;
pis->description_i18n = description_i18n; /* ownership taken */
pis->unit = unit;
- pis->price = *price;
+ GNUNET_assert (GNUNET_OK ==
+ TALER_string_to_amount (price,
+ &pis->price));
pis->image = image; /* ownership taken */
pis->taxes = taxes; /* ownership taken */
pis->total_stocked = total_stocked;
@@ -290,11 +292,6 @@ TALER_TESTING_cmd_merchant_post_products (const char
*label,
const char *price,
unsigned int http_status)
{
- struct TALER_Amount amount;
-
- GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (price,
- &amount));
return TALER_TESTING_cmd_merchant_post_products2 (
label,
merchant_url,
@@ -302,7 +299,7 @@ TALER_TESTING_cmd_merchant_post_products (const char *label,
description,
json_pack ("{s:s}", "en", description),
"test-unit",
- &amount,
+ price,
json_object (),
json_object (),
4,
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-merchant] 45/277: baseURL construction helper function', (continued)
- [taler-merchant] 45/277: baseURL construction helper function', gnunet, 2020/07/05
- [taler-merchant] 44/277: fix ftbfs in lock logic, gnunet, 2020/07/05
- [taler-merchant] 41/277: add DELETE/PURGE /instances/ID command, gnunet, 2020/07/05
- [taler-merchant] 42/277: implement purge, gnunet, 2020/07/05
- [taler-merchant] 43/277: toward stesting, gnunet, 2020/07/05
- [taler-merchant] 50/277: misc fixes, gnunet, 2020/07/05
- [taler-merchant] 49/277: fix fmt string, gnunet, 2020/07/05
- [taler-merchant] 68/277: sql-ing, gnunet, 2020/07/05
- [taler-merchant] 53/277: implemente DELETE /orders/ID, gnunet, 2020/07/05
- [taler-merchant] 38/277: add PATCH /instances/ID command, gnunet, 2020/07/05
- [taler-merchant] 46/277: improve API,
gnunet <=
- [taler-merchant] 54/277: first hack at POST /orders, gnunet, 2020/07/05
- [taler-merchant] 57/277: implement logic to complete POSTed /orders using inventory data, gnunet, 2020/07/05
- [taler-merchant] 62/277: mark as obsolete, gnunet, 2020/07/05
- [taler-merchant] 60/277: GET /orders logic, gnunet, 2020/07/05
- [taler-merchant] 48/277: fix tests, gnunet, 2020/07/05
- [taler-merchant] 56/277: implement POST /orders client with all optional arguments, gnunet, 2020/07/05
- [taler-merchant] 55/277: fix fTBFS, gnunet, 2020/07/05
- [taler-merchant] 61/277: rename fest to match new structure, gnunet, 2020/07/05
- [taler-merchant] 69/277: update pay logic, gnunet, 2020/07/05
- [taler-merchant] 74/277: DB API for /abort, gnunet, 2020/07/05