Skip to content

Commit

Permalink
Fix string references
Browse files Browse the repository at this point in the history
  • Loading branch information
jklein24 committed Nov 21, 2023
1 parent c48a857 commit 0db17b1
Showing 1 changed file with 67 additions and 48 deletions.
115 changes: 67 additions & 48 deletions lightspark/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -971,27 +971,31 @@ impl<K: OperationSigningKey> LightsparkClient<K> {
/// Creates an UMA invitation. If you are part of the incentive program, you should use
/// `create_uma_invitation_with_incentives`.
pub async fn create_uma_invitation(&self, inviter_uma: &str) -> Result<UmaInvitation, Error> {
let operation = "mutation CreateUmaInvitation(
let operation = format!(
"mutation CreateUmaInvitation(
$inviter_uma: String!
) {
create_uma_invitation(input: {
) {{
create_uma_invitation(input: {{
inviter_uma: $inviter_uma
}) {
invitation {
}}) {{
invitation {{
...UmaInvitationFragment
}
}
}
}}
}}
}}
" + uma_invitation::FRAGMENT;
{}
",
uma_invitation::FRAGMENT
);

let mut variables: HashMap<&str, Value> = HashMap::new();
variables.insert("inviter_uma", inviter_uma.into());

let value = serde_json::to_value(variables).map_err(Error::ConversionError)?;
let json = self
.requester
.execute_graphql(operation, Some(value))
.execute_graphql(&operation, Some(value))
.await?;

let result = serde_json::from_value(json["create_uma_invitation"]["invitation"].clone())
Expand All @@ -1007,23 +1011,27 @@ impl<K: OperationSigningKey> LightsparkClient<K> {
inviter_phone_number_e164: &str,
inviter_region: RegionCode,
) -> Result<UmaInvitation, Error> {
let operation = "mutation CreateUmaInvitationWithIncentives(
let operation = format!(
"mutation CreateUmaInvitationWithIncentives(
$inviter_uma: String!
$inviter_phone_hash: String!
$inviter_region: RegionCode!
) {
create_uma_invitation_with_incentives(input: {
) {{
create_uma_invitation_with_incentives(input: {{
inviter_uma: $inviter_uma
inviter_phone_hash: $inviter_phone_hash
inviter_region: $inviter_region
}) {
invitation {
}}) {{
invitation {{
...UmaInvitationFragment
}
}
}
}}
}}
}}
" + uma_invitation::FRAGMENT;
{}
",
uma_invitation::FRAGMENT
);

let mut variables: HashMap<&str, Value> = HashMap::new();
variables.insert("inviter_uma", inviter_uma.into());
Expand All @@ -1034,7 +1042,7 @@ impl<K: OperationSigningKey> LightsparkClient<K> {
let value = serde_json::to_value(variables).map_err(Error::ConversionError)?;
let json = self
.requester
.execute_graphql(operation, Some(value))
.execute_graphql(&operation, Some(value))
.await?;

let result = serde_json::from_value(
Expand All @@ -1051,21 +1059,25 @@ impl<K: OperationSigningKey> LightsparkClient<K> {
invitation_code: &str,
invitee_uma: &str,
) -> Result<UmaInvitation, Error> {
let operation = "mutation ClaimUmaInvitation(
let operation = format!(
"mutation ClaimUmaInvitation(
$invitation_code: String!
$invitee_uma: String!
) {
claim_uma_invitation(input: {
) {{
claim_uma_invitation(input: {{
invitation_code: $invitation_code
invitee_uma: $invitee_uma
}) {
invitation {
}}) {{
invitation {{
...UmaInvitationFragment
}
}
}
}}
}}
}}
" + uma_invitation::FRAGMENT;
{}
",
uma_invitation::FRAGMENT
);

let mut variables: HashMap<&str, Value> = HashMap::new();
variables.insert("invitation_code", invitation_code.into());
Expand All @@ -1074,7 +1086,7 @@ impl<K: OperationSigningKey> LightsparkClient<K> {
let value = serde_json::to_value(variables).map_err(Error::ConversionError)?;
let json = self
.requester
.execute_graphql(operation, Some(value))
.execute_graphql(&operation, Some(value))
.await?;

let result = serde_json::from_value(json["claim_uma_invitation"]["invitation"].clone())
Expand All @@ -1091,25 +1103,29 @@ impl<K: OperationSigningKey> LightsparkClient<K> {
invitee_phone_number_e164: &str,
invitee_region: RegionCode,
) -> Result<UmaInvitation, Error> {
let operation = "mutation ClaimUmaInvitation(
let operation = format!(
"mutation ClaimUmaInvitation(
$invitation_code: String!
$invitee_uma: String!
$invitee_phone_hash: String!
$invitee_region: RegionCode!
) {
claim_uma_invitation_with_incentives(input: {
) {{
claim_uma_invitation_with_incentives(input: {{
invitation_code: $invitation_code
invitee_uma: $invitee_uma
invitee_phone_hash: $invitee_phone_hash
invitee_region: $invitee_region
}) {
invitation {
}}) {{
invitation {{
...UmaInvitationFragment
}
}
}
}}
}}
}}
" + uma_invitation::FRAGMENT;
{}
",
uma_invitation::FRAGMENT
);

let mut variables: HashMap<&str, Value> = HashMap::new();
variables.insert("invitation_code", invitation_code.into());
Expand All @@ -1121,7 +1137,7 @@ impl<K: OperationSigningKey> LightsparkClient<K> {
let value = serde_json::to_value(variables).map_err(Error::ConversionError)?;
let json = self
.requester
.execute_graphql(operation, Some(value))
.execute_graphql(&operation, Some(value))
.await?;

let result = serde_json::from_value(
Expand All @@ -1136,23 +1152,26 @@ impl<K: OperationSigningKey> LightsparkClient<K> {
&self,
invitation_code: &str,
) -> Result<UmaInvitation, Error> {
let operation = "query FetchUmaInvitation(
let operation = format!(
"query FetchUmaInvitation(
$invitation_code: String!
) {
uma_invitation_by_code(code: $invitation_code) {
) {{
uma_invitation_by_code(code: $invitation_code) {{
...UmaInvitationFragment
}
}
" + uma_invitation::FRAGMENT;
}}
}}
{}
",
uma_invitation::FRAGMENT
);

let mut variables: HashMap<&str, Value> = HashMap::new();
variables.insert("invitation_code", invitation_code.into());

let value = serde_json::to_value(variables).map_err(Error::ConversionError)?;
let json = self
.requester
.execute_graphql(operation, Some(value))
.execute_graphql(&operation, Some(value))
.await?;

let result = serde_json::from_value(json["uma_invitation_by_code"].clone())
Expand Down

0 comments on commit 0db17b1

Please sign in to comment.