diff options
author | priscilla <priscilla.huang@efrei.net> | 2022-11-22 11:19:17 -0500 |
---|---|---|
committer | priscilla <priscilla.huang@efrei.net> | 2022-11-22 11:19:17 -0500 |
commit | 088ee12e5bddcf66c1a273995b2799227c73364f (patch) | |
tree | 1dda514636613eac14abca56666e7d8b6b7f5847 /src/include/taler_merchant_service.h | |
parent | e9735103820c6ed8fb74ef1afec44ee4be20e77c (diff) |
taler_mercahnt_service.h
Diffstat (limited to 'src/include/taler_merchant_service.h')
-rw-r--r-- | src/include/taler_merchant_service.h | 277 |
1 files changed, 277 insertions, 0 deletions
diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h index 089518f8..e3894cc5 100644 --- a/src/include/taler_merchant_service.h +++ b/src/include/taler_merchant_service.h @@ -4093,4 +4093,281 @@ TALER_MERCHANT_kyc_get_cancel ( struct TALER_MERCHANT_KycGetHandle *kyc); +/* ********************* /templates *********************** */ + + +/** + * Handle for a GET /templates operation. + */ +struct TALER_MERCHANT_TemplatesGetHandle; + +/** + * Individual template (minimal information + * returned via GET /templates). + */ +struct TALER_MERCHANT_TemplateEntry +{ + /** + * template identifier. + */ + const char *template_id; + +}; + + +/** + * Function called with the result of the GET /templates operation. + * + * @param cls closure + * @param hr HTTP response details + * @param templates_length length of the @a templates array + * @param templates array of templates the requested instance offers + */ +typedef void +(*TALER_MERCHANT_TemplatesGetCallback)( + void *cls, + const struct TALER_MERCHANT_HttpResponse *hr, + unsigned int templates_length, + const struct TALER_MERCHANT_TemplateEntry templates[]); + + +/** + * Make a GET /templates request. + * + * @param ctx the context + * @param backend_url HTTP base URL for the backend + * @param cb function to call with the backend information + * @param cb_cls closure for @a cb + * @return the request handle; NULL upon error + */ +struct TALER_MERCHANT_TemplatesGetHandle * +TALER_MERCHANT_templates_get ( + struct GNUNET_CURL_Context *ctx, + const char *backend_url, + TALER_MERCHANT_TemplatesGetCallback cb, + void *cb_cls); + + +/** + * Cancel GET /templates operation. + * + * @param tgh operation to cancel + */ +void +TALER_MERCHANT_templates_get_cancel ( + struct TALER_MERCHANT_TemplatesGetHandle *tgh); + + +/** + * Handle for a GET /template/$ID operation. Gets details + * about a single template. Do not confused with a + * `struct TALER_MERCHANT_TemplatesGetHandle`, which + * obtains a list of all templates. + */ +struct TALER_MERCHANT_TemplateGetHandle; + + +/** + * Function called with the result of the GET /templates operation. + * + * @param cls closure + * @param hr HTTP response details + * @param template_description description of the template + * @param image base64-encoded product image + * @param template_contract is the contract of the company + */ +typedef void +(*TALER_MERCHANT_TemplateGetCallback)( + void *cls, + const struct TALER_MERCHANT_HttpResponse *hr, + const char *template_description, + const char *image, + const json_t *template_contract); + + +/** + * Make a GET /template/$ID request to get details about an + * individual template. + * + * @param ctx the context + * @param backend_url HTTP base URL for the backend + * @param template_id identifier of the template to inquire about + * @param cb function to call with the backend's template information + * @param cb_cls closure for @a cb + * @return the request handle; NULL upon error + */ +struct TALER_MERCHANT_TemplateGetHandle * +TALER_MERCHANT_template_get ( + struct GNUNET_CURL_Context *ctx, + const char *backend_url, + const char *template_id, + TALER_MERCHANT_TemplateGetCallback cb, + void *cb_cls); + + +/** + * Cancel GET /templates/$ID operation. + * + * @param tgh operation to cancel + */ +void +TALER_MERCHANT_template_get_cancel ( + struct TALER_MERCHANT_TemplateGetHandle *tgh); + + +/** + * Handle for a POST /templates operation. + */ +struct TALER_MERCHANT_TemplatesPostHandle; + + +/** + * Function called with the result of the POST /templates operation. + * + * @param cls closure + * @param hr HTTP response details + */ +typedef void +(*TALER_MERCHANT_TemplatesPostCallback)( + void *cls, + const struct TALER_MERCHANT_HttpResponse *hr); + + +/** + * Make a POST /templates request to add a template + * + * @param ctx the context + * @param backend_url HTTP base URL for the backend + * @param template_id identifier to use for the template + * @param template_description description of the template + * @param image base64-encoded product image + * @param template_contract is the contract of the company + * @param cb function to call with the backend's result + * @param cb_cls closure for @a cb + * @return the request handle; NULL upon error + */ +struct TALER_MERCHANT_TemplatesPostHandle * +TALER_MERCHANT_templates_post ( + struct GNUNET_CURL_Context *ctx, + const char *backend_url, + const char *template_id, + const char *template_description, + const char *image, + const json_t *template_contract, + TALER_MERCHANT_TemplatesPostCallback cb, + void *cb_cls); + + +/** + * Cancel POST /templates operation. + * + * @param tph operation to cancel + */ +void +TALER_MERCHANT_templates_post_cancel ( + struct TALER_MERCHANT_TemplatesPostHandle *tph); + + +/** + * Handle for a PATCH /template operation. + */ +struct TALER_MERCHANT_TemplatePatchHandle; + + +/** + * Function called with the result of the PATCH /template operation. + * + * @param cls closure + * @param hr HTTP response details + */ +typedef void +(*TALER_MERCHANT_TemplatePatchCallback)( + void *cls, + const struct TALER_MERCHANT_HttpResponse *hr); + + +/** + * Make a PATCH /template request to update template details + * + * @param ctx the context + * @param backend_url HTTP base URL for the backend + * @param template_id identifier to use for the template; the template must exist, + * or the transaction will fail with a #MHD_HTTP_NOT_FOUND + * HTTP status code + * @param template_description description of the template + * @param image base64-encoded product image + * @param template_contract is the contract of the company + * @param cb function to call with the backend's result + * @param cb_cls closure for @a cb + * @return the request handle; NULL upon error + */ +struct TALER_MERCHANT_TemplatePatchHandle * +TALER_MERCHANT_template_patch ( + struct GNUNET_CURL_Context *ctx, + const char *backend_url, + const char *template_id, + const char *template_description, + const char *image, + const json_t *template_contract, + TALER_MERCHANT_ProductPatchCallback cb, + void *cb_cls); + + +/** + * Cancel PATCH /template operation. + * + * @param tph operation to cancel + */ +void +TALER_MERCHANT_template_patch_cancel ( + struct TALER_MERCHANT_TemplatePatchHandle *tph); + + +/** + * Handle for a DELETE /template/$ID operation. + */ +struct TALER_MERCHANT_TemplateDeleteHandle; + + +/** + * Function called with the result of the DELETE /template/$ID operation. + * + * @param cls closure + * @param hr HTTP response details + */ +typedef void +(*TALER_MERCHANT_TemplateDeleteCallback)( + void *cls, + const struct TALER_MERCHANT_HttpResponse *hr); + + +/** + * Make a DELETE /template/$ID request to delete a product. + * + * @param ctx the context + * @param backend_url HTTP base URL for the backend + * @param template_id identifier of the template + * @param cb function to call with the backend's deletion status + * @param cb_cls closure for @a cb + * @return the request handle; NULL upon error + */ +struct TALER_MERCHANT_TemplateDeleteHandle * +TALER_MERCHANT_template_delete ( + struct GNUNET_CURL_Context *ctx, + const char *backend_url, + const char *template_id, + TALER_MERCHANT_TemplateDeleteCallback cb, + void *cb_cls); + + +/** + * Cancel DELETE /template/$ID operation. + * + * @param pdh operation to cancel + */ +void +TALER_MERCHANT_template_delete_cancel ( + struct TALER_MERCHANT_TemplateDeleteHandle *tdh); + + #endif /* _TALER_MERCHANT_SERVICE_H */ |