From bfcbbfaaa9e2c0aa4011e7b9764716f8749aae56 Mon Sep 17 00:00:00 2001
From: librelois <c@elo.tf>
Date: Tue, 15 Dec 2020 19:35:59 +0100
Subject: [PATCH] ref: remove suffix Query on queries names

---
 gql/gva_queries.gql |  4 ++--
 src/commands.rs     | 34 +++++++++++++++++-----------------
 src/main.rs         |  4 ++--
 3 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/gql/gva_queries.gql b/gql/gva_queries.gql
index 2c1ae9f..52d8aba 100644
--- a/gql/gva_queries.gql
+++ b/gql/gva_queries.gql
@@ -1,4 +1,4 @@
-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
   }
diff --git a/src/commands.rs b/src/commands.rs
index d03ff59..ab1dfd4 100644
--- a/src/commands.rs
+++ b/src/commands.rs
@@ -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();
diff --git a/src/main.rs b/src/main.rs
index b664c1d..4b7e8e9 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -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.")]
-- 
GitLab