/*
This file is part of TALER
Copyright (C) 2020 Taler Systems SA
TALER is free software; you can redistribute it and/or modify
it under the terms of the GNU 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 General Public License for more details.
You should have received a copy of the GNU General Public
License along with TALER; see the file COPYING. If not, see
*/
/**
* @file lib/testing_api_trait_merchant_json.c
* @brief offer merchant address and jurisdiction
* @author Jonathan Buchanan
*/
#include "platform.h"
#include
#include
#include
#define TALER_TESTING_TRAIT_MERCHANT_ADDRESS "merchant-address"
#define TALER_TESTING_TRAIT_MERCHANT_JURISDICTION "merchant_jurisdiction"
/**
* Obtain merchant address from @a cmd.
*
* @param cmd command to extract the address from.
* @param index index number associate with the address on offer.
* @param[out] address where to write the address.
* @return #GNUNET_OK on success.
*/
int
TALER_TESTING_get_trait_merchant_address (const struct
TALER_TESTING_Command *cmd,
unsigned int index,
const json_t **address)
{
return cmd->traits (cmd->cls,
(const void **) address,
TALER_TESTING_TRAIT_MERCHANT_ADDRESS,
index);
}
/**
* Offer merchant address in a trait.
*
* @param index index number associate with the address
* on offer.
* @param address address to offer.
* @return the trait.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_merchant_address (unsigned int index,
const json_t *address)
{
struct TALER_TESTING_Trait ret = {
.index = index,
.trait_name = TALER_TESTING_TRAIT_MERCHANT_ADDRESS,
.ptr = (const void *) address
};
return ret;
}
/**
* Obtain merchant jurisdiction from @a cmd.
*
* @param cmd command to extract the jurisdiction from.
* @param index index number associate with the jurisdiction on offer.
* @param[out] jurisdiction where to write the jurisdiction.
* @return #GNUNET_OK on success.
*/
int
TALER_TESTING_get_trait_merchant_jurisdiction (const struct
TALER_TESTING_Command *cmd,
unsigned int index,
const json_t **jurisdiction)
{
return cmd->traits (cmd->cls,
(const void **) jurisdiction,
TALER_TESTING_TRAIT_MERCHANT_JURISDICTION,
index);
}
/**
* Offer merchant jurisdiction in a trait.
*
* @param index index number associate with the jurisdiction
* on offer.
* @param jurisdiction jurisdiction to offer.
* @return the trait.
*/
struct TALER_TESTING_Trait
TALER_TESTING_make_trait_merchant_jurisdiction (unsigned int index,
const json_t *jurisdiction)
{
struct TALER_TESTING_Trait ret = {
.index = index,
.trait_name = TALER_TESTING_TRAIT_MERCHANT_JURISDICTION,
.ptr = (const void *) jurisdiction
};
return ret;
}