dcash_wallet/wallet.cpp
string send(HttpClient *client, string to, string amount) {
  if (!is_loged_in) {
    throw "send: No User Logged In.";
  }

  WwwFormEncodedDict encoder;
  encoder.set("to", to);
  encoder.set("amount", get_input_amount(amount));
  string body = encoder.encode();

  client->set_header("x-auth-token", auth_token);
  HTTPClientResponse *response = client->post("/transfers", body);
  string rsp = response->body();
  bool success = response->success();
  delete response;

  if (!success) {
    throw "HTTP Client Response Failed.";
  }

  Document d;
  d.Parse(rsp);
  assert(d["balance"].IsInt());
  return get_output_amount(d["balance"].GetInt());
}
/**
 * @brief Send money from the current loged in user to another user in database.
 * 
 * @param client Http client to the API server.
 * @param to The recieptor's user name.
 * @param amount The amount to be sent.
 * @return string The user's current balance.
 */
@brief Send money from the current loged in user to another user in database.

@param client Http client to the API server.
@param to The recieptor's user name.
@param amount The amount to be sent.
@return string The user's current balance.
@brief Send money from the current loged in user to another user in database . @param client Http client to the API server . @param to The recieptor ' s user name . @param amount The amount to be sent . @return string The user ' s current balance .
string send(HttpClient *client, string to, string amount) {
  if (!is_loged_in) {
    throw "send: No User Logged In.";
  }
  WwwFormEncodedDict encoder;
  encoder.set("to", to);
  encoder.set("amount", get_input_amount(amount));
  string body = encoder.encode();
  client->set_header("x-auth-token", auth_token);
  HTTPClientResponse *response = client->post("/transfers", body);
  string rsp = response->body();
  bool success = response->success();
  delete response;
  if (!success) {
    throw "HTTP Client Response Failed.";
  }
  Document d;
  d.Parse(rsp);
  assert(d["balance"].IsInt());
  return get_output_amount(d["balance"].GetInt());
}
string send ( HttpClient * client , string to , string amount ) { if ( ! is_loged_in ) { throw " " ; } WwwFormEncodedDict encoder ; encoder . set ( " " , to ) ; encoder . set ( " " , get_input_amount ( amount ) ) ; string body = encoder . encode ( ) ; client -> set_header ( " " , auth_token ) ; HTTPClientResponse * response = client -> post ( " " , body ) ; string rsp = response -> body ( ) ; bool success = response -> success ( ) ; delete response ; if ( ! success ) { throw " " ; } Document d ; d . Parse ( rsp ) ; assert ( d [ " " ] . IsInt ( ) ) ; return get_output_amount ( d [ " " ] . GetInt ( ) ) ; }
@brief Send money from the current loged in user to another user in database.
@brief Send money from the current loged in user to another user in database .