Mise à jour effectuée, merci de nous signaler tout dysfonctionnement ! | Upgrade done, please let us know about any dysfunction!

Commit bfcbbfaa authored by Éloïs's avatar Éloïs
Browse files

ref: remove suffix Query on queries names

parent c43f6d28
query BalanceQuery($script: String!, $withUd: Boolean!) {
query Balance($script: String!, $withUd: Boolean!) {
balance(script: $script) {
amount
}
......@@ -7,7 +7,7 @@ query BalanceQuery($script: String!, $withUd: Boolean!) {
}
}
query CurrentUdQuery {
query CurrentUd {
currentUd {
amount
}
......
......@@ -33,17 +33,17 @@ pub(crate) fn balance<W: Write>(
pubkey_or_script: &str,
ud_unit: bool,
) -> anyhow::Result<()> {
let request_body = BalanceQuery::build_query(balance_query::Variables {
let request_body = Balance::build_query(balance::Variables {
script: pubkey_or_script.to_owned(),
with_ud: ud_unit,
});
let balance_query::ResponseData {
balance: balance_query::BalanceQueryBalance { amount },
let balance::ResponseData {
balance: balance::BalanceBalance { amount },
current_ud: current_ud_opt,
} = client.send_gql_query(&request_body)?;
if let Some(balance_query::BalanceQueryCurrentUd { amount: ud_amount }) = current_ud_opt {
if let Some(balance::BalanceCurrentUd { amount: ud_amount }) = current_ud_opt {
writeln!(
out,
"The balance of account '{}' is {:.2} UDĞ1 !",
......@@ -63,10 +63,10 @@ pub(crate) fn balance<W: Write>(
}
pub(crate) fn current_ud<W: Write>(client: &Client, out: &mut W) -> anyhow::Result<()> {
let request_body = CurrentUdQuery::build_query(current_ud_query::Variables);
let request_body = CurrentUd::build_query(current_ud::Variables);
if let current_ud_query::ResponseData {
current_ud: Some(current_ud_query::CurrentUdQueryCurrentUd { amount }),
if let current_ud::ResponseData {
current_ud: Some(current_ud::CurrentUdCurrentUd { amount }),
} = client.send_gql_query(&request_body)?
{
let int_part = amount / 100;
......@@ -91,10 +91,10 @@ mod tests {
fn test_balance() -> anyhow::Result<()> {
let mut client = Client::default();
client
.expect_send_gql_query::<graphql_client::QueryBody<balance_query::Variables>, _>()
.expect_send_gql_query::<graphql_client::QueryBody<balance::Variables>, _>()
.returning(|_| {
Ok(balance_query::ResponseData {
balance: balance_query::BalanceQueryBalance { amount: 2_046 },
Ok(balance::ResponseData {
balance: balance::BalanceBalance { amount: 2_046 },
current_ud: None,
})
});
......@@ -111,11 +111,11 @@ mod tests {
fn test_balance_with_ud_unit() -> anyhow::Result<()> {
let mut client = Client::default();
client
.expect_send_gql_query::<graphql_client::QueryBody<balance_query::Variables>, _>()
.expect_send_gql_query::<graphql_client::QueryBody<balance::Variables>, _>()
.returning(|_| {
Ok(balance_query::ResponseData {
balance: balance_query::BalanceQueryBalance { amount: 2_046 },
current_ud: Some(balance_query::BalanceQueryCurrentUd { amount: 1_023 }),
Ok(balance::ResponseData {
balance: balance::BalanceBalance { amount: 2_046 },
current_ud: Some(balance::BalanceCurrentUd { amount: 1_023 }),
})
});
let mut out = Vec::new();
......@@ -131,10 +131,10 @@ mod tests {
fn test_current_ud() -> anyhow::Result<()> {
let mut client = Client::default();
client
.expect_send_gql_query::<graphql_client::QueryBody<current_ud_query::Variables>, _>()
.expect_send_gql_query::<graphql_client::QueryBody<current_ud::Variables>, _>()
.returning(|_| {
Ok(current_ud_query::ResponseData {
current_ud: Some(current_ud_query::CurrentUdQueryCurrentUd { amount: 1_023 }),
Ok(current_ud::ResponseData {
current_ud: Some(current_ud::CurrentUdCurrentUd { amount: 1_023 }),
})
});
let mut out = Vec::new();
......
......@@ -43,11 +43,11 @@ const DEFAULT_GVA_SERVER: &str = "https://g1.librelois.fr/gva";
#[derive(Debug, Clone, Copy, GraphQLQuery)]
#[graphql(schema_path = "gql/gva_schema.gql", query_path = "gql/gva_queries.gql")]
pub struct BalanceQuery;
pub struct Balance;
#[derive(Debug, Clone, Copy, GraphQLQuery)]
#[graphql(schema_path = "gql/gva_schema.gql", query_path = "gql/gva_queries.gql")]
pub struct CurrentUdQuery;
pub struct CurrentUd;
#[derive(StructOpt)]
#[structopt(name = "rust-gva-client", about = "Client use GVA API of Duniter.")]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment