Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Ğ
Ğcli
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
clients
Rust
Ğcli
Commits
bfcbbfaa
Commit
bfcbbfaa
authored
4 years ago
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
ref: remove suffix Query on queries names
parent
c43f6d28
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
gql/gva_queries.gql
+2
-2
2 additions, 2 deletions
gql/gva_queries.gql
src/commands.rs
+17
-17
17 additions, 17 deletions
src/commands.rs
src/main.rs
+2
-2
2 additions, 2 deletions
src/main.rs
with
21 additions
and
21 deletions
gql/gva_queries.gql
+
2
−
2
View file @
bfcbbfaa
query
Balance
Query
(
$script
:
String
!,
$withUd
:
Boolean
!)
{
query
Balance
(
$script
:
String
!,
$withUd
:
Boolean
!)
{
balance
(
script
:
$script
)
{
balance
(
script
:
$script
)
{
amount
amount
}
}
...
@@ -7,7 +7,7 @@ query BalanceQuery($script: String!, $withUd: Boolean!) {
...
@@ -7,7 +7,7 @@ query BalanceQuery($script: String!, $withUd: Boolean!) {
}
}
}
}
query
CurrentUd
Query
{
query
CurrentUd
{
currentUd
{
currentUd
{
amount
amount
}
}
...
...
This diff is collapsed.
Click to expand it.
src/commands.rs
+
17
−
17
View file @
bfcbbfaa
...
@@ -33,17 +33,17 @@ pub(crate) fn balance<W: Write>(
...
@@ -33,17 +33,17 @@ pub(crate) fn balance<W: Write>(
pubkey_or_script
:
&
str
,
pubkey_or_script
:
&
str
,
ud_unit
:
bool
,
ud_unit
:
bool
,
)
->
anyhow
::
Result
<
()
>
{
)
->
anyhow
::
Result
<
()
>
{
let
request_body
=
Balance
Query
::
build_query
(
balance
_query
::
Variables
{
let
request_body
=
Balance
::
build_query
(
balance
::
Variables
{
script
:
pubkey_or_script
.to_owned
(),
script
:
pubkey_or_script
.to_owned
(),
with_ud
:
ud_unit
,
with_ud
:
ud_unit
,
});
});
let
balance
_query
::
ResponseData
{
let
balance
::
ResponseData
{
balance
:
balance
_query
::
Balance
Query
Balance
{
amount
},
balance
:
balance
::
BalanceBalance
{
amount
},
current_ud
:
current_ud_opt
,
current_ud
:
current_ud_opt
,
}
=
client
.send_gql_query
(
&
request_body
)
?
;
}
=
client
.send_gql_query
(
&
request_body
)
?
;
if
let
Some
(
balance
_query
::
Balance
Query
CurrentUd
{
amount
:
ud_amount
})
=
current_ud_opt
{
if
let
Some
(
balance
::
BalanceCurrentUd
{
amount
:
ud_amount
})
=
current_ud_opt
{
writeln!
(
writeln!
(
out
,
out
,
"The balance of account '{}' is {:.2} UDĞ1 !"
,
"The balance of account '{}' is {:.2} UDĞ1 !"
,
...
@@ -63,10 +63,10 @@ pub(crate) fn balance<W: Write>(
...
@@ -63,10 +63,10 @@ pub(crate) fn balance<W: Write>(
}
}
pub
(
crate
)
fn
current_ud
<
W
:
Write
>
(
client
:
&
Client
,
out
:
&
mut
W
)
->
anyhow
::
Result
<
()
>
{
pub
(
crate
)
fn
current_ud
<
W
:
Write
>
(
client
:
&
Client
,
out
:
&
mut
W
)
->
anyhow
::
Result
<
()
>
{
let
request_body
=
CurrentUd
Query
::
build_query
(
current_ud
_query
::
Variables
);
let
request_body
=
CurrentUd
::
build_query
(
current_ud
::
Variables
);
if
let
current_ud
_query
::
ResponseData
{
if
let
current_ud
::
ResponseData
{
current_ud
:
Some
(
current_ud
_query
::
CurrentUd
Query
CurrentUd
{
amount
}),
current_ud
:
Some
(
current_ud
::
CurrentUdCurrentUd
{
amount
}),
}
=
client
.send_gql_query
(
&
request_body
)
?
}
=
client
.send_gql_query
(
&
request_body
)
?
{
{
let
int_part
=
amount
/
100
;
let
int_part
=
amount
/
100
;
...
@@ -91,10 +91,10 @@ mod tests {
...
@@ -91,10 +91,10 @@ mod tests {
fn
test_balance
()
->
anyhow
::
Result
<
()
>
{
fn
test_balance
()
->
anyhow
::
Result
<
()
>
{
let
mut
client
=
Client
::
default
();
let
mut
client
=
Client
::
default
();
client
client
.expect_send_gql_query
::
<
graphql_client
::
QueryBody
<
balance
_query
::
Variables
>
,
_
>
()
.expect_send_gql_query
::
<
graphql_client
::
QueryBody
<
balance
::
Variables
>
,
_
>
()
.returning
(|
_
|
{
.returning
(|
_
|
{
Ok
(
balance
_query
::
ResponseData
{
Ok
(
balance
::
ResponseData
{
balance
:
balance
_query
::
Balance
Query
Balance
{
amount
:
2_046
},
balance
:
balance
::
BalanceBalance
{
amount
:
2_046
},
current_ud
:
None
,
current_ud
:
None
,
})
})
});
});
...
@@ -111,11 +111,11 @@ mod tests {
...
@@ -111,11 +111,11 @@ mod tests {
fn
test_balance_with_ud_unit
()
->
anyhow
::
Result
<
()
>
{
fn
test_balance_with_ud_unit
()
->
anyhow
::
Result
<
()
>
{
let
mut
client
=
Client
::
default
();
let
mut
client
=
Client
::
default
();
client
client
.expect_send_gql_query
::
<
graphql_client
::
QueryBody
<
balance
_query
::
Variables
>
,
_
>
()
.expect_send_gql_query
::
<
graphql_client
::
QueryBody
<
balance
::
Variables
>
,
_
>
()
.returning
(|
_
|
{
.returning
(|
_
|
{
Ok
(
balance
_query
::
ResponseData
{
Ok
(
balance
::
ResponseData
{
balance
:
balance
_query
::
Balance
Query
Balance
{
amount
:
2_046
},
balance
:
balance
::
BalanceBalance
{
amount
:
2_046
},
current_ud
:
Some
(
balance
_query
::
Balance
Query
CurrentUd
{
amount
:
1_023
}),
current_ud
:
Some
(
balance
::
BalanceCurrentUd
{
amount
:
1_023
}),
})
})
});
});
let
mut
out
=
Vec
::
new
();
let
mut
out
=
Vec
::
new
();
...
@@ -131,10 +131,10 @@ mod tests {
...
@@ -131,10 +131,10 @@ mod tests {
fn
test_current_ud
()
->
anyhow
::
Result
<
()
>
{
fn
test_current_ud
()
->
anyhow
::
Result
<
()
>
{
let
mut
client
=
Client
::
default
();
let
mut
client
=
Client
::
default
();
client
client
.expect_send_gql_query
::
<
graphql_client
::
QueryBody
<
current_ud
_query
::
Variables
>
,
_
>
()
.expect_send_gql_query
::
<
graphql_client
::
QueryBody
<
current_ud
::
Variables
>
,
_
>
()
.returning
(|
_
|
{
.returning
(|
_
|
{
Ok
(
current_ud
_query
::
ResponseData
{
Ok
(
current_ud
::
ResponseData
{
current_ud
:
Some
(
current_ud
_query
::
CurrentUd
Query
CurrentUd
{
amount
:
1_023
}),
current_ud
:
Some
(
current_ud
::
CurrentUdCurrentUd
{
amount
:
1_023
}),
})
})
});
});
let
mut
out
=
Vec
::
new
();
let
mut
out
=
Vec
::
new
();
...
...
This diff is collapsed.
Click to expand it.
src/main.rs
+
2
−
2
View file @
bfcbbfaa
...
@@ -43,11 +43,11 @@ const DEFAULT_GVA_SERVER: &str = "https://g1.librelois.fr/gva";
...
@@ -43,11 +43,11 @@ const DEFAULT_GVA_SERVER: &str = "https://g1.librelois.fr/gva";
#[derive(Debug,
Clone,
Copy,
GraphQLQuery)]
#[derive(Debug,
Clone,
Copy,
GraphQLQuery)]
#[graphql(schema_path
=
"gql/gva_schema.gql"
,
query_path
=
"gql/gva_queries.gql"
)]
#[graphql(schema_path
=
"gql/gva_schema.gql"
,
query_path
=
"gql/gva_queries.gql"
)]
pub
struct
Balance
Query
;
pub
struct
Balance
;
#[derive(Debug,
Clone,
Copy,
GraphQLQuery)]
#[derive(Debug,
Clone,
Copy,
GraphQLQuery)]
#[graphql(schema_path
=
"gql/gva_schema.gql"
,
query_path
=
"gql/gva_queries.gql"
)]
#[graphql(schema_path
=
"gql/gva_schema.gql"
,
query_path
=
"gql/gva_queries.gql"
)]
pub
struct
CurrentUd
Query
;
pub
struct
CurrentUd
;
#[derive(StructOpt)]
#[derive(StructOpt)]
#[structopt(name
=
"rust-gva-client"
,
about
=
"Client use GVA API of Duniter."
)]
#[structopt(name
=
"rust-gva-client"
,
about
=
"Client use GVA API of Duniter."
)]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment