From c48a857f56d352d5f2241bf212ba3cb109ef8a4d Mon Sep 17 00:00:00 2001 From: Jeremy Klein Date: Mon, 20 Nov 2023 21:55:10 -0800 Subject: [PATCH 1/3] Add UMA invitation functions to the SDK. --- lightspark/src/client.rs | 206 ++- lightspark/src/error.rs | 2 + .../objects/account_to_nodes_connection.rs | 3 +- .../account_to_payment_requests_connection.rs | 4 +- .../account_to_transactions_connection.rs | 1 + .../src/objects/claim_uma_invitation_input.rs | 9 + .../objects/claim_uma_invitation_output.rs | 18 + ...im_uma_invitation_with_incentives_input.rs | 14 + ...m_uma_invitation_with_incentives_output.rs | 18 + ...create_invitation_with_incentives_input.rs | 12 + ...reate_invitation_with_incentives_output.rs | 18 + .../objects/create_uma_invitation_input.rs | 7 + .../objects/create_uma_invitation_output.rs | 18 + lightspark/src/objects/entity.rs | 8 + .../incentives_ineligibility_reason.rs | 52 + lightspark/src/objects/incentives_status.rs | 37 + lightspark/src/objects/invoice_data.rs | 6 +- lightspark/src/objects/lightspark_node.rs | 7 +- .../src/objects/lightspark_node_with_o_s_k.rs | 18 +- .../lightspark_node_with_remote_signing.rs | 16 +- lightspark/src/objects/mod.rs | 12 + lightspark/src/objects/outgoing_payment.rs | 21 +- .../src/objects/outgoing_payment_attempt.rs | 10 +- lightspark/src/objects/region_code.rs | 1267 +++++++++++++++++ lightspark/src/objects/uma_invitation.rs | 106 ++ .../wallet_to_payment_requests_connection.rs | 4 +- .../wallet_to_transactions_connection.rs | 1 + lightspark/src/objects/webhook_event_type.rs | 8 + 28 files changed, 1862 insertions(+), 41 deletions(-) create mode 100644 lightspark/src/objects/claim_uma_invitation_input.rs create mode 100644 lightspark/src/objects/claim_uma_invitation_output.rs create mode 100644 lightspark/src/objects/claim_uma_invitation_with_incentives_input.rs create mode 100644 lightspark/src/objects/claim_uma_invitation_with_incentives_output.rs create mode 100644 lightspark/src/objects/create_invitation_with_incentives_input.rs create mode 100644 lightspark/src/objects/create_invitation_with_incentives_output.rs create mode 100644 lightspark/src/objects/create_uma_invitation_input.rs create mode 100644 lightspark/src/objects/create_uma_invitation_output.rs create mode 100644 lightspark/src/objects/incentives_ineligibility_reason.rs create mode 100644 lightspark/src/objects/incentives_status.rs create mode 100644 lightspark/src/objects/region_code.rs create mode 100644 lightspark/src/objects/uma_invitation.rs diff --git a/lightspark/src/client.rs b/lightspark/src/client.rs index ab8c1b8..50cfd8d 100644 --- a/lightspark/src/client.rs +++ b/lightspark/src/client.rs @@ -24,10 +24,12 @@ use crate::objects::invoice_type::InvoiceType; use crate::objects::lightning_fee_estimate_output::LightningFeeEstimateOutput; use crate::objects::outgoing_payment::OutgoingPayment; use crate::objects::permission::Permission; +use crate::objects::region_code::RegionCode; use crate::objects::risk_rating::RiskRating; +use crate::objects::uma_invitation::UmaInvitation; use crate::objects::withdrawal_mode::WithdrawalMode; use crate::objects::withdrawal_request::WithdrawalRequest; -use crate::objects::{account, invoice_data}; +use crate::objects::{account, invoice_data, uma_invitation}; use crate::objects::{api_token, incoming_payment, outgoing_payment}; use crate::objects::{bitcoin_network, withdrawal_request}; use crate::objects::{fee_estimate, lightning_fee_estimate_output}; @@ -965,4 +967,206 @@ impl LightsparkClient { .map_err(Error::JsonError)?; Ok(result) } + + /// 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 { + let operation = "mutation CreateUmaInvitation( + $inviter_uma: String! + ) { + create_uma_invitation(input: { + inviter_uma: $inviter_uma + }) { + invitation { + ...UmaInvitationFragment + } + } + } + + " + 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)) + .await?; + + let result = serde_json::from_value(json["create_uma_invitation"]["invitation"].clone()) + .map_err(Error::JsonError)?; + Ok(result) + } + + /// Creates an UMA invitation as part of the incentive program. If you are not part of the + /// incentive program, you should use `create_uma_invitation`. + pub async fn create_uma_invitation_with_incentives( + &self, + inviter_uma: &str, + inviter_phone_number_e164: &str, + inviter_region: RegionCode, + ) -> Result { + let operation = "mutation CreateUmaInvitationWithIncentives( + $inviter_uma: String! + $inviter_phone_hash: String! + $inviter_region: RegionCode! + ) { + create_uma_invitation_with_incentives(input: { + inviter_uma: $inviter_uma + inviter_phone_hash: $inviter_phone_hash + inviter_region: $inviter_region + }) { + invitation { + ...UmaInvitationFragment + } + } + } + + " + uma_invitation::FRAGMENT; + + let mut variables: HashMap<&str, Value> = HashMap::new(); + variables.insert("inviter_uma", inviter_uma.into()); + let inviter_phone_hash = self.hash_phone_number(inviter_phone_number_e164)?; + variables.insert("inviter_phone_hash", inviter_phone_hash.into()); + variables.insert("inviter_region", inviter_region.into()); + + let value = serde_json::to_value(variables).map_err(Error::ConversionError)?; + let json = self + .requester + .execute_graphql(operation, Some(value)) + .await?; + + let result = serde_json::from_value( + json["create_uma_invitation_with_incentives"]["invitation"].clone(), + ) + .map_err(Error::JsonError)?; + Ok(result) + } + + /// Claims an UMA invitation. If you are part of the incentive program, you should use + /// `claim_uma_invitation_with_incentives`. + pub async fn claim_uma_invitation( + &self, + invitation_code: &str, + invitee_uma: &str, + ) -> Result { + let operation = "mutation ClaimUmaInvitation( + $invitation_code: String! + $invitee_uma: String! + ) { + claim_uma_invitation(input: { + invitation_code: $invitation_code + invitee_uma: $invitee_uma + }) { + invitation { + ...UmaInvitationFragment + } + } + } + + " + uma_invitation::FRAGMENT; + + let mut variables: HashMap<&str, Value> = HashMap::new(); + variables.insert("invitation_code", invitation_code.into()); + variables.insert("invitee_uma", invitee_uma.into()); + + let value = serde_json::to_value(variables).map_err(Error::ConversionError)?; + let json = self + .requester + .execute_graphql(operation, Some(value)) + .await?; + + let result = serde_json::from_value(json["claim_uma_invitation"]["invitation"].clone()) + .map_err(Error::JsonError)?; + Ok(result) + } + + /// Claims an UMA invitation as part of the incentive program. If you are not part of the + /// incentive program, you should use `claim_uma_invitation`. + pub async fn claim_uma_invitation_with_incentives( + &self, + invitation_code: &str, + invitee_uma: &str, + invitee_phone_number_e164: &str, + invitee_region: RegionCode, + ) -> Result { + let operation = "mutation ClaimUmaInvitation( + $invitation_code: String! + $invitee_uma: String! + $invitee_phone_hash: String! + $invitee_region: RegionCode! + ) { + 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 { + ...UmaInvitationFragment + } + } + } + + " + uma_invitation::FRAGMENT; + + let mut variables: HashMap<&str, Value> = HashMap::new(); + variables.insert("invitation_code", invitation_code.into()); + variables.insert("invitee_uma", invitee_uma.into()); + let invitee_phone_hash = self.hash_phone_number(invitee_phone_number_e164)?; + variables.insert("invitee_phone_hash", invitee_phone_hash.into()); + variables.insert("invitee_region", invitee_region.into()); + + let value = serde_json::to_value(variables).map_err(Error::ConversionError)?; + let json = self + .requester + .execute_graphql(operation, Some(value)) + .await?; + + let result = serde_json::from_value( + json["claim_uma_invitation_with_incentives"]["invitation"].clone(), + ) + .map_err(Error::JsonError)?; + Ok(result) + } + + /// Fetches a UMA invitation by its code. + pub async fn fetch_uma_invitation( + &self, + invitation_code: &str, + ) -> Result { + let operation = "query FetchUmaInvitation( + $invitation_code: String! + ) { + uma_invitation_by_code(code: $invitation_code) { + ...UmaInvitationFragment + } + } + + " + 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)) + .await?; + + let result = serde_json::from_value(json["uma_invitation_by_code"].clone()) + .map_err(Error::JsonError)?; + Ok(result) + } + + fn hash_phone_number(phone_number_e164: &str) -> Result { + let e164_regex = regex::Regex::new(r"^\+[1-9]\d{1,14}$").unwrap(); + if !e164_regex.is_match(phone_number_e164) { + return Err(Error::InvalidPhoneNumber); + } + let mut hasher = Sha256::new(); + hasher.update(phone_number_e164.as_bytes()); + Ok(hex::encode(hasher.finalize())) + } } diff --git a/lightspark/src/error.rs b/lightspark/src/error.rs index 705da96..9c9708d 100644 --- a/lightspark/src/error.rs +++ b/lightspark/src/error.rs @@ -16,6 +16,7 @@ pub enum Error { WebhookSignatureError, SigningKeyNotFound, InvalidCurrencyConversion, + InvalidPhoneNumber, } impl fmt::Display for Error { @@ -33,6 +34,7 @@ impl fmt::Display for Error { } Self::SigningKeyNotFound => write!(f, "Signing key not found"), Self::InvalidCurrencyConversion => write!(f, "Invalid currency conversion"), + Self::InvalidPhoneNumber => write!(f, "Invalid phone number. Must be E.164 format."), } } } diff --git a/lightspark/src/objects/account_to_nodes_connection.rs b/lightspark/src/objects/account_to_nodes_connection.rs index f627e8a..b195826 100644 --- a/lightspark/src/objects/account_to_nodes_connection.rs +++ b/lightspark/src/objects/account_to_nodes_connection.rs @@ -1,8 +1,9 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use crate::objects::connection::Connection; +use serde::{Deserialize, Serialize}; + use crate::objects::lightspark_node::LightsparkNodeEnum; use crate::objects::page_info::PageInfo; -use serde::{Deserialize, Serialize}; use std::vec::Vec; /// A connection between an account and the nodes it manages. diff --git a/lightspark/src/objects/account_to_payment_requests_connection.rs b/lightspark/src/objects/account_to_payment_requests_connection.rs index 063aea4..1cf8321 100644 --- a/lightspark/src/objects/account_to_payment_requests_connection.rs +++ b/lightspark/src/objects/account_to_payment_requests_connection.rs @@ -1,10 +1,10 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use crate::objects::connection::Connection; +use crate::objects::payment_request::PaymentRequestEnum; use serde::{Deserialize, Serialize}; -use std::vec::Vec; use crate::objects::page_info::PageInfo; -use crate::objects::payment_request::PaymentRequestEnum; +use std::vec::Vec; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct AccountToPaymentRequestsConnection { diff --git a/lightspark/src/objects/account_to_transactions_connection.rs b/lightspark/src/objects/account_to_transactions_connection.rs index 3e1416d..1df3b5c 100644 --- a/lightspark/src/objects/account_to_transactions_connection.rs +++ b/lightspark/src/objects/account_to_transactions_connection.rs @@ -4,6 +4,7 @@ use crate::objects::currency_amount::CurrencyAmount; use crate::objects::page_info::PageInfo; use crate::objects::transaction::TransactionEnum; use serde::{Deserialize, Serialize}; + use std::vec::Vec; #[derive(Debug, Clone, Deserialize, Serialize)] diff --git a/lightspark/src/objects/claim_uma_invitation_input.rs b/lightspark/src/objects/claim_uma_invitation_input.rs new file mode 100644 index 0000000..17b133c --- /dev/null +++ b/lightspark/src/objects/claim_uma_invitation_input.rs @@ -0,0 +1,9 @@ +// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct ClaimUmaInvitationInput { + pub invitation_code: String, + + pub invitee_uma: String, +} diff --git a/lightspark/src/objects/claim_uma_invitation_output.rs b/lightspark/src/objects/claim_uma_invitation_output.rs new file mode 100644 index 0000000..6253ba8 --- /dev/null +++ b/lightspark/src/objects/claim_uma_invitation_output.rs @@ -0,0 +1,18 @@ +// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::types::entity_wrapper::EntityWrapper; +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct ClaimUmaInvitationOutput { + #[serde(rename = "claim_uma_invitation_output_invitation")] + pub invitation: EntityWrapper, +} + +pub const FRAGMENT: &str = " +fragment ClaimUmaInvitationOutputFragment on ClaimUmaInvitationOutput { + __typename + claim_uma_invitation_output_invitation: invitation { + id + } +} +"; diff --git a/lightspark/src/objects/claim_uma_invitation_with_incentives_input.rs b/lightspark/src/objects/claim_uma_invitation_with_incentives_input.rs new file mode 100644 index 0000000..420fdef --- /dev/null +++ b/lightspark/src/objects/claim_uma_invitation_with_incentives_input.rs @@ -0,0 +1,14 @@ +// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::objects::region_code::RegionCode; +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct ClaimUmaInvitationWithIncentivesInput { + pub invitation_code: String, + + pub invitee_uma: String, + + pub invitee_phone_hash: String, + + pub invitee_region: RegionCode, +} diff --git a/lightspark/src/objects/claim_uma_invitation_with_incentives_output.rs b/lightspark/src/objects/claim_uma_invitation_with_incentives_output.rs new file mode 100644 index 0000000..7da6e76 --- /dev/null +++ b/lightspark/src/objects/claim_uma_invitation_with_incentives_output.rs @@ -0,0 +1,18 @@ +// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::types::entity_wrapper::EntityWrapper; +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct ClaimUmaInvitationWithIncentivesOutput { + #[serde(rename = "claim_uma_invitation_with_incentives_output_invitation")] + pub invitation: EntityWrapper, +} + +pub const FRAGMENT: &str = " +fragment ClaimUmaInvitationWithIncentivesOutputFragment on ClaimUmaInvitationWithIncentivesOutput { + __typename + claim_uma_invitation_with_incentives_output_invitation: invitation { + id + } +} +"; diff --git a/lightspark/src/objects/create_invitation_with_incentives_input.rs b/lightspark/src/objects/create_invitation_with_incentives_input.rs new file mode 100644 index 0000000..5007a15 --- /dev/null +++ b/lightspark/src/objects/create_invitation_with_incentives_input.rs @@ -0,0 +1,12 @@ +// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::objects::region_code::RegionCode; +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct CreateInvitationWithIncentivesInput { + pub inviter_uma: String, + + pub inviter_phone_hash: String, + + pub inviter_region: RegionCode, +} diff --git a/lightspark/src/objects/create_invitation_with_incentives_output.rs b/lightspark/src/objects/create_invitation_with_incentives_output.rs new file mode 100644 index 0000000..c073e8e --- /dev/null +++ b/lightspark/src/objects/create_invitation_with_incentives_output.rs @@ -0,0 +1,18 @@ +// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::types::entity_wrapper::EntityWrapper; +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct CreateInvitationWithIncentivesOutput { + #[serde(rename = "create_invitation_with_incentives_output_invitation")] + pub invitation: EntityWrapper, +} + +pub const FRAGMENT: &str = " +fragment CreateInvitationWithIncentivesOutputFragment on CreateInvitationWithIncentivesOutput { + __typename + create_invitation_with_incentives_output_invitation: invitation { + id + } +} +"; diff --git a/lightspark/src/objects/create_uma_invitation_input.rs b/lightspark/src/objects/create_uma_invitation_input.rs new file mode 100644 index 0000000..304216f --- /dev/null +++ b/lightspark/src/objects/create_uma_invitation_input.rs @@ -0,0 +1,7 @@ +// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct CreateUmaInvitationInput { + pub inviter_uma: String, +} diff --git a/lightspark/src/objects/create_uma_invitation_output.rs b/lightspark/src/objects/create_uma_invitation_output.rs new file mode 100644 index 0000000..392e8be --- /dev/null +++ b/lightspark/src/objects/create_uma_invitation_output.rs @@ -0,0 +1,18 @@ +// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::types::entity_wrapper::EntityWrapper; +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct CreateUmaInvitationOutput { + #[serde(rename = "create_uma_invitation_output_invitation")] + pub invitation: EntityWrapper, +} + +pub const FRAGMENT: &str = " +fragment CreateUmaInvitationOutputFragment on CreateUmaInvitationOutput { + __typename + create_uma_invitation_output_invitation: invitation { + id + } +} +"; diff --git a/lightspark/src/objects/entity.rs b/lightspark/src/objects/entity.rs index 6d93157..4bd9bf1 100644 --- a/lightspark/src/objects/entity.rs +++ b/lightspark/src/objects/entity.rs @@ -18,6 +18,7 @@ use super::outgoing_payment_attempt::OutgoingPaymentAttempt; use super::routing_transaction::RoutingTransaction; use super::signable::Signable; use super::signable_payload::SignablePayload; +use super::uma_invitation::UmaInvitation; use super::wallet::Wallet; use super::withdrawal::Withdrawal; use super::withdrawal_request::WithdrawalRequest; @@ -59,6 +60,7 @@ pub enum EntityEnum { RoutingTransaction(RoutingTransaction), Signable(Signable), SignablePayload(SignablePayload), + UmaInvitation(UmaInvitation), Wallet(Wallet), Withdrawal(Withdrawal), WithdrawalRequest(WithdrawalRequest), @@ -181,6 +183,12 @@ impl<'de> Deserialize<'de> for EntityEnum { })?; Ok(EntityEnum::SignablePayload(obj)) } + "UmaInvitation" => { + let obj = UmaInvitation::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; + Ok(EntityEnum::UmaInvitation(obj)) + } "Wallet" => { let obj = Wallet::deserialize(value).map_err(|err| { serde::de::Error::custom(format!("Serde JSON Error {}", err)) diff --git a/lightspark/src/objects/incentives_ineligibility_reason.rs b/lightspark/src/objects/incentives_ineligibility_reason.rs new file mode 100644 index 0000000..65de36d --- /dev/null +++ b/lightspark/src/objects/incentives_ineligibility_reason.rs @@ -0,0 +1,52 @@ +// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use serde::{Deserialize, Serialize}; +use serde_json::Value; +use std::fmt; + +/// Describes the reason for an invitation to not be eligible for incentives. +#[derive(Debug, Clone, Deserialize, Serialize)] +pub enum IncentivesIneligibilityReason { + /// This invitation is not eligible for incentives because it has been created outside of the incentives flow. + + #[serde(rename = "DISABLED")] + Disabled, + /// This invitation is not eligible for incentives because the sender is not eligible. + + #[serde(rename = "SENDER_NOT_ELIGIBLE")] + SenderNotEligible, + /// This invitation is not eligible for incentives because the receiver is not eligible. + + #[serde(rename = "RECEIVER_NOT_ELIGIBLE")] + ReceiverNotEligible, + /// This invitation is not eligible for incentives because the sending VASP is not part of the incentives program. + + #[serde(rename = "SENDING_VASP_NOT_ELIGIBLE")] + SendingVaspNotEligible, + /// This invitation is not eligible for incentives because the receiving VASP is not part of the incentives program. + + #[serde(rename = "RECEIVING_VASP_NOT_ELIGIBLE")] + ReceivingVaspNotEligible, + /// This invitation is not eligible for incentives because the sender and receiver are in the same region. + + #[serde(rename = "NOT_CROSS_BORDER")] + NotCrossBorder, +} + +impl From for Value { + fn from(val: IncentivesIneligibilityReason) -> Self { + Value::from(val.to_string()) + } +} + +impl fmt::Display for IncentivesIneligibilityReason { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + Self::Disabled => write!(f, "DISABLED"), + Self::SenderNotEligible => write!(f, "SENDER_NOT_ELIGIBLE"), + Self::ReceiverNotEligible => write!(f, "RECEIVER_NOT_ELIGIBLE"), + Self::SendingVaspNotEligible => write!(f, "SENDING_VASP_NOT_ELIGIBLE"), + Self::ReceivingVaspNotEligible => write!(f, "RECEIVING_VASP_NOT_ELIGIBLE"), + Self::NotCrossBorder => write!(f, "NOT_CROSS_BORDER"), + } + } +} diff --git a/lightspark/src/objects/incentives_status.rs b/lightspark/src/objects/incentives_status.rs new file mode 100644 index 0000000..17dbac3 --- /dev/null +++ b/lightspark/src/objects/incentives_status.rs @@ -0,0 +1,37 @@ +// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use serde::{Deserialize, Serialize}; +use serde_json::Value; +use std::fmt; + +/// Describes the status of the incentives for this invitation. +#[derive(Debug, Clone, Deserialize, Serialize)] +pub enum IncentivesStatus { + /// The invitation is eligible for incentives in its current state. When it is claimed, we will reassess. + + #[serde(rename = "PENDING")] + Pending, + /// The incentives have been validated. + + #[serde(rename = "VALIDATED")] + Validated, + /// This invitation is not eligible for incentives. A more detailed reason can be found in the `incentives_ineligibility_reason` field. + + #[serde(rename = "INELIGIBLE")] + Ineligible, +} + +impl From for Value { + fn from(val: IncentivesStatus) -> Self { + Value::from(val.to_string()) + } +} + +impl fmt::Display for IncentivesStatus { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + Self::Pending => write!(f, "PENDING"), + Self::Validated => write!(f, "VALIDATED"), + Self::Ineligible => write!(f, "INELIGIBLE"), + } + } +} diff --git a/lightspark/src/objects/invoice_data.rs b/lightspark/src/objects/invoice_data.rs index 6eed977..0a65620 100644 --- a/lightspark/src/objects/invoice_data.rs +++ b/lightspark/src/objects/invoice_data.rs @@ -1,12 +1,12 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use crate::objects::currency_amount::CurrencyAmount; -use crate::objects::node::NodeEnum; -use crate::types::custom_date_formats::custom_date_format; -use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use crate::objects::bitcoin_network::BitcoinNetwork; +use crate::objects::node::NodeEnum; use crate::objects::payment_request_data::PaymentRequestData; +use crate::types::custom_date_formats::custom_date_format; +use chrono::{DateTime, Utc}; /// This object represents the data associated with a BOLT #11 invoice. You can retrieve this object to receive the relevant data associated with a specific invoice. #[derive(Debug, Clone, Deserialize, Serialize)] diff --git a/lightspark/src/objects/lightspark_node.rs b/lightspark/src/objects/lightspark_node.rs index 4db7881..5721546 100644 --- a/lightspark/src/objects/lightspark_node.rs +++ b/lightspark/src/objects/lightspark_node.rs @@ -1,17 +1,16 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use super::lightspark_node_with_o_s_k::LightsparkNodeWithOSK; +use super::lightspark_node_with_remote_signing::LightsparkNodeWithRemoteSigning; use crate::objects::balances::Balances; use crate::objects::blockchain_balance::BlockchainBalance; use crate::objects::currency_amount::CurrencyAmount; use crate::objects::entity::Entity; use crate::objects::lightspark_node_status::LightsparkNodeStatus; use crate::objects::node::Node; -use serde_json::Value; -use std::vec::Vec; - -use super::lightspark_node_with_remote_signing::LightsparkNodeWithRemoteSigning; use crate::types::entity_wrapper::EntityWrapper; use serde::{Deserialize, Deserializer, Serialize}; +use serde_json::Value; +use std::vec::Vec; pub trait LightsparkNode: Node + Entity { /// The owner of this LightsparkNode. diff --git a/lightspark/src/objects/lightspark_node_with_o_s_k.rs b/lightspark/src/objects/lightspark_node_with_o_s_k.rs index cda97ee..b221294 100644 --- a/lightspark/src/objects/lightspark_node_with_o_s_k.rs +++ b/lightspark/src/objects/lightspark_node_with_o_s_k.rs @@ -1,28 +1,28 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::objects::blockchain_balance::BlockchainBalance; +use crate::objects::channel_status::ChannelStatus; +use crate::objects::lightspark_node_status::LightsparkNodeStatus; +use crate::objects::secret::Secret; +use serde::{Deserialize, Serialize}; +use std::vec::Vec; + use crate::error::Error; use crate::objects::balances::Balances; use crate::objects::bitcoin_network::BitcoinNetwork; -use crate::objects::blockchain_balance::BlockchainBalance; -use crate::objects::channel_status::ChannelStatus; use crate::objects::currency_amount::CurrencyAmount; use crate::objects::entity::Entity; use crate::objects::lightspark_node::LightsparkNode; -use crate::objects::lightspark_node_status::LightsparkNodeStatus; use crate::objects::lightspark_node_to_channels_connection::LightsparkNodeToChannelsConnection; use crate::objects::node::Node; use crate::objects::node_address_type::NodeAddressType; use crate::objects::node_to_addresses_connection::NodeToAddressesConnection; -use crate::objects::secret::Secret; +use crate::types::custom_date_formats::custom_date_format; +use crate::types::entity_wrapper::EntityWrapper; use crate::types::get_entity::GetEntity; use crate::types::graphql_requester::GraphQLRequester; use chrono::{DateTime, Utc}; -use serde::{Deserialize, Serialize}; use serde_json::Value; use std::collections::HashMap; -use std::vec::Vec; - -use crate::types::custom_date_formats::custom_date_format; -use crate::types::entity_wrapper::EntityWrapper; /// This is a Lightspark node with OSK. #[derive(Debug, Clone, Deserialize, Serialize)] diff --git a/lightspark/src/objects/lightspark_node_with_remote_signing.rs b/lightspark/src/objects/lightspark_node_with_remote_signing.rs index 7bedb71..41df390 100644 --- a/lightspark/src/objects/lightspark_node_with_remote_signing.rs +++ b/lightspark/src/objects/lightspark_node_with_remote_signing.rs @@ -1,27 +1,27 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::objects::blockchain_balance::BlockchainBalance; +use crate::objects::channel_status::ChannelStatus; +use crate::objects::lightspark_node_status::LightsparkNodeStatus; +use serde::{Deserialize, Serialize}; +use std::vec::Vec; + use crate::error::Error; use crate::objects::balances::Balances; use crate::objects::bitcoin_network::BitcoinNetwork; -use crate::objects::blockchain_balance::BlockchainBalance; -use crate::objects::channel_status::ChannelStatus; use crate::objects::currency_amount::CurrencyAmount; use crate::objects::entity::Entity; use crate::objects::lightspark_node::LightsparkNode; -use crate::objects::lightspark_node_status::LightsparkNodeStatus; use crate::objects::lightspark_node_to_channels_connection::LightsparkNodeToChannelsConnection; use crate::objects::node::Node; use crate::objects::node_address_type::NodeAddressType; use crate::objects::node_to_addresses_connection::NodeToAddressesConnection; +use crate::types::custom_date_formats::custom_date_format; +use crate::types::entity_wrapper::EntityWrapper; use crate::types::get_entity::GetEntity; use crate::types::graphql_requester::GraphQLRequester; use chrono::{DateTime, Utc}; -use serde::{Deserialize, Serialize}; use serde_json::Value; use std::collections::HashMap; -use std::vec::Vec; - -use crate::types::custom_date_formats::custom_date_format; -use crate::types::entity_wrapper::EntityWrapper; /// This is a Lightspark node with remote signing. #[derive(Debug, Clone, Deserialize, Serialize)] diff --git a/lightspark/src/objects/mod.rs b/lightspark/src/objects/mod.rs index 7c59fb3..032ea48 100644 --- a/lightspark/src/objects/mod.rs +++ b/lightspark/src/objects/mod.rs @@ -18,10 +18,16 @@ pub mod channel_opening_transaction; pub mod channel_snapshot; pub mod channel_status; pub mod channel_to_transactions_connection; +pub mod claim_uma_invitation_input; +pub mod claim_uma_invitation_output; +pub mod claim_uma_invitation_with_incentives_input; +pub mod claim_uma_invitation_with_incentives_output; pub mod compliance_provider; pub mod connection; pub mod create_api_token_input; pub mod create_api_token_output; +pub mod create_invitation_with_incentives_input; +pub mod create_invitation_with_incentives_output; pub mod create_invoice_input; pub mod create_invoice_output; pub mod create_lnurl_invoice_input; @@ -31,6 +37,8 @@ pub mod create_test_mode_invoice_input; pub mod create_test_mode_invoice_output; pub mod create_test_mode_payment_input; pub mod create_test_mode_paymentoutput; +pub mod create_uma_invitation_input; +pub mod create_uma_invitation_output; pub mod create_uma_invoice_input; pub mod currency_amount; pub mod currency_unit; @@ -47,6 +55,8 @@ pub mod graph_node; pub mod hop; pub mod htlc_attempt_failure_code; pub mod id_and_signature; +pub mod incentives_ineligibility_reason; +pub mod incentives_status; pub mod incoming_payment; pub mod incoming_payment_attempt; pub mod incoming_payment_attempt_status; @@ -87,6 +97,7 @@ pub mod payment_request_data; pub mod payment_request_status; pub mod permission; pub mod post_transaction_data; +pub mod region_code; pub mod register_payment_input; pub mod register_payment_output; pub mod release_channel_per_commitment_secret_input; @@ -118,6 +129,7 @@ pub mod transaction; pub mod transaction_failures; pub mod transaction_status; pub mod transaction_type; +pub mod uma_invitation; pub mod update_channel_per_commitment_point_input; pub mod update_channel_per_commitment_point_output; pub mod update_node_shared_secret_input; diff --git a/lightspark/src/objects/outgoing_payment.rs b/lightspark/src/objects/outgoing_payment.rs index e5126d5..7556327 100644 --- a/lightspark/src/objects/outgoing_payment.rs +++ b/lightspark/src/objects/outgoing_payment.rs @@ -1,26 +1,26 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::objects::transaction_status::TransactionStatus; +use crate::types::custom_date_formats::custom_date_format; +use crate::types::custom_date_formats::custom_date_format_option; +use serde::{Deserialize, Serialize}; +use serde_json::Value; +use std::vec::Vec; + +use crate::error::Error; use crate::objects::currency_amount::CurrencyAmount; use crate::objects::entity::Entity; use crate::objects::lightning_transaction::LightningTransaction; use crate::objects::outgoing_payment_to_attempts_connection::OutgoingPaymentToAttemptsConnection; use crate::objects::payment_failure_reason::PaymentFailureReason; use crate::objects::payment_request_data::PaymentRequestDataEnum; +use crate::objects::post_transaction_data::PostTransactionData; use crate::objects::rich_text::RichText; use crate::objects::transaction::Transaction; -use crate::types::custom_date_formats::custom_date_format_option; +use crate::types::entity_wrapper::EntityWrapper; use crate::types::get_entity::GetEntity; use crate::types::graphql_requester::GraphQLRequester; use chrono::{DateTime, Utc}; -use serde::{Deserialize, Serialize}; use std::collections::HashMap; -use std::vec::Vec; - -use crate::error::Error; -use crate::objects::post_transaction_data::PostTransactionData; -use crate::objects::transaction_status::TransactionStatus; -use crate::types::custom_date_formats::custom_date_format; -use crate::types::entity_wrapper::EntityWrapper; -use serde_json::Value; /// This object represents a Lightning Network payment sent from a Lightspark Node. You can retrieve this object to receive payment related information about any payment sent from your Lightspark Node on the Lightning Network. #[derive(Debug, Clone, Deserialize, Serialize)] @@ -538,6 +538,7 @@ impl OutgoingPayment { outgoing_payment_attempt_status: status outgoing_payment_attempt_failure_code: failure_code outgoing_payment_attempt_failure_source_index: failure_source_index + outgoing_payment_attempt_attempted_at: attempted_at outgoing_payment_attempt_resolved_at: resolved_at outgoing_payment_attempt_amount: amount { __typename diff --git a/lightspark/src/objects/outgoing_payment_attempt.rs b/lightspark/src/objects/outgoing_payment_attempt.rs index 55d3834..5eb8a99 100644 --- a/lightspark/src/objects/outgoing_payment_attempt.rs +++ b/lightspark/src/objects/outgoing_payment_attempt.rs @@ -23,7 +23,7 @@ pub struct OutgoingPaymentAttempt { #[serde(rename = "outgoing_payment_attempt_id")] pub id: String, - /// The date and time when the attempt was initiated. + /// The date and time when the entity was first created. #[serde( with = "custom_date_format", rename = "outgoing_payment_attempt_created_at" @@ -49,6 +49,13 @@ pub struct OutgoingPaymentAttempt { #[serde(rename = "outgoing_payment_attempt_failure_source_index")] pub failure_source_index: Option, + /// The date and time when the attempt was initiated. + #[serde( + with = "custom_date_format", + rename = "outgoing_payment_attempt_attempted_at" + )] + pub attempted_at: DateTime, + /// The time the outgoing payment attempt failed or succeeded. #[serde( with = "custom_date_format_option", @@ -125,6 +132,7 @@ fragment OutgoingPaymentAttemptFragment on OutgoingPaymentAttempt { outgoing_payment_attempt_status: status outgoing_payment_attempt_failure_code: failure_code outgoing_payment_attempt_failure_source_index: failure_source_index + outgoing_payment_attempt_attempted_at: attempted_at outgoing_payment_attempt_resolved_at: resolved_at outgoing_payment_attempt_amount: amount { __typename diff --git a/lightspark/src/objects/region_code.rs b/lightspark/src/objects/region_code.rs new file mode 100644 index 0000000..631dce4 --- /dev/null +++ b/lightspark/src/objects/region_code.rs @@ -0,0 +1,1267 @@ +// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use serde::{Deserialize, Serialize}; +use serde_json::Value; +use std::fmt; + +/// The alpha-2 representation of a country, as defined by the ISO 3166-1 standard. +#[derive(Debug, Clone, Deserialize, Serialize)] +pub enum RegionCode { + /// The code representing the country of Afghanistan. + + #[serde(rename = "AF")] + Af, + /// The code representing the country of Åland Islands. + + #[serde(rename = "AX")] + Ax, + /// The code representing the country of Albania. + + #[serde(rename = "AL")] + Al, + /// The code representing the country of Algeria. + + #[serde(rename = "DZ")] + Dz, + /// The code representing the country of American Samoa. + + #[serde(rename = "AS")] + As, + /// The code representing the country of Andorra. + + #[serde(rename = "AD")] + Ad, + /// The code representing the country of Angola. + + #[serde(rename = "AO")] + Ao, + /// The code representing the country of Anguilla. + + #[serde(rename = "AI")] + Ai, + /// The code representing the country of Antarctica. + + #[serde(rename = "AQ")] + Aq, + /// The code representing the country of Antigua and Barbuda. + + #[serde(rename = "AG")] + Ag, + /// The code representing the country of Argentina. + + #[serde(rename = "AR")] + Ar, + /// The code representing the country of Armenia. + + #[serde(rename = "AM")] + Am, + /// The code representing the country of Aruba. + + #[serde(rename = "AW")] + Aw, + /// The code representing the country of Australia. + + #[serde(rename = "AU")] + Au, + /// The code representing the country of Austria. + + #[serde(rename = "AT")] + At, + /// The code representing the country of Azerbaijan. + + #[serde(rename = "AZ")] + Az, + /// The code representing the country of Bahamas. + + #[serde(rename = "BS")] + Bs, + /// The code representing the country of Bahrain. + + #[serde(rename = "BH")] + Bh, + /// The code representing the country of Bangladesh. + + #[serde(rename = "BD")] + Bd, + /// The code representing the country of Barbados. + + #[serde(rename = "BB")] + Bb, + /// The code representing the country of Belarus. + + #[serde(rename = "BY")] + By, + /// The code representing the country of Belgium. + + #[serde(rename = "BE")] + Be, + /// The code representing the country of Belize. + + #[serde(rename = "BZ")] + Bz, + /// The code representing the country of Benin. + + #[serde(rename = "BJ")] + Bj, + /// The code representing the country of Bermuda. + + #[serde(rename = "BM")] + Bm, + /// The code representing the country of Bhutan. + + #[serde(rename = "BT")] + Bt, + /// The code representing the country of The Plurinational State of Bolivia. + + #[serde(rename = "BO")] + Bo, + /// The code representing the country of Bonaire, Sint Eustatius, and Saba. + + #[serde(rename = "BQ")] + Bq, + /// The code representing the country of Bosnia and Herzegovina. + + #[serde(rename = "BA")] + Ba, + /// The code representing the country of Botswana. + + #[serde(rename = "BW")] + Bw, + /// The code representing the country of Bouvet Island. + + #[serde(rename = "BV")] + Bv, + /// The code representing the country of Brazil. + + #[serde(rename = "BR")] + Br, + /// The code representing the country of British Indian Ocean Territory. + + #[serde(rename = "IO")] + Io, + /// The code representing the country of Brunei Darussalam. + + #[serde(rename = "BN")] + Bn, + /// The code representing the country of Bulgaria. + + #[serde(rename = "BG")] + Bg, + /// The code representing the country of Burkina Faso. + + #[serde(rename = "BF")] + Bf, + /// The code representing the country of Burundi. + + #[serde(rename = "BI")] + Bi, + /// The code representing the country of Cambodia. + + #[serde(rename = "KH")] + Kh, + /// The code representing the country of Cameroon. + + #[serde(rename = "CM")] + Cm, + /// The code representing the country of Canada. + + #[serde(rename = "CA")] + Ca, + /// The code representing the country of Cape Verde. + + #[serde(rename = "CV")] + Cv, + /// The code representing the country of Cayman Islands. + + #[serde(rename = "KY")] + Ky, + /// The code representing the country of Central African Republic. + + #[serde(rename = "CF")] + Cf, + /// The code representing the country of Chad. + + #[serde(rename = "TD")] + Td, + /// The code representing the country of Chile. + + #[serde(rename = "CL")] + Cl, + /// The code representing the country of China. + + #[serde(rename = "CN")] + Cn, + /// The code representing the country of Christmas Island. + + #[serde(rename = "CX")] + Cx, + /// The code representing the country of Cocos (Keeling) Islands. + + #[serde(rename = "CC")] + Cc, + /// The code representing the country of Colombia. + + #[serde(rename = "CO")] + Co, + /// The code representing the country of Comoros. + + #[serde(rename = "KM")] + Km, + /// The code representing the country of Congo. + + #[serde(rename = "CG")] + Cg, + /// The code representing the country of The Democratic Republic of the Congo. + + #[serde(rename = "CD")] + Cd, + /// The code representing the country of Cook Islands. + + #[serde(rename = "CK")] + Ck, + /// The code representing the country of Costa Rica. + + #[serde(rename = "CR")] + Cr, + /// The code representing the country of Côte d'Ivoire. + + #[serde(rename = "CI")] + Ci, + /// The code representing the country of Croatia. + + #[serde(rename = "HR")] + Hr, + /// The code representing the country of Cuba. + + #[serde(rename = "CU")] + Cu, + /// The code representing the country of Curaçao. + + #[serde(rename = "CW")] + Cw, + /// The code representing the country of Cyprus. + + #[serde(rename = "CY")] + Cy, + /// The code representing the country of Czech Republic. + + #[serde(rename = "CZ")] + Cz, + /// The code representing the country of Denmark. + + #[serde(rename = "DK")] + Dk, + /// The code representing the country of Djibouti. + + #[serde(rename = "DJ")] + Dj, + /// The code representing the country of Dominica. + + #[serde(rename = "DM")] + Dm, + /// The code representing the country of Dominican Republic. + + #[serde(rename = "DO")] + Do, + /// The code representing the country of Ecuador. + + #[serde(rename = "EC")] + Ec, + /// The code representing the country of Egypt. + + #[serde(rename = "EG")] + Eg, + /// The code representing the country of El Salvador. + + #[serde(rename = "SV")] + Sv, + /// The code representing the country of Equatorial Guinea. + + #[serde(rename = "GQ")] + Gq, + /// The code representing the country of Eritrea. + + #[serde(rename = "ER")] + Er, + /// The code representing the country of Estonia. + + #[serde(rename = "EE")] + Ee, + /// The code representing the country of Ethiopia. + + #[serde(rename = "ET")] + Et, + /// The code representing the country of Falkland Islands (Malvinas). + + #[serde(rename = "FK")] + Fk, + /// The code representing the country of Faroe Islands. + + #[serde(rename = "FO")] + Fo, + /// The code representing the country of Fiji. + + #[serde(rename = "FJ")] + Fj, + /// The code representing the country of Finland. + + #[serde(rename = "FI")] + Fi, + /// The code representing the country of France. + + #[serde(rename = "FR")] + Fr, + /// The code representing the country of French Guiana. + + #[serde(rename = "GF")] + Gf, + /// The code representing the country of French Polynesia. + + #[serde(rename = "PF")] + Pf, + /// The code representing the country of French Southern Territories. + + #[serde(rename = "TF")] + Tf, + /// The code representing the country of Gabon. + + #[serde(rename = "GA")] + Ga, + /// The code representing the country of Gambia. + + #[serde(rename = "GM")] + Gm, + /// The code representing the country of Georgia. + + #[serde(rename = "GE")] + Ge, + /// The code representing the country of Germany. + + #[serde(rename = "DE")] + De, + /// The code representing the country of Ghana. + + #[serde(rename = "GH")] + Gh, + /// The code representing the country of Gibraltar. + + #[serde(rename = "GI")] + Gi, + /// The code representing the country of Greece. + + #[serde(rename = "GR")] + Gr, + /// The code representing the country of Greenland. + + #[serde(rename = "GL")] + Gl, + /// The code representing the country of Grenada. + + #[serde(rename = "GD")] + Gd, + /// The code representing the country of Guadeloupe. + + #[serde(rename = "GP")] + Gp, + /// The code representing the country of Guam. + + #[serde(rename = "GU")] + Gu, + /// The code representing the country of Guatemala. + + #[serde(rename = "GT")] + Gt, + /// The code representing the country of Guernsey. + + #[serde(rename = "GG")] + Gg, + /// The code representing the country of Guinea. + + #[serde(rename = "GN")] + Gn, + /// The code representing the country of Guinea-Bissau. + + #[serde(rename = "GW")] + Gw, + /// The code representing the country of Guyana. + + #[serde(rename = "GY")] + Gy, + /// The code representing the country of Haiti. + + #[serde(rename = "HT")] + Ht, + /// The code representing the country of Heard Island and McDonald Islands. + + #[serde(rename = "HM")] + Hm, + /// The code representing the country of Holy See (Vatican City State). + + #[serde(rename = "VA")] + Va, + /// The code representing the country of Honduras. + + #[serde(rename = "HN")] + Hn, + /// The code representing the country of Hong Kong. + + #[serde(rename = "HK")] + Hk, + /// The code representing the country of Hungary. + + #[serde(rename = "HU")] + Hu, + /// The code representing the country of Iceland. + + #[serde(rename = "IS")] + Is, + /// The code representing the country of India. + + #[serde(rename = "IN")] + In, + /// The code representing the country of Indonesia. + + #[serde(rename = "ID")] + Id, + /// The code representing the country of Islamic Republic of Iran. + + #[serde(rename = "IR")] + Ir, + /// The code representing the country of Iraq. + + #[serde(rename = "IQ")] + Iq, + /// The code representing the country of Ireland. + + #[serde(rename = "IE")] + Ie, + /// The code representing the country of Isle of Man. + + #[serde(rename = "IM")] + Im, + /// The code representing the country of Israel. + + #[serde(rename = "IL")] + Il, + /// The code representing the country of Italy. + + #[serde(rename = "IT")] + It, + /// The code representing the country of Jamaica. + + #[serde(rename = "JM")] + Jm, + /// The code representing the country of Japan. + + #[serde(rename = "JP")] + Jp, + /// The code representing the country of Jersey. + + #[serde(rename = "JE")] + Je, + /// The code representing the country of Jordan. + + #[serde(rename = "JO")] + Jo, + /// The code representing the country of Kazakhstan. + + #[serde(rename = "KZ")] + Kz, + /// The code representing the country of Kenya. + + #[serde(rename = "KE")] + Ke, + /// The code representing the country of Kiribati. + + #[serde(rename = "KI")] + Ki, + /// The code representing the country of Democratic People's Republic ofKorea. + + #[serde(rename = "KP")] + Kp, + /// The code representing the country of Republic of Korea. + + #[serde(rename = "KR")] + Kr, + /// The code representing the country of Kuwait. + + #[serde(rename = "KW")] + Kw, + /// The code representing the country of Kyrgyzstan. + + #[serde(rename = "KG")] + Kg, + /// The code representing the country of Lao People's Democratic Republic. + + #[serde(rename = "LA")] + La, + /// The code representing the country of Latvia. + + #[serde(rename = "LV")] + Lv, + /// The code representing the country of Lebanon. + + #[serde(rename = "LB")] + Lb, + /// The code representing the country of Lesotho. + + #[serde(rename = "LS")] + Ls, + /// The code representing the country of Liberia. + + #[serde(rename = "LR")] + Lr, + /// The code representing the country of Libya. + + #[serde(rename = "LY")] + Ly, + /// The code representing the country of Liechtenstein. + + #[serde(rename = "LI")] + Li, + /// The code representing the country of Lithuania. + + #[serde(rename = "LT")] + Lt, + /// The code representing the country of Luxembourg. + + #[serde(rename = "LU")] + Lu, + /// The code representing the country of Macao. + + #[serde(rename = "MO")] + Mo, + /// The code representing the country of The Former Yugoslav Republic of Macedonia. + + #[serde(rename = "MK")] + Mk, + /// The code representing the country of Madagascar. + + #[serde(rename = "MG")] + Mg, + /// The code representing the country of Malawi. + + #[serde(rename = "MW")] + Mw, + /// The code representing the country of Malaysia. + + #[serde(rename = "MY")] + My, + /// The code representing the country of Maldives. + + #[serde(rename = "MV")] + Mv, + /// The code representing the country of Mali. + + #[serde(rename = "ML")] + Ml, + /// The code representing the country of Malta. + + #[serde(rename = "MT")] + Mt, + /// The code representing the country of Marshall Islands. + + #[serde(rename = "MH")] + Mh, + /// The code representing the country of Martinique. + + #[serde(rename = "MQ")] + Mq, + /// The code representing the country of Mauritania. + + #[serde(rename = "MR")] + Mr, + /// The code representing the country of Mauritius. + + #[serde(rename = "MU")] + Mu, + /// The code representing the country of Mayotte. + + #[serde(rename = "YT")] + Yt, + /// The code representing the country of Mexico. + + #[serde(rename = "MX")] + Mx, + /// The code representing the country of Federated States ofMicronesia. + + #[serde(rename = "FM")] + Fm, + /// The code representing the country of Republic of Moldova. + + #[serde(rename = "MD")] + Md, + /// The code representing the country of Monaco. + + #[serde(rename = "MC")] + Mc, + /// The code representing the country of Mongolia. + + #[serde(rename = "MN")] + Mn, + /// The code representing the country of Montenegro. + + #[serde(rename = "ME")] + Me, + /// The code representing the country of Montserrat. + + #[serde(rename = "MS")] + Ms, + /// The code representing the country of Morocco. + + #[serde(rename = "MA")] + Ma, + /// The code representing the country of Mozambique. + + #[serde(rename = "MZ")] + Mz, + /// The code representing the country of Myanmar. + + #[serde(rename = "MM")] + Mm, + /// The code representing the country of Namibia. + + #[serde(rename = "NA")] + Na, + /// The code representing the country of Nauru. + + #[serde(rename = "NR")] + Nr, + /// The code representing the country of Nepal. + + #[serde(rename = "NP")] + Np, + /// The code representing the country of Netherlands. + + #[serde(rename = "NL")] + Nl, + /// The code representing the country of New Caledonia. + + #[serde(rename = "NC")] + Nc, + /// The code representing the country of New Zealand. + + #[serde(rename = "NZ")] + Nz, + /// The code representing the country of Nicaragua. + + #[serde(rename = "NI")] + Ni, + /// The code representing the country of Niger. + + #[serde(rename = "NE")] + Ne, + /// The code representing the country of Nigeria. + + #[serde(rename = "NG")] + Ng, + /// The code representing the country of Niue. + + #[serde(rename = "NU")] + Nu, + /// The code representing the country of Norfolk Island. + + #[serde(rename = "NF")] + Nf, + /// The code representing the country of Northern Mariana Islands. + + #[serde(rename = "MP")] + Mp, + /// The code representing the country of Norway. + + #[serde(rename = "NO")] + No, + /// The code representing the country of Oman. + + #[serde(rename = "OM")] + Om, + /// The code representing the country of Pakistan. + + #[serde(rename = "PK")] + Pk, + /// The code representing the country of Palau. + + #[serde(rename = "PW")] + Pw, + /// The code representing the country of State of Palestine. + + #[serde(rename = "PS")] + Ps, + /// The code representing the country of Panama. + + #[serde(rename = "PA")] + Pa, + /// The code representing the country of Papua New Guinea. + + #[serde(rename = "PG")] + Pg, + /// The code representing the country of Paraguay. + + #[serde(rename = "PY")] + Py, + /// The code representing the country of Peru. + + #[serde(rename = "PE")] + Pe, + /// The code representing the country of Philippines. + + #[serde(rename = "PH")] + Ph, + /// The code representing the country of Pitcairn. + + #[serde(rename = "PN")] + Pn, + /// The code representing the country of Poland. + + #[serde(rename = "PL")] + Pl, + /// The code representing the country of Portugal. + + #[serde(rename = "PT")] + Pt, + /// The code representing the country of Puerto Rico. + + #[serde(rename = "PR")] + Pr, + /// The code representing the country of Qatar. + + #[serde(rename = "QA")] + Qa, + /// The code representing the country of Réunion. + + #[serde(rename = "RE")] + Re, + /// The code representing the country of Romania. + + #[serde(rename = "RO")] + Ro, + /// The code representing the country of Russian Federation. + + #[serde(rename = "RU")] + Ru, + /// The code representing the country of Rwanda. + + #[serde(rename = "RW")] + Rw, + /// The code representing the country of Saint Barthélemy. + + #[serde(rename = "BL")] + Bl, + /// The code representing the country of Saint Helena Ascension and Tristan da Cunha. + + #[serde(rename = "SH")] + Sh, + /// The code representing the country of Saint Kitts and Nevis. + + #[serde(rename = "KN")] + Kn, + /// The code representing the country of Saint Lucia. + + #[serde(rename = "LC")] + Lc, + /// The code representing the country of Saint Martin (French part). + + #[serde(rename = "MF")] + Mf, + /// The code representing the country of Saint Pierre and Miquelon. + + #[serde(rename = "PM")] + Pm, + /// The code representing the country of Saint Vincent and the Grenadines. + + #[serde(rename = "VC")] + Vc, + /// The code representing the country of Samoa. + + #[serde(rename = "WS")] + Ws, + /// The code representing the country of San Marino. + + #[serde(rename = "SM")] + Sm, + /// The code representing the country of Sao Tome and Principe. + + #[serde(rename = "ST")] + St, + /// The code representing the country of Saudi Arabia. + + #[serde(rename = "SA")] + Sa, + /// The code representing the country of Senegal. + + #[serde(rename = "SN")] + Sn, + /// The code representing the country of Serbia. + + #[serde(rename = "RS")] + Rs, + /// The code representing the country of Seychelles. + + #[serde(rename = "SC")] + Sc, + /// The code representing the country of Sierra Leone. + + #[serde(rename = "SL")] + Sl, + /// The code representing the country of Singapore. + + #[serde(rename = "SG")] + Sg, + /// The code representing the country of Sint Maarten (Dutch part). + + #[serde(rename = "SX")] + Sx, + /// The code representing the country of Slovakia. + + #[serde(rename = "SK")] + Sk, + /// The code representing the country of Slovenia. + + #[serde(rename = "SI")] + Si, + /// The code representing the country of Solomon Islands. + + #[serde(rename = "SB")] + Sb, + /// The code representing the country of Somalia. + + #[serde(rename = "SO")] + So, + /// The code representing the country of South Africa. + + #[serde(rename = "ZA")] + Za, + /// The code representing the country of South Georgia and the South Sandwich Islands. + + #[serde(rename = "GS")] + Gs, + /// The code representing the country of South Sudan. + + #[serde(rename = "SS")] + Ss, + /// The code representing the country of Spain. + + #[serde(rename = "ES")] + Es, + /// The code representing the country of Sri Lanka. + + #[serde(rename = "LK")] + Lk, + /// The code representing the country of Sudan. + + #[serde(rename = "SD")] + Sd, + /// The code representing the country of Suriname. + + #[serde(rename = "SR")] + Sr, + /// The code representing the country of Svalbard and Jan Mayen. + + #[serde(rename = "SJ")] + Sj, + /// The code representing the country of Swaziland. + + #[serde(rename = "SZ")] + Sz, + /// The code representing the country of Sweden. + + #[serde(rename = "SE")] + Se, + /// The code representing the country of Switzerland. + + #[serde(rename = "CH")] + Ch, + /// The code representing the country of Syrian Arab Republic. + + #[serde(rename = "SY")] + Sy, + /// The code representing the country of Taiwan, Province of China. + + #[serde(rename = "TW")] + Tw, + /// The code representing the country of Tajikistan. + + #[serde(rename = "TJ")] + Tj, + /// The code representing the country of United Republic of Tanzania. + + #[serde(rename = "TZ")] + Tz, + /// The code representing the country of Thailand. + + #[serde(rename = "TH")] + Th, + /// The code representing the country of Timor-Leste. + + #[serde(rename = "TL")] + Tl, + /// The code representing the country of Togo. + + #[serde(rename = "TG")] + Tg, + /// The code representing the country of Tokelau. + + #[serde(rename = "TK")] + Tk, + /// The code representing the country of Tonga. + + #[serde(rename = "TO")] + To, + /// The code representing the country of Trinidad and Tobago. + + #[serde(rename = "TT")] + Tt, + /// The code representing the country of Tunisia. + + #[serde(rename = "TN")] + Tn, + /// The code representing the country of Turkey. + + #[serde(rename = "TR")] + Tr, + /// The code representing the country of Turkmenistan. + + #[serde(rename = "TM")] + Tm, + /// The code representing the country of Turks and Caicos Islands. + + #[serde(rename = "TC")] + Tc, + /// The code representing the country of Tuvalu. + + #[serde(rename = "TV")] + Tv, + /// The code representing the country of Uganda. + + #[serde(rename = "UG")] + Ug, + /// The code representing the country of Ukraine. + + #[serde(rename = "UA")] + Ua, + /// The code representing the country of United Arab Emirates. + + #[serde(rename = "AE")] + Ae, + /// The code representing the country of United Kingdom. + + #[serde(rename = "GB")] + Gb, + /// The code representing the country of United States. + + #[serde(rename = "US")] + Us, + /// The code representing the country of United States Minor Outlying Islands. + + #[serde(rename = "UM")] + Um, + /// The code representing the country of Uruguay. + + #[serde(rename = "UY")] + Uy, + /// The code representing the country of Uzbekistan. + + #[serde(rename = "UZ")] + Uz, + /// The code representing the country of Vanuatu. + + #[serde(rename = "VU")] + Vu, + /// The code representing the country of Bolivarian Republic of Venezuela. + + #[serde(rename = "VE")] + Ve, + /// The code representing the country of Viet Nam. + + #[serde(rename = "VN")] + Vn, + /// The code representing the country of British Virgin Islands. + + #[serde(rename = "VG")] + Vg, + /// The code representing the country of U.S. Virgin Islands. + + #[serde(rename = "VI")] + Vi, + /// The code representing the country of Wallis and Futuna. + + #[serde(rename = "WF")] + Wf, + /// The code representing the country of Western Sahara. + + #[serde(rename = "EH")] + Eh, + /// The code representing the country of Yemen. + + #[serde(rename = "YE")] + Ye, + /// The code representing the country of Zambia. + + #[serde(rename = "ZM")] + Zm, + /// The code representing the country of Zimbabwe. + + #[serde(rename = "ZW")] + Zw, +} + +impl From for Value { + fn from(val: RegionCode) -> Self { + Value::from(val.to_string()) + } +} + +impl fmt::Display for RegionCode { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + Self::Af => write!(f, "AF"), + Self::Ax => write!(f, "AX"), + Self::Al => write!(f, "AL"), + Self::Dz => write!(f, "DZ"), + Self::As => write!(f, "AS"), + Self::Ad => write!(f, "AD"), + Self::Ao => write!(f, "AO"), + Self::Ai => write!(f, "AI"), + Self::Aq => write!(f, "AQ"), + Self::Ag => write!(f, "AG"), + Self::Ar => write!(f, "AR"), + Self::Am => write!(f, "AM"), + Self::Aw => write!(f, "AW"), + Self::Au => write!(f, "AU"), + Self::At => write!(f, "AT"), + Self::Az => write!(f, "AZ"), + Self::Bs => write!(f, "BS"), + Self::Bh => write!(f, "BH"), + Self::Bd => write!(f, "BD"), + Self::Bb => write!(f, "BB"), + Self::By => write!(f, "BY"), + Self::Be => write!(f, "BE"), + Self::Bz => write!(f, "BZ"), + Self::Bj => write!(f, "BJ"), + Self::Bm => write!(f, "BM"), + Self::Bt => write!(f, "BT"), + Self::Bo => write!(f, "BO"), + Self::Bq => write!(f, "BQ"), + Self::Ba => write!(f, "BA"), + Self::Bw => write!(f, "BW"), + Self::Bv => write!(f, "BV"), + Self::Br => write!(f, "BR"), + Self::Io => write!(f, "IO"), + Self::Bn => write!(f, "BN"), + Self::Bg => write!(f, "BG"), + Self::Bf => write!(f, "BF"), + Self::Bi => write!(f, "BI"), + Self::Kh => write!(f, "KH"), + Self::Cm => write!(f, "CM"), + Self::Ca => write!(f, "CA"), + Self::Cv => write!(f, "CV"), + Self::Ky => write!(f, "KY"), + Self::Cf => write!(f, "CF"), + Self::Td => write!(f, "TD"), + Self::Cl => write!(f, "CL"), + Self::Cn => write!(f, "CN"), + Self::Cx => write!(f, "CX"), + Self::Cc => write!(f, "CC"), + Self::Co => write!(f, "CO"), + Self::Km => write!(f, "KM"), + Self::Cg => write!(f, "CG"), + Self::Cd => write!(f, "CD"), + Self::Ck => write!(f, "CK"), + Self::Cr => write!(f, "CR"), + Self::Ci => write!(f, "CI"), + Self::Hr => write!(f, "HR"), + Self::Cu => write!(f, "CU"), + Self::Cw => write!(f, "CW"), + Self::Cy => write!(f, "CY"), + Self::Cz => write!(f, "CZ"), + Self::Dk => write!(f, "DK"), + Self::Dj => write!(f, "DJ"), + Self::Dm => write!(f, "DM"), + Self::Do => write!(f, "DO"), + Self::Ec => write!(f, "EC"), + Self::Eg => write!(f, "EG"), + Self::Sv => write!(f, "SV"), + Self::Gq => write!(f, "GQ"), + Self::Er => write!(f, "ER"), + Self::Ee => write!(f, "EE"), + Self::Et => write!(f, "ET"), + Self::Fk => write!(f, "FK"), + Self::Fo => write!(f, "FO"), + Self::Fj => write!(f, "FJ"), + Self::Fi => write!(f, "FI"), + Self::Fr => write!(f, "FR"), + Self::Gf => write!(f, "GF"), + Self::Pf => write!(f, "PF"), + Self::Tf => write!(f, "TF"), + Self::Ga => write!(f, "GA"), + Self::Gm => write!(f, "GM"), + Self::Ge => write!(f, "GE"), + Self::De => write!(f, "DE"), + Self::Gh => write!(f, "GH"), + Self::Gi => write!(f, "GI"), + Self::Gr => write!(f, "GR"), + Self::Gl => write!(f, "GL"), + Self::Gd => write!(f, "GD"), + Self::Gp => write!(f, "GP"), + Self::Gu => write!(f, "GU"), + Self::Gt => write!(f, "GT"), + Self::Gg => write!(f, "GG"), + Self::Gn => write!(f, "GN"), + Self::Gw => write!(f, "GW"), + Self::Gy => write!(f, "GY"), + Self::Ht => write!(f, "HT"), + Self::Hm => write!(f, "HM"), + Self::Va => write!(f, "VA"), + Self::Hn => write!(f, "HN"), + Self::Hk => write!(f, "HK"), + Self::Hu => write!(f, "HU"), + Self::Is => write!(f, "IS"), + Self::In => write!(f, "IN"), + Self::Id => write!(f, "ID"), + Self::Ir => write!(f, "IR"), + Self::Iq => write!(f, "IQ"), + Self::Ie => write!(f, "IE"), + Self::Im => write!(f, "IM"), + Self::Il => write!(f, "IL"), + Self::It => write!(f, "IT"), + Self::Jm => write!(f, "JM"), + Self::Jp => write!(f, "JP"), + Self::Je => write!(f, "JE"), + Self::Jo => write!(f, "JO"), + Self::Kz => write!(f, "KZ"), + Self::Ke => write!(f, "KE"), + Self::Ki => write!(f, "KI"), + Self::Kp => write!(f, "KP"), + Self::Kr => write!(f, "KR"), + Self::Kw => write!(f, "KW"), + Self::Kg => write!(f, "KG"), + Self::La => write!(f, "LA"), + Self::Lv => write!(f, "LV"), + Self::Lb => write!(f, "LB"), + Self::Ls => write!(f, "LS"), + Self::Lr => write!(f, "LR"), + Self::Ly => write!(f, "LY"), + Self::Li => write!(f, "LI"), + Self::Lt => write!(f, "LT"), + Self::Lu => write!(f, "LU"), + Self::Mo => write!(f, "MO"), + Self::Mk => write!(f, "MK"), + Self::Mg => write!(f, "MG"), + Self::Mw => write!(f, "MW"), + Self::My => write!(f, "MY"), + Self::Mv => write!(f, "MV"), + Self::Ml => write!(f, "ML"), + Self::Mt => write!(f, "MT"), + Self::Mh => write!(f, "MH"), + Self::Mq => write!(f, "MQ"), + Self::Mr => write!(f, "MR"), + Self::Mu => write!(f, "MU"), + Self::Yt => write!(f, "YT"), + Self::Mx => write!(f, "MX"), + Self::Fm => write!(f, "FM"), + Self::Md => write!(f, "MD"), + Self::Mc => write!(f, "MC"), + Self::Mn => write!(f, "MN"), + Self::Me => write!(f, "ME"), + Self::Ms => write!(f, "MS"), + Self::Ma => write!(f, "MA"), + Self::Mz => write!(f, "MZ"), + Self::Mm => write!(f, "MM"), + Self::Na => write!(f, "NA"), + Self::Nr => write!(f, "NR"), + Self::Np => write!(f, "NP"), + Self::Nl => write!(f, "NL"), + Self::Nc => write!(f, "NC"), + Self::Nz => write!(f, "NZ"), + Self::Ni => write!(f, "NI"), + Self::Ne => write!(f, "NE"), + Self::Ng => write!(f, "NG"), + Self::Nu => write!(f, "NU"), + Self::Nf => write!(f, "NF"), + Self::Mp => write!(f, "MP"), + Self::No => write!(f, "NO"), + Self::Om => write!(f, "OM"), + Self::Pk => write!(f, "PK"), + Self::Pw => write!(f, "PW"), + Self::Ps => write!(f, "PS"), + Self::Pa => write!(f, "PA"), + Self::Pg => write!(f, "PG"), + Self::Py => write!(f, "PY"), + Self::Pe => write!(f, "PE"), + Self::Ph => write!(f, "PH"), + Self::Pn => write!(f, "PN"), + Self::Pl => write!(f, "PL"), + Self::Pt => write!(f, "PT"), + Self::Pr => write!(f, "PR"), + Self::Qa => write!(f, "QA"), + Self::Re => write!(f, "RE"), + Self::Ro => write!(f, "RO"), + Self::Ru => write!(f, "RU"), + Self::Rw => write!(f, "RW"), + Self::Bl => write!(f, "BL"), + Self::Sh => write!(f, "SH"), + Self::Kn => write!(f, "KN"), + Self::Lc => write!(f, "LC"), + Self::Mf => write!(f, "MF"), + Self::Pm => write!(f, "PM"), + Self::Vc => write!(f, "VC"), + Self::Ws => write!(f, "WS"), + Self::Sm => write!(f, "SM"), + Self::St => write!(f, "ST"), + Self::Sa => write!(f, "SA"), + Self::Sn => write!(f, "SN"), + Self::Rs => write!(f, "RS"), + Self::Sc => write!(f, "SC"), + Self::Sl => write!(f, "SL"), + Self::Sg => write!(f, "SG"), + Self::Sx => write!(f, "SX"), + Self::Sk => write!(f, "SK"), + Self::Si => write!(f, "SI"), + Self::Sb => write!(f, "SB"), + Self::So => write!(f, "SO"), + Self::Za => write!(f, "ZA"), + Self::Gs => write!(f, "GS"), + Self::Ss => write!(f, "SS"), + Self::Es => write!(f, "ES"), + Self::Lk => write!(f, "LK"), + Self::Sd => write!(f, "SD"), + Self::Sr => write!(f, "SR"), + Self::Sj => write!(f, "SJ"), + Self::Sz => write!(f, "SZ"), + Self::Se => write!(f, "SE"), + Self::Ch => write!(f, "CH"), + Self::Sy => write!(f, "SY"), + Self::Tw => write!(f, "TW"), + Self::Tj => write!(f, "TJ"), + Self::Tz => write!(f, "TZ"), + Self::Th => write!(f, "TH"), + Self::Tl => write!(f, "TL"), + Self::Tg => write!(f, "TG"), + Self::Tk => write!(f, "TK"), + Self::To => write!(f, "TO"), + Self::Tt => write!(f, "TT"), + Self::Tn => write!(f, "TN"), + Self::Tr => write!(f, "TR"), + Self::Tm => write!(f, "TM"), + Self::Tc => write!(f, "TC"), + Self::Tv => write!(f, "TV"), + Self::Ug => write!(f, "UG"), + Self::Ua => write!(f, "UA"), + Self::Ae => write!(f, "AE"), + Self::Gb => write!(f, "GB"), + Self::Us => write!(f, "US"), + Self::Um => write!(f, "UM"), + Self::Uy => write!(f, "UY"), + Self::Uz => write!(f, "UZ"), + Self::Vu => write!(f, "VU"), + Self::Ve => write!(f, "VE"), + Self::Vn => write!(f, "VN"), + Self::Vg => write!(f, "VG"), + Self::Vi => write!(f, "VI"), + Self::Wf => write!(f, "WF"), + Self::Eh => write!(f, "EH"), + Self::Ye => write!(f, "YE"), + Self::Zm => write!(f, "ZM"), + Self::Zw => write!(f, "ZW"), + } + } +} diff --git a/lightspark/src/objects/uma_invitation.rs b/lightspark/src/objects/uma_invitation.rs new file mode 100644 index 0000000..d96f723 --- /dev/null +++ b/lightspark/src/objects/uma_invitation.rs @@ -0,0 +1,106 @@ +// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::objects::entity::Entity; +use crate::objects::incentives_ineligibility_reason::IncentivesIneligibilityReason; +use crate::objects::incentives_status::IncentivesStatus; +use crate::types::custom_date_formats::custom_date_format; +use crate::types::get_entity::GetEntity; +use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; + +/// This is an object representing an UMA.ME invitation. +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct UmaInvitation { + /// The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string. + #[serde(rename = "uma_invitation_id")] + pub id: String, + + /// The date and time when the entity was first created. + #[serde(with = "custom_date_format", rename = "uma_invitation_created_at")] + pub created_at: DateTime, + + /// The date and time when the entity was last updated. + #[serde(with = "custom_date_format", rename = "uma_invitation_updated_at")] + pub updated_at: DateTime, + + /// The code that uniquely identifies this invitation. + #[serde(rename = "uma_invitation_code")] + pub code: String, + + /// The URL where this invitation can be claimed. + #[serde(rename = "uma_invitation_url")] + pub url: String, + + /// The UMA of the user who created the invitation. + #[serde(rename = "uma_invitation_inviter_uma")] + pub inviter_uma: String, + + /// The UMA of the user who claimed the invitation. + #[serde(rename = "uma_invitation_invitee_uma")] + pub invitee_uma: Option, + + /// The current status of the incentives that may be tied to this invitation. + #[serde(rename = "uma_invitation_incentives_status")] + pub incentives_status: IncentivesStatus, + + /// The reason why the invitation is not eligible for incentives, if applicable. + #[serde(rename = "uma_invitation_incentives_ineligibility_reason")] + pub incentives_ineligibility_reason: Option, + + /// The typename of the object + #[serde(rename = "__typename")] + pub typename: String, +} + +impl Entity for UmaInvitation { + /// The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string. + fn get_id(&self) -> String { + self.id.clone() + } + + /// The date and time when the entity was first created. + fn get_created_at(&self) -> DateTime { + self.created_at + } + + /// The date and time when the entity was last updated. + fn get_updated_at(&self) -> DateTime { + self.updated_at + } + + fn type_name(&self) -> &'static str { + "UmaInvitation" + } +} + +impl GetEntity for UmaInvitation { + fn get_entity_query() -> String { + format!( + " + query GetEntity($id: ID!) {{ + entity(id: $id) {{ + ... on UmaInvitation {{ + ... UmaInvitationFragment + }} + }} + }} + + {}", + FRAGMENT + ) + } +} + +pub const FRAGMENT: &str = " +fragment UmaInvitationFragment on UmaInvitation { + __typename + uma_invitation_id: id + uma_invitation_created_at: created_at + uma_invitation_updated_at: updated_at + uma_invitation_code: code + uma_invitation_url: url + uma_invitation_inviter_uma: inviter_uma + uma_invitation_invitee_uma: invitee_uma + uma_invitation_incentives_status: incentives_status + uma_invitation_incentives_ineligibility_reason: incentives_ineligibility_reason +} +"; diff --git a/lightspark/src/objects/wallet_to_payment_requests_connection.rs b/lightspark/src/objects/wallet_to_payment_requests_connection.rs index 1187794..639a745 100644 --- a/lightspark/src/objects/wallet_to_payment_requests_connection.rs +++ b/lightspark/src/objects/wallet_to_payment_requests_connection.rs @@ -1,10 +1,10 @@ // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use crate::objects::connection::Connection; +use crate::objects::payment_request::PaymentRequestEnum; use serde::{Deserialize, Serialize}; -use std::vec::Vec; use crate::objects::page_info::PageInfo; -use crate::objects::payment_request::PaymentRequestEnum; +use std::vec::Vec; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct WalletToPaymentRequestsConnection { diff --git a/lightspark/src/objects/wallet_to_transactions_connection.rs b/lightspark/src/objects/wallet_to_transactions_connection.rs index 483e78b..13ae235 100644 --- a/lightspark/src/objects/wallet_to_transactions_connection.rs +++ b/lightspark/src/objects/wallet_to_transactions_connection.rs @@ -3,6 +3,7 @@ use crate::objects::connection::Connection; use crate::objects::page_info::PageInfo; use crate::objects::transaction::TransactionEnum; use serde::{Deserialize, Serialize}; + use std::vec::Vec; #[derive(Debug, Clone, Deserialize, Serialize)] diff --git a/lightspark/src/objects/webhook_event_type.rs b/lightspark/src/objects/webhook_event_type.rs index c52056c..d52e934 100644 --- a/lightspark/src/objects/webhook_event_type.rs +++ b/lightspark/src/objects/webhook_event_type.rs @@ -9,6 +9,9 @@ pub enum WebhookEventType { #[serde(rename = "PAYMENT_FINISHED")] PaymentFinished, + #[serde(rename = "FORCE_CLOSURE")] + ForceClosure, + #[serde(rename = "WITHDRAWAL_FINISHED")] WithdrawalFinished, @@ -18,6 +21,9 @@ pub enum WebhookEventType { #[serde(rename = "NODE_STATUS")] NodeStatus, + #[serde(rename = "UMA_INVITATION_CLAIMED")] + UmaInvitationClaimed, + #[serde(rename = "WALLET_STATUS")] WalletStatus, @@ -50,9 +56,11 @@ impl fmt::Display for WebhookEventType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { Self::PaymentFinished => write!(f, "PAYMENT_FINISHED"), + Self::ForceClosure => write!(f, "FORCE_CLOSURE"), Self::WithdrawalFinished => write!(f, "WITHDRAWAL_FINISHED"), Self::FundsReceived => write!(f, "FUNDS_RECEIVED"), Self::NodeStatus => write!(f, "NODE_STATUS"), + Self::UmaInvitationClaimed => write!(f, "UMA_INVITATION_CLAIMED"), Self::WalletStatus => write!(f, "WALLET_STATUS"), Self::WalletOutgoingPaymentFinished => write!(f, "WALLET_OUTGOING_PAYMENT_FINISHED"), Self::WalletIncomingPaymentFinished => write!(f, "WALLET_INCOMING_PAYMENT_FINISHED"), From 0db17b128c5a70190e6810e01ff8432a0b70a09d Mon Sep 17 00:00:00 2001 From: Jeremy Klein Date: Mon, 20 Nov 2023 23:30:21 -0800 Subject: [PATCH 2/3] Fix string references --- lightspark/src/client.rs | 115 +++++++++++++++++++++++---------------- 1 file changed, 67 insertions(+), 48 deletions(-) diff --git a/lightspark/src/client.rs b/lightspark/src/client.rs index 50cfd8d..564ffee 100644 --- a/lightspark/src/client.rs +++ b/lightspark/src/client.rs @@ -971,19 +971,23 @@ impl LightsparkClient { /// 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 { - 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()); @@ -991,7 +995,7 @@ impl LightsparkClient { 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()) @@ -1007,23 +1011,27 @@ impl LightsparkClient { inviter_phone_number_e164: &str, inviter_region: RegionCode, ) -> Result { - 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()); @@ -1034,7 +1042,7 @@ impl LightsparkClient { 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( @@ -1051,21 +1059,25 @@ impl LightsparkClient { invitation_code: &str, invitee_uma: &str, ) -> Result { - 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()); @@ -1074,7 +1086,7 @@ impl LightsparkClient { 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()) @@ -1091,25 +1103,29 @@ impl LightsparkClient { invitee_phone_number_e164: &str, invitee_region: RegionCode, ) -> Result { - 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()); @@ -1121,7 +1137,7 @@ impl LightsparkClient { 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( @@ -1136,15 +1152,18 @@ impl LightsparkClient { &self, invitation_code: &str, ) -> Result { - 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()); @@ -1152,7 +1171,7 @@ impl LightsparkClient { 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()) From a242402df41f927fa38476412e06e496bab3d254 Mon Sep 17 00:00:00 2001 From: Jeremy Klein Date: Mon, 20 Nov 2023 23:36:00 -0800 Subject: [PATCH 3/3] associated funcs --- lightspark/src/client.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lightspark/src/client.rs b/lightspark/src/client.rs index 564ffee..a451f9f 100644 --- a/lightspark/src/client.rs +++ b/lightspark/src/client.rs @@ -1035,7 +1035,7 @@ impl LightsparkClient { let mut variables: HashMap<&str, Value> = HashMap::new(); variables.insert("inviter_uma", inviter_uma.into()); - let inviter_phone_hash = self.hash_phone_number(inviter_phone_number_e164)?; + let inviter_phone_hash = Self::hash_phone_number(inviter_phone_number_e164)?; variables.insert("inviter_phone_hash", inviter_phone_hash.into()); variables.insert("inviter_region", inviter_region.into()); @@ -1130,7 +1130,7 @@ impl LightsparkClient { let mut variables: HashMap<&str, Value> = HashMap::new(); variables.insert("invitation_code", invitation_code.into()); variables.insert("invitee_uma", invitee_uma.into()); - let invitee_phone_hash = self.hash_phone_number(invitee_phone_number_e164)?; + let invitee_phone_hash = Self::hash_phone_number(invitee_phone_number_e164)?; variables.insert("invitee_phone_hash", invitee_phone_hash.into()); variables.insert("invitee_region", invitee_region.into());