/*
This file is part of TALER
Copyright (C) 2014-2019 GNUnet e.V.
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
TALER is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with
TALER; see the file COPYING. If not, see
*/
/**
* @file taler-exchange-httpd_responses.h
* @brief API for generating generic replies of the exchange; these
* functions are called TEH_RESPONSE_reply_ and they generate
* and queue MHD response objects for a given connection.
* @author Florian Dold
* @author Benedikt Mueller
* @author Christian Grothoff
*/
#ifndef TALER_EXCHANGE_HTTPD_RESPONSES_H
#define TALER_EXCHANGE_HTTPD_RESPONSES_H
#include
#include
#include
#include
#include "taler_error_codes.h"
#include "taler-exchange-httpd.h"
#include "taler-exchange-httpd_db.h"
/**
* Compile the history of a reserve into a JSON object
* and calculate the total balance.
*
* @param rh reserve history to JSON-ify
* @param[out] balance set to current reserve balance
* @return json representation of the @a rh, NULL on error
*/
json_t *
TEH_RESPONSE_compile_reserve_history (const struct
TALER_EXCHANGEDB_ReserveHistory *rh,
struct TALER_Amount *balance);
/**
* Send proof that a request is invalid to client because of
* insufficient funds. This function will create a message with all
* of the operations affecting the coin that demonstrate that the coin
* has insufficient value.
*
* @param connection connection to the client
* @param ec error code to return
* @param tl transaction list to use to build reply
* @return MHD result code
*/
int
TEH_RESPONSE_reply_coin_insufficient_funds (struct MHD_Connection *connection,
enum TALER_ErrorCode ec,
const struct
TALER_EXCHANGEDB_TransactionList *tl);
/**
* Compile the transaction history of a coin into a JSON object.
*
* @param tl transaction history to JSON-ify
* @return json representation of the @a rh
*/
json_t *
TEH_RESPONSE_compile_transaction_history (const struct
TALER_EXCHANGEDB_TransactionList *tl);
#endif