diff --git a/lightspark/src/objects/account.rs b/lightspark/src/objects/account.rs index d3e621e..5cbf7ab 100644 --- a/lightspark/src/objects/account.rs +++ b/lightspark/src/objects/account.rs @@ -1,37 +1,35 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; -use serde_json::Value; -use crate::objects::withdrawal_request_status::WithdrawalRequestStatus; -use crate::objects::bitcoin_network::BitcoinNetwork; -use crate::objects::account_to_payment_requests_connection::AccountToPaymentRequestsConnection; -use crate::objects::account_to_nodes_connection::AccountToNodesConnection; -use crate::objects::transaction_status::TransactionStatus; -use crate::types::graphql_requester::GraphQLRequester; -use crate::objects::entity::Entity; -use crate::types::custom_date_formats::custom_date_format; -use crate::objects::account_to_withdrawal_requests_connection::AccountToWithdrawalRequestsConnection; use crate::error::Error; -use std::collections::HashMap; -use std::vec::Vec; -use crate::objects::blockchain_balance::BlockchainBalance; -use crate::objects::lightspark_node_owner::LightsparkNodeOwner; +use crate::objects::account_to_api_tokens_connection::AccountToApiTokensConnection; use crate::objects::account_to_channels_connection::AccountToChannelsConnection; -use chrono::{DateTime, Utc}; +use crate::objects::account_to_nodes_connection::AccountToNodesConnection; +use crate::objects::account_to_payment_requests_connection::AccountToPaymentRequestsConnection; +use crate::objects::account_to_transactions_connection::AccountToTransactionsConnection; use crate::objects::account_to_wallets_connection::AccountToWalletsConnection; +use crate::objects::account_to_withdrawal_requests_connection::AccountToWithdrawalRequestsConnection; +use crate::objects::bitcoin_network::BitcoinNetwork; +use crate::objects::blockchain_balance::BlockchainBalance; use crate::objects::currency_amount::CurrencyAmount; -use crate::types::get_entity::GetEntity; -use crate::objects::account_to_api_tokens_connection::AccountToApiTokensConnection; -use crate::objects::account_to_transactions_connection::AccountToTransactionsConnection; +use crate::objects::entity::Entity; +use crate::objects::lightspark_node_owner::LightsparkNodeOwner; use crate::objects::transaction_failures::TransactionFailures; +use crate::objects::transaction_status::TransactionStatus; use crate::objects::transaction_type::TransactionType; +use crate::objects::withdrawal_request_status::WithdrawalRequestStatus; +use crate::types::custom_date_formats::custom_date_format; +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; /// This is an object representing the connected Lightspark account. You can retrieve this object to see your account information and objects tied to your account. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct Account { - /// The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string. - #[serde (rename = "account_id")] + #[serde(rename = "account_id")] pub id: String, /// The date and time when the entity was first created. @@ -43,28 +41,21 @@ pub struct Account { pub updated_at: DateTime, /// The name of this account. - #[serde (rename = "account_name")] + #[serde(rename = "account_name")] pub name: Option, /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl LightsparkNodeOwner for Account { - - fn type_name(&self) -> &'static str { "Account" } } - - impl Entity for Account { - /// 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() @@ -80,16 +71,15 @@ impl Entity for Account { self.updated_at } - fn type_name(&self) -> &'static str { "Account" } } - impl GetEntity for Account { fn get_entity_query() -> String { - format!(" + format!( + " query GetEntity($id: ID!) {{ entity(id: $id) {{ ... on Account {{ @@ -98,12 +88,12 @@ impl GetEntity for Account { }} }} - {}", FRAGMENT) - } + {}", + FRAGMENT + ) + } } - - pub const FRAGMENT: &str = " fragment AccountFragment on Account { __typename @@ -114,11 +104,13 @@ fragment AccountFragment on Account { } "; - impl Account { - - - pub async fn get_api_tokens(&self, requester:&impl GraphQLRequester, first: Option, after: Option) -> Result { + pub async fn get_api_tokens( + &self, + requester: &impl GraphQLRequester, + first: Option, + after: Option, + ) -> Result { let query = "query FetchAccountToApiTokensConnection($entity_id: ID!, $first: Int, $after: String) { entity(id: $entity_id) { ... on Account { @@ -151,7 +143,6 @@ impl Account { variables.insert("first", first.into()); variables.insert("after", after.into()); - let value = serde_json::to_value(variables).map_err(|err| Error::ConversionError(err))?; let result = requester.execute_graphql(&query, Some(value)).await?; let json = result["entity"]["api_tokens"].clone(); @@ -159,8 +150,12 @@ impl Account { Ok(result) } - - pub async fn get_blockchain_balance(&self, requester:&impl GraphQLRequester, bitcoin_networks: Option>, node_ids: Option>) -> Result, Error> { + pub async fn get_blockchain_balance( + &self, + requester: &impl GraphQLRequester, + bitcoin_networks: Option>, + node_ids: Option>, + ) -> Result, Error> { let query = "query FetchAccountBlockchainBalance($entity_id: ID!, $bitcoin_networks: [BitcoinNetwork!], $node_ids: [ID!]) { entity(id: $entity_id) { ... on Account { @@ -223,16 +218,23 @@ impl Account { variables.insert("bitcoin_networks", bitcoin_networks.into()); variables.insert("node_ids", node_ids.into()); - let value = serde_json::to_value(variables).map_err(|err| Error::ConversionError(err))?; let result = requester.execute_graphql(&query, Some(value)).await?; let json = result["entity"]["blockchain_balance"].clone(); - let result = if json.is_null() { None } else { Some(serde_json::from_value(json).map_err(|err| Error::JsonError(err))?) }; + let result = if json.is_null() { + None + } else { + Some(serde_json::from_value(json).map_err(|err| Error::JsonError(err))?) + }; Ok(result) } - - pub async fn get_conductivity(&self, requester:&impl GraphQLRequester, bitcoin_networks: Option>, node_ids: Option>) -> Result, Error> { + pub async fn get_conductivity( + &self, + requester: &impl GraphQLRequester, + bitcoin_networks: Option>, + node_ids: Option>, + ) -> Result, Error> { let query = "query FetchAccountConductivity($entity_id: ID!, $bitcoin_networks: [BitcoinNetwork!], $node_ids: [ID!]) { entity(id: $entity_id) { ... on Account { @@ -245,7 +247,6 @@ impl Account { variables.insert("bitcoin_networks", bitcoin_networks.into()); variables.insert("node_ids", node_ids.into()); - let value = serde_json::to_value(variables).map_err(|err| Error::ConversionError(err))?; let result = requester.execute_graphql(&query, Some(value)).await?; let json = result["entity"]["conductivity"].clone(); @@ -253,8 +254,12 @@ impl Account { Ok(result) } - - pub async fn get_local_balance(&self, requester:&impl GraphQLRequester, bitcoin_networks: Option>, node_ids: Option>) -> Result, Error> { + pub async fn get_local_balance( + &self, + requester: &impl GraphQLRequester, + bitcoin_networks: Option>, + node_ids: Option>, + ) -> Result, Error> { let query = "query FetchAccountLocalBalance($entity_id: ID!, $bitcoin_networks: [BitcoinNetwork!], $node_ids: [ID!]) { entity(id: $entity_id) { ... on Account { @@ -274,16 +279,25 @@ impl Account { variables.insert("bitcoin_networks", bitcoin_networks.into()); variables.insert("node_ids", node_ids.into()); - let value = serde_json::to_value(variables).map_err(|err| Error::ConversionError(err))?; let result = requester.execute_graphql(&query, Some(value)).await?; let json = result["entity"]["local_balance"].clone(); - let result = if json.is_null() { None } else { Some(serde_json::from_value(json).map_err(|err| Error::JsonError(err))?) }; + let result = if json.is_null() { + None + } else { + Some(serde_json::from_value(json).map_err(|err| Error::JsonError(err))?) + }; Ok(result) } - - pub async fn get_nodes(&self, requester:&impl GraphQLRequester, first: Option, bitcoin_networks: Option>, node_ids: Option>, after: Option) -> Result { + pub async fn get_nodes( + &self, + requester: &impl GraphQLRequester, + first: Option, + bitcoin_networks: Option>, + node_ids: Option>, + after: Option, + ) -> Result { let query = "query FetchAccountToNodesConnection($entity_id: ID!, $first: Int, $bitcoin_networks: [BitcoinNetwork!], $node_ids: [ID!], $after: String) { entity(id: $entity_id) { ... on Account { @@ -570,7 +584,6 @@ impl Account { variables.insert("node_ids", node_ids.into()); variables.insert("after", after.into()); - let value = serde_json::to_value(variables).map_err(|err| Error::ConversionError(err))?; let result = requester.execute_graphql(&query, Some(value)).await?; let json = result["entity"]["nodes"].clone(); @@ -578,8 +591,12 @@ impl Account { Ok(result) } - - pub async fn get_remote_balance(&self, requester:&impl GraphQLRequester, bitcoin_networks: Option>, node_ids: Option>) -> Result, Error> { + pub async fn get_remote_balance( + &self, + requester: &impl GraphQLRequester, + bitcoin_networks: Option>, + node_ids: Option>, + ) -> Result, Error> { let query = "query FetchAccountRemoteBalance($entity_id: ID!, $bitcoin_networks: [BitcoinNetwork!], $node_ids: [ID!]) { entity(id: $entity_id) { ... on Account { @@ -599,16 +616,25 @@ impl Account { variables.insert("bitcoin_networks", bitcoin_networks.into()); variables.insert("node_ids", node_ids.into()); - let value = serde_json::to_value(variables).map_err(|err| Error::ConversionError(err))?; let result = requester.execute_graphql(&query, Some(value)).await?; let json = result["entity"]["remote_balance"].clone(); - let result = if json.is_null() { None } else { Some(serde_json::from_value(json).map_err(|err| Error::JsonError(err))?) }; + let result = if json.is_null() { + None + } else { + Some(serde_json::from_value(json).map_err(|err| Error::JsonError(err))?) + }; Ok(result) } - - pub async fn get_uptime_percentage(&self, requester:&impl GraphQLRequester, after_date: Option>, before_date: Option>, bitcoin_networks: Option>, node_ids: Option>) -> Result, Error> { + pub async fn get_uptime_percentage( + &self, + requester: &impl GraphQLRequester, + after_date: Option>, + before_date: Option>, + bitcoin_networks: Option>, + node_ids: Option>, + ) -> Result, Error> { let query = "query FetchAccountUptimePercentage($entity_id: ID!, $after_date: DateTime, $before_date: DateTime, $bitcoin_networks: [BitcoinNetwork!], $node_ids: [ID!]) { entity(id: $entity_id) { ... on Account { @@ -623,7 +649,6 @@ impl Account { variables.insert("bitcoin_networks", bitcoin_networks.into()); variables.insert("node_ids", node_ids.into()); - let value = serde_json::to_value(variables).map_err(|err| Error::ConversionError(err))?; let result = requester.execute_graphql(&query, Some(value)).await?; let json = result["entity"]["uptime_percentage"].clone(); @@ -632,7 +657,16 @@ impl Account { } #[allow(clippy::too_many_arguments)] - pub async fn get_channels(&self, requester:&impl GraphQLRequester, bitcoin_network: BitcoinNetwork, lightning_node_id: Option, after_date: Option>, before_date: Option>, first: Option, after: Option) -> Result { + pub async fn get_channels( + &self, + requester: &impl GraphQLRequester, + bitcoin_network: BitcoinNetwork, + lightning_node_id: Option, + after_date: Option>, + before_date: Option>, + first: Option, + after: Option, + ) -> Result { let query = "query FetchAccountToChannelsConnection($entity_id: ID!, $bitcoin_network: BitcoinNetwork!, $lightning_node_id: ID, $after_date: DateTime, $before_date: DateTime, $first: Int, $after: String) { entity(id: $entity_id) { ... on Account { @@ -753,7 +787,6 @@ impl Account { variables.insert("first", first.into()); variables.insert("after", after.into()); - let value = serde_json::to_value(variables).map_err(|err| Error::ConversionError(err))?; let result = requester.execute_graphql(&query, Some(value)).await?; let json = result["entity"]["channels"].clone(); @@ -762,7 +795,19 @@ impl Account { } #[allow(clippy::too_many_arguments)] - pub async fn get_transactions(&self, requester:&impl GraphQLRequester, first: Option, after: Option, types: Option>, after_date: Option>, before_date: Option>, bitcoin_network: Option, lightning_node_id: Option, statuses: Option>, exclude_failures: Option) -> Result { + pub async fn get_transactions( + &self, + requester: &impl GraphQLRequester, + first: Option, + after: Option, + types: Option>, + after_date: Option>, + before_date: Option>, + bitcoin_network: Option, + lightning_node_id: Option, + statuses: Option>, + exclude_failures: Option, + ) -> Result { let query = "query FetchAccountToTransactionsConnection($entity_id: ID!, $first: Int, $after: String, $types: [TransactionType!], $after_date: DateTime, $before_date: DateTime, $bitcoin_network: BitcoinNetwork, $lightning_node_id: ID, $statuses: [TransactionStatus!], $exclude_failures: TransactionFailures) { entity(id: $entity_id) { ... on Account { @@ -1364,9 +1409,11 @@ impl Account { variables.insert("bitcoin_network", bitcoin_network.into()); variables.insert("lightning_node_id", lightning_node_id.into()); variables.insert("statuses", statuses.into()); - variables.insert("exclude_failures", serde_json::to_value(&exclude_failures).map_err(|err| Error::ConversionError(err))?); + variables.insert( + "exclude_failures", + serde_json::to_value(&exclude_failures).map_err(|err| Error::ConversionError(err))?, + ); - let value = serde_json::to_value(variables).map_err(|err| Error::ConversionError(err))?; let result = requester.execute_graphql(&query, Some(value)).await?; let json = result["entity"]["transactions"].clone(); @@ -1375,7 +1422,16 @@ impl Account { } #[allow(clippy::too_many_arguments)] - pub async fn get_payment_requests(&self, requester:&impl GraphQLRequester, first: Option, after: Option, after_date: Option>, before_date: Option>, bitcoin_network: Option, lightning_node_id: Option) -> Result { + pub async fn get_payment_requests( + &self, + requester: &impl GraphQLRequester, + first: Option, + after: Option, + after_date: Option>, + before_date: Option>, + bitcoin_network: Option, + lightning_node_id: Option, + ) -> Result { let query = "query FetchAccountToPaymentRequestsConnection($entity_id: ID!, $first: Int, $after: String, $after_date: DateTime, $before_date: DateTime, $bitcoin_network: BitcoinNetwork, $lightning_node_id: ID) { entity(id: $entity_id) { ... on Account { @@ -1713,7 +1769,6 @@ impl Account { variables.insert("bitcoin_network", bitcoin_network.into()); variables.insert("lightning_node_id", lightning_node_id.into()); - let value = serde_json::to_value(variables).map_err(|err| Error::ConversionError(err))?; let result = requester.execute_graphql(&query, Some(value)).await?; let json = result["entity"]["payment_requests"].clone(); @@ -1722,7 +1777,18 @@ impl Account { } #[allow(clippy::too_many_arguments)] - pub async fn get_withdrawal_requests(&self, requester:&impl GraphQLRequester, first: Option, after: Option, bitcoin_networks: Option>, statuses: Option>, node_ids: Option>, idempotency_keys: Option>, after_date: Option>, before_date: Option>) -> Result { + pub async fn get_withdrawal_requests( + &self, + requester: &impl GraphQLRequester, + first: Option, + after: Option, + bitcoin_networks: Option>, + statuses: Option>, + node_ids: Option>, + idempotency_keys: Option>, + after_date: Option>, + before_date: Option>, + ) -> Result { let query = "query FetchAccountToWithdrawalRequestsConnection($entity_id: ID!, $first: Int, $after: String, $bitcoin_networks: [BitcoinNetwork!], $statuses: [WithdrawalRequestStatus!], $node_ids: [ID!], $idempotency_keys: [String!], $after_date: DateTime, $before_date: DateTime) { entity(id: $entity_id) { ... on Account { @@ -1806,7 +1872,6 @@ impl Account { variables.insert("after_date", after_date.map(|dt| dt.to_rfc3339()).into()); variables.insert("before_date", before_date.map(|dt| dt.to_rfc3339()).into()); - let value = serde_json::to_value(variables).map_err(|err| Error::ConversionError(err))?; let result = requester.execute_graphql(&query, Some(value)).await?; let json = result["entity"]["withdrawal_requests"].clone(); @@ -1814,8 +1879,13 @@ impl Account { Ok(result) } - - pub async fn get_wallets(&self, requester:&impl GraphQLRequester, first: Option, after: Option, third_party_ids: Option>) -> Result { + pub async fn get_wallets( + &self, + requester: &impl GraphQLRequester, + first: Option, + after: Option, + third_party_ids: Option>, + ) -> Result { let query = "query FetchAccountToWalletsConnection($entity_id: ID!, $first: Int, $after: String, $third_party_ids: [String!]) { entity(id: $entity_id) { ... on Account { @@ -1878,12 +1948,10 @@ impl Account { variables.insert("after", after.into()); variables.insert("third_party_ids", third_party_ids.into()); - let value = serde_json::to_value(variables).map_err(|err| Error::ConversionError(err))?; let result = requester.execute_graphql(&query, Some(value)).await?; let json = result["entity"]["wallets"].clone(); let result = serde_json::from_value(json).map_err(|err| Error::JsonError(err))?; Ok(result) } - } diff --git a/lightspark/src/objects/account_to_api_tokens_connection.rs b/lightspark/src/objects/account_to_api_tokens_connection.rs index e904343..9169c69 100644 --- a/lightspark/src/objects/account_to_api_tokens_connection.rs +++ b/lightspark/src/objects/account_to_api_tokens_connection.rs @@ -1,36 +1,30 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; -use std::vec::Vec; use crate::objects::api_token::ApiToken; -use crate::objects::page_info::PageInfo; use crate::objects::connection::Connection; - +use crate::objects::page_info::PageInfo; +use serde::{Deserialize, Serialize}; +use std::vec::Vec; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct AccountToApiTokensConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). - #[serde (rename = "account_to_api_tokens_connection_count")] + #[serde(rename = "account_to_api_tokens_connection_count")] pub count: i64, /// An object that holds pagination information about the objects in this connection. - #[serde (rename = "account_to_api_tokens_connection_page_info")] + #[serde(rename = "account_to_api_tokens_connection_page_info")] pub page_info: PageInfo, /// The API tokens for the current page of this connection. - #[serde (rename = "account_to_api_tokens_connection_entities")] + #[serde(rename = "account_to_api_tokens_connection_entities")] pub entities: Vec, /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl Connection for AccountToApiTokensConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). fn get_count(&self) -> i64 { self.count @@ -41,15 +35,11 @@ impl Connection for AccountToApiTokensConnection { self.page_info.clone() } - fn type_name(&self) -> &'static str { "AccountToApiTokensConnection" } } - - - pub const FRAGMENT: &str = " fragment AccountToApiTokensConnectionFragment on AccountToApiTokensConnection { __typename @@ -66,6 +56,3 @@ fragment AccountToApiTokensConnectionFragment on AccountToApiTokensConnection { } } "; - - - diff --git a/lightspark/src/objects/account_to_channels_connection.rs b/lightspark/src/objects/account_to_channels_connection.rs index cfbb06c..677980d 100644 --- a/lightspark/src/objects/account_to_channels_connection.rs +++ b/lightspark/src/objects/account_to_channels_connection.rs @@ -1,36 +1,30 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; -use std::vec::Vec; use crate::objects::channel::Channel; -use crate::objects::page_info::PageInfo; use crate::objects::connection::Connection; - +use crate::objects::page_info::PageInfo; +use serde::{Deserialize, Serialize}; +use std::vec::Vec; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct AccountToChannelsConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). - #[serde (rename = "account_to_channels_connection_count")] + #[serde(rename = "account_to_channels_connection_count")] pub count: i64, /// An object that holds pagination information about the objects in this connection. - #[serde (rename = "account_to_channels_connection_page_info")] + #[serde(rename = "account_to_channels_connection_page_info")] pub page_info: PageInfo, /// The channels for the current page of this connection. - #[serde (rename = "account_to_channels_connection_entities")] + #[serde(rename = "account_to_channels_connection_entities")] pub entities: Vec, /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl Connection for AccountToChannelsConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). fn get_count(&self) -> i64 { self.count @@ -41,15 +35,11 @@ impl Connection for AccountToChannelsConnection { self.page_info.clone() } - fn type_name(&self) -> &'static str { "AccountToChannelsConnection" } } - - - pub const FRAGMENT: &str = " fragment AccountToChannelsConnectionFragment on AccountToChannelsConnection { __typename @@ -66,6 +56,3 @@ fragment AccountToChannelsConnectionFragment on AccountToChannelsConnection { } } "; - - - diff --git a/lightspark/src/objects/account_to_nodes_connection.rs b/lightspark/src/objects/account_to_nodes_connection.rs index 73b8482..8bc9f09 100644 --- a/lightspark/src/objects/account_to_nodes_connection.rs +++ b/lightspark/src/objects/account_to_nodes_connection.rs @@ -1,37 +1,32 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::connection::Connection; -use std::vec::Vec; use crate::objects::lightspark_node::LightsparkNode; -use crate::objects::page_info::PageInfo; 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. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct AccountToNodesConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). - #[serde (rename = "account_to_nodes_connection_count")] + #[serde(rename = "account_to_nodes_connection_count")] pub count: i64, /// An object that holds pagination information about the objects in this connection. - #[serde (rename = "account_to_nodes_connection_page_info")] + #[serde(rename = "account_to_nodes_connection_page_info")] pub page_info: PageInfo, /// The nodes for the current page of this connection. - #[serde (rename = "account_to_nodes_connection_entities")] + #[serde(rename = "account_to_nodes_connection_entities")] pub entities: Vec, /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl Connection for AccountToNodesConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). fn get_count(&self) -> i64 { self.count @@ -42,15 +37,11 @@ impl Connection for AccountToNodesConnection { self.page_info.clone() } - fn type_name(&self) -> &'static str { "AccountToNodesConnection" } } - - - pub const FRAGMENT: &str = " fragment AccountToNodesConnectionFragment on AccountToNodesConnection { __typename @@ -67,6 +58,3 @@ fragment AccountToNodesConnectionFragment on AccountToNodesConnection { } } "; - - - diff --git a/lightspark/src/objects/account_to_payment_requests_connection.rs b/lightspark/src/objects/account_to_payment_requests_connection.rs index ef13f1a..02a1103 100644 --- a/lightspark/src/objects/account_to_payment_requests_connection.rs +++ b/lightspark/src/objects/account_to_payment_requests_connection.rs @@ -1,37 +1,31 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; -use std::vec::Vec; -use crate::objects::payment_request::PaymentRequest; use crate::objects::connection::Connection; -use crate::objects::payment_request::PaymentRequestEnum; use crate::objects::page_info::PageInfo; - +use crate::objects::payment_request::PaymentRequest; +use crate::objects::payment_request::PaymentRequestEnum; +use serde::{Deserialize, Serialize}; +use std::vec::Vec; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct AccountToPaymentRequestsConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). - #[serde (rename = "account_to_payment_requests_connection_count")] + #[serde(rename = "account_to_payment_requests_connection_count")] pub count: i64, /// An object that holds pagination information about the objects in this connection. - #[serde (rename = "account_to_payment_requests_connection_page_info")] + #[serde(rename = "account_to_payment_requests_connection_page_info")] pub page_info: PageInfo, /// The payment requests for the current page of this connection. - #[serde (rename = "account_to_payment_requests_connection_entities")] + #[serde(rename = "account_to_payment_requests_connection_entities")] pub entities: Vec, /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl Connection for AccountToPaymentRequestsConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). fn get_count(&self) -> i64 { self.count @@ -42,15 +36,11 @@ impl Connection for AccountToPaymentRequestsConnection { self.page_info.clone() } - fn type_name(&self) -> &'static str { "AccountToPaymentRequestsConnection" } } - - - pub const FRAGMENT: &str = " fragment AccountToPaymentRequestsConnectionFragment on AccountToPaymentRequestsConnection { __typename @@ -67,6 +57,3 @@ fragment AccountToPaymentRequestsConnectionFragment on AccountToPaymentRequestsC } } "; - - - diff --git a/lightspark/src/objects/account_to_transactions_connection.rs b/lightspark/src/objects/account_to_transactions_connection.rs index ac5a45f..217466b 100644 --- a/lightspark/src/objects/account_to_transactions_connection.rs +++ b/lightspark/src/objects/account_to_transactions_connection.rs @@ -1,50 +1,44 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; -use crate::objects::currency_amount::CurrencyAmount; -use std::vec::Vec; use crate::objects::connection::Connection; +use crate::objects::currency_amount::CurrencyAmount; +use crate::objects::page_info::PageInfo; use crate::objects::transaction::Transaction; use crate::objects::transaction::TransactionEnum; -use crate::objects::page_info::PageInfo; - +use serde::{Deserialize, Serialize}; +use std::vec::Vec; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct AccountToTransactionsConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). - #[serde (rename = "account_to_transactions_connection_count")] + #[serde(rename = "account_to_transactions_connection_count")] pub count: i64, /// An object that holds pagination information about the objects in this connection. - #[serde (rename = "account_to_transactions_connection_page_info")] + #[serde(rename = "account_to_transactions_connection_page_info")] pub page_info: PageInfo, /// Profit (or loss) generated by the transactions in this connection, with the set of filters and constraints provided. - #[serde (rename = "account_to_transactions_connection_profit_loss")] + #[serde(rename = "account_to_transactions_connection_profit_loss")] pub profit_loss: Option, /// Average fee earned for the transactions in this connection, with the set of filters and constraints provided. - #[serde (rename = "account_to_transactions_connection_average_fee_earned")] + #[serde(rename = "account_to_transactions_connection_average_fee_earned")] pub average_fee_earned: Option, /// Total amount transacted by the transactions in this connection, with the set of filters and constraints provided. - #[serde (rename = "account_to_transactions_connection_total_amount_transacted")] + #[serde(rename = "account_to_transactions_connection_total_amount_transacted")] pub total_amount_transacted: Option, /// The transactions for the current page of this connection. - #[serde (rename = "account_to_transactions_connection_entities")] + #[serde(rename = "account_to_transactions_connection_entities")] pub entities: Vec, /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl Connection for AccountToTransactionsConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). fn get_count(&self) -> i64 { self.count @@ -55,15 +49,11 @@ impl Connection for AccountToTransactionsConnection { self.page_info.clone() } - fn type_name(&self) -> &'static str { "AccountToTransactionsConnection" } } - - - pub const FRAGMENT: &str = " fragment AccountToTransactionsConnectionFragment on AccountToTransactionsConnection { __typename @@ -104,6 +94,3 @@ fragment AccountToTransactionsConnectionFragment on AccountToTransactionsConnect } } "; - - - diff --git a/lightspark/src/objects/account_to_wallets_connection.rs b/lightspark/src/objects/account_to_wallets_connection.rs index 87c4ea4..8280fa2 100644 --- a/lightspark/src/objects/account_to_wallets_connection.rs +++ b/lightspark/src/objects/account_to_wallets_connection.rs @@ -1,36 +1,30 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::objects::connection::Connection; +use crate::objects::page_info::PageInfo; +use crate::objects::wallet::Wallet; use serde::{Deserialize, Serialize}; use std::vec::Vec; -use crate::objects::wallet::Wallet; -use crate::objects::page_info::PageInfo; -use crate::objects::connection::Connection; - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct AccountToWalletsConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). - #[serde (rename = "account_to_wallets_connection_count")] + #[serde(rename = "account_to_wallets_connection_count")] pub count: i64, /// An object that holds pagination information about the objects in this connection. - #[serde (rename = "account_to_wallets_connection_page_info")] + #[serde(rename = "account_to_wallets_connection_page_info")] pub page_info: PageInfo, /// The wallets for the current page of this connection. - #[serde (rename = "account_to_wallets_connection_entities")] + #[serde(rename = "account_to_wallets_connection_entities")] pub entities: Vec, /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl Connection for AccountToWalletsConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). fn get_count(&self) -> i64 { self.count @@ -41,15 +35,11 @@ impl Connection for AccountToWalletsConnection { self.page_info.clone() } - fn type_name(&self) -> &'static str { "AccountToWalletsConnection" } } - - - pub const FRAGMENT: &str = " fragment AccountToWalletsConnectionFragment on AccountToWalletsConnection { __typename @@ -66,6 +56,3 @@ fragment AccountToWalletsConnectionFragment on AccountToWalletsConnection { } } "; - - - diff --git a/lightspark/src/objects/account_to_withdrawal_requests_connection.rs b/lightspark/src/objects/account_to_withdrawal_requests_connection.rs index b9a0237..1c0b10c 100644 --- a/lightspark/src/objects/account_to_withdrawal_requests_connection.rs +++ b/lightspark/src/objects/account_to_withdrawal_requests_connection.rs @@ -1,36 +1,31 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::objects::connection::Connection; +use crate::objects::page_info::PageInfo; +use crate::objects::withdrawal_request::WithdrawalRequest; use serde::{Deserialize, Serialize}; use std::vec::Vec; -use crate::objects::withdrawal_request::WithdrawalRequest; -use crate::objects::page_info::PageInfo; -use crate::objects::connection::Connection; /// A connection between an account and its past and present withdrawal requests. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct AccountToWithdrawalRequestsConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). - #[serde (rename = "account_to_withdrawal_requests_connection_count")] + #[serde(rename = "account_to_withdrawal_requests_connection_count")] pub count: i64, /// An object that holds pagination information about the objects in this connection. - #[serde (rename = "account_to_withdrawal_requests_connection_page_info")] + #[serde(rename = "account_to_withdrawal_requests_connection_page_info")] pub page_info: PageInfo, /// The withdrawal requests for the current page of this connection. - #[serde (rename = "account_to_withdrawal_requests_connection_entities")] + #[serde(rename = "account_to_withdrawal_requests_connection_entities")] pub entities: Vec, /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl Connection for AccountToWithdrawalRequestsConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). fn get_count(&self) -> i64 { self.count @@ -41,15 +36,11 @@ impl Connection for AccountToWithdrawalRequestsConnection { self.page_info.clone() } - fn type_name(&self) -> &'static str { "AccountToWithdrawalRequestsConnection" } } - - - pub const FRAGMENT: &str = " fragment AccountToWithdrawalRequestsConnectionFragment on AccountToWithdrawalRequestsConnection { __typename @@ -66,6 +57,3 @@ fragment AccountToWithdrawalRequestsConnectionFragment on AccountToWithdrawalReq } } "; - - - diff --git a/lightspark/src/objects/api_token.rs b/lightspark/src/objects/api_token.rs index af2dc66..0439ebc 100644 --- a/lightspark/src/objects/api_token.rs +++ b/lightspark/src/objects/api_token.rs @@ -1,20 +1,18 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; +use crate::objects::audit_log_actor::AuditLogActor; use crate::objects::entity::Entity; -use crate::types::get_entity::GetEntity; -use std::vec::Vec; use crate::objects::permission::Permission; use crate::types::custom_date_formats::custom_date_format; -use crate::objects::audit_log_actor::AuditLogActor; +use crate::types::get_entity::GetEntity; use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; +use std::vec::Vec; /// This is an object representing a Lightspark API token, that can be used to authenticate this account when making API calls or using our SDKs. See the “Authentication” section of our API docs for more details on its usage. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct ApiToken { - /// The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string. - #[serde (rename = "api_token_id")] + #[serde(rename = "api_token_id")] pub id: String, /// The date and time when the entity was first created. @@ -26,40 +24,33 @@ pub struct ApiToken { pub updated_at: DateTime, /// An opaque identifier that should be used as a client_id (or username) in the HTTP Basic Authentication scheme when issuing requests against the Lightspark API. - #[serde (rename = "api_token_client_id")] + #[serde(rename = "api_token_client_id")] pub client_id: String, /// An arbitrary name chosen by the creator of the token to help identify the token in the list of tokens that have been created for the account. - #[serde (rename = "api_token_name")] + #[serde(rename = "api_token_name")] pub name: String, /// A list of permissions granted to the token. - #[serde (rename = "api_token_permissions")] + #[serde(rename = "api_token_permissions")] pub permissions: Vec, /// Whether the api token has been deleted. - #[serde (rename = "api_token_is_deleted")] + #[serde(rename = "api_token_is_deleted")] pub is_deleted: bool, /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl AuditLogActor for ApiToken { - - fn type_name(&self) -> &'static str { "ApiToken" } } - - impl Entity for ApiToken { - /// 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() @@ -75,16 +66,15 @@ impl Entity for ApiToken { self.updated_at } - fn type_name(&self) -> &'static str { "ApiToken" } } - impl GetEntity for ApiToken { fn get_entity_query() -> String { - format!(" + format!( + " query GetEntity($id: ID!) {{ entity(id: $id) {{ ... on ApiToken {{ @@ -93,12 +83,12 @@ impl GetEntity for ApiToken { }} }} - {}", FRAGMENT) - } + {}", + FRAGMENT + ) + } } - - pub const FRAGMENT: &str = " fragment ApiTokenFragment on ApiToken { __typename @@ -111,6 +101,3 @@ fragment ApiTokenFragment on ApiToken { api_token_is_deleted: is_deleted } "; - - - diff --git a/lightspark/src/objects/audit_log_actor.rs b/lightspark/src/objects/audit_log_actor.rs index da12bd2..7379df1 100644 --- a/lightspark/src/objects/audit_log_actor.rs +++ b/lightspark/src/objects/audit_log_actor.rs @@ -1,26 +1,19 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use super::api_token::ApiToken; use crate::objects::entity::Entity; -use serde_json::Value; use serde::{Deserialize, Deserializer, Serialize}; -use super::api_token::ApiToken; - -pub trait AuditLogActor : Entity { - +use serde_json::Value; -fn type_name(&self) -> &'static str; +pub trait AuditLogActor: Entity { + fn type_name(&self) -> &'static str; } - #[allow(clippy::large_enum_variant)] #[derive(Debug, Clone, Serialize)] pub enum AuditLogActorEnum { ApiToken(ApiToken), - } - - impl<'de> Deserialize<'de> for AuditLogActorEnum { fn deserialize(deserializer: D) -> Result where @@ -30,18 +23,18 @@ impl<'de> Deserialize<'de> for AuditLogActorEnum { if let Some(typename) = value.get("__typename").and_then(Value::as_str) { match typename { "ApiToken" => { - let obj = ApiToken::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = ApiToken::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(AuditLogActorEnum::ApiToken(obj)) - }, + } _ => Err(serde::de::Error::custom("unknown typename")), } } else { - Err(serde::de::Error::custom("missing __typename field on AuditLogActor")) + Err(serde::de::Error::custom( + "missing __typename field on AuditLogActor", + )) } } } - diff --git a/lightspark/src/objects/balances.rs b/lightspark/src/objects/balances.rs index 077f192..09c6c37 100644 --- a/lightspark/src/objects/balances.rs +++ b/lightspark/src/objects/balances.rs @@ -1,34 +1,29 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::currency_amount::CurrencyAmount; +use serde::{Deserialize, Serialize}; /// This is an object representing the balance associated with your Lightspark account. You can retrieve this object to see your balance, which can be broken down into several different categorizations. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct Balances { - /// This represents the balance that should be displayed when asked "how much do I own right now?". - // + // // It represents the amount currently owned, including things that may not be owned soon (e.g. in-flight outgoing payments, in-flight withdrawals, commit fees, etc.). It really is a snapshot of what is officially owned at this instant. - #[serde (rename = "balances_owned_balance")] + #[serde(rename = "balances_owned_balance")] pub owned_balance: CurrencyAmount, /// This represents the balance that should be displayed when asked "how much can I send on Lightning right now?". - // + // // It represents the amount currently available to be sent on the Lightning network. We remove from the balance all the funds that are temporarily locked (e.g. channel reserves). - #[serde (rename = "balances_available_to_send_balance")] + #[serde(rename = "balances_available_to_send_balance")] pub available_to_send_balance: CurrencyAmount, /// This represents the balance that should be displayed when asked "how much money can I withdraw on the Bitcoin network right now?". - // + // // It represents the amount currently available to withdraw and is usually equal to the `owned_balance` but it does not include in-flight operations (which would likely succeed and therefore likely make your withdrawal fail). - #[serde (rename = "balances_available_to_withdraw_balance")] + #[serde(rename = "balances_available_to_withdraw_balance")] pub available_to_withdraw_balance: CurrencyAmount, - } - - pub const FRAGMENT: &str = " fragment BalancesFragment on Balances { __typename @@ -58,6 +53,3 @@ fragment BalancesFragment on Balances { } } "; - - - diff --git a/lightspark/src/objects/bitcoin_network.rs b/lightspark/src/objects/bitcoin_network.rs index 9e4a792..eb46bc6 100644 --- a/lightspark/src/objects/bitcoin_network.rs +++ b/lightspark/src/objects/bitcoin_network.rs @@ -1,4 +1,3 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -9,21 +8,20 @@ use std::fmt; pub enum BitcoinNetwork { /// The production version of the Bitcoin Blockchain. - #[serde(rename="MAINNET")] + #[serde(rename = "MAINNET")] Mainnet, /// A test version of the Bitcoin Blockchain, maintained by Lightspark. - #[serde(rename="REGTEST")] + #[serde(rename = "REGTEST")] Regtest, /// A test version of the Bitcoin Blockchain, maintained by a centralized organization. Not in use at Lightspark. - #[serde(rename="SIGNET")] + #[serde(rename = "SIGNET")] Signet, /// A test version of the Bitcoin Blockchain, publicly available. - #[serde(rename="TESTNET")] + #[serde(rename = "TESTNET")] Testnet, - } impl Into for BitcoinNetwork { @@ -39,8 +37,6 @@ impl fmt::Display for BitcoinNetwork { Self::Regtest => write!(f, "REGTEST"), Self::Signet => write!(f, "SIGNET"), Self::Testnet => write!(f, "TESTNET"), - } } } - diff --git a/lightspark/src/objects/blockchain_balance.rs b/lightspark/src/objects/blockchain_balance.rs index 9bfad32..d07dfb2 100644 --- a/lightspark/src/objects/blockchain_balance.rs +++ b/lightspark/src/objects/blockchain_balance.rs @@ -1,40 +1,35 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::currency_amount::CurrencyAmount; +use serde::{Deserialize, Serialize}; /// This is an object representing a detailed breakdown of the balance for a Lightspark Node. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct BlockchainBalance { - /// The total wallet balance, including unconfirmed UTXOs. - #[serde (rename = "blockchain_balance_total_balance")] + #[serde(rename = "blockchain_balance_total_balance")] pub total_balance: Option, /// The balance of confirmed UTXOs in the wallet. - #[serde (rename = "blockchain_balance_confirmed_balance")] + #[serde(rename = "blockchain_balance_confirmed_balance")] pub confirmed_balance: Option, /// The balance of unconfirmed UTXOs in the wallet. - #[serde (rename = "blockchain_balance_unconfirmed_balance")] + #[serde(rename = "blockchain_balance_unconfirmed_balance")] pub unconfirmed_balance: Option, /// The balance that's locked by an on-chain transaction. - #[serde (rename = "blockchain_balance_locked_balance")] + #[serde(rename = "blockchain_balance_locked_balance")] pub locked_balance: Option, /// Funds required to be held in reserve for channel bumping. - #[serde (rename = "blockchain_balance_required_reserve")] + #[serde(rename = "blockchain_balance_required_reserve")] pub required_reserve: Option, /// Funds available for creating channels or withdrawing. - #[serde (rename = "blockchain_balance_available_balance")] + #[serde(rename = "blockchain_balance_available_balance")] pub available_balance: Option, - } - - pub const FRAGMENT: &str = " fragment BlockchainBalanceFragment on BlockchainBalance { __typename @@ -88,6 +83,3 @@ fragment BlockchainBalanceFragment on BlockchainBalance { } } "; - - - diff --git a/lightspark/src/objects/cancel_invoice_input.rs b/lightspark/src/objects/cancel_invoice_input.rs index 77da74c..1cf4f24 100644 --- a/lightspark/src/objects/cancel_invoice_input.rs +++ b/lightspark/src/objects/cancel_invoice_input.rs @@ -1,19 +1,8 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; - /// The unique identifier of the Invoice that should be cancelled. The invoice is supposed to be open, not settled and not expired. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct CancelInvoiceInput { - - - pub invoice_id: String, - } - - - - - diff --git a/lightspark/src/objects/cancel_invoice_output.rs b/lightspark/src/objects/cancel_invoice_output.rs index 0e1aa79..ddcf827 100644 --- a/lightspark/src/objects/cancel_invoice_output.rs +++ b/lightspark/src/objects/cancel_invoice_output.rs @@ -1,20 +1,14 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::types::entity_wrapper::EntityWrapper; +use serde::{Deserialize, Serialize}; /// The Invoice that was cancelled. If the invoice was already cancelled, the same invoice is returned. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct CancelInvoiceOutput { - - #[serde(rename = "cancel_invoice_output_invoice")] pub invoice: EntityWrapper, - } - - pub const FRAGMENT: &str = " fragment CancelInvoiceOutputFragment on CancelInvoiceOutput { __typename @@ -23,6 +17,3 @@ fragment CancelInvoiceOutputFragment on CancelInvoiceOutput { } } "; - - - diff --git a/lightspark/src/objects/channel.rs b/lightspark/src/objects/channel.rs index 4f3d012..d5a5dea 100644 --- a/lightspark/src/objects/channel.rs +++ b/lightspark/src/objects/channel.rs @@ -1,28 +1,26 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; -use crate::objects::currency_amount::CurrencyAmount; -use serde_json::Value; -use crate::types::entity_wrapper::EntityWrapper; -use crate::objects::entity::Entity; use crate::error::Error; -use crate::types::get_entity::GetEntity; -use std::collections::HashMap; -use std::vec::Vec; -use crate::objects::channel_status::ChannelStatus; use crate::objects::channel_fees::ChannelFees; +use crate::objects::channel_status::ChannelStatus; +use crate::objects::channel_to_transactions_connection::ChannelToTransactionsConnection; +use crate::objects::currency_amount::CurrencyAmount; +use crate::objects::entity::Entity; +use crate::objects::transaction_type::TransactionType; 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 crate::objects::channel_to_transactions_connection::ChannelToTransactionsConnection; use chrono::{DateTime, Utc}; -use crate::objects::transaction_type::TransactionType; +use serde::{Deserialize, Serialize}; +use serde_json::Value; +use std::collections::HashMap; +use std::vec::Vec; /// This is an object representing a channel on the Lightning Network. You can retrieve this object to get detailed information on a specific Lightning Network channel. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct Channel { - /// The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string. - #[serde (rename = "channel_id")] + #[serde(rename = "channel_id")] pub id: String, /// The date and time when the entity was first created. @@ -38,47 +36,47 @@ pub struct Channel { pub funding_transaction: Option, /// The total amount of funds in this channel, including the channel balance on the local node, the channel balance on the remote node and the on-chain fees to close the channel. - #[serde (rename = "channel_capacity")] + #[serde(rename = "channel_capacity")] pub capacity: Option, /// The channel balance on the local node. - #[serde (rename = "channel_local_balance")] + #[serde(rename = "channel_local_balance")] pub local_balance: Option, /// The channel balance on the local node that is currently allocated to in-progress payments. - #[serde (rename = "channel_local_unsettled_balance")] + #[serde(rename = "channel_local_unsettled_balance")] pub local_unsettled_balance: Option, /// The channel balance on the remote node. - #[serde (rename = "channel_remote_balance")] + #[serde(rename = "channel_remote_balance")] pub remote_balance: Option, /// The channel balance on the remote node that is currently allocated to in-progress payments. - #[serde (rename = "channel_remote_unsettled_balance")] + #[serde(rename = "channel_remote_unsettled_balance")] pub remote_unsettled_balance: Option, /// The channel balance that is currently allocated to in-progress payments. - #[serde (rename = "channel_unsettled_balance")] + #[serde(rename = "channel_unsettled_balance")] pub unsettled_balance: Option, /// The total balance in this channel, including the channel balance on both local and remote nodes. - #[serde (rename = "channel_total_balance")] + #[serde(rename = "channel_total_balance")] pub total_balance: Option, /// The current status of this channel. - #[serde (rename = "channel_status")] + #[serde(rename = "channel_status")] pub status: Option, /// The estimated time to wait for the channel's hash timelock contract to expire when force closing the channel. It is in unit of minutes. - #[serde (rename = "channel_estimated_force_closure_wait_minutes")] + #[serde(rename = "channel_estimated_force_closure_wait_minutes")] pub estimated_force_closure_wait_minutes: Option, /// The amount to be paid in fees for the current set of commitment transactions. - #[serde (rename = "channel_commit_fee")] + #[serde(rename = "channel_commit_fee")] pub commit_fee: Option, /// The fees charged for routing payments through this channel. - #[serde (rename = "channel_fees")] + #[serde(rename = "channel_fees")] pub fees: Option, /// If known, the remote node of the channel. @@ -90,18 +88,15 @@ pub struct Channel { pub local_node: EntityWrapper, /// The unique identifier of the channel on Lightning Network, which is the location in the chain that the channel was confirmed. The format is ::. - #[serde (rename = "channel_short_channel_id")] + #[serde(rename = "channel_short_channel_id")] pub short_channel_id: Option, /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl Entity for Channel { - /// 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() @@ -117,16 +112,15 @@ impl Entity for Channel { self.updated_at } - fn type_name(&self) -> &'static str { "Channel" } } - impl GetEntity for Channel { fn get_entity_query() -> String { - format!(" + format!( + " query GetEntity($id: ID!) {{ entity(id: $id) {{ ... on Channel {{ @@ -135,12 +129,12 @@ impl GetEntity for Channel { }} }} - {}", FRAGMENT) - } + {}", + FRAGMENT + ) + } } - - pub const FRAGMENT: &str = " fragment ChannelFragment on Channel { __typename @@ -238,11 +232,13 @@ fragment ChannelFragment on Channel { } "; - impl Channel { - - - pub async fn get_uptime_percentage(&self, requester:&impl GraphQLRequester, after_date: Option>, before_date: Option>) -> Result, Error> { + pub async fn get_uptime_percentage( + &self, + requester: &impl GraphQLRequester, + after_date: Option>, + before_date: Option>, + ) -> Result, Error> { let query = "query FetchChannelUptimePercentage($entity_id: ID!, $after_date: DateTime, $before_date: DateTime) { entity(id: $entity_id) { ... on Channel { @@ -255,7 +251,6 @@ impl Channel { variables.insert("after_date", after_date.map(|dt| dt.to_rfc3339()).into()); variables.insert("before_date", before_date.map(|dt| dt.to_rfc3339()).into()); - let value = serde_json::to_value(variables).map_err(|err| Error::ConversionError(err))?; let result = requester.execute_graphql(&query, Some(value)).await?; let json = result["entity"]["uptime_percentage"].clone(); @@ -263,8 +258,13 @@ impl Channel { Ok(result) } - - pub async fn get_transactions(&self, requester:&impl GraphQLRequester, types: Option>, after_date: Option>, before_date: Option>) -> Result { + pub async fn get_transactions( + &self, + requester: &impl GraphQLRequester, + types: Option>, + after_date: Option>, + before_date: Option>, + ) -> Result { let query = "query FetchChannelToTransactionsConnection($entity_id: ID!, $types: [TransactionType!], $after_date: DateTime, $before_date: DateTime) { entity(id: $entity_id) { ... on Channel { @@ -305,12 +305,10 @@ impl Channel { variables.insert("after_date", after_date.map(|dt| dt.to_rfc3339()).into()); variables.insert("before_date", before_date.map(|dt| dt.to_rfc3339()).into()); - let value = serde_json::to_value(variables).map_err(|err| Error::ConversionError(err))?; let result = requester.execute_graphql(&query, Some(value)).await?; let json = result["entity"]["transactions"].clone(); let result = serde_json::from_value(json).map_err(|err| Error::JsonError(err))?; Ok(result) } - } diff --git a/lightspark/src/objects/channel_closing_transaction.rs b/lightspark/src/objects/channel_closing_transaction.rs index d2c2aa2..de3a582 100644 --- a/lightspark/src/objects/channel_closing_transaction.rs +++ b/lightspark/src/objects/channel_closing_transaction.rs @@ -1,68 +1,75 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::currency_amount::CurrencyAmount; -use crate::types::entity_wrapper::EntityWrapper; -use crate::objects::transaction_status::TransactionStatus; -use crate::objects::on_chain_transaction::OnChainTransaction; use crate::objects::entity::Entity; -use crate::types::get_entity::GetEntity; -use std::vec::Vec; -use crate::types::custom_date_formats::custom_date_format_option; +use crate::objects::on_chain_transaction::OnChainTransaction; use crate::objects::transaction::Transaction; +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 crate::types::entity_wrapper::EntityWrapper; +use crate::types::get_entity::GetEntity; use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; +use std::vec::Vec; /// This is an object representing a transaction which closes a channel on the Lightning Network. This operation allocates balances back to the local and remote nodes. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct ChannelClosingTransaction { - /// The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string. - #[serde (rename = "channel_closing_transaction_id")] + #[serde(rename = "channel_closing_transaction_id")] pub id: String, /// The date and time when this transaction was initiated. - #[serde(with = "custom_date_format", rename = "channel_closing_transaction_created_at")] + #[serde( + with = "custom_date_format", + rename = "channel_closing_transaction_created_at" + )] pub created_at: DateTime, /// The date and time when the entity was last updated. - #[serde(with = "custom_date_format", rename = "channel_closing_transaction_updated_at")] + #[serde( + with = "custom_date_format", + rename = "channel_closing_transaction_updated_at" + )] pub updated_at: DateTime, /// The current status of this transaction. - #[serde (rename = "channel_closing_transaction_status")] + #[serde(rename = "channel_closing_transaction_status")] pub status: TransactionStatus, /// The date and time when this transaction was completed or failed. - #[serde(with = "custom_date_format_option", rename = "channel_closing_transaction_resolved_at")] + #[serde( + with = "custom_date_format_option", + rename = "channel_closing_transaction_resolved_at" + )] pub resolved_at: Option>, /// The amount of money involved in this transaction. - #[serde (rename = "channel_closing_transaction_amount")] + #[serde(rename = "channel_closing_transaction_amount")] pub amount: CurrencyAmount, /// The hash of this transaction, so it can be uniquely identified on the Lightning Network. - #[serde (rename = "channel_closing_transaction_transaction_hash")] + #[serde(rename = "channel_closing_transaction_transaction_hash")] pub transaction_hash: Option, /// The fees that were paid by the node for this transaction. - #[serde (rename = "channel_closing_transaction_fees")] + #[serde(rename = "channel_closing_transaction_fees")] pub fees: Option, /// The hash of the block that included this transaction. This will be null for unconfirmed transactions. - #[serde (rename = "channel_closing_transaction_block_hash")] + #[serde(rename = "channel_closing_transaction_block_hash")] pub block_hash: Option, /// The height of the block that included this transaction. This will be zero for unconfirmed transactions. - #[serde (rename = "channel_closing_transaction_block_height")] + #[serde(rename = "channel_closing_transaction_block_height")] pub block_height: i64, /// The Bitcoin blockchain addresses this transaction was sent to. - #[serde (rename = "channel_closing_transaction_destination_addresses")] + #[serde(rename = "channel_closing_transaction_destination_addresses")] pub destination_addresses: Vec, /// The number of blockchain confirmations for this transaction in real time. - #[serde (rename = "channel_closing_transaction_num_confirmations")] + #[serde(rename = "channel_closing_transaction_num_confirmations")] pub num_confirmations: Option, /// If known, the channel this transaction is closing. @@ -72,12 +79,9 @@ pub struct ChannelClosingTransaction { /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl OnChainTransaction for ChannelClosingTransaction { - /// The fees that were paid by the node for this transaction. fn get_fees(&self) -> Option { self.fees.clone() @@ -103,16 +107,12 @@ impl OnChainTransaction for ChannelClosingTransaction { self.num_confirmations } - fn type_name(&self) -> &'static str { "ChannelClosingTransaction" } } - - impl Transaction for ChannelClosingTransaction { - /// The current status of this transaction. fn get_status(&self) -> TransactionStatus { self.status.clone() @@ -133,16 +133,12 @@ impl Transaction for ChannelClosingTransaction { self.transaction_hash.clone() } - fn type_name(&self) -> &'static str { "ChannelClosingTransaction" } } - - impl Entity for ChannelClosingTransaction { - /// 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() @@ -158,16 +154,15 @@ impl Entity for ChannelClosingTransaction { self.updated_at } - fn type_name(&self) -> &'static str { "ChannelClosingTransaction" } } - impl GetEntity for ChannelClosingTransaction { fn get_entity_query() -> String { - format!(" + format!( + " query GetEntity($id: ID!) {{ entity(id: $id) {{ ... on ChannelClosingTransaction {{ @@ -176,12 +171,12 @@ impl GetEntity for ChannelClosingTransaction { }} }} - {}", FRAGMENT) - } + {}", + FRAGMENT + ) + } } - - pub const FRAGMENT: &str = " fragment ChannelClosingTransactionFragment on ChannelClosingTransaction { __typename @@ -216,6 +211,3 @@ fragment ChannelClosingTransactionFragment on ChannelClosingTransaction { } } "; - - - diff --git a/lightspark/src/objects/channel_fees.rs b/lightspark/src/objects/channel_fees.rs index 12392b7..f89ecbc 100644 --- a/lightspark/src/objects/channel_fees.rs +++ b/lightspark/src/objects/channel_fees.rs @@ -1,24 +1,17 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::currency_amount::CurrencyAmount; +use serde::{Deserialize, Serialize}; /// This represents the fee policies set for a channel on the Lightning Network. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct ChannelFees { - - - #[serde (rename = "channel_fees_base_fee")] + #[serde(rename = "channel_fees_base_fee")] pub base_fee: Option, - - #[serde (rename = "channel_fees_fee_rate_per_mil")] + #[serde(rename = "channel_fees_fee_rate_per_mil")] pub fee_rate_per_mil: Option, - } - - pub const FRAGMENT: &str = " fragment ChannelFeesFragment on ChannelFees { __typename @@ -33,6 +26,3 @@ fragment ChannelFeesFragment on ChannelFees { channel_fees_fee_rate_per_mil: fee_rate_per_mil } "; - - - diff --git a/lightspark/src/objects/channel_opening_transaction.rs b/lightspark/src/objects/channel_opening_transaction.rs index 50f1d21..70215e4 100644 --- a/lightspark/src/objects/channel_opening_transaction.rs +++ b/lightspark/src/objects/channel_opening_transaction.rs @@ -1,68 +1,75 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::currency_amount::CurrencyAmount; -use crate::types::entity_wrapper::EntityWrapper; -use crate::objects::transaction_status::TransactionStatus; -use crate::objects::on_chain_transaction::OnChainTransaction; use crate::objects::entity::Entity; -use crate::types::get_entity::GetEntity; -use std::vec::Vec; -use crate::types::custom_date_formats::custom_date_format_option; +use crate::objects::on_chain_transaction::OnChainTransaction; use crate::objects::transaction::Transaction; +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 crate::types::entity_wrapper::EntityWrapper; +use crate::types::get_entity::GetEntity; use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; +use std::vec::Vec; /// This is an object representing a transaction which opens a channel on the Lightning Network. This object occurs only for channels funded by the local Lightspark node. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct ChannelOpeningTransaction { - /// The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string. - #[serde (rename = "channel_opening_transaction_id")] + #[serde(rename = "channel_opening_transaction_id")] pub id: String, /// The date and time when this transaction was initiated. - #[serde(with = "custom_date_format", rename = "channel_opening_transaction_created_at")] + #[serde( + with = "custom_date_format", + rename = "channel_opening_transaction_created_at" + )] pub created_at: DateTime, /// The date and time when the entity was last updated. - #[serde(with = "custom_date_format", rename = "channel_opening_transaction_updated_at")] + #[serde( + with = "custom_date_format", + rename = "channel_opening_transaction_updated_at" + )] pub updated_at: DateTime, /// The current status of this transaction. - #[serde (rename = "channel_opening_transaction_status")] + #[serde(rename = "channel_opening_transaction_status")] pub status: TransactionStatus, /// The date and time when this transaction was completed or failed. - #[serde(with = "custom_date_format_option", rename = "channel_opening_transaction_resolved_at")] + #[serde( + with = "custom_date_format_option", + rename = "channel_opening_transaction_resolved_at" + )] pub resolved_at: Option>, /// The amount of money involved in this transaction. - #[serde (rename = "channel_opening_transaction_amount")] + #[serde(rename = "channel_opening_transaction_amount")] pub amount: CurrencyAmount, /// The hash of this transaction, so it can be uniquely identified on the Lightning Network. - #[serde (rename = "channel_opening_transaction_transaction_hash")] + #[serde(rename = "channel_opening_transaction_transaction_hash")] pub transaction_hash: Option, /// The fees that were paid by the node for this transaction. - #[serde (rename = "channel_opening_transaction_fees")] + #[serde(rename = "channel_opening_transaction_fees")] pub fees: Option, /// The hash of the block that included this transaction. This will be null for unconfirmed transactions. - #[serde (rename = "channel_opening_transaction_block_hash")] + #[serde(rename = "channel_opening_transaction_block_hash")] pub block_hash: Option, /// The height of the block that included this transaction. This will be zero for unconfirmed transactions. - #[serde (rename = "channel_opening_transaction_block_height")] + #[serde(rename = "channel_opening_transaction_block_height")] pub block_height: i64, /// The Bitcoin blockchain addresses this transaction was sent to. - #[serde (rename = "channel_opening_transaction_destination_addresses")] + #[serde(rename = "channel_opening_transaction_destination_addresses")] pub destination_addresses: Vec, /// The number of blockchain confirmations for this transaction in real time. - #[serde (rename = "channel_opening_transaction_num_confirmations")] + #[serde(rename = "channel_opening_transaction_num_confirmations")] pub num_confirmations: Option, /// If known, the channel this transaction is opening. @@ -72,12 +79,9 @@ pub struct ChannelOpeningTransaction { /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl OnChainTransaction for ChannelOpeningTransaction { - /// The fees that were paid by the node for this transaction. fn get_fees(&self) -> Option { self.fees.clone() @@ -103,16 +107,12 @@ impl OnChainTransaction for ChannelOpeningTransaction { self.num_confirmations } - fn type_name(&self) -> &'static str { "ChannelOpeningTransaction" } } - - impl Transaction for ChannelOpeningTransaction { - /// The current status of this transaction. fn get_status(&self) -> TransactionStatus { self.status.clone() @@ -133,16 +133,12 @@ impl Transaction for ChannelOpeningTransaction { self.transaction_hash.clone() } - fn type_name(&self) -> &'static str { "ChannelOpeningTransaction" } } - - impl Entity for ChannelOpeningTransaction { - /// 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() @@ -158,16 +154,15 @@ impl Entity for ChannelOpeningTransaction { self.updated_at } - fn type_name(&self) -> &'static str { "ChannelOpeningTransaction" } } - impl GetEntity for ChannelOpeningTransaction { fn get_entity_query() -> String { - format!(" + format!( + " query GetEntity($id: ID!) {{ entity(id: $id) {{ ... on ChannelOpeningTransaction {{ @@ -176,12 +171,12 @@ impl GetEntity for ChannelOpeningTransaction { }} }} - {}", FRAGMENT) - } + {}", + FRAGMENT + ) + } } - - pub const FRAGMENT: &str = " fragment ChannelOpeningTransactionFragment on ChannelOpeningTransaction { __typename @@ -216,6 +211,3 @@ fragment ChannelOpeningTransactionFragment on ChannelOpeningTransaction { } } "; - - - diff --git a/lightspark/src/objects/channel_snapshot.rs b/lightspark/src/objects/channel_snapshot.rs index abb1312..dbbff21 100644 --- a/lightspark/src/objects/channel_snapshot.rs +++ b/lightspark/src/objects/channel_snapshot.rs @@ -1,19 +1,16 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::currency_amount::CurrencyAmount; -use crate::types::entity_wrapper::EntityWrapper; use crate::objects::entity::Entity; -use crate::types::get_entity::GetEntity; use crate::types::custom_date_formats::custom_date_format; +use crate::types::entity_wrapper::EntityWrapper; +use crate::types::get_entity::GetEntity; use chrono::{DateTime, Utc}; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct ChannelSnapshot { - /// The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string. - #[serde (rename = "channel_snapshot_id")] + #[serde(rename = "channel_snapshot_id")] pub id: String, /// The date and time when the entity was first created. @@ -24,32 +21,25 @@ pub struct ChannelSnapshot { #[serde(with = "custom_date_format", rename = "channel_snapshot_updated_at")] pub updated_at: DateTime, - - #[serde (rename = "channel_snapshot_local_balance")] + #[serde(rename = "channel_snapshot_local_balance")] pub local_balance: Option, - - #[serde (rename = "channel_snapshot_local_unsettled_balance")] + #[serde(rename = "channel_snapshot_local_unsettled_balance")] pub local_unsettled_balance: Option, - - #[serde (rename = "channel_snapshot_remote_balance")] + #[serde(rename = "channel_snapshot_remote_balance")] pub remote_balance: Option, - - #[serde (rename = "channel_snapshot_remote_unsettled_balance")] + #[serde(rename = "channel_snapshot_remote_unsettled_balance")] pub remote_unsettled_balance: Option, - - #[serde (rename = "channel_snapshot_status")] + #[serde(rename = "channel_snapshot_status")] pub status: Option, - #[serde(rename = "channel_snapshot_channel")] pub channel: EntityWrapper, - - #[serde (rename = "channel_snapshot_local_channel_reserve")] + #[serde(rename = "channel_snapshot_local_channel_reserve")] pub local_channel_reserve: Option, /// The timestamp that was used to query the snapshot of the channel @@ -59,12 +49,9 @@ pub struct ChannelSnapshot { /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl Entity for ChannelSnapshot { - /// 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() @@ -80,16 +67,15 @@ impl Entity for ChannelSnapshot { self.updated_at } - fn type_name(&self) -> &'static str { "ChannelSnapshot" } } - impl GetEntity for ChannelSnapshot { fn get_entity_query() -> String { - format!(" + format!( + " query GetEntity($id: ID!) {{ entity(id: $id) {{ ... on ChannelSnapshot {{ @@ -98,12 +84,12 @@ impl GetEntity for ChannelSnapshot { }} }} - {}", FRAGMENT) - } + {}", + FRAGMENT + ) + } } - - pub const FRAGMENT: &str = " fragment ChannelSnapshotFragment on ChannelSnapshot { __typename @@ -157,6 +143,3 @@ fragment ChannelSnapshotFragment on ChannelSnapshot { channel_snapshot_timestamp: timestamp } "; - - - diff --git a/lightspark/src/objects/channel_status.rs b/lightspark/src/objects/channel_status.rs index b92efe4..a92768e 100644 --- a/lightspark/src/objects/channel_status.rs +++ b/lightspark/src/objects/channel_status.rs @@ -1,4 +1,3 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -9,33 +8,32 @@ use std::fmt; pub enum ChannelStatus { /// The channel is online and ready to send and receive funds. - #[serde(rename="OK")] + #[serde(rename = "OK")] Ok, /// The channel has been created, but the Bitcoin transaction that initiates it still needs to be confirmed on the Bitcoin blockchain. - #[serde(rename="PENDING")] + #[serde(rename = "PENDING")] Pending, /// The channel is not available, likely because the peer is not online. - #[serde(rename="OFFLINE")] + #[serde(rename = "OFFLINE")] Offline, /// The channel is behaving properly, but its remote balance is much higher than its local balance so it is not balanced properly for sending funds out. - #[serde(rename="UNBALANCED_FOR_SEND")] + #[serde(rename = "UNBALANCED_FOR_SEND")] UnbalancedForSend, /// The channel is behaving properly, but its remote balance is much lower than its local balance so it is not balanced properly for receiving funds. - #[serde(rename="UNBALANCED_FOR_RECEIVE")] + #[serde(rename = "UNBALANCED_FOR_RECEIVE")] UnbalancedForReceive, /// The channel has been closed. Information about the channel is still available for historical purposes but the channel cannot be used anymore. - #[serde(rename="CLOSED")] + #[serde(rename = "CLOSED")] Closed, /// Something unexpected happened and we cannot determine the status of this channel. Please try again later or contact the support. - #[serde(rename="ERROR")] + #[serde(rename = "ERROR")] Error, - } impl Into for ChannelStatus { @@ -54,8 +52,6 @@ impl fmt::Display for ChannelStatus { Self::UnbalancedForReceive => write!(f, "UNBALANCED_FOR_RECEIVE"), Self::Closed => write!(f, "CLOSED"), Self::Error => write!(f, "ERROR"), - } } } - diff --git a/lightspark/src/objects/channel_to_transactions_connection.rs b/lightspark/src/objects/channel_to_transactions_connection.rs index f9cf2f0..df95c45 100644 --- a/lightspark/src/objects/channel_to_transactions_connection.rs +++ b/lightspark/src/objects/channel_to_transactions_connection.rs @@ -1,32 +1,26 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::currency_amount::CurrencyAmount; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct ChannelToTransactionsConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). - #[serde (rename = "channel_to_transactions_connection_count")] + #[serde(rename = "channel_to_transactions_connection_count")] pub count: i64, /// The average fee for the transactions that transited through this channel, according to the filters and constraints of the connection. - #[serde (rename = "channel_to_transactions_connection_average_fee")] + #[serde(rename = "channel_to_transactions_connection_average_fee")] pub average_fee: Option, /// The total amount transacted for the transactions that transited through this channel, according to the filters and constraints of the connection. - #[serde (rename = "channel_to_transactions_connection_total_amount_transacted")] + #[serde(rename = "channel_to_transactions_connection_total_amount_transacted")] pub total_amount_transacted: Option, /// The total amount of fees for the transactions that transited through this channel, according to the filters and constraints of the connection. - #[serde (rename = "channel_to_transactions_connection_total_fees")] + #[serde(rename = "channel_to_transactions_connection_total_fees")] pub total_fees: Option, - } - - pub const FRAGMENT: &str = " fragment ChannelToTransactionsConnectionFragment on ChannelToTransactionsConnection { __typename @@ -57,6 +51,3 @@ fragment ChannelToTransactionsConnectionFragment on ChannelToTransactionsConnect } } "; - - - diff --git a/lightspark/src/objects/claim_uma_invitation_input.rs b/lightspark/src/objects/claim_uma_invitation_input.rs index 95652cb..160b71a 100644 --- a/lightspark/src/objects/claim_uma_invitation_input.rs +++ b/lightspark/src/objects/claim_uma_invitation_input.rs @@ -1,23 +1,11 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; - - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct ClaimUmaInvitationInput { - /// The unique code that identifies this invitation and was shared by the inviter. - pub invitation_code: String, /// The UMA of the user claiming the invitation. It will be sent to the inviter so that they can start transacting with the invitee. - pub invitee_uma: String, - } - - - - - diff --git a/lightspark/src/objects/claim_uma_invitation_output.rs b/lightspark/src/objects/claim_uma_invitation_output.rs index 46b7cf4..2fc5f5a 100644 --- a/lightspark/src/objects/claim_uma_invitation_output.rs +++ b/lightspark/src/objects/claim_uma_invitation_output.rs @@ -1,20 +1,14 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::types::entity_wrapper::EntityWrapper; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct ClaimUmaInvitationOutput { - /// An UMA.ME invitation object. #[serde(rename = "claim_uma_invitation_output_invitation")] pub invitation: EntityWrapper, - } - - pub const FRAGMENT: &str = " fragment ClaimUmaInvitationOutputFragment on ClaimUmaInvitationOutput { __typename @@ -23,6 +17,3 @@ fragment ClaimUmaInvitationOutputFragment on ClaimUmaInvitationOutput { } } "; - - - diff --git a/lightspark/src/objects/claim_uma_invitation_with_incentives_input.rs b/lightspark/src/objects/claim_uma_invitation_with_incentives_input.rs index 0e781cd..0971e8e 100644 --- a/lightspark/src/objects/claim_uma_invitation_with_incentives_input.rs +++ b/lightspark/src/objects/claim_uma_invitation_with_incentives_input.rs @@ -1,31 +1,18 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::region_code::RegionCode; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct ClaimUmaInvitationWithIncentivesInput { - /// The unique code that identifies this invitation and was shared by the inviter. - pub invitation_code: String, /// The UMA of the user claiming the invitation. It will be sent to the inviter so that they can start transacting with the invitee. - pub invitee_uma: String, /// The phone hash of the user getting the invitation. - pub invitee_phone_hash: String, /// The region of the user getting the invitation. - 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 index 4555be1..6a058e2 100644 --- a/lightspark/src/objects/claim_uma_invitation_with_incentives_output.rs +++ b/lightspark/src/objects/claim_uma_invitation_with_incentives_output.rs @@ -1,20 +1,14 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::types::entity_wrapper::EntityWrapper; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct ClaimUmaInvitationWithIncentivesOutput { - /// An UMA.ME invitation object. #[serde(rename = "claim_uma_invitation_with_incentives_output_invitation")] pub invitation: EntityWrapper, - } - - pub const FRAGMENT: &str = " fragment ClaimUmaInvitationWithIncentivesOutputFragment on ClaimUmaInvitationWithIncentivesOutput { __typename @@ -23,6 +17,3 @@ fragment ClaimUmaInvitationWithIncentivesOutputFragment on ClaimUmaInvitationWit } } "; - - - diff --git a/lightspark/src/objects/compliance_provider.rs b/lightspark/src/objects/compliance_provider.rs index ee87b08..6b3d687 100644 --- a/lightspark/src/objects/compliance_provider.rs +++ b/lightspark/src/objects/compliance_provider.rs @@ -1,4 +1,3 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -7,10 +6,8 @@ use std::fmt; /// This is an enum identifying a type of compliance provider. #[derive(Debug, Clone, Deserialize, Serialize)] pub enum ComplianceProvider { - - #[serde(rename="CHAINALYSIS")] + #[serde(rename = "CHAINALYSIS")] Chainalysis, - } impl Into for ComplianceProvider { @@ -23,8 +20,6 @@ impl fmt::Display for ComplianceProvider { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { Self::Chainalysis => write!(f, "CHAINALYSIS"), - } } } - diff --git a/lightspark/src/objects/connection.rs b/lightspark/src/objects/connection.rs index fbb311c..668be65 100644 --- a/lightspark/src/objects/connection.rs +++ b/lightspark/src/objects/connection.rs @@ -1,39 +1,35 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde_json::Value; +use super::account_to_api_tokens_connection::AccountToApiTokensConnection; +use super::account_to_channels_connection::AccountToChannelsConnection; +use super::account_to_nodes_connection::AccountToNodesConnection; use super::account_to_payment_requests_connection::AccountToPaymentRequestsConnection; -use super::outgoing_payment_to_attempts_connection::OutgoingPaymentToAttemptsConnection; +use super::account_to_transactions_connection::AccountToTransactionsConnection; +use super::account_to_wallets_connection::AccountToWalletsConnection; use super::account_to_withdrawal_requests_connection::AccountToWithdrawalRequestsConnection; -use crate::objects::page_info::PageInfo; -use super::wallet_to_withdrawal_requests_connection::WalletToWithdrawalRequestsConnection; -use super::wallet_to_transactions_connection::WalletToTransactionsConnection; use super::incoming_payment_to_attempts_connection::IncomingPaymentToAttemptsConnection; -use super::withdrawal_request_to_channel_closing_transactions_connection::WithdrawalRequestToChannelClosingTransactionsConnection; use super::lightspark_node_to_channels_connection::LightsparkNodeToChannelsConnection; use super::outgoing_payment_attempt_to_hops_connection::OutgoingPaymentAttemptToHopsConnection; -use super::account_to_transactions_connection::AccountToTransactionsConnection; -use super::account_to_api_tokens_connection::AccountToApiTokensConnection; -use super::account_to_nodes_connection::AccountToNodesConnection; -use super::withdrawal_request_to_channel_opening_transactions_connection::WithdrawalRequestToChannelOpeningTransactionsConnection; -use super::account_to_wallets_connection::AccountToWalletsConnection; +use super::outgoing_payment_to_attempts_connection::OutgoingPaymentToAttemptsConnection; use super::wallet_to_payment_requests_connection::WalletToPaymentRequestsConnection; +use super::wallet_to_transactions_connection::WalletToTransactionsConnection; +use super::wallet_to_withdrawal_requests_connection::WalletToWithdrawalRequestsConnection; +use super::withdrawal_request_to_channel_closing_transactions_connection::WithdrawalRequestToChannelClosingTransactionsConnection; +use super::withdrawal_request_to_channel_opening_transactions_connection::WithdrawalRequestToChannelOpeningTransactionsConnection; +use crate::objects::page_info::PageInfo; use serde::{Deserialize, Deserializer, Serialize}; -use super::account_to_channels_connection::AccountToChannelsConnection; +use serde_json::Value; pub trait Connection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). fn get_count(&self) -> i64; /// An object that holds pagination information about the objects in this connection. fn get_page_info(&self) -> PageInfo; - -fn type_name(&self) -> &'static str; + fn type_name(&self) -> &'static str; } - #[allow(clippy::large_enum_variant)] #[derive(Debug, Clone, Serialize)] pub enum ConnectionEnum { @@ -51,13 +47,14 @@ pub enum ConnectionEnum { WalletToPaymentRequestsConnection(WalletToPaymentRequestsConnection), WalletToTransactionsConnection(WalletToTransactionsConnection), WalletToWithdrawalRequestsConnection(WalletToWithdrawalRequestsConnection), - WithdrawalRequestToChannelClosingTransactionsConnection(WithdrawalRequestToChannelClosingTransactionsConnection), - WithdrawalRequestToChannelOpeningTransactionsConnection(WithdrawalRequestToChannelOpeningTransactionsConnection), - + WithdrawalRequestToChannelClosingTransactionsConnection( + WithdrawalRequestToChannelClosingTransactionsConnection, + ), + WithdrawalRequestToChannelOpeningTransactionsConnection( + WithdrawalRequestToChannelOpeningTransactionsConnection, + ), } - - impl<'de> Deserialize<'de> for ConnectionEnum { fn deserialize(deserializer: D) -> Result where @@ -67,123 +64,127 @@ impl<'de> Deserialize<'de> for ConnectionEnum { if let Some(typename) = value.get("__typename").and_then(Value::as_str) { match typename { "AccountToApiTokensConnection" => { - let obj = AccountToApiTokensConnection::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = AccountToApiTokensConnection::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(ConnectionEnum::AccountToApiTokensConnection(obj)) - }, + } "AccountToChannelsConnection" => { - let obj = AccountToChannelsConnection::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = AccountToChannelsConnection::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(ConnectionEnum::AccountToChannelsConnection(obj)) - }, + } "AccountToNodesConnection" => { - let obj = AccountToNodesConnection::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = AccountToNodesConnection::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(ConnectionEnum::AccountToNodesConnection(obj)) - }, + } "AccountToPaymentRequestsConnection" => { - let obj = AccountToPaymentRequestsConnection::deserialize(value) - .map_err(|err| + let obj = + AccountToPaymentRequestsConnection::deserialize(value).map_err(|err| { serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + })?; Ok(ConnectionEnum::AccountToPaymentRequestsConnection(obj)) - }, + } "AccountToTransactionsConnection" => { - let obj = AccountToTransactionsConnection::deserialize(value) - .map_err(|err| + let obj = + AccountToTransactionsConnection::deserialize(value).map_err(|err| { serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + })?; Ok(ConnectionEnum::AccountToTransactionsConnection(obj)) - }, + } "AccountToWalletsConnection" => { - let obj = AccountToWalletsConnection::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = AccountToWalletsConnection::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(ConnectionEnum::AccountToWalletsConnection(obj)) - }, + } "AccountToWithdrawalRequestsConnection" => { - let obj = AccountToWithdrawalRequestsConnection::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = AccountToWithdrawalRequestsConnection::deserialize(value).map_err( + |err| serde::de::Error::custom(format!("Serde JSON Error {}", err)), + )?; Ok(ConnectionEnum::AccountToWithdrawalRequestsConnection(obj)) - }, + } "IncomingPaymentToAttemptsConnection" => { - let obj = IncomingPaymentToAttemptsConnection::deserialize(value) - .map_err(|err| + let obj = + IncomingPaymentToAttemptsConnection::deserialize(value).map_err(|err| { serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + })?; Ok(ConnectionEnum::IncomingPaymentToAttemptsConnection(obj)) - }, + } "LightsparkNodeToChannelsConnection" => { - let obj = LightsparkNodeToChannelsConnection::deserialize(value) - .map_err(|err| + let obj = + LightsparkNodeToChannelsConnection::deserialize(value).map_err(|err| { serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + })?; Ok(ConnectionEnum::LightsparkNodeToChannelsConnection(obj)) - }, + } "OutgoingPaymentAttemptToHopsConnection" => { - let obj = OutgoingPaymentAttemptToHopsConnection::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = OutgoingPaymentAttemptToHopsConnection::deserialize(value).map_err( + |err| serde::de::Error::custom(format!("Serde JSON Error {}", err)), + )?; Ok(ConnectionEnum::OutgoingPaymentAttemptToHopsConnection(obj)) - }, + } "OutgoingPaymentToAttemptsConnection" => { - let obj = OutgoingPaymentToAttemptsConnection::deserialize(value) - .map_err(|err| + let obj = + OutgoingPaymentToAttemptsConnection::deserialize(value).map_err(|err| { serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + })?; Ok(ConnectionEnum::OutgoingPaymentToAttemptsConnection(obj)) - }, + } "WalletToPaymentRequestsConnection" => { - let obj = WalletToPaymentRequestsConnection::deserialize(value) - .map_err(|err| + let obj = + WalletToPaymentRequestsConnection::deserialize(value).map_err(|err| { serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + })?; Ok(ConnectionEnum::WalletToPaymentRequestsConnection(obj)) - }, + } "WalletToTransactionsConnection" => { - let obj = WalletToTransactionsConnection::deserialize(value) - .map_err(|err| + let obj = + WalletToTransactionsConnection::deserialize(value).map_err(|err| { serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + })?; Ok(ConnectionEnum::WalletToTransactionsConnection(obj)) - }, + } "WalletToWithdrawalRequestsConnection" => { - let obj = WalletToWithdrawalRequestsConnection::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = WalletToWithdrawalRequestsConnection::deserialize(value).map_err( + |err| serde::de::Error::custom(format!("Serde JSON Error {}", err)), + )?; Ok(ConnectionEnum::WalletToWithdrawalRequestsConnection(obj)) - }, + } "WithdrawalRequestToChannelClosingTransactionsConnection" => { - let obj = WithdrawalRequestToChannelClosingTransactionsConnection::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; - Ok(ConnectionEnum::WithdrawalRequestToChannelClosingTransactionsConnection(obj)) - }, + let obj = + WithdrawalRequestToChannelClosingTransactionsConnection::deserialize(value) + .map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; + Ok( + ConnectionEnum::WithdrawalRequestToChannelClosingTransactionsConnection( + obj, + ), + ) + } "WithdrawalRequestToChannelOpeningTransactionsConnection" => { - let obj = WithdrawalRequestToChannelOpeningTransactionsConnection::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; - Ok(ConnectionEnum::WithdrawalRequestToChannelOpeningTransactionsConnection(obj)) - }, + let obj = + WithdrawalRequestToChannelOpeningTransactionsConnection::deserialize(value) + .map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; + Ok( + ConnectionEnum::WithdrawalRequestToChannelOpeningTransactionsConnection( + obj, + ), + ) + } _ => Err(serde::de::Error::custom("unknown typename")), } } else { - Err(serde::de::Error::custom("missing __typename field on Connection")) + Err(serde::de::Error::custom( + "missing __typename field on Connection", + )) } } } - diff --git a/lightspark/src/objects/create_api_token_input.rs b/lightspark/src/objects/create_api_token_input.rs index fed4a30..fcabf80 100644 --- a/lightspark/src/objects/create_api_token_input.rs +++ b/lightspark/src/objects/create_api_token_input.rs @@ -1,24 +1,13 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::permission::Permission; +use serde::{Deserialize, Serialize}; use std::vec::Vec; - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct CreateApiTokenInput { - /// An arbitrary name that the user can choose to identify the API token in a list. - pub name: String, /// List of permissions to grant to the API token - pub permissions: Vec, - } - - - - - diff --git a/lightspark/src/objects/create_api_token_output.rs b/lightspark/src/objects/create_api_token_output.rs index 3fc1a6e..2cbf1df 100644 --- a/lightspark/src/objects/create_api_token_output.rs +++ b/lightspark/src/objects/create_api_token_output.rs @@ -1,25 +1,19 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::api_token::ApiToken; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct CreateApiTokenOutput { - /// The API Token that has been created. - #[serde (rename = "create_api_token_output_api_token")] + #[serde(rename = "create_api_token_output_api_token")] pub api_token: ApiToken, /// The secret that should be used to authenticate against our API. // This secret is not stored and will never be available again after this. You must keep this secret secure as it grants access to your account. - #[serde (rename = "create_api_token_output_client_secret")] + #[serde(rename = "create_api_token_output_client_secret")] pub client_secret: String, - } - - pub const FRAGMENT: &str = " fragment CreateApiTokenOutputFragment on CreateApiTokenOutput { __typename @@ -36,6 +30,3 @@ fragment CreateApiTokenOutputFragment on CreateApiTokenOutput { create_api_token_output_client_secret: client_secret } "; - - - diff --git a/lightspark/src/objects/create_invitation_with_incentives_input.rs b/lightspark/src/objects/create_invitation_with_incentives_input.rs index 26bc389..f6d6bd9 100644 --- a/lightspark/src/objects/create_invitation_with_incentives_input.rs +++ b/lightspark/src/objects/create_invitation_with_incentives_input.rs @@ -1,27 +1,15 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::region_code::RegionCode; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct CreateInvitationWithIncentivesInput { - /// The UMA of the user creating the invitation. It will be used to identify the inviter when receiving the invitation. - pub inviter_uma: String, /// The phone hash of the user creating the invitation. - pub inviter_phone_hash: String, /// The region of the user creating the invitation. - 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 index c7a9292..d136323 100644 --- a/lightspark/src/objects/create_invitation_with_incentives_output.rs +++ b/lightspark/src/objects/create_invitation_with_incentives_output.rs @@ -1,20 +1,14 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::types::entity_wrapper::EntityWrapper; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct CreateInvitationWithIncentivesOutput { - /// The created invitation in the form of a string identifier. #[serde(rename = "create_invitation_with_incentives_output_invitation")] pub invitation: EntityWrapper, - } - - pub const FRAGMENT: &str = " fragment CreateInvitationWithIncentivesOutputFragment on CreateInvitationWithIncentivesOutput { __typename @@ -23,6 +17,3 @@ fragment CreateInvitationWithIncentivesOutputFragment on CreateInvitationWithInc } } "; - - - diff --git a/lightspark/src/objects/create_invoice_input.rs b/lightspark/src/objects/create_invoice_input.rs index bf27e6d..7287726 100644 --- a/lightspark/src/objects/create_invoice_input.rs +++ b/lightspark/src/objects/create_invoice_input.rs @@ -1,35 +1,19 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::invoice_type::InvoiceType; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct CreateInvoiceInput { - /// The node from which to create the invoice. - pub node_id: String, /// The amount for which the invoice should be created, in millisatoshis. Setting the amount to 0 will allow the payer to specify an amount. - pub amount_msats: i64, - - pub memo: Option, - - pub invoice_type: Option, /// The expiry of the invoice in seconds. Default value is 86400 (1 day). - pub expiry_secs: Option, - } - - - - - diff --git a/lightspark/src/objects/create_invoice_output.rs b/lightspark/src/objects/create_invoice_output.rs index 09aaa33..a515ea2 100644 --- a/lightspark/src/objects/create_invoice_output.rs +++ b/lightspark/src/objects/create_invoice_output.rs @@ -1,20 +1,13 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::types::entity_wrapper::EntityWrapper; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct CreateInvoiceOutput { - - #[serde(rename = "create_invoice_output_invoice")] pub invoice: EntityWrapper, - } - - pub const FRAGMENT: &str = " fragment CreateInvoiceOutputFragment on CreateInvoiceOutput { __typename @@ -23,6 +16,3 @@ fragment CreateInvoiceOutputFragment on CreateInvoiceOutput { } } "; - - - diff --git a/lightspark/src/objects/create_lnurl_invoice_input.rs b/lightspark/src/objects/create_lnurl_invoice_input.rs index f99ead1..742b22a 100644 --- a/lightspark/src/objects/create_lnurl_invoice_input.rs +++ b/lightspark/src/objects/create_lnurl_invoice_input.rs @@ -1,35 +1,20 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; - - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct CreateLnurlInvoiceInput { - /// The node from which to create the invoice. - pub node_id: String, /// The amount for which the invoice should be created, in millisatoshis. - pub amount_msats: i64, /// The SHA256 hash of the LNURL metadata payload. This will be present in the h-tag (SHA256 purpose of payment) of the resulting Bolt 11 invoice. - pub metadata_hash: String, /// The expiry of the invoice in seconds. Default value is 86400 (1 day). - pub expiry_secs: Option, /// An optional, monthly-rotated, unique hashed identifier corresponding to the receiver of the payment. - pub receiver_hash: Option, - } - - - - - diff --git a/lightspark/src/objects/create_node_wallet_address_input.rs b/lightspark/src/objects/create_node_wallet_address_input.rs index 049ad23..b0d10bd 100644 --- a/lightspark/src/objects/create_node_wallet_address_input.rs +++ b/lightspark/src/objects/create_node_wallet_address_input.rs @@ -1,19 +1,7 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; - - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct CreateNodeWalletAddressInput { - - - pub node_id: String, - } - - - - - diff --git a/lightspark/src/objects/create_node_wallet_address_output.rs b/lightspark/src/objects/create_node_wallet_address_output.rs index 44c8107..a943dd4 100644 --- a/lightspark/src/objects/create_node_wallet_address_output.rs +++ b/lightspark/src/objects/create_node_wallet_address_output.rs @@ -1,29 +1,23 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::multi_sig_address_validation_parameters::MultiSigAddressValidationParameters; use crate::types::entity_wrapper::EntityWrapper; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct CreateNodeWalletAddressOutput { - - #[serde(rename = "create_node_wallet_address_output_node")] pub node: EntityWrapper, - - #[serde (rename = "create_node_wallet_address_output_wallet_address")] + #[serde(rename = "create_node_wallet_address_output_wallet_address")] pub wallet_address: String, /// Vaildation parameters for the 2-of-2 multisig address. None if the address is not a 2-of-2 multisig address. - #[serde (rename = "create_node_wallet_address_output_multisig_wallet_address_validation_parameters")] + #[serde( + rename = "create_node_wallet_address_output_multisig_wallet_address_validation_parameters" + )] pub multisig_wallet_address_validation_parameters: Option, - } - - pub const FRAGMENT: &str = " fragment CreateNodeWalletAddressOutputFragment on CreateNodeWalletAddressOutput { __typename @@ -38,6 +32,3 @@ fragment CreateNodeWalletAddressOutputFragment on CreateNodeWalletAddressOutput } } "; - - - diff --git a/lightspark/src/objects/create_test_mode_invoice_input.rs b/lightspark/src/objects/create_test_mode_invoice_input.rs index 926f010..4f6cbdb 100644 --- a/lightspark/src/objects/create_test_mode_invoice_input.rs +++ b/lightspark/src/objects/create_test_mode_invoice_input.rs @@ -1,31 +1,14 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::invoice_type::InvoiceType; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct CreateTestModeInvoiceInput { - - - pub local_node_id: String, - - pub amount_msats: i64, - - pub memo: Option, - - pub invoice_type: Option, - } - - - - - diff --git a/lightspark/src/objects/create_test_mode_invoice_output.rs b/lightspark/src/objects/create_test_mode_invoice_output.rs index a4fb744..2ef0609 100644 --- a/lightspark/src/objects/create_test_mode_invoice_output.rs +++ b/lightspark/src/objects/create_test_mode_invoice_output.rs @@ -1,26 +1,15 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; - - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct CreateTestModeInvoiceOutput { - - - #[serde (rename = "create_test_mode_invoice_output_encoded_payment_request")] + #[serde(rename = "create_test_mode_invoice_output_encoded_payment_request")] pub encoded_payment_request: String, - } - - pub const FRAGMENT: &str = " fragment CreateTestModeInvoiceOutputFragment on CreateTestModeInvoiceOutput { __typename create_test_mode_invoice_output_encoded_payment_request: encoded_payment_request } "; - - - diff --git a/lightspark/src/objects/create_test_mode_payment_input.rs b/lightspark/src/objects/create_test_mode_payment_input.rs index d284ab1..5d6aa8b 100644 --- a/lightspark/src/objects/create_test_mode_payment_input.rs +++ b/lightspark/src/objects/create_test_mode_payment_input.rs @@ -1,27 +1,14 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; - - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct CreateTestModePaymentInput { - /// The node to where you want to send the payment. - pub local_node_id: String, /// The invoice you want to be paid (as defined by the BOLT11 standard). - pub encoded_invoice: String, /// The amount you will be paid for this invoice, expressed in msats. It should ONLY be set when the invoice amount is zero. - pub amount_msats: Option, - } - - - - - diff --git a/lightspark/src/objects/create_test_mode_paymentoutput.rs b/lightspark/src/objects/create_test_mode_paymentoutput.rs index 287feae..6f67622 100644 --- a/lightspark/src/objects/create_test_mode_paymentoutput.rs +++ b/lightspark/src/objects/create_test_mode_paymentoutput.rs @@ -1,12 +1,10 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::types::entity_wrapper::EntityWrapper; +use serde::{Deserialize, Serialize}; /// This is an object identifying the output of a test mode payment. This object can be used to retrieve the associated payment made from a Test Mode Payment call. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct CreateTestModePaymentoutput { - /// The payment that has been sent. #[serde(rename = "create_test_mode_paymentoutput_payment")] pub payment: EntityWrapper, @@ -14,11 +12,8 @@ pub struct CreateTestModePaymentoutput { /// The payment that has been received. #[serde(rename = "create_test_mode_paymentoutput_incoming_payment")] pub incoming_payment: EntityWrapper, - } - - pub const FRAGMENT: &str = " fragment CreateTestModePaymentoutputFragment on CreateTestModePaymentoutput { __typename @@ -30,6 +25,3 @@ fragment CreateTestModePaymentoutputFragment on CreateTestModePaymentoutput { } } "; - - - diff --git a/lightspark/src/objects/create_uma_invitation_input.rs b/lightspark/src/objects/create_uma_invitation_input.rs index 041d24d..52b3041 100644 --- a/lightspark/src/objects/create_uma_invitation_input.rs +++ b/lightspark/src/objects/create_uma_invitation_input.rs @@ -1,19 +1,8 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; - - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct CreateUmaInvitationInput { - /// The UMA of the user creating the invitation. It will be used to identify the inviter when receiving the invitation. - pub inviter_uma: String, - } - - - - - diff --git a/lightspark/src/objects/create_uma_invitation_output.rs b/lightspark/src/objects/create_uma_invitation_output.rs index 154b776..cbdc14f 100644 --- a/lightspark/src/objects/create_uma_invitation_output.rs +++ b/lightspark/src/objects/create_uma_invitation_output.rs @@ -1,20 +1,14 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::types::entity_wrapper::EntityWrapper; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct CreateUmaInvitationOutput { - /// The created invitation in the form of a string identifier. #[serde(rename = "create_uma_invitation_output_invitation")] pub invitation: EntityWrapper, - } - - pub const FRAGMENT: &str = " fragment CreateUmaInvitationOutputFragment on CreateUmaInvitationOutput { __typename @@ -23,6 +17,3 @@ fragment CreateUmaInvitationOutputFragment on CreateUmaInvitationOutput { } } "; - - - diff --git a/lightspark/src/objects/create_uma_invoice_input.rs b/lightspark/src/objects/create_uma_invoice_input.rs index 5c7511a..d00eacb 100644 --- a/lightspark/src/objects/create_uma_invoice_input.rs +++ b/lightspark/src/objects/create_uma_invoice_input.rs @@ -1,35 +1,20 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; - - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct CreateUmaInvoiceInput { - /// The node from which to create the invoice. - pub node_id: String, /// The amount for which the invoice should be created, in millisatoshis. - pub amount_msats: i64, /// The SHA256 hash of the UMA metadata payload. This will be present in the h-tag (SHA256 purpose of payment) of the resulting Bolt 11 invoice. - pub metadata_hash: String, /// The expiry of the invoice in seconds. Default value is 86400 (1 day). - pub expiry_secs: Option, /// An optional, monthly-rotated, unique hashed identifier corresponding to the receiver of the payment. - pub receiver_hash: Option, - } - - - - - diff --git a/lightspark/src/objects/currency_amount.rs b/lightspark/src/objects/currency_amount.rs index c0f413e..1ce51a9 100644 --- a/lightspark/src/objects/currency_amount.rs +++ b/lightspark/src/objects/currency_amount.rs @@ -1,36 +1,31 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::currency_unit::CurrencyUnit; +use serde::{Deserialize, Serialize}; /// This object represents the value and unit for an amount of currency. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct CurrencyAmount { - /// The original numeric value for this CurrencyAmount. - #[serde (rename = "currency_amount_original_value")] + #[serde(rename = "currency_amount_original_value")] pub original_value: i64, /// The original unit of currency for this CurrencyAmount. - #[serde (rename = "currency_amount_original_unit")] + #[serde(rename = "currency_amount_original_unit")] pub original_unit: CurrencyUnit, /// The unit of user's preferred currency. - #[serde (rename = "currency_amount_preferred_currency_unit")] + #[serde(rename = "currency_amount_preferred_currency_unit")] pub preferred_currency_unit: CurrencyUnit, /// The rounded numeric value for this CurrencyAmount in the very base level of user's preferred currency. For example, for USD, the value will be in cents. - #[serde (rename = "currency_amount_preferred_currency_value_rounded")] + #[serde(rename = "currency_amount_preferred_currency_value_rounded")] pub preferred_currency_value_rounded: i64, /// The approximate float value for this CurrencyAmount in the very base level of user's preferred currency. For example, for USD, the value will be in cents. - #[serde (rename = "currency_amount_preferred_currency_value_approx")] + #[serde(rename = "currency_amount_preferred_currency_value_approx")] pub preferred_currency_value_approx: f64, - } - - pub const FRAGMENT: &str = " fragment CurrencyAmountFragment on CurrencyAmount { __typename @@ -41,6 +36,3 @@ fragment CurrencyAmountFragment on CurrencyAmount { currency_amount_preferred_currency_value_approx: preferred_currency_value_approx } "; - - - diff --git a/lightspark/src/objects/currency_unit.rs b/lightspark/src/objects/currency_unit.rs index 157ec2e..2c59898 100644 --- a/lightspark/src/objects/currency_unit.rs +++ b/lightspark/src/objects/currency_unit.rs @@ -1,4 +1,3 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -9,37 +8,36 @@ use std::fmt; pub enum CurrencyUnit { /// Bitcoin is the cryptocurrency native to the Bitcoin network. It is used as the native medium for value transfer for the Lightning Network. - #[serde(rename="BITCOIN")] + #[serde(rename = "BITCOIN")] Bitcoin, /// 0.00000001 (10e-8) Bitcoin or one hundred millionth of a Bitcoin. This is the unit most commonly used in Lightning transactions. - #[serde(rename="SATOSHI")] + #[serde(rename = "SATOSHI")] Satoshi, /// 0.001 Satoshi, or 10e-11 Bitcoin. We recommend using the Satoshi unit instead when possible. - #[serde(rename="MILLISATOSHI")] + #[serde(rename = "MILLISATOSHI")] Millisatoshi, /// United States Dollar. - #[serde(rename="USD")] + #[serde(rename = "USD")] Usd, /// Mexican Peso. - #[serde(rename="MXN")] + #[serde(rename = "MXN")] Mxn, /// 0.000000001 (10e-9) Bitcoin or a billionth of a Bitcoin. We recommend using the Satoshi unit instead when possible. - #[serde(rename="NANOBITCOIN")] + #[serde(rename = "NANOBITCOIN")] Nanobitcoin, /// 0.000001 (10e-6) Bitcoin or a millionth of a Bitcoin. We recommend using the Satoshi unit instead when possible. - #[serde(rename="MICROBITCOIN")] + #[serde(rename = "MICROBITCOIN")] Microbitcoin, /// 0.001 (10e-3) Bitcoin or a thousandth of a Bitcoin. We recommend using the Satoshi unit instead when possible. - #[serde(rename="MILLIBITCOIN")] + #[serde(rename = "MILLIBITCOIN")] Millibitcoin, - } impl Into for CurrencyUnit { @@ -59,8 +57,6 @@ impl fmt::Display for CurrencyUnit { Self::Nanobitcoin => write!(f, "NANOBITCOIN"), Self::Microbitcoin => write!(f, "MICROBITCOIN"), Self::Millibitcoin => write!(f, "MILLIBITCOIN"), - } } } - diff --git a/lightspark/src/objects/daily_liquidity_forecast.rs b/lightspark/src/objects/daily_liquidity_forecast.rs index 4a3ee94..405417f 100644 --- a/lightspark/src/objects/daily_liquidity_forecast.rs +++ b/lightspark/src/objects/daily_liquidity_forecast.rs @@ -1,31 +1,28 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::currency_amount::CurrencyAmount; use crate::objects::lightning_payment_direction::LightningPaymentDirection; -use chrono::NaiveDate; use crate::types::custom_date_formats::custom_date_only_format; - +use chrono::NaiveDate; +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct DailyLiquidityForecast { - /// The date for which this forecast was generated. - #[serde(with = "custom_date_only_format", rename = "daily_liquidity_forecast_date")] + #[serde( + with = "custom_date_only_format", + rename = "daily_liquidity_forecast_date" + )] pub date: NaiveDate, /// The direction for which this forecast was generated. - #[serde (rename = "daily_liquidity_forecast_direction")] + #[serde(rename = "daily_liquidity_forecast_direction")] pub direction: LightningPaymentDirection, /// The value of the forecast. It represents the amount of msats that we think will be moved for that specified direction, for that node, on that date. - #[serde (rename = "daily_liquidity_forecast_amount")] + #[serde(rename = "daily_liquidity_forecast_amount")] pub amount: CurrencyAmount, - } - - pub const FRAGMENT: &str = " fragment DailyLiquidityForecastFragment on DailyLiquidityForecast { __typename @@ -41,6 +38,3 @@ fragment DailyLiquidityForecastFragment on DailyLiquidityForecast { } } "; - - - diff --git a/lightspark/src/objects/decline_to_sign_messages_input.rs b/lightspark/src/objects/decline_to_sign_messages_input.rs index 3c54277..e476b7f 100644 --- a/lightspark/src/objects/decline_to_sign_messages_input.rs +++ b/lightspark/src/objects/decline_to_sign_messages_input.rs @@ -1,19 +1,9 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; use std::vec::Vec; - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct DeclineToSignMessagesInput { - /// List of payload ids to decline to sign because validation failed. - pub payload_ids: Vec, - } - - - - - diff --git a/lightspark/src/objects/decline_to_sign_messages_output.rs b/lightspark/src/objects/decline_to_sign_messages_output.rs index ac5e112..9de091c 100644 --- a/lightspark/src/objects/decline_to_sign_messages_output.rs +++ b/lightspark/src/objects/decline_to_sign_messages_output.rs @@ -1,21 +1,14 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::signable_payload::SignablePayload; +use serde::{Deserialize, Serialize}; use std::vec::Vec; - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct DeclineToSignMessagesOutput { - - - #[serde (rename = "decline_to_sign_messages_output_declined_payloads")] + #[serde(rename = "decline_to_sign_messages_output_declined_payloads")] pub declined_payloads: Vec, - } - - pub const FRAGMENT: &str = " fragment DeclineToSignMessagesOutputFragment on DeclineToSignMessagesOutput { __typename @@ -24,6 +17,3 @@ fragment DeclineToSignMessagesOutputFragment on DeclineToSignMessagesOutput { } } "; - - - diff --git a/lightspark/src/objects/delete_api_token_input.rs b/lightspark/src/objects/delete_api_token_input.rs index df4bb39..2c226e2 100644 --- a/lightspark/src/objects/delete_api_token_input.rs +++ b/lightspark/src/objects/delete_api_token_input.rs @@ -1,19 +1,7 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; - - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct DeleteApiTokenInput { - - - pub api_token_id: String, - } - - - - - diff --git a/lightspark/src/objects/delete_api_token_output.rs b/lightspark/src/objects/delete_api_token_output.rs index 5f271dd..16d8b96 100644 --- a/lightspark/src/objects/delete_api_token_output.rs +++ b/lightspark/src/objects/delete_api_token_output.rs @@ -1,20 +1,13 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::types::entity_wrapper::EntityWrapper; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct DeleteApiTokenOutput { - - #[serde(rename = "delete_api_token_output_account")] pub account: EntityWrapper, - } - - pub const FRAGMENT: &str = " fragment DeleteApiTokenOutputFragment on DeleteApiTokenOutput { __typename @@ -23,6 +16,3 @@ fragment DeleteApiTokenOutputFragment on DeleteApiTokenOutput { } } "; - - - diff --git a/lightspark/src/objects/deposit.rs b/lightspark/src/objects/deposit.rs index b86afe8..b295be9 100644 --- a/lightspark/src/objects/deposit.rs +++ b/lightspark/src/objects/deposit.rs @@ -1,24 +1,22 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::currency_amount::CurrencyAmount; -use crate::types::entity_wrapper::EntityWrapper; -use crate::objects::transaction_status::TransactionStatus; -use crate::objects::on_chain_transaction::OnChainTransaction; use crate::objects::entity::Entity; -use crate::types::get_entity::GetEntity; -use std::vec::Vec; -use crate::types::custom_date_formats::custom_date_format_option; +use crate::objects::on_chain_transaction::OnChainTransaction; use crate::objects::transaction::Transaction; +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 crate::types::entity_wrapper::EntityWrapper; +use crate::types::get_entity::GetEntity; use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; +use std::vec::Vec; /// This object represents a Deposit made to a Lightspark node wallet. This operation occurs for any L1 funding transaction to the wallet. You can retrieve this object to receive detailed information about the deposit. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct Deposit { - /// The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string. - #[serde (rename = "deposit_id")] + #[serde(rename = "deposit_id")] pub id: String, /// The date and time when this transaction was initiated. @@ -30,7 +28,7 @@ pub struct Deposit { pub updated_at: DateTime, /// The current status of this transaction. - #[serde (rename = "deposit_status")] + #[serde(rename = "deposit_status")] pub status: TransactionStatus, /// The date and time when this transaction was completed or failed. @@ -38,31 +36,31 @@ pub struct Deposit { pub resolved_at: Option>, /// The amount of money involved in this transaction. - #[serde (rename = "deposit_amount")] + #[serde(rename = "deposit_amount")] pub amount: CurrencyAmount, /// The hash of this transaction, so it can be uniquely identified on the Lightning Network. - #[serde (rename = "deposit_transaction_hash")] + #[serde(rename = "deposit_transaction_hash")] pub transaction_hash: Option, /// The fees that were paid by the node for this transaction. - #[serde (rename = "deposit_fees")] + #[serde(rename = "deposit_fees")] pub fees: Option, /// The hash of the block that included this transaction. This will be null for unconfirmed transactions. - #[serde (rename = "deposit_block_hash")] + #[serde(rename = "deposit_block_hash")] pub block_hash: Option, /// The height of the block that included this transaction. This will be zero for unconfirmed transactions. - #[serde (rename = "deposit_block_height")] + #[serde(rename = "deposit_block_height")] pub block_height: i64, /// The Bitcoin blockchain addresses this transaction was sent to. - #[serde (rename = "deposit_destination_addresses")] + #[serde(rename = "deposit_destination_addresses")] pub destination_addresses: Vec, /// The number of blockchain confirmations for this transaction in real time. - #[serde (rename = "deposit_num_confirmations")] + #[serde(rename = "deposit_num_confirmations")] pub num_confirmations: Option, /// The recipient Lightspark node this deposit was sent to. @@ -72,12 +70,9 @@ pub struct Deposit { /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl OnChainTransaction for Deposit { - /// The fees that were paid by the node for this transaction. fn get_fees(&self) -> Option { self.fees.clone() @@ -103,16 +98,12 @@ impl OnChainTransaction for Deposit { self.num_confirmations } - fn type_name(&self) -> &'static str { "Deposit" } } - - impl Transaction for Deposit { - /// The current status of this transaction. fn get_status(&self) -> TransactionStatus { self.status.clone() @@ -133,16 +124,12 @@ impl Transaction for Deposit { self.transaction_hash.clone() } - fn type_name(&self) -> &'static str { "Deposit" } } - - impl Entity for Deposit { - /// 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() @@ -158,16 +145,15 @@ impl Entity for Deposit { self.updated_at } - fn type_name(&self) -> &'static str { "Deposit" } } - impl GetEntity for Deposit { fn get_entity_query() -> String { - format!(" + format!( + " query GetEntity($id: ID!) {{ entity(id: $id) {{ ... on Deposit {{ @@ -176,12 +162,12 @@ impl GetEntity for Deposit { }} }} - {}", FRAGMENT) - } + {}", + FRAGMENT + ) + } } - - pub const FRAGMENT: &str = " fragment DepositFragment on Deposit { __typename @@ -216,6 +202,3 @@ fragment DepositFragment on Deposit { } } "; - - - diff --git a/lightspark/src/objects/entity.rs b/lightspark/src/objects/entity.rs index f20fef0..b00c3ef 100644 --- a/lightspark/src/objects/entity.rs +++ b/lightspark/src/objects/entity.rs @@ -1,35 +1,33 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde_json::Value; -use super::withdrawal::Withdrawal; -use super::invoice::Invoice; -use super::channel_opening_transaction::ChannelOpeningTransaction; -use super::outgoing_payment_attempt::OutgoingPaymentAttempt; -use super::channel::Channel; -use super::lightspark_node_with_o_s_k::LightsparkNodeWithOSK; use super::account::Account; -use super::incoming_payment_attempt::IncomingPaymentAttempt; -use super::routing_transaction::RoutingTransaction; +use super::api_token::ApiToken; +use super::channel::Channel; use super::channel_closing_transaction::ChannelClosingTransaction; -use super::lightspark_node_with_remote_signing::LightsparkNodeWithRemoteSigning; -use super::wallet::Wallet; -use chrono::{DateTime, Utc}; -use super::signable_payload::SignablePayload; -use super::graph_node::GraphNode; -use super::signable::Signable; +use super::channel_opening_transaction::ChannelOpeningTransaction; +use super::channel_snapshot::ChannelSnapshot; use super::deposit::Deposit; -use super::outgoing_payment::OutgoingPayment; -use super::withdrawal_request::WithdrawalRequest; +use super::graph_node::GraphNode; +use super::hop::Hop; use super::incoming_payment::IncomingPayment; +use super::incoming_payment_attempt::IncomingPaymentAttempt; +use super::invoice::Invoice; +use super::lightspark_node_with_o_s_k::LightsparkNodeWithOSK; +use super::lightspark_node_with_remote_signing::LightsparkNodeWithRemoteSigning; +use super::outgoing_payment::OutgoingPayment; +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::api_token::ApiToken; +use super::wallet::Wallet; +use super::withdrawal::Withdrawal; +use super::withdrawal_request::WithdrawalRequest; +use chrono::{DateTime, Utc}; use serde::{Deserialize, Deserializer, Serialize}; -use super::channel_snapshot::ChannelSnapshot; -use super::hop::Hop; +use serde_json::Value; pub trait Entity { - /// The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string. fn get_id(&self) -> String; @@ -39,11 +37,9 @@ pub trait Entity { /// The date and time when the entity was last updated. fn get_updated_at(&self) -> DateTime; - -fn type_name(&self) -> &'static str; + fn type_name(&self) -> &'static str; } - #[allow(clippy::large_enum_variant)] #[derive(Debug, Clone, Serialize)] pub enum EntityEnum { @@ -70,11 +66,8 @@ pub enum EntityEnum { Wallet(Wallet), Withdrawal(Withdrawal), WithdrawalRequest(WithdrawalRequest), - } - - impl<'de> Deserialize<'de> for EntityEnum { fn deserialize(deserializer: D) -> Result where @@ -84,172 +77,151 @@ impl<'de> Deserialize<'de> for EntityEnum { if let Some(typename) = value.get("__typename").and_then(Value::as_str) { match typename { "Account" => { - let obj = Account::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = Account::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(EntityEnum::Account(obj)) - }, + } "ApiToken" => { - let obj = ApiToken::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = ApiToken::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(EntityEnum::ApiToken(obj)) - }, + } "Channel" => { - let obj = Channel::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = Channel::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(EntityEnum::Channel(obj)) - }, + } "ChannelClosingTransaction" => { - let obj = ChannelClosingTransaction::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = ChannelClosingTransaction::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(EntityEnum::ChannelClosingTransaction(obj)) - }, + } "ChannelOpeningTransaction" => { - let obj = ChannelOpeningTransaction::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = ChannelOpeningTransaction::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(EntityEnum::ChannelOpeningTransaction(obj)) - }, + } "ChannelSnapshot" => { - let obj = ChannelSnapshot::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = ChannelSnapshot::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(EntityEnum::ChannelSnapshot(obj)) - }, + } "Deposit" => { - let obj = Deposit::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = Deposit::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(EntityEnum::Deposit(obj)) - }, + } "GraphNode" => { - let obj = GraphNode::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = GraphNode::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(EntityEnum::GraphNode(obj)) - }, + } "Hop" => { - let obj = Hop::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = Hop::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(EntityEnum::Hop(obj)) - }, + } "IncomingPayment" => { - let obj = IncomingPayment::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = IncomingPayment::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(EntityEnum::IncomingPayment(obj)) - }, + } "IncomingPaymentAttempt" => { - let obj = IncomingPaymentAttempt::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = IncomingPaymentAttempt::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(EntityEnum::IncomingPaymentAttempt(obj)) - }, + } "Invoice" => { - let obj = Invoice::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = Invoice::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(EntityEnum::Invoice(obj)) - }, + } "LightsparkNodeWithOSK" => { - let obj = LightsparkNodeWithOSK::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = LightsparkNodeWithOSK::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(EntityEnum::LightsparkNodeWithOSK(obj)) - }, + } "LightsparkNodeWithRemoteSigning" => { - let obj = LightsparkNodeWithRemoteSigning::deserialize(value) - .map_err(|err| + let obj = + LightsparkNodeWithRemoteSigning::deserialize(value).map_err(|err| { serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + })?; Ok(EntityEnum::LightsparkNodeWithRemoteSigning(obj)) - }, + } "OutgoingPayment" => { - let obj = OutgoingPayment::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = OutgoingPayment::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(EntityEnum::OutgoingPayment(obj)) - }, + } "OutgoingPaymentAttempt" => { - let obj = OutgoingPaymentAttempt::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = OutgoingPaymentAttempt::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(EntityEnum::OutgoingPaymentAttempt(obj)) - }, + } "RoutingTransaction" => { - let obj = RoutingTransaction::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = RoutingTransaction::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(EntityEnum::RoutingTransaction(obj)) - }, + } "Signable" => { - let obj = Signable::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = Signable::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(EntityEnum::Signable(obj)) - }, + } "SignablePayload" => { - let obj = SignablePayload::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = SignablePayload::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(EntityEnum::SignablePayload(obj)) - }, + } "UmaInvitation" => { - let obj = UmaInvitation::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + 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)) - )?; + let obj = Wallet::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(EntityEnum::Wallet(obj)) - }, + } "Withdrawal" => { - let obj = Withdrawal::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = Withdrawal::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(EntityEnum::Withdrawal(obj)) - }, + } "WithdrawalRequest" => { - let obj = WithdrawalRequest::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = WithdrawalRequest::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(EntityEnum::WithdrawalRequest(obj)) - }, + } _ => Err(serde::de::Error::custom("unknown typename")), } } else { - Err(serde::de::Error::custom("missing __typename field on Entity")) + Err(serde::de::Error::custom( + "missing __typename field on Entity", + )) } } } - diff --git a/lightspark/src/objects/fail_htlcs_input.rs b/lightspark/src/objects/fail_htlcs_input.rs index 60bd9ef..5a05798 100644 --- a/lightspark/src/objects/fail_htlcs_input.rs +++ b/lightspark/src/objects/fail_htlcs_input.rs @@ -1,23 +1,11 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; - - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct FailHtlcsInput { - /// The id of invoice which the pending HTLCs that need to be failed are paying for. - pub invoice_id: String, /// Whether the invoice needs to be canceled after failing the htlcs. If yes, the invoice cannot be paid anymore. - pub cancel_invoice: bool, - } - - - - - diff --git a/lightspark/src/objects/fail_htlcs_output.rs b/lightspark/src/objects/fail_htlcs_output.rs index ff7681d..66c79fb 100644 --- a/lightspark/src/objects/fail_htlcs_output.rs +++ b/lightspark/src/objects/fail_htlcs_output.rs @@ -1,20 +1,13 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::types::entity_wrapper::EntityWrapper; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct FailHtlcsOutput { - - #[serde(rename = "fail_htlcs_output_invoice")] pub invoice: EntityWrapper, - } - - pub const FRAGMENT: &str = " fragment FailHtlcsOutputFragment on FailHtlcsOutput { __typename @@ -23,6 +16,3 @@ fragment FailHtlcsOutputFragment on FailHtlcsOutput { } } "; - - - diff --git a/lightspark/src/objects/fee_estimate.rs b/lightspark/src/objects/fee_estimate.rs index f1a78fe..fb6c449 100644 --- a/lightspark/src/objects/fee_estimate.rs +++ b/lightspark/src/objects/fee_estimate.rs @@ -1,24 +1,17 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::currency_amount::CurrencyAmount; +use serde::{Deserialize, Serialize}; /// This object represents the estimated L1 transaction fees for the Bitcoin network. Fee estimates are separated by potential confirmation speeds for settlement. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct FeeEstimate { - - - #[serde (rename = "fee_estimate_fee_fast")] + #[serde(rename = "fee_estimate_fee_fast")] pub fee_fast: CurrencyAmount, - - #[serde (rename = "fee_estimate_fee_min")] + #[serde(rename = "fee_estimate_fee_min")] pub fee_min: CurrencyAmount, - } - - pub const FRAGMENT: &str = " fragment FeeEstimateFragment on FeeEstimate { __typename @@ -40,6 +33,3 @@ fragment FeeEstimateFragment on FeeEstimate { } } "; - - - diff --git a/lightspark/src/objects/fund_node_input.rs b/lightspark/src/objects/fund_node_input.rs index 8dd2226..5c4ed5f 100644 --- a/lightspark/src/objects/fund_node_input.rs +++ b/lightspark/src/objects/fund_node_input.rs @@ -1,27 +1,11 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; - - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct FundNodeInput { - - - pub node_id: String, - - pub amount_sats: Option, - - pub funding_address: Option, - } - - - - - diff --git a/lightspark/src/objects/fund_node_output.rs b/lightspark/src/objects/fund_node_output.rs index 4cc67f2..eca2551 100644 --- a/lightspark/src/objects/fund_node_output.rs +++ b/lightspark/src/objects/fund_node_output.rs @@ -1,20 +1,13 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::currency_amount::CurrencyAmount; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct FundNodeOutput { - - - #[serde (rename = "fund_node_output_amount")] + #[serde(rename = "fund_node_output_amount")] pub amount: CurrencyAmount, - } - - pub const FRAGMENT: &str = " fragment FundNodeOutputFragment on FundNodeOutput { __typename @@ -28,6 +21,3 @@ fragment FundNodeOutputFragment on FundNodeOutput { } } "; - - - diff --git a/lightspark/src/objects/graph_node.rs b/lightspark/src/objects/graph_node.rs index 019fcbb..297200d 100644 --- a/lightspark/src/objects/graph_node.rs +++ b/lightspark/src/objects/graph_node.rs @@ -1,26 +1,24 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; -use serde_json::Value; -use crate::objects::entity::Entity; use crate::error::Error; -use crate::types::get_entity::GetEntity; -use std::collections::HashMap; -use std::vec::Vec; use crate::objects::bitcoin_network::BitcoinNetwork; -use crate::objects::node_to_addresses_connection::NodeToAddressesConnection; +use crate::objects::entity::Entity; 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::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; /// This object represents a node that exists on the Lightning Network, including nodes not managed by Lightspark. You can retrieve this object to get publicly available information about any node on the Lightning Network. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct GraphNode { - /// The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string. - #[serde (rename = "graph_node_id")] + #[serde(rename = "graph_node_id")] pub id: String, /// The date and time when the entity was first created. @@ -32,38 +30,35 @@ pub struct GraphNode { pub updated_at: DateTime, /// A name that identifies the node. It has no importance in terms of operating the node, it is just a way to identify and search for commercial services or popular nodes. This alias can be changed at any time by the node operator. - #[serde (rename = "graph_node_alias")] + #[serde(rename = "graph_node_alias")] pub alias: Option, /// The Bitcoin Network this node is deployed in. - #[serde (rename = "graph_node_bitcoin_network")] + #[serde(rename = "graph_node_bitcoin_network")] pub bitcoin_network: BitcoinNetwork, /// A hexadecimal string that describes a color. For example "#000000" is black, "#FFFFFF" is white. It has no importance in terms of operating the node, it is just a way to visually differentiate nodes. That color can be changed at any time by the node operator. - #[serde (rename = "graph_node_color")] + #[serde(rename = "graph_node_color")] pub color: Option, /// A summary metric used to capture how well positioned a node is to send, receive, or route transactions efficiently. Maximizing a node's conductivity helps a node’s transactions to be capital efficient. The value is an integer ranging between 0 and 10 (bounds included). - #[serde (rename = "graph_node_conductivity")] + #[serde(rename = "graph_node_conductivity")] pub conductivity: Option, /// The name of this node in the network. It will be the most human-readable option possible, depending on the data available for this node. - #[serde (rename = "graph_node_display_name")] + #[serde(rename = "graph_node_display_name")] pub display_name: String, /// The public key of this node. It acts as a unique identifier of this node in the Lightning Network. - #[serde (rename = "graph_node_public_key")] + #[serde(rename = "graph_node_public_key")] pub public_key: Option, /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl Node for GraphNode { - /// A name that identifies the node. It has no importance in terms of operating the node, it is just a way to identify and search for commercial services or popular nodes. This alias can be changed at any time by the node operator. fn get_alias(&self) -> Option { self.alias.clone() @@ -94,16 +89,12 @@ impl Node for GraphNode { self.public_key.clone() } - fn type_name(&self) -> &'static str { "GraphNode" } } - - impl Entity for GraphNode { - /// 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() @@ -119,16 +110,15 @@ impl Entity for GraphNode { self.updated_at } - fn type_name(&self) -> &'static str { "GraphNode" } } - impl GetEntity for GraphNode { fn get_entity_query() -> String { - format!(" + format!( + " query GetEntity($id: ID!) {{ entity(id: $id) {{ ... on GraphNode {{ @@ -137,12 +127,12 @@ impl GetEntity for GraphNode { }} }} - {}", FRAGMENT) - } + {}", + FRAGMENT + ) + } } - - pub const FRAGMENT: &str = " fragment GraphNodeFragment on GraphNode { __typename @@ -158,11 +148,13 @@ fragment GraphNodeFragment on GraphNode { } "; - impl GraphNode { - - - pub async fn get_addresses(&self, requester:&impl GraphQLRequester, first: Option, types: Option>) -> Result { + pub async fn get_addresses( + &self, + requester: &impl GraphQLRequester, + first: Option, + types: Option>, + ) -> Result { let query = "query FetchNodeToAddressesConnection($entity_id: ID!, $first: Int, $types: [NodeAddressType!]) { entity(id: $entity_id) { ... on GraphNode { @@ -183,12 +175,10 @@ impl GraphNode { variables.insert("first", first.into()); variables.insert("types", types.into()); - let value = serde_json::to_value(variables).map_err(|err| Error::ConversionError(err))?; let result = requester.execute_graphql(&query, Some(value)).await?; let json = result["entity"]["addresses"].clone(); let result = serde_json::from_value(json).map_err(|err| Error::JsonError(err))?; Ok(result) } - } diff --git a/lightspark/src/objects/hop.rs b/lightspark/src/objects/hop.rs index 43daf47..762f8d5 100644 --- a/lightspark/src/objects/hop.rs +++ b/lightspark/src/objects/hop.rs @@ -1,19 +1,17 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::currency_amount::CurrencyAmount; -use crate::types::entity_wrapper::EntityWrapper; use crate::objects::entity::Entity; -use crate::types::get_entity::GetEntity; use crate::types::custom_date_formats::custom_date_format; +use crate::types::entity_wrapper::EntityWrapper; +use crate::types::get_entity::GetEntity; use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; /// This object represents a specific node that existed on a particular payment route. You can retrieve this object to get information about a node on a particular payment path and all payment-relevant information for that node. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct Hop { - /// The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string. - #[serde (rename = "hop_id")] + #[serde(rename = "hop_id")] pub id: String, /// The date and time when the entity was first created. @@ -29,34 +27,31 @@ pub struct Hop { pub destination: Option, /// The zero-based index position of this hop in the path - #[serde (rename = "hop_index")] + #[serde(rename = "hop_index")] pub index: i64, /// The public key of the node to which the hop is bound. - #[serde (rename = "hop_public_key")] + #[serde(rename = "hop_public_key")] pub public_key: Option, /// The amount that is to be forwarded to the destination node. - #[serde (rename = "hop_amount_to_forward")] + #[serde(rename = "hop_amount_to_forward")] pub amount_to_forward: Option, /// The fees to be collected by the source node for forwarding the payment over the hop. - #[serde (rename = "hop_fee")] + #[serde(rename = "hop_fee")] pub fee: Option, /// The block height at which an unsettled HTLC is considered expired. - #[serde (rename = "hop_expiry_block_height")] + #[serde(rename = "hop_expiry_block_height")] pub expiry_block_height: Option, /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl Entity for Hop { - /// 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() @@ -72,16 +67,15 @@ impl Entity for Hop { self.updated_at } - fn type_name(&self) -> &'static str { "Hop" } } - impl GetEntity for Hop { fn get_entity_query() -> String { - format!(" + format!( + " query GetEntity($id: ID!) {{ entity(id: $id) {{ ... on Hop {{ @@ -90,12 +84,12 @@ impl GetEntity for Hop { }} }} - {}", FRAGMENT) - } + {}", + FRAGMENT + ) + } } - - pub const FRAGMENT: &str = " fragment HopFragment on Hop { __typename @@ -126,6 +120,3 @@ fragment HopFragment on Hop { hop_expiry_block_height: expiry_block_height } "; - - - diff --git a/lightspark/src/objects/htlc_attempt_failure_code.rs b/lightspark/src/objects/htlc_attempt_failure_code.rs index 9619247..2c96122 100644 --- a/lightspark/src/objects/htlc_attempt_failure_code.rs +++ b/lightspark/src/objects/htlc_attempt_failure_code.rs @@ -1,4 +1,3 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -7,91 +6,89 @@ use std::fmt; /// This is an enum representing a particular reason why an htlc sent over the Lightning Network may have failed. #[derive(Debug, Clone, Deserialize, Serialize)] pub enum HtlcAttemptFailureCode { - - #[serde(rename="INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS")] + #[serde(rename = "INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS")] IncorrectOrUnknownPaymentDetails, - #[serde(rename="INCORRECT_PAYMENT_AMOUNT")] + #[serde(rename = "INCORRECT_PAYMENT_AMOUNT")] IncorrectPaymentAmount, - #[serde(rename="FINAL_INCORRECT_CLTV_EXPIRY")] + #[serde(rename = "FINAL_INCORRECT_CLTV_EXPIRY")] FinalIncorrectCltvExpiry, - #[serde(rename="FINAL_INCORRECT_HTLC_AMOUNT")] + #[serde(rename = "FINAL_INCORRECT_HTLC_AMOUNT")] FinalIncorrectHtlcAmount, - #[serde(rename="FINAL_EXPIRY_TOO_SOON")] + #[serde(rename = "FINAL_EXPIRY_TOO_SOON")] FinalExpiryTooSoon, - #[serde(rename="INVALID_REALM")] + #[serde(rename = "INVALID_REALM")] InvalidRealm, - #[serde(rename="EXPIRY_TOO_SOON")] + #[serde(rename = "EXPIRY_TOO_SOON")] ExpiryTooSoon, - #[serde(rename="INVALID_ONION_VERSION")] + #[serde(rename = "INVALID_ONION_VERSION")] InvalidOnionVersion, - #[serde(rename="INVALID_ONION_HMAC")] + #[serde(rename = "INVALID_ONION_HMAC")] InvalidOnionHmac, - #[serde(rename="INVALID_ONION_KEY")] + #[serde(rename = "INVALID_ONION_KEY")] InvalidOnionKey, - #[serde(rename="AMOUNT_BELOW_MINIMUM")] + #[serde(rename = "AMOUNT_BELOW_MINIMUM")] AmountBelowMinimum, - #[serde(rename="FEE_INSUFFICIENT")] + #[serde(rename = "FEE_INSUFFICIENT")] FeeInsufficient, - #[serde(rename="INCORRECT_CLTV_EXPIRY")] + #[serde(rename = "INCORRECT_CLTV_EXPIRY")] IncorrectCltvExpiry, - #[serde(rename="CHANNEL_DISABLED")] + #[serde(rename = "CHANNEL_DISABLED")] ChannelDisabled, - #[serde(rename="TEMPORARY_CHANNEL_FAILURE")] + #[serde(rename = "TEMPORARY_CHANNEL_FAILURE")] TemporaryChannelFailure, - #[serde(rename="REQUIRED_NODE_FEATURE_MISSING")] + #[serde(rename = "REQUIRED_NODE_FEATURE_MISSING")] RequiredNodeFeatureMissing, - #[serde(rename="REQUIRED_CHANNEL_FEATURE_MISSING")] + #[serde(rename = "REQUIRED_CHANNEL_FEATURE_MISSING")] RequiredChannelFeatureMissing, - #[serde(rename="UNKNOWN_NEXT_PEER")] + #[serde(rename = "UNKNOWN_NEXT_PEER")] UnknownNextPeer, - #[serde(rename="TEMPORARY_NODE_FAILURE")] + #[serde(rename = "TEMPORARY_NODE_FAILURE")] TemporaryNodeFailure, - #[serde(rename="PERMANENT_NODE_FAILURE")] + #[serde(rename = "PERMANENT_NODE_FAILURE")] PermanentNodeFailure, - #[serde(rename="PERMANENT_CHANNEL_FAILURE")] + #[serde(rename = "PERMANENT_CHANNEL_FAILURE")] PermanentChannelFailure, - #[serde(rename="EXPIRY_TOO_FAR")] + #[serde(rename = "EXPIRY_TOO_FAR")] ExpiryTooFar, - #[serde(rename="MPP_TIMEOUT")] + #[serde(rename = "MPP_TIMEOUT")] MppTimeout, - #[serde(rename="INVALID_ONION_PAYLOAD")] + #[serde(rename = "INVALID_ONION_PAYLOAD")] InvalidOnionPayload, - #[serde(rename="INVALID_ONION_BLINDING")] + #[serde(rename = "INVALID_ONION_BLINDING")] InvalidOnionBlinding, - #[serde(rename="INTERNAL_FAILURE")] + #[serde(rename = "INTERNAL_FAILURE")] InternalFailure, - #[serde(rename="UNKNOWN_FAILURE")] + #[serde(rename = "UNKNOWN_FAILURE")] UnknownFailure, - #[serde(rename="UNREADABLE_FAILURE")] + #[serde(rename = "UNREADABLE_FAILURE")] UnreadableFailure, - } impl Into for HtlcAttemptFailureCode { @@ -103,7 +100,9 @@ impl Into for HtlcAttemptFailureCode { impl fmt::Display for HtlcAttemptFailureCode { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { - Self::IncorrectOrUnknownPaymentDetails => write!(f, "INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS"), + Self::IncorrectOrUnknownPaymentDetails => { + write!(f, "INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS") + } Self::IncorrectPaymentAmount => write!(f, "INCORRECT_PAYMENT_AMOUNT"), Self::FinalIncorrectCltvExpiry => write!(f, "FINAL_INCORRECT_CLTV_EXPIRY"), Self::FinalIncorrectHtlcAmount => write!(f, "FINAL_INCORRECT_HTLC_AMOUNT"), @@ -131,8 +130,6 @@ impl fmt::Display for HtlcAttemptFailureCode { Self::InternalFailure => write!(f, "INTERNAL_FAILURE"), Self::UnknownFailure => write!(f, "UNKNOWN_FAILURE"), Self::UnreadableFailure => write!(f, "UNREADABLE_FAILURE"), - } } } - diff --git a/lightspark/src/objects/id_and_signature.rs b/lightspark/src/objects/id_and_signature.rs index 00093e5..bca2cba 100644 --- a/lightspark/src/objects/id_and_signature.rs +++ b/lightspark/src/objects/id_and_signature.rs @@ -1,23 +1,11 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; - - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct IdAndSignature { - /// The id of the message. - pub id: String, /// The signature of the message. - pub signature: String, - } - - - - - diff --git a/lightspark/src/objects/incentives_ineligibility_reason.rs b/lightspark/src/objects/incentives_ineligibility_reason.rs index 44e7612..216bada 100644 --- a/lightspark/src/objects/incentives_ineligibility_reason.rs +++ b/lightspark/src/objects/incentives_ineligibility_reason.rs @@ -1,4 +1,3 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -9,29 +8,28 @@ use std::fmt; pub enum IncentivesIneligibilityReason { /// This invitation is not eligible for incentives because it has been created outside of the incentives flow. - #[serde(rename="DISABLED")] + #[serde(rename = "DISABLED")] Disabled, /// This invitation is not eligible for incentives because the sender is not eligible. - #[serde(rename="SENDER_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")] + #[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")] + #[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")] + #[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")] + #[serde(rename = "NOT_CROSS_BORDER")] NotCrossBorder, - } impl Into for IncentivesIneligibilityReason { @@ -49,8 +47,6 @@ impl fmt::Display for IncentivesIneligibilityReason { 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 index 708548e..874317d 100644 --- a/lightspark/src/objects/incentives_status.rs +++ b/lightspark/src/objects/incentives_status.rs @@ -1,4 +1,3 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -9,17 +8,16 @@ use std::fmt; pub enum IncentivesStatus { /// The invitation is eligible for incentives in its current state. When it is claimed, we will reassess. - #[serde(rename="PENDING")] + #[serde(rename = "PENDING")] Pending, /// The incentives have been validated. - #[serde(rename="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")] + #[serde(rename = "INELIGIBLE")] Ineligible, - } impl Into for IncentivesStatus { @@ -34,8 +32,6 @@ impl fmt::Display for IncentivesStatus { Self::Pending => write!(f, "PENDING"), Self::Validated => write!(f, "VALIDATED"), Self::Ineligible => write!(f, "INELIGIBLE"), - } } } - diff --git a/lightspark/src/objects/incoming_payment.rs b/lightspark/src/objects/incoming_payment.rs index abe0f57..330ae00 100644 --- a/lightspark/src/objects/incoming_payment.rs +++ b/lightspark/src/objects/incoming_payment.rs @@ -1,31 +1,29 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; +use crate::error::Error; use crate::objects::currency_amount::CurrencyAmount; -use serde_json::Value; -use crate::objects::incoming_payment_to_attempts_connection::IncomingPaymentToAttemptsConnection; -use crate::types::entity_wrapper::EntityWrapper; -use crate::objects::transaction_status::TransactionStatus; use crate::objects::entity::Entity; -use crate::error::Error; -use crate::types::get_entity::GetEntity; -use std::vec::Vec; -use crate::types::custom_date_formats::custom_date_format_option; -use std::collections::HashMap; use crate::objects::incoming_payment_attempt_status::IncomingPaymentAttemptStatus; -use crate::objects::transaction::Transaction; -use crate::objects::post_transaction_data::PostTransactionData; +use crate::objects::incoming_payment_to_attempts_connection::IncomingPaymentToAttemptsConnection; use crate::objects::lightning_transaction::LightningTransaction; +use crate::objects::post_transaction_data::PostTransactionData; +use crate::objects::transaction::Transaction; +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 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; /// This object represents any payment sent to a Lightspark node on the Lightning Network. You can retrieve this object to receive payment related information about a specific payment received by a Lightspark node. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct IncomingPayment { - /// The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string. - #[serde (rename = "incoming_payment_id")] + #[serde(rename = "incoming_payment_id")] pub id: String, /// The date and time when this transaction was initiated. @@ -37,23 +35,26 @@ pub struct IncomingPayment { pub updated_at: DateTime, /// The current status of this transaction. - #[serde (rename = "incoming_payment_status")] + #[serde(rename = "incoming_payment_status")] pub status: TransactionStatus, /// The date and time when this transaction was completed or failed. - #[serde(with = "custom_date_format_option", rename = "incoming_payment_resolved_at")] + #[serde( + with = "custom_date_format_option", + rename = "incoming_payment_resolved_at" + )] pub resolved_at: Option>, /// The amount of money involved in this transaction. - #[serde (rename = "incoming_payment_amount")] + #[serde(rename = "incoming_payment_amount")] pub amount: CurrencyAmount, /// The hash of this transaction, so it can be uniquely identified on the Lightning Network. - #[serde (rename = "incoming_payment_transaction_hash")] + #[serde(rename = "incoming_payment_transaction_hash")] pub transaction_hash: Option, /// Whether this payment is an UMA payment or not. NOTE: this field is only set if the invoice that is being paid has been created using the recommended `create_uma_invoice` function. - #[serde (rename = "incoming_payment_is_uma")] + #[serde(rename = "incoming_payment_is_uma")] pub is_uma: bool, /// The recipient Lightspark node this payment was sent to. @@ -65,32 +66,25 @@ pub struct IncomingPayment { pub payment_request: Option, /// The post transaction data which can be used in KYT payment registration. - #[serde (rename = "incoming_payment_uma_post_transaction_data")] + #[serde(rename = "incoming_payment_uma_post_transaction_data")] pub uma_post_transaction_data: Option>, /// Whether the payment is made from the same node. - #[serde (rename = "incoming_payment_is_internal_payment")] + #[serde(rename = "incoming_payment_is_internal_payment")] pub is_internal_payment: bool, /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl LightningTransaction for IncomingPayment { - - fn type_name(&self) -> &'static str { "IncomingPayment" } } - - impl Transaction for IncomingPayment { - /// The current status of this transaction. fn get_status(&self) -> TransactionStatus { self.status.clone() @@ -111,16 +105,12 @@ impl Transaction for IncomingPayment { self.transaction_hash.clone() } - fn type_name(&self) -> &'static str { "IncomingPayment" } } - - impl Entity for IncomingPayment { - /// 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() @@ -136,16 +126,15 @@ impl Entity for IncomingPayment { self.updated_at } - fn type_name(&self) -> &'static str { "IncomingPayment" } } - impl GetEntity for IncomingPayment { fn get_entity_query() -> String { - format!(" + format!( + " query GetEntity($id: ID!) {{ entity(id: $id) {{ ... on IncomingPayment {{ @@ -154,12 +143,12 @@ impl GetEntity for IncomingPayment { }} }} - {}", FRAGMENT) - } + {}", + FRAGMENT + ) + } } - - pub const FRAGMENT: &str = " fragment IncomingPaymentFragment on IncomingPayment { __typename @@ -200,11 +189,14 @@ fragment IncomingPaymentFragment on IncomingPayment { } "; - impl IncomingPayment { - - - pub async fn get_attempts(&self, requester:&impl GraphQLRequester, first: Option, statuses: Option>, after: Option) -> Result { + pub async fn get_attempts( + &self, + requester: &impl GraphQLRequester, + first: Option, + statuses: Option>, + after: Option, + ) -> Result { let query = "query FetchIncomingPaymentToAttemptsConnection($entity_id: ID!, $first: Int, $statuses: [IncomingPaymentAttemptStatus!], $after: String) { entity(id: $entity_id) { ... on IncomingPayment { @@ -247,12 +239,10 @@ impl IncomingPayment { variables.insert("statuses", statuses.into()); variables.insert("after", after.into()); - let value = serde_json::to_value(variables).map_err(|err| Error::ConversionError(err))?; let result = requester.execute_graphql(&query, Some(value)).await?; let json = result["entity"]["attempts"].clone(); let result = serde_json::from_value(json).map_err(|err| Error::JsonError(err))?; Ok(result) } - } diff --git a/lightspark/src/objects/incoming_payment_attempt.rs b/lightspark/src/objects/incoming_payment_attempt.rs index b349929..13af87a 100644 --- a/lightspark/src/objects/incoming_payment_attempt.rs +++ b/lightspark/src/objects/incoming_payment_attempt.rs @@ -1,41 +1,48 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::currency_amount::CurrencyAmount; -use crate::types::entity_wrapper::EntityWrapper; use crate::objects::entity::Entity; -use crate::types::get_entity::GetEntity; -use crate::types::custom_date_formats::custom_date_format_option; use crate::objects::incoming_payment_attempt_status::IncomingPaymentAttemptStatus; use crate::types::custom_date_formats::custom_date_format; +use crate::types::custom_date_formats::custom_date_format_option; +use crate::types::entity_wrapper::EntityWrapper; +use crate::types::get_entity::GetEntity; use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; /// This object represents any attempted payment sent to a Lightspark node on the Lightning Network. You can retrieve this object to receive payment related information about a specific incoming payment attempt. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct IncomingPaymentAttempt { - /// The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string. - #[serde (rename = "incoming_payment_attempt_id")] + #[serde(rename = "incoming_payment_attempt_id")] pub id: String, /// The date and time when the entity was first created. - #[serde(with = "custom_date_format", rename = "incoming_payment_attempt_created_at")] + #[serde( + with = "custom_date_format", + rename = "incoming_payment_attempt_created_at" + )] pub created_at: DateTime, /// The date and time when the entity was last updated. - #[serde(with = "custom_date_format", rename = "incoming_payment_attempt_updated_at")] + #[serde( + with = "custom_date_format", + rename = "incoming_payment_attempt_updated_at" + )] pub updated_at: DateTime, /// The status of the incoming payment attempt. - #[serde (rename = "incoming_payment_attempt_status")] + #[serde(rename = "incoming_payment_attempt_status")] pub status: IncomingPaymentAttemptStatus, /// The time the incoming payment attempt failed or succeeded. - #[serde(with = "custom_date_format_option", rename = "incoming_payment_attempt_resolved_at")] + #[serde( + with = "custom_date_format_option", + rename = "incoming_payment_attempt_resolved_at" + )] pub resolved_at: Option>, /// The total amount of that was attempted to send. - #[serde (rename = "incoming_payment_attempt_amount")] + #[serde(rename = "incoming_payment_attempt_amount")] pub amount: CurrencyAmount, /// The channel this attempt was made on. @@ -45,12 +52,9 @@ pub struct IncomingPaymentAttempt { /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl Entity for IncomingPaymentAttempt { - /// 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() @@ -66,16 +70,15 @@ impl Entity for IncomingPaymentAttempt { self.updated_at } - fn type_name(&self) -> &'static str { "IncomingPaymentAttempt" } } - impl GetEntity for IncomingPaymentAttempt { fn get_entity_query() -> String { - format!(" + format!( + " query GetEntity($id: ID!) {{ entity(id: $id) {{ ... on IncomingPaymentAttempt {{ @@ -84,12 +87,12 @@ impl GetEntity for IncomingPaymentAttempt { }} }} - {}", FRAGMENT) - } + {}", + FRAGMENT + ) + } } - - pub const FRAGMENT: &str = " fragment IncomingPaymentAttemptFragment on IncomingPaymentAttempt { __typename @@ -111,6 +114,3 @@ fragment IncomingPaymentAttemptFragment on IncomingPaymentAttempt { } } "; - - - diff --git a/lightspark/src/objects/incoming_payment_attempt_status.rs b/lightspark/src/objects/incoming_payment_attempt_status.rs index 04a40a4..7134229 100644 --- a/lightspark/src/objects/incoming_payment_attempt_status.rs +++ b/lightspark/src/objects/incoming_payment_attempt_status.rs @@ -1,4 +1,3 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -7,19 +6,17 @@ use std::fmt; /// This is an enum that enumerates all potential statuses for an incoming payment attempt. #[derive(Debug, Clone, Deserialize, Serialize)] pub enum IncomingPaymentAttemptStatus { - - #[serde(rename="ACCEPTED")] + #[serde(rename = "ACCEPTED")] Accepted, - #[serde(rename="SETTLED")] + #[serde(rename = "SETTLED")] Settled, - #[serde(rename="CANCELED")] + #[serde(rename = "CANCELED")] Canceled, - #[serde(rename="UNKNOWN")] + #[serde(rename = "UNKNOWN")] Unknown, - } impl Into for IncomingPaymentAttemptStatus { @@ -35,8 +32,6 @@ impl fmt::Display for IncomingPaymentAttemptStatus { Self::Settled => write!(f, "SETTLED"), Self::Canceled => write!(f, "CANCELED"), Self::Unknown => write!(f, "UNKNOWN"), - } } } - diff --git a/lightspark/src/objects/incoming_payment_to_attempts_connection.rs b/lightspark/src/objects/incoming_payment_to_attempts_connection.rs index 9b3f43b..ccf7bc7 100644 --- a/lightspark/src/objects/incoming_payment_to_attempts_connection.rs +++ b/lightspark/src/objects/incoming_payment_to_attempts_connection.rs @@ -1,36 +1,31 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; -use std::vec::Vec; use crate::objects::connection::Connection; -use crate::objects::page_info::PageInfo; use crate::objects::incoming_payment_attempt::IncomingPaymentAttempt; +use crate::objects::page_info::PageInfo; +use serde::{Deserialize, Serialize}; +use std::vec::Vec; /// The connection from incoming payment to all attempts. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct IncomingPaymentToAttemptsConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). - #[serde (rename = "incoming_payment_to_attempts_connection_count")] + #[serde(rename = "incoming_payment_to_attempts_connection_count")] pub count: i64, /// An object that holds pagination information about the objects in this connection. - #[serde (rename = "incoming_payment_to_attempts_connection_page_info")] + #[serde(rename = "incoming_payment_to_attempts_connection_page_info")] pub page_info: PageInfo, /// The incoming payment attempts for the current page of this connection. - #[serde (rename = "incoming_payment_to_attempts_connection_entities")] + #[serde(rename = "incoming_payment_to_attempts_connection_entities")] pub entities: Vec, /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl Connection for IncomingPaymentToAttemptsConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). fn get_count(&self) -> i64 { self.count @@ -41,15 +36,11 @@ impl Connection for IncomingPaymentToAttemptsConnection { self.page_info.clone() } - fn type_name(&self) -> &'static str { "IncomingPaymentToAttemptsConnection" } } - - - pub const FRAGMENT: &str = " fragment IncomingPaymentToAttemptsConnectionFragment on IncomingPaymentToAttemptsConnection { __typename @@ -66,6 +57,3 @@ fragment IncomingPaymentToAttemptsConnectionFragment on IncomingPaymentToAttempt } } "; - - - diff --git a/lightspark/src/objects/incoming_payments_for_invoice_query_input.rs b/lightspark/src/objects/incoming_payments_for_invoice_query_input.rs index f94f137..ded744d 100644 --- a/lightspark/src/objects/incoming_payments_for_invoice_query_input.rs +++ b/lightspark/src/objects/incoming_payments_for_invoice_query_input.rs @@ -1,24 +1,12 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::transaction_status::TransactionStatus; +use serde::{Deserialize, Serialize}; use std::vec::Vec; - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct IncomingPaymentsForInvoiceQueryInput { - - - pub invoice_id: String, /// An optional filter to only query outgoing payments of given statuses. - pub statuses: Option>, - } - - - - - diff --git a/lightspark/src/objects/incoming_payments_for_invoice_query_output.rs b/lightspark/src/objects/incoming_payments_for_invoice_query_output.rs index 735688e..0573e5c 100644 --- a/lightspark/src/objects/incoming_payments_for_invoice_query_output.rs +++ b/lightspark/src/objects/incoming_payments_for_invoice_query_output.rs @@ -1,21 +1,14 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::objects::incoming_payment::IncomingPayment; use serde::{Deserialize, Serialize}; use std::vec::Vec; -use crate::objects::incoming_payment::IncomingPayment; - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct IncomingPaymentsForInvoiceQueryOutput { - - - #[serde (rename = "incoming_payments_for_invoice_query_output_payments")] + #[serde(rename = "incoming_payments_for_invoice_query_output_payments")] pub payments: Vec, - } - - pub const FRAGMENT: &str = " fragment IncomingPaymentsForInvoiceQueryOutputFragment on IncomingPaymentsForInvoiceQueryOutput { __typename @@ -58,6 +51,3 @@ fragment IncomingPaymentsForInvoiceQueryOutputFragment on IncomingPaymentsForInv } } "; - - - diff --git a/lightspark/src/objects/incoming_payments_for_payment_hash_query_input.rs b/lightspark/src/objects/incoming_payments_for_payment_hash_query_input.rs index b0f1b05..0fdb899 100644 --- a/lightspark/src/objects/incoming_payments_for_payment_hash_query_input.rs +++ b/lightspark/src/objects/incoming_payments_for_payment_hash_query_input.rs @@ -1,24 +1,13 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::transaction_status::TransactionStatus; +use serde::{Deserialize, Serialize}; use std::vec::Vec; - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct IncomingPaymentsForPaymentHashQueryInput { - /// The 32-byte hash of the payment preimage for which to fetch payments - pub payment_hash: String, /// An optional filter to only query incoming payments of given statuses. - pub statuses: Option>, - } - - - - - diff --git a/lightspark/src/objects/incoming_payments_for_payment_hash_query_output.rs b/lightspark/src/objects/incoming_payments_for_payment_hash_query_output.rs index d7bbe50..7993c76 100644 --- a/lightspark/src/objects/incoming_payments_for_payment_hash_query_output.rs +++ b/lightspark/src/objects/incoming_payments_for_payment_hash_query_output.rs @@ -1,21 +1,14 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::objects::incoming_payment::IncomingPayment; use serde::{Deserialize, Serialize}; use std::vec::Vec; -use crate::objects::incoming_payment::IncomingPayment; - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct IncomingPaymentsForPaymentHashQueryOutput { - - - #[serde (rename = "incoming_payments_for_payment_hash_query_output_payments")] + #[serde(rename = "incoming_payments_for_payment_hash_query_output_payments")] pub payments: Vec, - } - - pub const FRAGMENT: &str = " fragment IncomingPaymentsForPaymentHashQueryOutputFragment on IncomingPaymentsForPaymentHashQueryOutput { __typename @@ -24,6 +17,3 @@ fragment IncomingPaymentsForPaymentHashQueryOutputFragment on IncomingPaymentsFo } } "; - - - diff --git a/lightspark/src/objects/invoice.rs b/lightspark/src/objects/invoice.rs index 6ee451c..fd80bef 100644 --- a/lightspark/src/objects/invoice.rs +++ b/lightspark/src/objects/invoice.rs @@ -1,22 +1,20 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::currency_amount::CurrencyAmount; use crate::objects::entity::Entity; -use crate::objects::payment_request_status::PaymentRequestStatus; -use crate::types::get_entity::GetEntity; +use crate::objects::invoice_data::InvoiceData; use crate::objects::payment_request::PaymentRequest; -use crate::types::custom_date_formats::custom_date_format; use crate::objects::payment_request_data::PaymentRequestData; +use crate::objects::payment_request_status::PaymentRequestStatus; +use crate::types::custom_date_formats::custom_date_format; +use crate::types::get_entity::GetEntity; use chrono::{DateTime, Utc}; -use crate::objects::invoice_data::InvoiceData; +use serde::{Deserialize, Serialize}; /// This object represents a BOLT #11 invoice (https://github.com/lightning/bolts/blob/master/11-payment-encoding.md) created by a Lightspark Node. You can retrieve this object to receive relevant payment information for a specific invoice generated by a Lightspark node. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct Invoice { - /// The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string. - #[serde (rename = "invoice_id")] + #[serde(rename = "invoice_id")] pub id: String, /// The date and time when the entity was first created. @@ -28,34 +26,31 @@ pub struct Invoice { pub updated_at: DateTime, /// The details of the invoice. - #[serde (rename = "invoice_data")] + #[serde(rename = "invoice_data")] pub data: InvoiceData, /// The status of the payment request. - #[serde (rename = "invoice_status")] + #[serde(rename = "invoice_status")] pub status: PaymentRequestStatus, /// The total amount that has been paid to this invoice. - #[serde (rename = "invoice_amount_paid")] + #[serde(rename = "invoice_amount_paid")] pub amount_paid: Option, /// Whether this invoice is an UMA invoice or not. NOTE: this field is only set if the invoice was created using the recommended `create_uma_invoice` function. - #[serde (rename = "invoice_is_uma")] + #[serde(rename = "invoice_is_uma")] pub is_uma: Option, /// Whether this invoice is an LNURL invoice or not. NOTE: this field is only set if the invoice was created using the recommended `create_lnurl_invoice` function. - #[serde (rename = "invoice_is_lnurl")] + #[serde(rename = "invoice_is_lnurl")] pub is_lnurl: Option, /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl PaymentRequest for Invoice { - /// The details of the payment request. fn get_data(&self) -> &dyn PaymentRequestData { &self.data @@ -66,16 +61,12 @@ impl PaymentRequest for Invoice { self.status.clone() } - fn type_name(&self) -> &'static str { "Invoice" } } - - impl Entity for Invoice { - /// 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() @@ -91,16 +82,15 @@ impl Entity for Invoice { self.updated_at } - fn type_name(&self) -> &'static str { "Invoice" } } - impl GetEntity for Invoice { fn get_entity_query() -> String { - format!(" + format!( + " query GetEntity($id: ID!) {{ entity(id: $id) {{ ... on Invoice {{ @@ -109,12 +99,12 @@ impl GetEntity for Invoice { }} }} - {}", FRAGMENT) - } + {}", + FRAGMENT + ) + } } - - pub const FRAGMENT: &str = " fragment InvoiceFragment on Invoice { __typename @@ -425,6 +415,3 @@ fragment InvoiceFragment on Invoice { invoice_is_lnurl: is_lnurl } "; - - - diff --git a/lightspark/src/objects/invoice_data.rs b/lightspark/src/objects/invoice_data.rs index 555aaa6..7da3702 100644 --- a/lightspark/src/objects/invoice_data.rs +++ b/lightspark/src/objects/invoice_data.rs @@ -1,32 +1,28 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; -use crate::objects::currency_amount::CurrencyAmount; -use crate::objects::node::NodeEnum; use crate::objects::bitcoin_network::BitcoinNetwork; +use crate::objects::currency_amount::CurrencyAmount; use crate::objects::node::Node; -use crate::types::custom_date_formats::custom_date_format; +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}; +use serde::{Deserialize, Serialize}; /// 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)] pub struct InvoiceData { - - - #[serde (rename = "invoice_data_encoded_payment_request")] + #[serde(rename = "invoice_data_encoded_payment_request")] pub encoded_payment_request: String, - - #[serde (rename = "invoice_data_bitcoin_network")] + #[serde(rename = "invoice_data_bitcoin_network")] pub bitcoin_network: BitcoinNetwork, /// The payment hash of this invoice. - #[serde (rename = "invoice_data_payment_hash")] + #[serde(rename = "invoice_data_payment_hash")] pub payment_hash: String, /// The requested amount in this invoice. If it is equal to 0, the sender should choose the amount to send. - #[serde (rename = "invoice_data_amount")] + #[serde(rename = "invoice_data_amount")] pub amount: CurrencyAmount, /// The date and time when this invoice was created. @@ -38,41 +34,32 @@ pub struct InvoiceData { pub expires_at: DateTime, /// A short, UTF-8 encoded, description of the purpose of this invoice. - #[serde (rename = "invoice_data_memo")] + #[serde(rename = "invoice_data_memo")] pub memo: Option, /// The lightning node that will be paid when fulfilling this invoice. - #[serde (rename = "invoice_data_destination")] + #[serde(rename = "invoice_data_destination")] pub destination: NodeEnum, /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl PaymentRequestData for InvoiceData { - - fn get_encoded_payment_request(&self) -> String { self.encoded_payment_request.clone() } - fn get_bitcoin_network(&self) -> BitcoinNetwork { self.bitcoin_network.clone() } - fn type_name(&self) -> &'static str { "InvoiceData" } } - - - pub const FRAGMENT: &str = " fragment InvoiceDataFragment on InvoiceData { __typename @@ -366,6 +353,3 @@ fragment InvoiceDataFragment on InvoiceData { } } "; - - - diff --git a/lightspark/src/objects/invoice_for_payment_hash_input.rs b/lightspark/src/objects/invoice_for_payment_hash_input.rs index fbc7232..d460cc7 100644 --- a/lightspark/src/objects/invoice_for_payment_hash_input.rs +++ b/lightspark/src/objects/invoice_for_payment_hash_input.rs @@ -1,19 +1,8 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; - - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct InvoiceForPaymentHashInput { - /// The 32-byte hash of the payment preimage for which to fetch an invoice. - pub payment_hash: String, - } - - - - - diff --git a/lightspark/src/objects/invoice_for_payment_hash_output.rs b/lightspark/src/objects/invoice_for_payment_hash_output.rs index a91535e..8e4f814 100644 --- a/lightspark/src/objects/invoice_for_payment_hash_output.rs +++ b/lightspark/src/objects/invoice_for_payment_hash_output.rs @@ -1,20 +1,13 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::types::entity_wrapper::EntityWrapper; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct InvoiceForPaymentHashOutput { - - #[serde(rename = "invoice_for_payment_hash_output_invoice")] pub invoice: Option, - } - - pub const FRAGMENT: &str = " fragment InvoiceForPaymentHashOutputFragment on InvoiceForPaymentHashOutput { __typename @@ -23,6 +16,3 @@ fragment InvoiceForPaymentHashOutputFragment on InvoiceForPaymentHashOutput { } } "; - - - diff --git a/lightspark/src/objects/invoice_type.rs b/lightspark/src/objects/invoice_type.rs index 5062745..6432f93 100644 --- a/lightspark/src/objects/invoice_type.rs +++ b/lightspark/src/objects/invoice_type.rs @@ -1,4 +1,3 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -9,13 +8,12 @@ use std::fmt; pub enum InvoiceType { /// A standard Bolt 11 invoice. - #[serde(rename="STANDARD")] + #[serde(rename = "STANDARD")] Standard, /// An AMP (Atomic Multi-path Payment) invoice. - #[serde(rename="AMP")] + #[serde(rename = "AMP")] Amp, - } impl Into for InvoiceType { @@ -29,8 +27,6 @@ impl fmt::Display for InvoiceType { match self { Self::Standard => write!(f, "STANDARD"), Self::Amp => write!(f, "AMP"), - } } } - diff --git a/lightspark/src/objects/lightning_fee_estimate_for_invoice_input.rs b/lightspark/src/objects/lightning_fee_estimate_for_invoice_input.rs index 3663a6e..463068b 100644 --- a/lightspark/src/objects/lightning_fee_estimate_for_invoice_input.rs +++ b/lightspark/src/objects/lightning_fee_estimate_for_invoice_input.rs @@ -1,27 +1,14 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; - - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct LightningFeeEstimateForInvoiceInput { - /// The node from where you want to send the payment. - pub node_id: String, /// The invoice you want to pay (as defined by the BOLT11 standard). - pub encoded_payment_request: String, /// If the invoice does not specify a payment amount, then the amount that you wish to pay, expressed in msats. - pub amount_msats: Option, - } - - - - - diff --git a/lightspark/src/objects/lightning_fee_estimate_for_node_input.rs b/lightspark/src/objects/lightning_fee_estimate_for_node_input.rs index 9030792..e4cf245 100644 --- a/lightspark/src/objects/lightning_fee_estimate_for_node_input.rs +++ b/lightspark/src/objects/lightning_fee_estimate_for_node_input.rs @@ -1,27 +1,14 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; - - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct LightningFeeEstimateForNodeInput { - /// The node from where you want to send the payment. - pub node_id: String, /// The public key of the node that you want to pay. - pub destination_node_public_key: String, /// The payment amount expressed in msats. - pub amount_msats: i64, - } - - - - - diff --git a/lightspark/src/objects/lightning_fee_estimate_output.rs b/lightspark/src/objects/lightning_fee_estimate_output.rs index 04e8536..fa078b3 100644 --- a/lightspark/src/objects/lightning_fee_estimate_output.rs +++ b/lightspark/src/objects/lightning_fee_estimate_output.rs @@ -1,20 +1,14 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::currency_amount::CurrencyAmount; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct LightningFeeEstimateOutput { - /// The estimated fees for the payment. - #[serde (rename = "lightning_fee_estimate_output_fee_estimate")] + #[serde(rename = "lightning_fee_estimate_output_fee_estimate")] pub fee_estimate: CurrencyAmount, - } - - pub const FRAGMENT: &str = " fragment LightningFeeEstimateOutputFragment on LightningFeeEstimateOutput { __typename @@ -28,6 +22,3 @@ fragment LightningFeeEstimateOutputFragment on LightningFeeEstimateOutput { } } "; - - - diff --git a/lightspark/src/objects/lightning_payment_direction.rs b/lightspark/src/objects/lightning_payment_direction.rs index 890e367..79fb3fb 100644 --- a/lightspark/src/objects/lightning_payment_direction.rs +++ b/lightspark/src/objects/lightning_payment_direction.rs @@ -1,4 +1,3 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -9,13 +8,12 @@ use std::fmt; pub enum LightningPaymentDirection { /// A payment that is received by the node. - #[serde(rename="INCOMING")] + #[serde(rename = "INCOMING")] Incoming, /// A payment that is sent by the node. - #[serde(rename="OUTGOING")] + #[serde(rename = "OUTGOING")] Outgoing, - } impl Into for LightningPaymentDirection { @@ -29,8 +27,6 @@ impl fmt::Display for LightningPaymentDirection { match self { Self::Incoming => write!(f, "INCOMING"), Self::Outgoing => write!(f, "OUTGOING"), - } } } - diff --git a/lightspark/src/objects/lightning_transaction.rs b/lightspark/src/objects/lightning_transaction.rs index d3f3077..7780e18 100644 --- a/lightspark/src/objects/lightning_transaction.rs +++ b/lightspark/src/objects/lightning_transaction.rs @@ -1,31 +1,24 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use crate::objects::transaction::Transaction; -use crate::objects::entity::Entity; -use serde_json::Value; -use super::routing_transaction::RoutingTransaction; -use super::outgoing_payment::OutgoingPayment; use super::incoming_payment::IncomingPayment; +use super::outgoing_payment::OutgoingPayment; +use super::routing_transaction::RoutingTransaction; +use crate::objects::entity::Entity; +use crate::objects::transaction::Transaction; use serde::{Deserialize, Deserializer, Serialize}; +use serde_json::Value; -pub trait LightningTransaction : Transaction + Entity { - - -fn type_name(&self) -> &'static str; +pub trait LightningTransaction: Transaction + Entity { + fn type_name(&self) -> &'static str; } - #[allow(clippy::large_enum_variant)] #[derive(Debug, Clone, Serialize)] pub enum LightningTransactionEnum { IncomingPayment(IncomingPayment), OutgoingPayment(OutgoingPayment), RoutingTransaction(RoutingTransaction), - } - - impl<'de> Deserialize<'de> for LightningTransactionEnum { fn deserialize(deserializer: D) -> Result where @@ -35,32 +28,30 @@ impl<'de> Deserialize<'de> for LightningTransactionEnum { if let Some(typename) = value.get("__typename").and_then(Value::as_str) { match typename { "IncomingPayment" => { - let obj = IncomingPayment::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = IncomingPayment::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(LightningTransactionEnum::IncomingPayment(obj)) - }, + } "OutgoingPayment" => { - let obj = OutgoingPayment::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = OutgoingPayment::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(LightningTransactionEnum::OutgoingPayment(obj)) - }, + } "RoutingTransaction" => { - let obj = RoutingTransaction::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = RoutingTransaction::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(LightningTransactionEnum::RoutingTransaction(obj)) - }, + } _ => Err(serde::de::Error::custom("unknown typename")), } } else { - Err(serde::de::Error::custom("missing __typename field on LightningTransaction")) + Err(serde::de::Error::custom( + "missing __typename field on LightningTransaction", + )) } } } - diff --git a/lightspark/src/objects/lightspark_node.rs b/lightspark/src/objects/lightspark_node.rs index 7f7932f..59549a5 100644 --- a/lightspark/src/objects/lightspark_node.rs +++ b/lightspark/src/objects/lightspark_node.rs @@ -1,21 +1,19 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use crate::objects::node::Node; -use crate::objects::entity::Entity; -use crate::objects::currency_amount::CurrencyAmount; -use crate::objects::balances::Balances; -use serde_json::Value; -use crate::types::entity_wrapper::EntityWrapper; use super::lightspark_node_with_o_s_k::LightsparkNodeWithOSK; -use crate::objects::lightspark_node_status::LightsparkNodeStatus; -use std::vec::Vec; +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_owner::LightsparkNodeOwner; -use super::lightspark_node_with_remote_signing::LightsparkNodeWithRemoteSigning; +use crate::objects::lightspark_node_status::LightsparkNodeStatus; +use crate::objects::node::Node; +use crate::types::entity_wrapper::EntityWrapper; use serde::{Deserialize, Deserializer, Serialize}; +use serde_json::Value; +use std::vec::Vec; -pub trait LightsparkNode : Node + Entity { - +pub trait LightsparkNode: Node + Entity { /// The owner of this LightsparkNode. fn get_owner_id(&self) -> EntityWrapper; @@ -43,21 +41,16 @@ pub trait LightsparkNode : Node + Entity { /// The balances that describe the funds in this node. fn get_balances(&self) -> Option; - -fn type_name(&self) -> &'static str; + fn type_name(&self) -> &'static str; } - #[allow(clippy::large_enum_variant)] #[derive(Debug, Clone, Serialize)] pub enum LightsparkNodeEnum { LightsparkNodeWithOSK(LightsparkNodeWithOSK), LightsparkNodeWithRemoteSigning(LightsparkNodeWithRemoteSigning), - } - - impl<'de> Deserialize<'de> for LightsparkNodeEnum { fn deserialize(deserializer: D) -> Result where @@ -67,25 +60,25 @@ impl<'de> Deserialize<'de> for LightsparkNodeEnum { if let Some(typename) = value.get("__typename").and_then(Value::as_str) { match typename { "LightsparkNodeWithOSK" => { - let obj = LightsparkNodeWithOSK::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = LightsparkNodeWithOSK::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(LightsparkNodeEnum::LightsparkNodeWithOSK(obj)) - }, + } "LightsparkNodeWithRemoteSigning" => { - let obj = LightsparkNodeWithRemoteSigning::deserialize(value) - .map_err(|err| + let obj = + LightsparkNodeWithRemoteSigning::deserialize(value).map_err(|err| { serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + })?; Ok(LightsparkNodeEnum::LightsparkNodeWithRemoteSigning(obj)) - }, + } _ => Err(serde::de::Error::custom("unknown typename")), } } else { - Err(serde::de::Error::custom("missing __typename field on LightsparkNode")) + Err(serde::de::Error::custom( + "missing __typename field on LightsparkNode", + )) } } } - diff --git a/lightspark/src/objects/lightspark_node_owner.rs b/lightspark/src/objects/lightspark_node_owner.rs index 8717150..961bea5 100644 --- a/lightspark/src/objects/lightspark_node_owner.rs +++ b/lightspark/src/objects/lightspark_node_owner.rs @@ -1,28 +1,21 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use crate::objects::entity::Entity; -use serde_json::Value; -use serde::{Deserialize, Deserializer, Serialize}; use super::account::Account; use super::wallet::Wallet; +use crate::objects::entity::Entity; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_json::Value; -pub trait LightsparkNodeOwner : Entity { - - -fn type_name(&self) -> &'static str; +pub trait LightsparkNodeOwner: Entity { + fn type_name(&self) -> &'static str; } - #[allow(clippy::large_enum_variant)] #[derive(Debug, Clone, Serialize)] pub enum LightsparkNodeOwnerEnum { Account(Account), Wallet(Wallet), - } - - impl<'de> Deserialize<'de> for LightsparkNodeOwnerEnum { fn deserialize(deserializer: D) -> Result where @@ -32,25 +25,24 @@ impl<'de> Deserialize<'de> for LightsparkNodeOwnerEnum { if let Some(typename) = value.get("__typename").and_then(Value::as_str) { match typename { "Account" => { - let obj = Account::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = Account::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(LightsparkNodeOwnerEnum::Account(obj)) - }, + } "Wallet" => { - let obj = Wallet::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = Wallet::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(LightsparkNodeOwnerEnum::Wallet(obj)) - }, + } _ => Err(serde::de::Error::custom("unknown typename")), } } else { - Err(serde::de::Error::custom("missing __typename field on LightsparkNodeOwner")) + Err(serde::de::Error::custom( + "missing __typename field on LightsparkNodeOwner", + )) } } } - diff --git a/lightspark/src/objects/lightspark_node_status.rs b/lightspark/src/objects/lightspark_node_status.rs index d0348d0..e3b9af5 100644 --- a/lightspark/src/objects/lightspark_node_status.rs +++ b/lightspark/src/objects/lightspark_node_status.rs @@ -1,43 +1,39 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; use serde_json::Value; use std::fmt; - #[derive(Debug, Clone, Deserialize, Serialize)] pub enum LightsparkNodeStatus { - - #[serde(rename="CREATED")] + #[serde(rename = "CREATED")] Created, - #[serde(rename="DEPLOYED")] + #[serde(rename = "DEPLOYED")] Deployed, - #[serde(rename="STARTED")] + #[serde(rename = "STARTED")] Started, - #[serde(rename="SYNCING")] + #[serde(rename = "SYNCING")] Syncing, - #[serde(rename="READY")] + #[serde(rename = "READY")] Ready, - #[serde(rename="STOPPED")] + #[serde(rename = "STOPPED")] Stopped, - #[serde(rename="TERMINATED")] + #[serde(rename = "TERMINATED")] Terminated, - #[serde(rename="TERMINATING")] + #[serde(rename = "TERMINATING")] Terminating, - #[serde(rename="WALLET_LOCKED")] + #[serde(rename = "WALLET_LOCKED")] WalletLocked, - #[serde(rename="FAILED_TO_DEPLOY")] + #[serde(rename = "FAILED_TO_DEPLOY")] FailedToDeploy, - } impl Into for LightsparkNodeStatus { @@ -59,8 +55,6 @@ impl fmt::Display for LightsparkNodeStatus { Self::Terminating => write!(f, "TERMINATING"), Self::WalletLocked => write!(f, "WALLET_LOCKED"), Self::FailedToDeploy => write!(f, "FAILED_TO_DEPLOY"), - } } } - diff --git a/lightspark/src/objects/lightspark_node_to_channels_connection.rs b/lightspark/src/objects/lightspark_node_to_channels_connection.rs index 6264c03..afae81c 100644 --- a/lightspark/src/objects/lightspark_node_to_channels_connection.rs +++ b/lightspark/src/objects/lightspark_node_to_channels_connection.rs @@ -1,36 +1,30 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; -use std::vec::Vec; use crate::objects::channel::Channel; -use crate::objects::page_info::PageInfo; use crate::objects::connection::Connection; - +use crate::objects::page_info::PageInfo; +use serde::{Deserialize, Serialize}; +use std::vec::Vec; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct LightsparkNodeToChannelsConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). - #[serde (rename = "lightspark_node_to_channels_connection_count")] + #[serde(rename = "lightspark_node_to_channels_connection_count")] pub count: i64, /// An object that holds pagination information about the objects in this connection. - #[serde (rename = "lightspark_node_to_channels_connection_page_info")] + #[serde(rename = "lightspark_node_to_channels_connection_page_info")] pub page_info: PageInfo, /// The channels for the current page of this connection. - #[serde (rename = "lightspark_node_to_channels_connection_entities")] + #[serde(rename = "lightspark_node_to_channels_connection_entities")] pub entities: Vec, /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl Connection for LightsparkNodeToChannelsConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). fn get_count(&self) -> i64 { self.count @@ -41,15 +35,11 @@ impl Connection for LightsparkNodeToChannelsConnection { self.page_info.clone() } - fn type_name(&self) -> &'static str { "LightsparkNodeToChannelsConnection" } } - - - pub const FRAGMENT: &str = " fragment LightsparkNodeToChannelsConnectionFragment on LightsparkNodeToChannelsConnection { __typename @@ -66,6 +56,3 @@ fragment LightsparkNodeToChannelsConnectionFragment on LightsparkNodeToChannelsC } } "; - - - diff --git a/lightspark/src/objects/lightspark_node_to_daily_liquidity_forecasts_connection.rs b/lightspark/src/objects/lightspark_node_to_daily_liquidity_forecasts_connection.rs index 3eb0707..ea31b6e 100644 --- a/lightspark/src/objects/lightspark_node_to_daily_liquidity_forecasts_connection.rs +++ b/lightspark/src/objects/lightspark_node_to_daily_liquidity_forecasts_connection.rs @@ -1,36 +1,33 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; -use chrono::NaiveDate; -use std::vec::Vec; +use crate::objects::daily_liquidity_forecast::DailyLiquidityForecast; use crate::objects::lightning_payment_direction::LightningPaymentDirection; use crate::types::custom_date_formats::custom_date_only_format; -use crate::objects::daily_liquidity_forecast::DailyLiquidityForecast; - +use chrono::NaiveDate; +use serde::{Deserialize, Serialize}; +use std::vec::Vec; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct LightsparkNodeToDailyLiquidityForecastsConnection { - - - #[serde(with = "custom_date_only_format", rename = "lightspark_node_to_daily_liquidity_forecasts_connection_from_date")] + #[serde( + with = "custom_date_only_format", + rename = "lightspark_node_to_daily_liquidity_forecasts_connection_from_date" + )] pub from_date: NaiveDate, - - #[serde(with = "custom_date_only_format", rename = "lightspark_node_to_daily_liquidity_forecasts_connection_to_date")] + #[serde( + with = "custom_date_only_format", + rename = "lightspark_node_to_daily_liquidity_forecasts_connection_to_date" + )] pub to_date: NaiveDate, - - #[serde (rename = "lightspark_node_to_daily_liquidity_forecasts_connection_direction")] + #[serde(rename = "lightspark_node_to_daily_liquidity_forecasts_connection_direction")] pub direction: LightningPaymentDirection, /// The daily liquidity forecasts for the current page of this connection. - #[serde (rename = "lightspark_node_to_daily_liquidity_forecasts_connection_entities")] + #[serde(rename = "lightspark_node_to_daily_liquidity_forecasts_connection_entities")] pub entities: Vec, - } - - pub const FRAGMENT: &str = " fragment LightsparkNodeToDailyLiquidityForecastsConnectionFragment on LightsparkNodeToDailyLiquidityForecastsConnection { __typename @@ -52,6 +49,3 @@ fragment LightsparkNodeToDailyLiquidityForecastsConnectionFragment on Lightspark } } "; - - - 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 dfd967a..87cd002 100644 --- a/lightspark/src/objects/lightspark_node_with_o_s_k.rs +++ b/lightspark/src/objects/lightspark_node_with_o_s_k.rs @@ -1,71 +1,75 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; -use serde_json::Value; -use crate::types::entity_wrapper::EntityWrapper; -use crate::objects::lightning_payment_direction::LightningPaymentDirection; +use crate::error::Error; +use crate::objects::balances::Balances; use crate::objects::bitcoin_network::BitcoinNetwork; -use crate::objects::secret::Secret; +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::lightning_payment_direction::LightningPaymentDirection; +use crate::objects::lightspark_node::LightsparkNode; +use crate::objects::lightspark_node_owner::LightsparkNodeOwner; +use crate::objects::lightspark_node_status::LightsparkNodeStatus; +use crate::objects::lightspark_node_to_channels_connection::LightsparkNodeToChannelsConnection; +use crate::objects::lightspark_node_to_daily_liquidity_forecasts_connection::LightsparkNodeToDailyLiquidityForecastsConnection; use crate::objects::node::Node; use crate::objects::node_address_type::NodeAddressType; -use crate::types::graphql_requester::GraphQLRequester; -use crate::objects::entity::Entity; -use crate::objects::channel_status::ChannelStatus; +use crate::objects::node_to_addresses_connection::NodeToAddressesConnection; +use crate::objects::secret::Secret; use crate::types::custom_date_formats::custom_date_format; -use crate::objects::balances::Balances; -use crate::objects::lightspark_node_status::LightsparkNodeStatus; -use crate::error::Error; +use crate::types::entity_wrapper::EntityWrapper; +use crate::types::get_entity::GetEntity; +use crate::types::graphql_requester::GraphQLRequester; +use chrono::NaiveDate; +use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; +use serde_json::Value; use std::collections::HashMap; use std::vec::Vec; -use crate::objects::blockchain_balance::BlockchainBalance; -use crate::objects::lightspark_node_owner::LightsparkNodeOwner; -use crate::objects::lightspark_node_to_channels_connection::LightsparkNodeToChannelsConnection; -use chrono::{DateTime, Utc}; -use crate::objects::currency_amount::CurrencyAmount; -use chrono::NaiveDate; -use crate::types::get_entity::GetEntity; -use crate::objects::lightspark_node::LightsparkNode; -use crate::objects::node_to_addresses_connection::NodeToAddressesConnection; -use crate::objects::lightspark_node_to_daily_liquidity_forecasts_connection::LightsparkNodeToDailyLiquidityForecastsConnection; /// This is a Lightspark node with OSK. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct LightsparkNodeWithOSK { - /// The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string. - #[serde (rename = "lightspark_node_with_o_s_k_id")] + #[serde(rename = "lightspark_node_with_o_s_k_id")] pub id: String, /// The date and time when the entity was first created. - #[serde(with = "custom_date_format", rename = "lightspark_node_with_o_s_k_created_at")] + #[serde( + with = "custom_date_format", + rename = "lightspark_node_with_o_s_k_created_at" + )] pub created_at: DateTime, /// The date and time when the entity was last updated. - #[serde(with = "custom_date_format", rename = "lightspark_node_with_o_s_k_updated_at")] + #[serde( + with = "custom_date_format", + rename = "lightspark_node_with_o_s_k_updated_at" + )] pub updated_at: DateTime, /// A name that identifies the node. It has no importance in terms of operating the node, it is just a way to identify and search for commercial services or popular nodes. This alias can be changed at any time by the node operator. - #[serde (rename = "lightspark_node_with_o_s_k_alias")] + #[serde(rename = "lightspark_node_with_o_s_k_alias")] pub alias: Option, /// The Bitcoin Network this node is deployed in. - #[serde (rename = "lightspark_node_with_o_s_k_bitcoin_network")] + #[serde(rename = "lightspark_node_with_o_s_k_bitcoin_network")] pub bitcoin_network: BitcoinNetwork, /// A hexadecimal string that describes a color. For example "#000000" is black, "#FFFFFF" is white. It has no importance in terms of operating the node, it is just a way to visually differentiate nodes. That color can be changed at any time by the node operator. - #[serde (rename = "lightspark_node_with_o_s_k_color")] + #[serde(rename = "lightspark_node_with_o_s_k_color")] pub color: Option, /// A summary metric used to capture how well positioned a node is to send, receive, or route transactions efficiently. Maximizing a node's conductivity helps a node’s transactions to be capital efficient. The value is an integer ranging between 0 and 10 (bounds included). - #[serde (rename = "lightspark_node_with_o_s_k_conductivity")] + #[serde(rename = "lightspark_node_with_o_s_k_conductivity")] pub conductivity: Option, /// The name of this node in the network. It will be the most human-readable option possible, depending on the data available for this node. - #[serde (rename = "lightspark_node_with_o_s_k_display_name")] + #[serde(rename = "lightspark_node_with_o_s_k_display_name")] pub display_name: String, /// The public key of this node. It acts as a unique identifier of this node in the Lightning Network. - #[serde (rename = "lightspark_node_with_o_s_k_public_key")] + #[serde(rename = "lightspark_node_with_o_s_k_public_key")] pub public_key: Option, /// The owner of this LightsparkNode. @@ -73,50 +77,47 @@ pub struct LightsparkNodeWithOSK { pub owner: EntityWrapper, /// The current status of this node. - #[serde (rename = "lightspark_node_with_o_s_k_status")] + #[serde(rename = "lightspark_node_with_o_s_k_status")] pub status: Option, /// The sum of the balance on the Bitcoin Network, channel balances, and commit fees on this node. - #[serde (rename = "lightspark_node_with_o_s_k_total_balance")] + #[serde(rename = "lightspark_node_with_o_s_k_total_balance")] pub total_balance: Option, /// The total sum of the channel balances (online and offline) on this node. - #[serde (rename = "lightspark_node_with_o_s_k_total_local_balance")] + #[serde(rename = "lightspark_node_with_o_s_k_total_local_balance")] pub total_local_balance: Option, /// The sum of the channel balances (online only) that are available to send on this node. - #[serde (rename = "lightspark_node_with_o_s_k_local_balance")] + #[serde(rename = "lightspark_node_with_o_s_k_local_balance")] pub local_balance: Option, /// The sum of the channel balances that are available to receive on this node. - #[serde (rename = "lightspark_node_with_o_s_k_remote_balance")] + #[serde(rename = "lightspark_node_with_o_s_k_remote_balance")] pub remote_balance: Option, /// The details of the balance of this node on the Bitcoin Network. - #[serde (rename = "lightspark_node_with_o_s_k_blockchain_balance")] + #[serde(rename = "lightspark_node_with_o_s_k_blockchain_balance")] pub blockchain_balance: Option, /// The utxos of the channels that are connected to this node. This is used in uma flow for pre-screening. - #[serde (rename = "lightspark_node_with_o_s_k_uma_prescreening_utxos")] + #[serde(rename = "lightspark_node_with_o_s_k_uma_prescreening_utxos")] pub uma_prescreening_utxos: Vec, /// The balances that describe the funds in this node. - #[serde (rename = "lightspark_node_with_o_s_k_balances")] + #[serde(rename = "lightspark_node_with_o_s_k_balances")] pub balances: Option, /// The private key client is using to sign a GraphQL request which will be verified at server side. - #[serde (rename = "lightspark_node_with_o_s_k_encrypted_signing_private_key")] + #[serde(rename = "lightspark_node_with_o_s_k_encrypted_signing_private_key")] pub encrypted_signing_private_key: Option, /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl LightsparkNode for LightsparkNodeWithOSK { - /// The owner of this LightsparkNode. fn get_owner_id(&self) -> EntityWrapper { self.owner.clone() @@ -162,16 +163,12 @@ impl LightsparkNode for LightsparkNodeWithOSK { self.balances.clone() } - fn type_name(&self) -> &'static str { "LightsparkNodeWithOSK" } } - - impl Node for LightsparkNodeWithOSK { - /// A name that identifies the node. It has no importance in terms of operating the node, it is just a way to identify and search for commercial services or popular nodes. This alias can be changed at any time by the node operator. fn get_alias(&self) -> Option { self.alias.clone() @@ -202,16 +199,12 @@ impl Node for LightsparkNodeWithOSK { self.public_key.clone() } - fn type_name(&self) -> &'static str { "LightsparkNodeWithOSK" } } - - impl Entity for LightsparkNodeWithOSK { - /// 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() @@ -227,16 +220,15 @@ impl Entity for LightsparkNodeWithOSK { self.updated_at } - fn type_name(&self) -> &'static str { "LightsparkNodeWithOSK" } } - impl GetEntity for LightsparkNodeWithOSK { fn get_entity_query() -> String { - format!(" + format!( + " query GetEntity($id: ID!) {{ entity(id: $id) {{ ... on LightsparkNodeWithOSK {{ @@ -245,12 +237,12 @@ impl GetEntity for LightsparkNodeWithOSK { }} }} - {}", FRAGMENT) - } + {}", + FRAGMENT + ) + } } - - pub const FRAGMENT: &str = " fragment LightsparkNodeWithOSKFragment on LightsparkNodeWithOSK { __typename @@ -386,11 +378,13 @@ fragment LightsparkNodeWithOSKFragment on LightsparkNodeWithOSK { } "; - impl LightsparkNodeWithOSK { - - - pub async fn get_addresses(&self, requester:&impl GraphQLRequester, first: Option, types: Option>) -> Result { + pub async fn get_addresses( + &self, + requester: &impl GraphQLRequester, + first: Option, + types: Option>, + ) -> Result { let query = "query FetchNodeToAddressesConnection($entity_id: ID!, $first: Int, $types: [NodeAddressType!]) { entity(id: $entity_id) { ... on LightsparkNodeWithOSK { @@ -411,7 +405,6 @@ impl LightsparkNodeWithOSK { variables.insert("first", first.into()); variables.insert("types", types.into()); - let value = serde_json::to_value(variables).map_err(|err| Error::ConversionError(err))?; let result = requester.execute_graphql(&query, Some(value)).await?; let json = result["entity"]["addresses"].clone(); @@ -419,8 +412,15 @@ impl LightsparkNodeWithOSK { Ok(result) } - - pub async fn get_channels(&self, requester:&impl GraphQLRequester, first: Option, after: Option, before_date: Option>, after_date: Option>, statuses: Option>) -> Result { + pub async fn get_channels( + &self, + requester: &impl GraphQLRequester, + first: Option, + after: Option, + before_date: Option>, + after_date: Option>, + statuses: Option>, + ) -> Result { let query = "query FetchLightsparkNodeToChannelsConnection($entity_id: ID!, $first: Int, $after: String, $before_date: DateTime, $after_date: DateTime, $statuses: [ChannelStatus!]) { entity(id: $entity_id) { ... on LightsparkNodeWithOSK { @@ -540,7 +540,6 @@ impl LightsparkNodeWithOSK { variables.insert("after_date", after_date.map(|dt| dt.to_rfc3339()).into()); variables.insert("statuses", statuses.into()); - let value = serde_json::to_value(variables).map_err(|err| Error::ConversionError(err))?; let result = requester.execute_graphql(&query, Some(value)).await?; let json = result["entity"]["channels"].clone(); @@ -548,8 +547,13 @@ impl LightsparkNodeWithOSK { Ok(result) } - - pub async fn get_daily_liquidity_forecasts(&self, requester:&impl GraphQLRequester, from_date: NaiveDate, to_date: NaiveDate, direction: LightningPaymentDirection) -> Result { + pub async fn get_daily_liquidity_forecasts( + &self, + requester: &impl GraphQLRequester, + from_date: NaiveDate, + to_date: NaiveDate, + direction: LightningPaymentDirection, + ) -> Result { let query = "query FetchLightsparkNodeToDailyLiquidityForecastsConnection($entity_id: ID!, $from_date: Date!, $to_date: Date!, $direction: LightningPaymentDirection!) { entity(id: $entity_id) { ... on LightsparkNodeWithOSK { @@ -581,12 +585,10 @@ impl LightsparkNodeWithOSK { variables.insert("to_date", to_date.format("%Y-%m-%d").to_string().into()); variables.insert("direction", direction.into()); - let value = serde_json::to_value(variables).map_err(|err| Error::ConversionError(err))?; let result = requester.execute_graphql(&query, Some(value)).await?; let json = result["entity"]["daily_liquidity_forecasts"].clone(); let result = serde_json::from_value(json).map_err(|err| Error::JsonError(err))?; Ok(result) } - } diff --git a/lightspark/src/objects/lightspark_node_with_remote_signing.rs b/lightspark/src/objects/lightspark_node_with_remote_signing.rs index da140d7..eaa8e25 100644 --- a/lightspark/src/objects/lightspark_node_with_remote_signing.rs +++ b/lightspark/src/objects/lightspark_node_with_remote_signing.rs @@ -1,70 +1,74 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; -use serde_json::Value; -use crate::types::entity_wrapper::EntityWrapper; -use crate::objects::lightning_payment_direction::LightningPaymentDirection; +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::lightning_payment_direction::LightningPaymentDirection; +use crate::objects::lightspark_node::LightsparkNode; +use crate::objects::lightspark_node_owner::LightsparkNodeOwner; +use crate::objects::lightspark_node_status::LightsparkNodeStatus; +use crate::objects::lightspark_node_to_channels_connection::LightsparkNodeToChannelsConnection; +use crate::objects::lightspark_node_to_daily_liquidity_forecasts_connection::LightsparkNodeToDailyLiquidityForecastsConnection; use crate::objects::node::Node; use crate::objects::node_address_type::NodeAddressType; -use crate::types::graphql_requester::GraphQLRequester; -use crate::objects::entity::Entity; -use crate::objects::channel_status::ChannelStatus; +use crate::objects::node_to_addresses_connection::NodeToAddressesConnection; use crate::types::custom_date_formats::custom_date_format; -use crate::objects::balances::Balances; -use crate::objects::lightspark_node_status::LightsparkNodeStatus; -use crate::error::Error; +use crate::types::entity_wrapper::EntityWrapper; +use crate::types::get_entity::GetEntity; +use crate::types::graphql_requester::GraphQLRequester; +use chrono::NaiveDate; +use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; +use serde_json::Value; use std::collections::HashMap; use std::vec::Vec; -use crate::objects::blockchain_balance::BlockchainBalance; -use crate::objects::lightspark_node_owner::LightsparkNodeOwner; -use crate::objects::lightspark_node_to_channels_connection::LightsparkNodeToChannelsConnection; -use chrono::{DateTime, Utc}; -use crate::objects::currency_amount::CurrencyAmount; -use chrono::NaiveDate; -use crate::types::get_entity::GetEntity; -use crate::objects::lightspark_node::LightsparkNode; -use crate::objects::node_to_addresses_connection::NodeToAddressesConnection; -use crate::objects::lightspark_node_to_daily_liquidity_forecasts_connection::LightsparkNodeToDailyLiquidityForecastsConnection; /// This is a Lightspark node with remote signing. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct LightsparkNodeWithRemoteSigning { - /// The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string. - #[serde (rename = "lightspark_node_with_remote_signing_id")] + #[serde(rename = "lightspark_node_with_remote_signing_id")] pub id: String, /// The date and time when the entity was first created. - #[serde(with = "custom_date_format", rename = "lightspark_node_with_remote_signing_created_at")] + #[serde( + with = "custom_date_format", + rename = "lightspark_node_with_remote_signing_created_at" + )] pub created_at: DateTime, /// The date and time when the entity was last updated. - #[serde(with = "custom_date_format", rename = "lightspark_node_with_remote_signing_updated_at")] + #[serde( + with = "custom_date_format", + rename = "lightspark_node_with_remote_signing_updated_at" + )] pub updated_at: DateTime, /// A name that identifies the node. It has no importance in terms of operating the node, it is just a way to identify and search for commercial services or popular nodes. This alias can be changed at any time by the node operator. - #[serde (rename = "lightspark_node_with_remote_signing_alias")] + #[serde(rename = "lightspark_node_with_remote_signing_alias")] pub alias: Option, /// The Bitcoin Network this node is deployed in. - #[serde (rename = "lightspark_node_with_remote_signing_bitcoin_network")] + #[serde(rename = "lightspark_node_with_remote_signing_bitcoin_network")] pub bitcoin_network: BitcoinNetwork, /// A hexadecimal string that describes a color. For example "#000000" is black, "#FFFFFF" is white. It has no importance in terms of operating the node, it is just a way to visually differentiate nodes. That color can be changed at any time by the node operator. - #[serde (rename = "lightspark_node_with_remote_signing_color")] + #[serde(rename = "lightspark_node_with_remote_signing_color")] pub color: Option, /// A summary metric used to capture how well positioned a node is to send, receive, or route transactions efficiently. Maximizing a node's conductivity helps a node’s transactions to be capital efficient. The value is an integer ranging between 0 and 10 (bounds included). - #[serde (rename = "lightspark_node_with_remote_signing_conductivity")] + #[serde(rename = "lightspark_node_with_remote_signing_conductivity")] pub conductivity: Option, /// The name of this node in the network. It will be the most human-readable option possible, depending on the data available for this node. - #[serde (rename = "lightspark_node_with_remote_signing_display_name")] + #[serde(rename = "lightspark_node_with_remote_signing_display_name")] pub display_name: String, /// The public key of this node. It acts as a unique identifier of this node in the Lightning Network. - #[serde (rename = "lightspark_node_with_remote_signing_public_key")] + #[serde(rename = "lightspark_node_with_remote_signing_public_key")] pub public_key: Option, /// The owner of this LightsparkNode. @@ -72,46 +76,43 @@ pub struct LightsparkNodeWithRemoteSigning { pub owner: EntityWrapper, /// The current status of this node. - #[serde (rename = "lightspark_node_with_remote_signing_status")] + #[serde(rename = "lightspark_node_with_remote_signing_status")] pub status: Option, /// The sum of the balance on the Bitcoin Network, channel balances, and commit fees on this node. - #[serde (rename = "lightspark_node_with_remote_signing_total_balance")] + #[serde(rename = "lightspark_node_with_remote_signing_total_balance")] pub total_balance: Option, /// The total sum of the channel balances (online and offline) on this node. - #[serde (rename = "lightspark_node_with_remote_signing_total_local_balance")] + #[serde(rename = "lightspark_node_with_remote_signing_total_local_balance")] pub total_local_balance: Option, /// The sum of the channel balances (online only) that are available to send on this node. - #[serde (rename = "lightspark_node_with_remote_signing_local_balance")] + #[serde(rename = "lightspark_node_with_remote_signing_local_balance")] pub local_balance: Option, /// The sum of the channel balances that are available to receive on this node. - #[serde (rename = "lightspark_node_with_remote_signing_remote_balance")] + #[serde(rename = "lightspark_node_with_remote_signing_remote_balance")] pub remote_balance: Option, /// The details of the balance of this node on the Bitcoin Network. - #[serde (rename = "lightspark_node_with_remote_signing_blockchain_balance")] + #[serde(rename = "lightspark_node_with_remote_signing_blockchain_balance")] pub blockchain_balance: Option, /// The utxos of the channels that are connected to this node. This is used in uma flow for pre-screening. - #[serde (rename = "lightspark_node_with_remote_signing_uma_prescreening_utxos")] + #[serde(rename = "lightspark_node_with_remote_signing_uma_prescreening_utxos")] pub uma_prescreening_utxos: Vec, /// The balances that describe the funds in this node. - #[serde (rename = "lightspark_node_with_remote_signing_balances")] + #[serde(rename = "lightspark_node_with_remote_signing_balances")] pub balances: Option, /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl LightsparkNode for LightsparkNodeWithRemoteSigning { - /// The owner of this LightsparkNode. fn get_owner_id(&self) -> EntityWrapper { self.owner.clone() @@ -157,16 +158,12 @@ impl LightsparkNode for LightsparkNodeWithRemoteSigning { self.balances.clone() } - fn type_name(&self) -> &'static str { "LightsparkNodeWithRemoteSigning" } } - - impl Node for LightsparkNodeWithRemoteSigning { - /// A name that identifies the node. It has no importance in terms of operating the node, it is just a way to identify and search for commercial services or popular nodes. This alias can be changed at any time by the node operator. fn get_alias(&self) -> Option { self.alias.clone() @@ -197,16 +194,12 @@ impl Node for LightsparkNodeWithRemoteSigning { self.public_key.clone() } - fn type_name(&self) -> &'static str { "LightsparkNodeWithRemoteSigning" } } - - impl Entity for LightsparkNodeWithRemoteSigning { - /// 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() @@ -222,16 +215,15 @@ impl Entity for LightsparkNodeWithRemoteSigning { self.updated_at } - fn type_name(&self) -> &'static str { "LightsparkNodeWithRemoteSigning" } } - impl GetEntity for LightsparkNodeWithRemoteSigning { fn get_entity_query() -> String { - format!(" + format!( + " query GetEntity($id: ID!) {{ entity(id: $id) {{ ... on LightsparkNodeWithRemoteSigning {{ @@ -240,12 +232,12 @@ impl GetEntity for LightsparkNodeWithRemoteSigning { }} }} - {}", FRAGMENT) - } + {}", + FRAGMENT + ) + } } - - pub const FRAGMENT: &str = " fragment LightsparkNodeWithRemoteSigningFragment on LightsparkNodeWithRemoteSigning { __typename @@ -376,11 +368,13 @@ fragment LightsparkNodeWithRemoteSigningFragment on LightsparkNodeWithRemoteSign } "; - impl LightsparkNodeWithRemoteSigning { - - - pub async fn get_addresses(&self, requester:&impl GraphQLRequester, first: Option, types: Option>) -> Result { + pub async fn get_addresses( + &self, + requester: &impl GraphQLRequester, + first: Option, + types: Option>, + ) -> Result { let query = "query FetchNodeToAddressesConnection($entity_id: ID!, $first: Int, $types: [NodeAddressType!]) { entity(id: $entity_id) { ... on LightsparkNodeWithRemoteSigning { @@ -401,7 +395,6 @@ impl LightsparkNodeWithRemoteSigning { variables.insert("first", first.into()); variables.insert("types", types.into()); - let value = serde_json::to_value(variables).map_err(|err| Error::ConversionError(err))?; let result = requester.execute_graphql(&query, Some(value)).await?; let json = result["entity"]["addresses"].clone(); @@ -409,8 +402,15 @@ impl LightsparkNodeWithRemoteSigning { Ok(result) } - - pub async fn get_channels(&self, requester:&impl GraphQLRequester, first: Option, after: Option, before_date: Option>, after_date: Option>, statuses: Option>) -> Result { + pub async fn get_channels( + &self, + requester: &impl GraphQLRequester, + first: Option, + after: Option, + before_date: Option>, + after_date: Option>, + statuses: Option>, + ) -> Result { let query = "query FetchLightsparkNodeToChannelsConnection($entity_id: ID!, $first: Int, $after: String, $before_date: DateTime, $after_date: DateTime, $statuses: [ChannelStatus!]) { entity(id: $entity_id) { ... on LightsparkNodeWithRemoteSigning { @@ -530,7 +530,6 @@ impl LightsparkNodeWithRemoteSigning { variables.insert("after_date", after_date.map(|dt| dt.to_rfc3339()).into()); variables.insert("statuses", statuses.into()); - let value = serde_json::to_value(variables).map_err(|err| Error::ConversionError(err))?; let result = requester.execute_graphql(&query, Some(value)).await?; let json = result["entity"]["channels"].clone(); @@ -538,8 +537,13 @@ impl LightsparkNodeWithRemoteSigning { Ok(result) } - - pub async fn get_daily_liquidity_forecasts(&self, requester:&impl GraphQLRequester, from_date: NaiveDate, to_date: NaiveDate, direction: LightningPaymentDirection) -> Result { + pub async fn get_daily_liquidity_forecasts( + &self, + requester: &impl GraphQLRequester, + from_date: NaiveDate, + to_date: NaiveDate, + direction: LightningPaymentDirection, + ) -> Result { let query = "query FetchLightsparkNodeToDailyLiquidityForecastsConnection($entity_id: ID!, $from_date: Date!, $to_date: Date!, $direction: LightningPaymentDirection!) { entity(id: $entity_id) { ... on LightsparkNodeWithRemoteSigning { @@ -571,12 +575,10 @@ impl LightsparkNodeWithRemoteSigning { variables.insert("to_date", to_date.format("%Y-%m-%d").to_string().into()); variables.insert("direction", direction.into()); - let value = serde_json::to_value(variables).map_err(|err| Error::ConversionError(err))?; let result = requester.execute_graphql(&query, Some(value)).await?; let json = result["entity"]["daily_liquidity_forecasts"].clone(); let result = serde_json::from_value(json).map_err(|err| Error::JsonError(err))?; Ok(result) } - } diff --git a/lightspark/src/objects/multi_sig_address_validation_parameters.rs b/lightspark/src/objects/multi_sig_address_validation_parameters.rs index 6b34bb1..60e579b 100644 --- a/lightspark/src/objects/multi_sig_address_validation_parameters.rs +++ b/lightspark/src/objects/multi_sig_address_validation_parameters.rs @@ -1,24 +1,17 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; - - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct MultiSigAddressValidationParameters { - /// The counterparty funding public key used to create the 2-of-2 multisig for the address. - #[serde (rename = "multi_sig_address_validation_parameters_counterparty_funding_pubkey")] + #[serde(rename = "multi_sig_address_validation_parameters_counterparty_funding_pubkey")] pub counterparty_funding_pubkey: String, /// The derivation path used to derive the funding public key for the 2-of-2 multisig address. - #[serde (rename = "multi_sig_address_validation_parameters_funding_pubkey_derivation_path")] + #[serde(rename = "multi_sig_address_validation_parameters_funding_pubkey_derivation_path")] pub funding_pubkey_derivation_path: String, - } - - pub const FRAGMENT: &str = " fragment MultiSigAddressValidationParametersFragment on MultiSigAddressValidationParameters { __typename @@ -26,6 +19,3 @@ fragment MultiSigAddressValidationParametersFragment on MultiSigAddressValidatio multi_sig_address_validation_parameters_funding_pubkey_derivation_path: funding_pubkey_derivation_path } "; - - - diff --git a/lightspark/src/objects/node.rs b/lightspark/src/objects/node.rs index 79c6ae7..e507dcb 100644 --- a/lightspark/src/objects/node.rs +++ b/lightspark/src/objects/node.rs @@ -1,15 +1,13 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use crate::objects::entity::Entity; -use serde_json::Value; +use super::graph_node::GraphNode; use super::lightspark_node_with_o_s_k::LightsparkNodeWithOSK; -use crate::objects::bitcoin_network::BitcoinNetwork; use super::lightspark_node_with_remote_signing::LightsparkNodeWithRemoteSigning; +use crate::objects::bitcoin_network::BitcoinNetwork; +use crate::objects::entity::Entity; use serde::{Deserialize, Deserializer, Serialize}; -use super::graph_node::GraphNode; - -pub trait Node : Entity { +use serde_json::Value; +pub trait Node: Entity { /// A name that identifies the node. It has no importance in terms of operating the node, it is just a way to identify and search for commercial services or popular nodes. This alias can be changed at any time by the node operator. fn get_alias(&self) -> Option; @@ -28,22 +26,17 @@ pub trait Node : Entity { /// The public key of this node. It acts as a unique identifier of this node in the Lightning Network. fn get_public_key(&self) -> Option; - -fn type_name(&self) -> &'static str; + fn type_name(&self) -> &'static str; } - #[allow(clippy::large_enum_variant)] #[derive(Debug, Clone, Serialize)] pub enum NodeEnum { GraphNode(GraphNode), LightsparkNodeWithOSK(LightsparkNodeWithOSK), LightsparkNodeWithRemoteSigning(LightsparkNodeWithRemoteSigning), - } - - impl<'de> Deserialize<'de> for NodeEnum { fn deserialize(deserializer: D) -> Result where @@ -53,26 +46,24 @@ impl<'de> Deserialize<'de> for NodeEnum { if let Some(typename) = value.get("__typename").and_then(Value::as_str) { match typename { "GraphNode" => { - let obj = GraphNode::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = GraphNode::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(NodeEnum::GraphNode(obj)) - }, + } "LightsparkNodeWithOSK" => { - let obj = LightsparkNodeWithOSK::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = LightsparkNodeWithOSK::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(NodeEnum::LightsparkNodeWithOSK(obj)) - }, + } "LightsparkNodeWithRemoteSigning" => { - let obj = LightsparkNodeWithRemoteSigning::deserialize(value) - .map_err(|err| + let obj = + LightsparkNodeWithRemoteSigning::deserialize(value).map_err(|err| { serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + })?; Ok(NodeEnum::LightsparkNodeWithRemoteSigning(obj)) - }, + } _ => Err(serde::de::Error::custom("unknown typename")), } @@ -81,4 +72,3 @@ impl<'de> Deserialize<'de> for NodeEnum { } } } - diff --git a/lightspark/src/objects/node_address.rs b/lightspark/src/objects/node_address.rs index a7ec0f0..d070a31 100644 --- a/lightspark/src/objects/node_address.rs +++ b/lightspark/src/objects/node_address.rs @@ -1,24 +1,19 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::node_address_type::NodeAddressType; +use serde::{Deserialize, Serialize}; /// This object represents the address of a node on the Lightning Network. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct NodeAddress { - /// The string representation of the address. - #[serde (rename = "node_address_address")] + #[serde(rename = "node_address_address")] pub address: String, /// The type, or protocol, of this address. - #[serde (rename = "node_address_type")] + #[serde(rename = "node_address_type")] pub _type: NodeAddressType, - } - - pub const FRAGMENT: &str = " fragment NodeAddressFragment on NodeAddress { __typename @@ -26,6 +21,3 @@ fragment NodeAddressFragment on NodeAddress { node_address_type: type } "; - - - diff --git a/lightspark/src/objects/node_address_type.rs b/lightspark/src/objects/node_address_type.rs index 2cd8384..2f7e2dd 100644 --- a/lightspark/src/objects/node_address_type.rs +++ b/lightspark/src/objects/node_address_type.rs @@ -1,4 +1,3 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -7,16 +6,14 @@ use std::fmt; /// This is an enum of the potential types of addresses that a node on the Lightning Network can have. #[derive(Debug, Clone, Deserialize, Serialize)] pub enum NodeAddressType { - - #[serde(rename="IPV4")] + #[serde(rename = "IPV4")] Ipv4, - #[serde(rename="IPV6")] + #[serde(rename = "IPV6")] Ipv6, - #[serde(rename="TOR")] + #[serde(rename = "TOR")] Tor, - } impl Into for NodeAddressType { @@ -31,8 +28,6 @@ impl fmt::Display for NodeAddressType { Self::Ipv4 => write!(f, "IPV4"), Self::Ipv6 => write!(f, "IPV6"), Self::Tor => write!(f, "TOR"), - } } } - diff --git a/lightspark/src/objects/node_to_addresses_connection.rs b/lightspark/src/objects/node_to_addresses_connection.rs index c013d23..feb1fb8 100644 --- a/lightspark/src/objects/node_to_addresses_connection.rs +++ b/lightspark/src/objects/node_to_addresses_connection.rs @@ -1,25 +1,20 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::objects::node_address::NodeAddress; use serde::{Deserialize, Serialize}; use std::vec::Vec; -use crate::objects::node_address::NodeAddress; /// A connection between a node and the addresses it has announced for itself on Lightning Network. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct NodeToAddressesConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). - #[serde (rename = "node_to_addresses_connection_count")] + #[serde(rename = "node_to_addresses_connection_count")] pub count: i64, /// The addresses for the current page of this connection. - #[serde (rename = "node_to_addresses_connection_entities")] + #[serde(rename = "node_to_addresses_connection_entities")] pub entities: Vec, - } - - pub const FRAGMENT: &str = " fragment NodeToAddressesConnectionFragment on NodeToAddressesConnection { __typename @@ -31,6 +26,3 @@ fragment NodeToAddressesConnectionFragment on NodeToAddressesConnection { } } "; - - - diff --git a/lightspark/src/objects/on_chain_fee_target.rs b/lightspark/src/objects/on_chain_fee_target.rs index c90f16c..43871b5 100644 --- a/lightspark/src/objects/on_chain_fee_target.rs +++ b/lightspark/src/objects/on_chain_fee_target.rs @@ -1,29 +1,26 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; use serde_json::Value; use std::fmt; - #[derive(Debug, Clone, Deserialize, Serialize)] pub enum OnChainFeeTarget { /// Transaction expected to be confirmed within 2 blocks. - #[serde(rename="HIGH")] + #[serde(rename = "HIGH")] High, /// Transaction expected to be confirmed within 6 blocks. - #[serde(rename="MEDIUM")] + #[serde(rename = "MEDIUM")] Medium, /// Transaction expected to be confirmed within 18 blocks. - #[serde(rename="LOW")] + #[serde(rename = "LOW")] Low, /// Transaction expected to be confirmed within 50 blocks. - #[serde(rename="BACKGROUND")] + #[serde(rename = "BACKGROUND")] Background, - } impl Into for OnChainFeeTarget { @@ -39,8 +36,6 @@ impl fmt::Display for OnChainFeeTarget { Self::Medium => write!(f, "MEDIUM"), Self::Low => write!(f, "LOW"), Self::Background => write!(f, "BACKGROUND"), - } } } - diff --git a/lightspark/src/objects/on_chain_transaction.rs b/lightspark/src/objects/on_chain_transaction.rs index c5d3168..884726e 100644 --- a/lightspark/src/objects/on_chain_transaction.rs +++ b/lightspark/src/objects/on_chain_transaction.rs @@ -1,18 +1,16 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use crate::objects::transaction::Transaction; -use crate::objects::entity::Entity; -use crate::objects::currency_amount::CurrencyAmount; -use serde_json::Value; -use super::withdrawal::Withdrawal; +use super::channel_closing_transaction::ChannelClosingTransaction; use super::channel_opening_transaction::ChannelOpeningTransaction; -use std::vec::Vec; use super::deposit::Deposit; -use super::channel_closing_transaction::ChannelClosingTransaction; +use super::withdrawal::Withdrawal; +use crate::objects::currency_amount::CurrencyAmount; +use crate::objects::entity::Entity; +use crate::objects::transaction::Transaction; use serde::{Deserialize, Deserializer, Serialize}; +use serde_json::Value; +use std::vec::Vec; -pub trait OnChainTransaction : Transaction + Entity { - +pub trait OnChainTransaction: Transaction + Entity { /// The fees that were paid by the node for this transaction. fn get_fees(&self) -> Option; @@ -28,11 +26,9 @@ pub trait OnChainTransaction : Transaction + Entity { /// The number of blockchain confirmations for this transaction in real time. fn get_num_confirmations(&self) -> Option; - -fn type_name(&self) -> &'static str; + fn type_name(&self) -> &'static str; } - #[allow(clippy::large_enum_variant)] #[derive(Debug, Clone, Serialize)] pub enum OnChainTransactionEnum { @@ -40,11 +36,8 @@ pub enum OnChainTransactionEnum { ChannelOpeningTransaction(ChannelOpeningTransaction), Deposit(Deposit), Withdrawal(Withdrawal), - } - - impl<'de> Deserialize<'de> for OnChainTransactionEnum { fn deserialize(deserializer: D) -> Result where @@ -54,39 +47,36 @@ impl<'de> Deserialize<'de> for OnChainTransactionEnum { if let Some(typename) = value.get("__typename").and_then(Value::as_str) { match typename { "ChannelClosingTransaction" => { - let obj = ChannelClosingTransaction::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = ChannelClosingTransaction::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(OnChainTransactionEnum::ChannelClosingTransaction(obj)) - }, + } "ChannelOpeningTransaction" => { - let obj = ChannelOpeningTransaction::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = ChannelOpeningTransaction::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(OnChainTransactionEnum::ChannelOpeningTransaction(obj)) - }, + } "Deposit" => { - let obj = Deposit::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = Deposit::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(OnChainTransactionEnum::Deposit(obj)) - }, + } "Withdrawal" => { - let obj = Withdrawal::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = Withdrawal::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(OnChainTransactionEnum::Withdrawal(obj)) - }, + } _ => Err(serde::de::Error::custom("unknown typename")), } } else { - Err(serde::de::Error::custom("missing __typename field on OnChainTransaction")) + Err(serde::de::Error::custom( + "missing __typename field on OnChainTransaction", + )) } } } - diff --git a/lightspark/src/objects/outgoing_payment.rs b/lightspark/src/objects/outgoing_payment.rs index af0e806..fd21451 100644 --- a/lightspark/src/objects/outgoing_payment.rs +++ b/lightspark/src/objects/outgoing_payment.rs @@ -1,34 +1,32 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; -use serde_json::Value; -use crate::types::entity_wrapper::EntityWrapper; -use crate::objects::transaction_status::TransactionStatus; -use crate::types::graphql_requester::GraphQLRequester; -use crate::objects::payment_request_data::PaymentRequestData; +use crate::error::Error; +use crate::objects::currency_amount::CurrencyAmount; use crate::objects::entity::Entity; -use crate::objects::post_transaction_data::PostTransactionData; 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::PaymentRequestData; +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::objects::transaction_status::TransactionStatus; use crate::types::custom_date_formats::custom_date_format; -use crate::error::Error; +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 serde_json::Value; use std::collections::HashMap; use std::vec::Vec; -use crate::objects::transaction::Transaction; -use chrono::{DateTime, Utc}; -use crate::objects::outgoing_payment_to_attempts_connection::OutgoingPaymentToAttemptsConnection; -use crate::objects::currency_amount::CurrencyAmount; -use crate::objects::payment_failure_reason::PaymentFailureReason; -use crate::types::get_entity::GetEntity; -use crate::types::custom_date_formats::custom_date_format_option; -use crate::objects::payment_request_data::PaymentRequestDataEnum; /// 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)] pub struct OutgoingPayment { - /// The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string. - #[serde (rename = "outgoing_payment_id")] + #[serde(rename = "outgoing_payment_id")] pub id: String, /// The date and time when this transaction was initiated. @@ -40,23 +38,26 @@ pub struct OutgoingPayment { pub updated_at: DateTime, /// The current status of this transaction. - #[serde (rename = "outgoing_payment_status")] + #[serde(rename = "outgoing_payment_status")] pub status: TransactionStatus, /// The date and time when this transaction was completed or failed. - #[serde(with = "custom_date_format_option", rename = "outgoing_payment_resolved_at")] + #[serde( + with = "custom_date_format_option", + rename = "outgoing_payment_resolved_at" + )] pub resolved_at: Option>, /// The amount of money involved in this transaction. - #[serde (rename = "outgoing_payment_amount")] + #[serde(rename = "outgoing_payment_amount")] pub amount: CurrencyAmount, /// The hash of this transaction, so it can be uniquely identified on the Lightning Network. - #[serde (rename = "outgoing_payment_transaction_hash")] + #[serde(rename = "outgoing_payment_transaction_hash")] pub transaction_hash: Option, /// Whether this payment is an UMA payment or not. NOTE: this field is only set if the payment has been sent using the recommended `pay_uma_invoice` function. - #[serde (rename = "outgoing_payment_is_uma")] + #[serde(rename = "outgoing_payment_is_uma")] pub is_uma: bool, /// The Lightspark node this payment originated from. @@ -68,56 +69,49 @@ pub struct OutgoingPayment { pub destination: Option, /// The fees paid by the sender node to send the payment. - #[serde (rename = "outgoing_payment_fees")] + #[serde(rename = "outgoing_payment_fees")] pub fees: Option, /// The data of the payment request that was paid by this transaction, if known. - #[serde (rename = "outgoing_payment_payment_request_data")] + #[serde(rename = "outgoing_payment_payment_request_data")] pub payment_request_data: Option, /// If applicable, the reason why the payment failed. - #[serde (rename = "outgoing_payment_failure_reason")] + #[serde(rename = "outgoing_payment_failure_reason")] pub failure_reason: Option, /// If applicable, user-facing error message describing why the payment failed. - #[serde (rename = "outgoing_payment_failure_message")] + #[serde(rename = "outgoing_payment_failure_message")] pub failure_message: Option, /// The post transaction data which can be used in KYT payment registration. - #[serde (rename = "outgoing_payment_uma_post_transaction_data")] + #[serde(rename = "outgoing_payment_uma_post_transaction_data")] pub uma_post_transaction_data: Option>, /// The preimage of the payment. - #[serde (rename = "outgoing_payment_payment_preimage")] + #[serde(rename = "outgoing_payment_payment_preimage")] pub payment_preimage: Option, /// Whether the payment is made to the same node. - #[serde (rename = "outgoing_payment_is_internal_payment")] + #[serde(rename = "outgoing_payment_is_internal_payment")] pub is_internal_payment: bool, /// The idempotency key of the payment. - #[serde (rename = "outgoing_payment_idempotency_key")] + #[serde(rename = "outgoing_payment_idempotency_key")] pub idempotency_key: Option, /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl LightningTransaction for OutgoingPayment { - - fn type_name(&self) -> &'static str { "OutgoingPayment" } } - - impl Transaction for OutgoingPayment { - /// The current status of this transaction. fn get_status(&self) -> TransactionStatus { self.status.clone() @@ -138,16 +132,12 @@ impl Transaction for OutgoingPayment { self.transaction_hash.clone() } - fn type_name(&self) -> &'static str { "OutgoingPayment" } } - - impl Entity for OutgoingPayment { - /// 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() @@ -163,16 +153,15 @@ impl Entity for OutgoingPayment { self.updated_at } - fn type_name(&self) -> &'static str { "OutgoingPayment" } } - impl GetEntity for OutgoingPayment { fn get_entity_query() -> String { - format!(" + format!( + " query GetEntity($id: ID!) {{ entity(id: $id) {{ ... on OutgoingPayment {{ @@ -181,12 +170,12 @@ impl GetEntity for OutgoingPayment { }} }} - {}", FRAGMENT) - } + {}", + FRAGMENT + ) + } } - - pub const FRAGMENT: &str = " fragment OutgoingPaymentFragment on OutgoingPayment { __typename @@ -536,11 +525,13 @@ fragment OutgoingPaymentFragment on OutgoingPayment { } "; - impl OutgoingPayment { - - - pub async fn get_attempts(&self, requester:&impl GraphQLRequester, first: Option, after: Option) -> Result { + pub async fn get_attempts( + &self, + requester: &impl GraphQLRequester, + first: Option, + after: Option, + ) -> Result { let query = "query FetchOutgoingPaymentToAttemptsConnection($entity_id: ID!, $first: Int, $after: String) { entity(id: $entity_id) { ... on OutgoingPayment { @@ -596,12 +587,10 @@ impl OutgoingPayment { variables.insert("first", first.into()); variables.insert("after", after.into()); - let value = serde_json::to_value(variables).map_err(|err| Error::ConversionError(err))?; let result = requester.execute_graphql(&query, Some(value)).await?; let json = result["entity"]["attempts"].clone(); let result = serde_json::from_value(json).map_err(|err| Error::JsonError(err))?; Ok(result) } - } diff --git a/lightspark/src/objects/outgoing_payment_attempt.rs b/lightspark/src/objects/outgoing_payment_attempt.rs index c6a64d3..ba7995d 100644 --- a/lightspark/src/objects/outgoing_payment_attempt.rs +++ b/lightspark/src/objects/outgoing_payment_attempt.rs @@ -1,63 +1,73 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; +use crate::error::Error; use crate::objects::currency_amount::CurrencyAmount; -use serde_json::Value; -use crate::types::entity_wrapper::EntityWrapper; use crate::objects::entity::Entity; -use crate::error::Error; -use crate::types::get_entity::GetEntity; -use std::collections::HashMap; -use crate::types::custom_date_formats::custom_date_format_option; use crate::objects::htlc_attempt_failure_code::HtlcAttemptFailureCode; +use crate::objects::outgoing_payment_attempt_status::OutgoingPaymentAttemptStatus; use crate::objects::outgoing_payment_attempt_to_hops_connection::OutgoingPaymentAttemptToHopsConnection; use crate::types::custom_date_formats::custom_date_format; +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 crate::objects::outgoing_payment_attempt_status::OutgoingPaymentAttemptStatus; +use serde::{Deserialize, Serialize}; +use serde_json::Value; +use std::collections::HashMap; /// This object represents an attempted Lightning Network payment sent from a Lightspark Node. You can retrieve this object to receive payment related information about any payment attempt sent from your Lightspark Node on the Lightning Network, including any potential reasons the payment may have failed. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct OutgoingPaymentAttempt { - /// The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string. - #[serde (rename = "outgoing_payment_attempt_id")] + #[serde(rename = "outgoing_payment_attempt_id")] pub id: String, /// The date and time when the entity was first created. - #[serde(with = "custom_date_format", rename = "outgoing_payment_attempt_created_at")] + #[serde( + with = "custom_date_format", + rename = "outgoing_payment_attempt_created_at" + )] pub created_at: DateTime, /// The date and time when the entity was last updated. - #[serde(with = "custom_date_format", rename = "outgoing_payment_attempt_updated_at")] + #[serde( + with = "custom_date_format", + rename = "outgoing_payment_attempt_updated_at" + )] pub updated_at: DateTime, /// The status of an outgoing payment attempt. - #[serde (rename = "outgoing_payment_attempt_status")] + #[serde(rename = "outgoing_payment_attempt_status")] pub status: OutgoingPaymentAttemptStatus, /// If the payment attempt failed, then this contains the Bolt #4 failure code. - #[serde (rename = "outgoing_payment_attempt_failure_code")] + #[serde(rename = "outgoing_payment_attempt_failure_code")] pub failure_code: Option, /// If the payment attempt failed, then this contains the index of the hop at which the problem occurred. - #[serde (rename = "outgoing_payment_attempt_failure_source_index")] + #[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")] + #[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", rename = "outgoing_payment_attempt_resolved_at")] + #[serde( + with = "custom_date_format_option", + rename = "outgoing_payment_attempt_resolved_at" + )] pub resolved_at: Option>, /// The total amount of funds required to complete a payment over this route. This value includes the cumulative fees for each hop. As a result, the attempt extended to the first-hop in the route will need to have at least this much value, otherwise the route will fail at an intermediate node due to an insufficient amount. - #[serde (rename = "outgoing_payment_attempt_amount")] + #[serde(rename = "outgoing_payment_attempt_amount")] pub amount: Option, /// The sum of the fees paid at each hop within the route of this attempt. In the case of a one-hop payment, this value will be zero as we don't need to pay a fee to ourselves. - #[serde (rename = "outgoing_payment_attempt_fees")] + #[serde(rename = "outgoing_payment_attempt_fees")] pub fees: Option, /// The outgoing payment for this attempt. @@ -71,12 +81,9 @@ pub struct OutgoingPaymentAttempt { /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl Entity for OutgoingPaymentAttempt { - /// 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() @@ -92,16 +99,15 @@ impl Entity for OutgoingPaymentAttempt { self.updated_at } - fn type_name(&self) -> &'static str { "OutgoingPaymentAttempt" } } - impl GetEntity for OutgoingPaymentAttempt { fn get_entity_query() -> String { - format!(" + format!( + " query GetEntity($id: ID!) {{ entity(id: $id) {{ ... on OutgoingPaymentAttempt {{ @@ -110,12 +116,12 @@ impl GetEntity for OutgoingPaymentAttempt { }} }} - {}", FRAGMENT) - } + {}", + FRAGMENT + ) + } } - - pub const FRAGMENT: &str = " fragment OutgoingPaymentAttemptFragment on OutgoingPaymentAttempt { __typename @@ -152,11 +158,13 @@ fragment OutgoingPaymentAttemptFragment on OutgoingPaymentAttempt { } "; - impl OutgoingPaymentAttempt { - - - pub async fn get_hops(&self, requester:&impl GraphQLRequester, first: Option, after: Option) -> Result { + pub async fn get_hops( + &self, + requester: &impl GraphQLRequester, + first: Option, + after: Option, + ) -> Result { let query = "query FetchOutgoingPaymentAttemptToHopsConnection($entity_id: ID!, $first: Int, $after: String) { entity(id: $entity_id) { ... on OutgoingPaymentAttempt { @@ -207,12 +215,10 @@ impl OutgoingPaymentAttempt { variables.insert("first", first.into()); variables.insert("after", after.into()); - let value = serde_json::to_value(variables).map_err(|err| Error::ConversionError(err))?; let result = requester.execute_graphql(&query, Some(value)).await?; let json = result["entity"]["hops"].clone(); let result = serde_json::from_value(json).map_err(|err| Error::JsonError(err))?; Ok(result) } - } diff --git a/lightspark/src/objects/outgoing_payment_attempt_status.rs b/lightspark/src/objects/outgoing_payment_attempt_status.rs index 46282a6..9ffae68 100644 --- a/lightspark/src/objects/outgoing_payment_attempt_status.rs +++ b/lightspark/src/objects/outgoing_payment_attempt_status.rs @@ -1,4 +1,3 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -7,16 +6,14 @@ use std::fmt; /// This is an enum of all potential statuses of a payment attempt made from a Lightspark Node. #[derive(Debug, Clone, Deserialize, Serialize)] pub enum OutgoingPaymentAttemptStatus { - - #[serde(rename="IN_FLIGHT")] + #[serde(rename = "IN_FLIGHT")] InFlight, - #[serde(rename="SUCCEEDED")] + #[serde(rename = "SUCCEEDED")] Succeeded, - #[serde(rename="FAILED")] + #[serde(rename = "FAILED")] Failed, - } impl Into for OutgoingPaymentAttemptStatus { @@ -31,8 +28,6 @@ impl fmt::Display for OutgoingPaymentAttemptStatus { Self::InFlight => write!(f, "IN_FLIGHT"), Self::Succeeded => write!(f, "SUCCEEDED"), Self::Failed => write!(f, "FAILED"), - } } } - diff --git a/lightspark/src/objects/outgoing_payment_attempt_to_hops_connection.rs b/lightspark/src/objects/outgoing_payment_attempt_to_hops_connection.rs index d74e1e1..5c5e899 100644 --- a/lightspark/src/objects/outgoing_payment_attempt_to_hops_connection.rs +++ b/lightspark/src/objects/outgoing_payment_attempt_to_hops_connection.rs @@ -1,36 +1,31 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; +use crate::objects::connection::Connection; use crate::objects::hop::Hop; -use std::vec::Vec; use crate::objects::page_info::PageInfo; -use crate::objects::connection::Connection; +use serde::{Deserialize, Serialize}; +use std::vec::Vec; /// The connection from an outgoing payment attempt to the list of sequential hops that define the path from sender node to recipient node. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct OutgoingPaymentAttemptToHopsConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). - #[serde (rename = "outgoing_payment_attempt_to_hops_connection_count")] + #[serde(rename = "outgoing_payment_attempt_to_hops_connection_count")] pub count: i64, /// An object that holds pagination information about the objects in this connection. - #[serde (rename = "outgoing_payment_attempt_to_hops_connection_page_info")] + #[serde(rename = "outgoing_payment_attempt_to_hops_connection_page_info")] pub page_info: PageInfo, /// The hops for the current page of this connection. - #[serde (rename = "outgoing_payment_attempt_to_hops_connection_entities")] + #[serde(rename = "outgoing_payment_attempt_to_hops_connection_entities")] pub entities: Vec, /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl Connection for OutgoingPaymentAttemptToHopsConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). fn get_count(&self) -> i64 { self.count @@ -41,15 +36,11 @@ impl Connection for OutgoingPaymentAttemptToHopsConnection { self.page_info.clone() } - fn type_name(&self) -> &'static str { "OutgoingPaymentAttemptToHopsConnection" } } - - - pub const FRAGMENT: &str = " fragment OutgoingPaymentAttemptToHopsConnectionFragment on OutgoingPaymentAttemptToHopsConnection { __typename @@ -66,6 +57,3 @@ fragment OutgoingPaymentAttemptToHopsConnectionFragment on OutgoingPaymentAttemp } } "; - - - diff --git a/lightspark/src/objects/outgoing_payment_for_idempotency_key_input.rs b/lightspark/src/objects/outgoing_payment_for_idempotency_key_input.rs index 86995c8..a708a4b 100644 --- a/lightspark/src/objects/outgoing_payment_for_idempotency_key_input.rs +++ b/lightspark/src/objects/outgoing_payment_for_idempotency_key_input.rs @@ -1,19 +1,7 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; - - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct OutgoingPaymentForIdempotencyKeyInput { - - - pub idempotency_key: String, - } - - - - - diff --git a/lightspark/src/objects/outgoing_payment_for_idempotency_key_output.rs b/lightspark/src/objects/outgoing_payment_for_idempotency_key_output.rs index cadc74b..9211c96 100644 --- a/lightspark/src/objects/outgoing_payment_for_idempotency_key_output.rs +++ b/lightspark/src/objects/outgoing_payment_for_idempotency_key_output.rs @@ -1,20 +1,13 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::types::entity_wrapper::EntityWrapper; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct OutgoingPaymentForIdempotencyKeyOutput { - - #[serde(rename = "outgoing_payment_for_idempotency_key_output_payment")] pub payment: Option, - } - - pub const FRAGMENT: &str = " fragment OutgoingPaymentForIdempotencyKeyOutputFragment on OutgoingPaymentForIdempotencyKeyOutput { __typename @@ -23,6 +16,3 @@ fragment OutgoingPaymentForIdempotencyKeyOutputFragment on OutgoingPaymentForIde } } "; - - - diff --git a/lightspark/src/objects/outgoing_payment_to_attempts_connection.rs b/lightspark/src/objects/outgoing_payment_to_attempts_connection.rs index b97ca9d..2d9fd60 100644 --- a/lightspark/src/objects/outgoing_payment_to_attempts_connection.rs +++ b/lightspark/src/objects/outgoing_payment_to_attempts_connection.rs @@ -1,36 +1,31 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; +use crate::objects::connection::Connection; use crate::objects::outgoing_payment_attempt::OutgoingPaymentAttempt; -use std::vec::Vec; use crate::objects::page_info::PageInfo; -use crate::objects::connection::Connection; +use serde::{Deserialize, Serialize}; +use std::vec::Vec; /// The connection from outgoing payment to all attempts. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct OutgoingPaymentToAttemptsConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). - #[serde (rename = "outgoing_payment_to_attempts_connection_count")] + #[serde(rename = "outgoing_payment_to_attempts_connection_count")] pub count: i64, /// An object that holds pagination information about the objects in this connection. - #[serde (rename = "outgoing_payment_to_attempts_connection_page_info")] + #[serde(rename = "outgoing_payment_to_attempts_connection_page_info")] pub page_info: PageInfo, /// The attempts for the current page of this connection. - #[serde (rename = "outgoing_payment_to_attempts_connection_entities")] + #[serde(rename = "outgoing_payment_to_attempts_connection_entities")] pub entities: Vec, /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl Connection for OutgoingPaymentToAttemptsConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). fn get_count(&self) -> i64 { self.count @@ -41,15 +36,11 @@ impl Connection for OutgoingPaymentToAttemptsConnection { self.page_info.clone() } - fn type_name(&self) -> &'static str { "OutgoingPaymentToAttemptsConnection" } } - - - pub const FRAGMENT: &str = " fragment OutgoingPaymentToAttemptsConnectionFragment on OutgoingPaymentToAttemptsConnection { __typename @@ -66,6 +57,3 @@ fragment OutgoingPaymentToAttemptsConnectionFragment on OutgoingPaymentToAttempt } } "; - - - diff --git a/lightspark/src/objects/outgoing_payments_for_invoice_query_input.rs b/lightspark/src/objects/outgoing_payments_for_invoice_query_input.rs index e141a56..4cae2f7 100644 --- a/lightspark/src/objects/outgoing_payments_for_invoice_query_input.rs +++ b/lightspark/src/objects/outgoing_payments_for_invoice_query_input.rs @@ -1,24 +1,13 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::transaction_status::TransactionStatus; +use serde::{Deserialize, Serialize}; use std::vec::Vec; - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct OutgoingPaymentsForInvoiceQueryInput { - /// The encoded invoice that the outgoing payments paid to. - pub encoded_invoice: String, /// An optional filter to only query outgoing payments of given statuses. - pub statuses: Option>, - } - - - - - diff --git a/lightspark/src/objects/outgoing_payments_for_invoice_query_output.rs b/lightspark/src/objects/outgoing_payments_for_invoice_query_output.rs index 5cd7a21..6d8a48e 100644 --- a/lightspark/src/objects/outgoing_payments_for_invoice_query_output.rs +++ b/lightspark/src/objects/outgoing_payments_for_invoice_query_output.rs @@ -1,21 +1,14 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::objects::outgoing_payment::OutgoingPayment; use serde::{Deserialize, Serialize}; use std::vec::Vec; -use crate::objects::outgoing_payment::OutgoingPayment; - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct OutgoingPaymentsForInvoiceQueryOutput { - - - #[serde (rename = "outgoing_payments_for_invoice_query_output_payments")] + #[serde(rename = "outgoing_payments_for_invoice_query_output_payments")] pub payments: Vec, - } - - pub const FRAGMENT: &str = " fragment OutgoingPaymentsForInvoiceQueryOutputFragment on OutgoingPaymentsForInvoiceQueryOutput { __typename @@ -367,6 +360,3 @@ fragment OutgoingPaymentsForInvoiceQueryOutputFragment on OutgoingPaymentsForInv } } "; - - - diff --git a/lightspark/src/objects/outgoing_payments_for_payment_hash_query_input.rs b/lightspark/src/objects/outgoing_payments_for_payment_hash_query_input.rs index d061ece..78afcb6 100644 --- a/lightspark/src/objects/outgoing_payments_for_payment_hash_query_input.rs +++ b/lightspark/src/objects/outgoing_payments_for_payment_hash_query_input.rs @@ -1,24 +1,13 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::transaction_status::TransactionStatus; +use serde::{Deserialize, Serialize}; use std::vec::Vec; - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct OutgoingPaymentsForPaymentHashQueryInput { - /// The 32-byte hash of the payment preimage for which to fetch payments - pub payment_hash: String, /// An optional filter to only query outgoing payments of given statuses. - pub statuses: Option>, - } - - - - - diff --git a/lightspark/src/objects/outgoing_payments_for_payment_hash_query_output.rs b/lightspark/src/objects/outgoing_payments_for_payment_hash_query_output.rs index 8a7c515..60f7c21 100644 --- a/lightspark/src/objects/outgoing_payments_for_payment_hash_query_output.rs +++ b/lightspark/src/objects/outgoing_payments_for_payment_hash_query_output.rs @@ -1,21 +1,14 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::objects::outgoing_payment::OutgoingPayment; use serde::{Deserialize, Serialize}; use std::vec::Vec; -use crate::objects::outgoing_payment::OutgoingPayment; - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct OutgoingPaymentsForPaymentHashQueryOutput { - - - #[serde (rename = "outgoing_payments_for_payment_hash_query_output_payments")] + #[serde(rename = "outgoing_payments_for_payment_hash_query_output_payments")] pub payments: Vec, - } - - pub const FRAGMENT: &str = " fragment OutgoingPaymentsForPaymentHashQueryOutputFragment on OutgoingPaymentsForPaymentHashQueryOutput { __typename @@ -24,6 +17,3 @@ fragment OutgoingPaymentsForPaymentHashQueryOutputFragment on OutgoingPaymentsFo } } "; - - - diff --git a/lightspark/src/objects/page_info.rs b/lightspark/src/objects/page_info.rs index f04046b..984877e 100644 --- a/lightspark/src/objects/page_info.rs +++ b/lightspark/src/objects/page_info.rs @@ -1,32 +1,22 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; - /// This is an object representing information about a page returned by the Lightspark API. For more information, please see the “Pagination” section of our API docs for more information about its usage. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct PageInfo { - - - #[serde (rename = "page_info_has_next_page")] + #[serde(rename = "page_info_has_next_page")] pub has_next_page: Option, - - #[serde (rename = "page_info_has_previous_page")] + #[serde(rename = "page_info_has_previous_page")] pub has_previous_page: Option, - - #[serde (rename = "page_info_start_cursor")] + #[serde(rename = "page_info_start_cursor")] pub start_cursor: Option, - - #[serde (rename = "page_info_end_cursor")] + #[serde(rename = "page_info_end_cursor")] pub end_cursor: Option, - } - - pub const FRAGMENT: &str = " fragment PageInfoFragment on PageInfo { __typename @@ -36,6 +26,3 @@ fragment PageInfoFragment on PageInfo { page_info_end_cursor: end_cursor } "; - - - diff --git a/lightspark/src/objects/pay_invoice_input.rs b/lightspark/src/objects/pay_invoice_input.rs index 9c7358e..6bb1c89 100644 --- a/lightspark/src/objects/pay_invoice_input.rs +++ b/lightspark/src/objects/pay_invoice_input.rs @@ -1,39 +1,23 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; - - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct PayInvoiceInput { - /// The node from where you want to send the payment. - pub node_id: String, /// The invoice you want to pay (as defined by the BOLT11 standard). - pub encoded_invoice: String, /// The timeout in seconds that we will try to make the payment. - pub timeout_secs: i64, /// The maximum amount of fees that you want to pay for this payment to be sent, expressed in msats. - pub maximum_fees_msats: i64, /// The amount you will pay for this invoice, expressed in msats. It should ONLY be set when the invoice amount is zero. - pub amount_msats: Option, /// The idempotency key of the request. The same result will be returned for the same idempotency key. - pub idempotency_key: Option, - } - - - - - diff --git a/lightspark/src/objects/pay_invoice_output.rs b/lightspark/src/objects/pay_invoice_output.rs index 1609268..c8eec58 100644 --- a/lightspark/src/objects/pay_invoice_output.rs +++ b/lightspark/src/objects/pay_invoice_output.rs @@ -1,20 +1,14 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::types::entity_wrapper::EntityWrapper; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct PayInvoiceOutput { - /// The payment that has been sent. #[serde(rename = "pay_invoice_output_payment")] pub payment: EntityWrapper, - } - - pub const FRAGMENT: &str = " fragment PayInvoiceOutputFragment on PayInvoiceOutput { __typename @@ -23,6 +17,3 @@ fragment PayInvoiceOutputFragment on PayInvoiceOutput { } } "; - - - diff --git a/lightspark/src/objects/pay_uma_invoice_input.rs b/lightspark/src/objects/pay_uma_invoice_input.rs index c53d664..0a3faca 100644 --- a/lightspark/src/objects/pay_uma_invoice_input.rs +++ b/lightspark/src/objects/pay_uma_invoice_input.rs @@ -1,43 +1,20 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; - - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct PayUmaInvoiceInput { - - - pub node_id: String, - - pub encoded_invoice: String, - - pub timeout_secs: i64, - - pub maximum_fees_msats: i64, - - pub amount_msats: Option, - - pub idempotency_key: Option, /// An optional, monthly-rotated, unique hashed identifier corresponding to the sender of the payment. - pub sender_hash: Option, - } - - - - - diff --git a/lightspark/src/objects/payment_direction.rs b/lightspark/src/objects/payment_direction.rs index 607115d..2a13ede 100644 --- a/lightspark/src/objects/payment_direction.rs +++ b/lightspark/src/objects/payment_direction.rs @@ -1,4 +1,3 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -7,13 +6,11 @@ use std::fmt; /// This is an enum indicating the direction of the payment. #[derive(Debug, Clone, Deserialize, Serialize)] pub enum PaymentDirection { - - #[serde(rename="SENT")] + #[serde(rename = "SENT")] Sent, - #[serde(rename="RECEIVED")] + #[serde(rename = "RECEIVED")] Received, - } impl Into for PaymentDirection { @@ -27,8 +24,6 @@ impl fmt::Display for PaymentDirection { match self { Self::Sent => write!(f, "SENT"), Self::Received => write!(f, "RECEIVED"), - } } } - diff --git a/lightspark/src/objects/payment_failure_reason.rs b/lightspark/src/objects/payment_failure_reason.rs index 893508c..1811015 100644 --- a/lightspark/src/objects/payment_failure_reason.rs +++ b/lightspark/src/objects/payment_failure_reason.rs @@ -1,4 +1,3 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -7,43 +6,41 @@ use std::fmt; /// This is an enum of the potential reasons why an OutgoingPayment sent from a Lightspark Node may have failed. #[derive(Debug, Clone, Deserialize, Serialize)] pub enum PaymentFailureReason { - - #[serde(rename="NONE")] + #[serde(rename = "NONE")] None, - #[serde(rename="TIMEOUT")] + #[serde(rename = "TIMEOUT")] Timeout, - #[serde(rename="NO_ROUTE")] + #[serde(rename = "NO_ROUTE")] NoRoute, - #[serde(rename="ERROR")] + #[serde(rename = "ERROR")] Error, - #[serde(rename="INCORRECT_PAYMENT_DETAILS")] + #[serde(rename = "INCORRECT_PAYMENT_DETAILS")] IncorrectPaymentDetails, - #[serde(rename="INSUFFICIENT_BALANCE")] + #[serde(rename = "INSUFFICIENT_BALANCE")] InsufficientBalance, - #[serde(rename="INVOICE_ALREADY_PAID")] + #[serde(rename = "INVOICE_ALREADY_PAID")] InvoiceAlreadyPaid, - #[serde(rename="SELF_PAYMENT")] + #[serde(rename = "SELF_PAYMENT")] SelfPayment, - #[serde(rename="INVOICE_EXPIRED")] + #[serde(rename = "INVOICE_EXPIRED")] InvoiceExpired, - #[serde(rename="INVOICE_CANCELLED")] + #[serde(rename = "INVOICE_CANCELLED")] InvoiceCancelled, - #[serde(rename="RISK_SCREENING_FAILED")] + #[serde(rename = "RISK_SCREENING_FAILED")] RiskScreeningFailed, - #[serde(rename="INSUFFICIENT_BALANCE_ON_SINGLE_PATH_INVOICE")] + #[serde(rename = "INSUFFICIENT_BALANCE_ON_SINGLE_PATH_INVOICE")] InsufficientBalanceOnSinglePathInvoice, - } impl Into for PaymentFailureReason { @@ -66,9 +63,9 @@ impl fmt::Display for PaymentFailureReason { Self::InvoiceExpired => write!(f, "INVOICE_EXPIRED"), Self::InvoiceCancelled => write!(f, "INVOICE_CANCELLED"), Self::RiskScreeningFailed => write!(f, "RISK_SCREENING_FAILED"), - Self::InsufficientBalanceOnSinglePathInvoice => write!(f, "INSUFFICIENT_BALANCE_ON_SINGLE_PATH_INVOICE"), - + Self::InsufficientBalanceOnSinglePathInvoice => { + write!(f, "INSUFFICIENT_BALANCE_ON_SINGLE_PATH_INVOICE") + } } } } - diff --git a/lightspark/src/objects/payment_request.rs b/lightspark/src/objects/payment_request.rs index b5211ba..b1f5efb 100644 --- a/lightspark/src/objects/payment_request.rs +++ b/lightspark/src/objects/payment_request.rs @@ -1,34 +1,27 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use crate::objects::entity::Entity; -use serde_json::Value; use super::invoice::Invoice; +use crate::objects::entity::Entity; +use crate::objects::payment_request_data::PaymentRequestData; use crate::objects::payment_request_status::PaymentRequestStatus; use serde::{Deserialize, Deserializer, Serialize}; -use crate::objects::payment_request_data::PaymentRequestData; - -pub trait PaymentRequest : Entity { +use serde_json::Value; +pub trait PaymentRequest: Entity { /// The details of the payment request. fn get_data(&self) -> &dyn PaymentRequestData; /// The status of the payment request. fn get_status(&self) -> PaymentRequestStatus; - -fn type_name(&self) -> &'static str; + fn type_name(&self) -> &'static str; } - #[allow(clippy::large_enum_variant)] #[derive(Debug, Clone, Serialize)] pub enum PaymentRequestEnum { Invoice(Invoice), - } - - impl<'de> Deserialize<'de> for PaymentRequestEnum { fn deserialize(deserializer: D) -> Result where @@ -38,18 +31,18 @@ impl<'de> Deserialize<'de> for PaymentRequestEnum { if let Some(typename) = value.get("__typename").and_then(Value::as_str) { match typename { "Invoice" => { - let obj = Invoice::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = Invoice::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(PaymentRequestEnum::Invoice(obj)) - }, + } _ => Err(serde::de::Error::custom("unknown typename")), } } else { - Err(serde::de::Error::custom("missing __typename field on PaymentRequest")) + Err(serde::de::Error::custom( + "missing __typename field on PaymentRequest", + )) } } } - diff --git a/lightspark/src/objects/payment_request_data.rs b/lightspark/src/objects/payment_request_data.rs index b644d50..6affc0e 100644 --- a/lightspark/src/objects/payment_request_data.rs +++ b/lightspark/src/objects/payment_request_data.rs @@ -1,33 +1,24 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde_json::Value; use super::invoice_data::InvoiceData; -use serde::{Deserialize, Deserializer, Serialize}; use crate::objects::bitcoin_network::BitcoinNetwork; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_json::Value; pub trait PaymentRequestData { - - fn get_encoded_payment_request(&self) -> String; - fn get_bitcoin_network(&self) -> BitcoinNetwork; - -fn type_name(&self) -> &'static str; + fn type_name(&self) -> &'static str; } - #[allow(clippy::large_enum_variant)] #[derive(Debug, Clone, Serialize)] pub enum PaymentRequestDataEnum { InvoiceData(InvoiceData), - } - - impl<'de> Deserialize<'de> for PaymentRequestDataEnum { fn deserialize(deserializer: D) -> Result where @@ -37,18 +28,18 @@ impl<'de> Deserialize<'de> for PaymentRequestDataEnum { if let Some(typename) = value.get("__typename").and_then(Value::as_str) { match typename { "InvoiceData" => { - let obj = InvoiceData::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = InvoiceData::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(PaymentRequestDataEnum::InvoiceData(obj)) - }, + } _ => Err(serde::de::Error::custom("unknown typename")), } } else { - Err(serde::de::Error::custom("missing __typename field on PaymentRequestData")) + Err(serde::de::Error::custom( + "missing __typename field on PaymentRequestData", + )) } } } - diff --git a/lightspark/src/objects/payment_request_status.rs b/lightspark/src/objects/payment_request_status.rs index b7e6e64..20d9e43 100644 --- a/lightspark/src/objects/payment_request_status.rs +++ b/lightspark/src/objects/payment_request_status.rs @@ -1,4 +1,3 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -7,13 +6,11 @@ use std::fmt; /// This is an enum of the potential states that a payment request on the Lightning Network can take. #[derive(Debug, Clone, Deserialize, Serialize)] pub enum PaymentRequestStatus { - - #[serde(rename="OPEN")] + #[serde(rename = "OPEN")] Open, - #[serde(rename="CLOSED")] + #[serde(rename = "CLOSED")] Closed, - } impl Into for PaymentRequestStatus { @@ -27,8 +24,6 @@ impl fmt::Display for PaymentRequestStatus { match self { Self::Open => write!(f, "OPEN"), Self::Closed => write!(f, "CLOSED"), - } } } - diff --git a/lightspark/src/objects/permission.rs b/lightspark/src/objects/permission.rs index 30fc369..7f7c3bd 100644 --- a/lightspark/src/objects/permission.rs +++ b/lightspark/src/objects/permission.rs @@ -1,4 +1,3 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -7,49 +6,47 @@ use std::fmt; /// This is an enum of the potential permissions that a Lightspark user can have in regards to account management. #[derive(Debug, Clone, Deserialize, Serialize)] pub enum Permission { - - #[serde(rename="ALL")] + #[serde(rename = "ALL")] All, - #[serde(rename="MAINNET_VIEW")] + #[serde(rename = "MAINNET_VIEW")] MainnetView, - #[serde(rename="MAINNET_TRANSACT")] + #[serde(rename = "MAINNET_TRANSACT")] MainnetTransact, - #[serde(rename="MAINNET_MANAGE")] + #[serde(rename = "MAINNET_MANAGE")] MainnetManage, - #[serde(rename="TESTNET_VIEW")] + #[serde(rename = "TESTNET_VIEW")] TestnetView, - #[serde(rename="TESTNET_TRANSACT")] + #[serde(rename = "TESTNET_TRANSACT")] TestnetTransact, - #[serde(rename="TESTNET_MANAGE")] + #[serde(rename = "TESTNET_MANAGE")] TestnetManage, - #[serde(rename="REGTEST_VIEW")] + #[serde(rename = "REGTEST_VIEW")] RegtestView, - #[serde(rename="REGTEST_TRANSACT")] + #[serde(rename = "REGTEST_TRANSACT")] RegtestTransact, - #[serde(rename="REGTEST_MANAGE")] + #[serde(rename = "REGTEST_MANAGE")] RegtestManage, - #[serde(rename="USER_VIEW")] + #[serde(rename = "USER_VIEW")] UserView, - #[serde(rename="USER_MANAGE")] + #[serde(rename = "USER_MANAGE")] UserManage, - #[serde(rename="ACCOUNT_VIEW")] + #[serde(rename = "ACCOUNT_VIEW")] AccountView, - #[serde(rename="ACCOUNT_MANAGE")] + #[serde(rename = "ACCOUNT_MANAGE")] AccountManage, - } impl Into for Permission { @@ -75,8 +72,6 @@ impl fmt::Display for Permission { Self::UserManage => write!(f, "USER_MANAGE"), Self::AccountView => write!(f, "ACCOUNT_VIEW"), Self::AccountManage => write!(f, "ACCOUNT_MANAGE"), - } } } - diff --git a/lightspark/src/objects/post_transaction_data.rs b/lightspark/src/objects/post_transaction_data.rs index a6b4ab9..cc0ebc4 100644 --- a/lightspark/src/objects/post_transaction_data.rs +++ b/lightspark/src/objects/post_transaction_data.rs @@ -1,24 +1,19 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::currency_amount::CurrencyAmount; +use serde::{Deserialize, Serialize}; /// This object represents post-transaction data that could be used to register payment for KYT. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct PostTransactionData { - /// The utxo of the channel over which the payment went through in the format of :. - #[serde (rename = "post_transaction_data_utxo")] + #[serde(rename = "post_transaction_data_utxo")] pub utxo: String, /// The amount of funds transferred in the payment. - #[serde (rename = "post_transaction_data_amount")] + #[serde(rename = "post_transaction_data_amount")] pub amount: CurrencyAmount, - } - - pub const FRAGMENT: &str = " fragment PostTransactionDataFragment on PostTransactionData { __typename @@ -33,6 +28,3 @@ fragment PostTransactionDataFragment on PostTransactionData { } } "; - - - diff --git a/lightspark/src/objects/region_code.rs b/lightspark/src/objects/region_code.rs index cd3271f..998f3ac 100644 --- a/lightspark/src/objects/region_code.rs +++ b/lightspark/src/objects/region_code.rs @@ -1,4 +1,3 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -9,1005 +8,1004 @@ use std::fmt; pub enum RegionCode { /// The code representing the country of Afghanistan. - #[serde(rename="AF")] + #[serde(rename = "AF")] Af, /// The code representing the country of Åland Islands. - #[serde(rename="AX")] + #[serde(rename = "AX")] Ax, /// The code representing the country of Albania. - #[serde(rename="AL")] + #[serde(rename = "AL")] Al, /// The code representing the country of Algeria. - #[serde(rename="DZ")] + #[serde(rename = "DZ")] Dz, /// The code representing the country of American Samoa. - #[serde(rename="AS")] + #[serde(rename = "AS")] As, /// The code representing the country of Andorra. - #[serde(rename="AD")] + #[serde(rename = "AD")] Ad, /// The code representing the country of Angola. - #[serde(rename="AO")] + #[serde(rename = "AO")] Ao, /// The code representing the country of Anguilla. - #[serde(rename="AI")] + #[serde(rename = "AI")] Ai, /// The code representing the country of Antarctica. - #[serde(rename="AQ")] + #[serde(rename = "AQ")] Aq, /// The code representing the country of Antigua and Barbuda. - #[serde(rename="AG")] + #[serde(rename = "AG")] Ag, /// The code representing the country of Argentina. - #[serde(rename="AR")] + #[serde(rename = "AR")] Ar, /// The code representing the country of Armenia. - #[serde(rename="AM")] + #[serde(rename = "AM")] Am, /// The code representing the country of Aruba. - #[serde(rename="AW")] + #[serde(rename = "AW")] Aw, /// The code representing the country of Australia. - #[serde(rename="AU")] + #[serde(rename = "AU")] Au, /// The code representing the country of Austria. - #[serde(rename="AT")] + #[serde(rename = "AT")] At, /// The code representing the country of Azerbaijan. - #[serde(rename="AZ")] + #[serde(rename = "AZ")] Az, /// The code representing the country of Bahamas. - #[serde(rename="BS")] + #[serde(rename = "BS")] Bs, /// The code representing the country of Bahrain. - #[serde(rename="BH")] + #[serde(rename = "BH")] Bh, /// The code representing the country of Bangladesh. - #[serde(rename="BD")] + #[serde(rename = "BD")] Bd, /// The code representing the country of Barbados. - #[serde(rename="BB")] + #[serde(rename = "BB")] Bb, /// The code representing the country of Belarus. - #[serde(rename="BY")] + #[serde(rename = "BY")] By, /// The code representing the country of Belgium. - #[serde(rename="BE")] + #[serde(rename = "BE")] Be, /// The code representing the country of Belize. - #[serde(rename="BZ")] + #[serde(rename = "BZ")] Bz, /// The code representing the country of Benin. - #[serde(rename="BJ")] + #[serde(rename = "BJ")] Bj, /// The code representing the country of Bermuda. - #[serde(rename="BM")] + #[serde(rename = "BM")] Bm, /// The code representing the country of Bhutan. - #[serde(rename="BT")] + #[serde(rename = "BT")] Bt, /// The code representing the country of The Plurinational State of Bolivia. - #[serde(rename="BO")] + #[serde(rename = "BO")] Bo, /// The code representing the country of Bonaire, Sint Eustatius, and Saba. - #[serde(rename="BQ")] + #[serde(rename = "BQ")] Bq, /// The code representing the country of Bosnia and Herzegovina. - #[serde(rename="BA")] + #[serde(rename = "BA")] Ba, /// The code representing the country of Botswana. - #[serde(rename="BW")] + #[serde(rename = "BW")] Bw, /// The code representing the country of Bouvet Island. - #[serde(rename="BV")] + #[serde(rename = "BV")] Bv, /// The code representing the country of Brazil. - #[serde(rename="BR")] + #[serde(rename = "BR")] Br, /// The code representing the country of British Indian Ocean Territory. - #[serde(rename="IO")] + #[serde(rename = "IO")] Io, /// The code representing the country of Brunei Darussalam. - #[serde(rename="BN")] + #[serde(rename = "BN")] Bn, /// The code representing the country of Bulgaria. - #[serde(rename="BG")] + #[serde(rename = "BG")] Bg, /// The code representing the country of Burkina Faso. - #[serde(rename="BF")] + #[serde(rename = "BF")] Bf, /// The code representing the country of Burundi. - #[serde(rename="BI")] + #[serde(rename = "BI")] Bi, /// The code representing the country of Cambodia. - #[serde(rename="KH")] + #[serde(rename = "KH")] Kh, /// The code representing the country of Cameroon. - #[serde(rename="CM")] + #[serde(rename = "CM")] Cm, /// The code representing the country of Canada. - #[serde(rename="CA")] + #[serde(rename = "CA")] Ca, /// The code representing the country of Cape Verde. - #[serde(rename="CV")] + #[serde(rename = "CV")] Cv, /// The code representing the country of Cayman Islands. - #[serde(rename="KY")] + #[serde(rename = "KY")] Ky, /// The code representing the country of Central African Republic. - #[serde(rename="CF")] + #[serde(rename = "CF")] Cf, /// The code representing the country of Chad. - #[serde(rename="TD")] + #[serde(rename = "TD")] Td, /// The code representing the country of Chile. - #[serde(rename="CL")] + #[serde(rename = "CL")] Cl, /// The code representing the country of China. - #[serde(rename="CN")] + #[serde(rename = "CN")] Cn, /// The code representing the country of Christmas Island. - #[serde(rename="CX")] + #[serde(rename = "CX")] Cx, /// The code representing the country of Cocos (Keeling) Islands. - #[serde(rename="CC")] + #[serde(rename = "CC")] Cc, /// The code representing the country of Colombia. - #[serde(rename="CO")] + #[serde(rename = "CO")] Co, /// The code representing the country of Comoros. - #[serde(rename="KM")] + #[serde(rename = "KM")] Km, /// The code representing the country of Congo. - #[serde(rename="CG")] + #[serde(rename = "CG")] Cg, /// The code representing the country of The Democratic Republic of the Congo. - #[serde(rename="CD")] + #[serde(rename = "CD")] Cd, /// The code representing the country of Cook Islands. - #[serde(rename="CK")] + #[serde(rename = "CK")] Ck, /// The code representing the country of Costa Rica. - #[serde(rename="CR")] + #[serde(rename = "CR")] Cr, /// The code representing the country of Côte d'Ivoire. - #[serde(rename="CI")] + #[serde(rename = "CI")] Ci, /// The code representing the country of Croatia. - #[serde(rename="HR")] + #[serde(rename = "HR")] Hr, /// The code representing the country of Cuba. - #[serde(rename="CU")] + #[serde(rename = "CU")] Cu, /// The code representing the country of Curaçao. - #[serde(rename="CW")] + #[serde(rename = "CW")] Cw, /// The code representing the country of Cyprus. - #[serde(rename="CY")] + #[serde(rename = "CY")] Cy, /// The code representing the country of Czech Republic. - #[serde(rename="CZ")] + #[serde(rename = "CZ")] Cz, /// The code representing the country of Denmark. - #[serde(rename="DK")] + #[serde(rename = "DK")] Dk, /// The code representing the country of Djibouti. - #[serde(rename="DJ")] + #[serde(rename = "DJ")] Dj, /// The code representing the country of Dominica. - #[serde(rename="DM")] + #[serde(rename = "DM")] Dm, /// The code representing the country of Dominican Republic. - #[serde(rename="DO")] + #[serde(rename = "DO")] Do, /// The code representing the country of Ecuador. - #[serde(rename="EC")] + #[serde(rename = "EC")] Ec, /// The code representing the country of Egypt. - #[serde(rename="EG")] + #[serde(rename = "EG")] Eg, /// The code representing the country of El Salvador. - #[serde(rename="SV")] + #[serde(rename = "SV")] Sv, /// The code representing the country of Equatorial Guinea. - #[serde(rename="GQ")] + #[serde(rename = "GQ")] Gq, /// The code representing the country of Eritrea. - #[serde(rename="ER")] + #[serde(rename = "ER")] Er, /// The code representing the country of Estonia. - #[serde(rename="EE")] + #[serde(rename = "EE")] Ee, /// The code representing the country of Ethiopia. - #[serde(rename="ET")] + #[serde(rename = "ET")] Et, /// The code representing the country of Falkland Islands (Malvinas). - #[serde(rename="FK")] + #[serde(rename = "FK")] Fk, /// The code representing the country of Faroe Islands. - #[serde(rename="FO")] + #[serde(rename = "FO")] Fo, /// The code representing the country of Fiji. - #[serde(rename="FJ")] + #[serde(rename = "FJ")] Fj, /// The code representing the country of Finland. - #[serde(rename="FI")] + #[serde(rename = "FI")] Fi, /// The code representing the country of France. - #[serde(rename="FR")] + #[serde(rename = "FR")] Fr, /// The code representing the country of French Guiana. - #[serde(rename="GF")] + #[serde(rename = "GF")] Gf, /// The code representing the country of French Polynesia. - #[serde(rename="PF")] + #[serde(rename = "PF")] Pf, /// The code representing the country of French Southern Territories. - #[serde(rename="TF")] + #[serde(rename = "TF")] Tf, /// The code representing the country of Gabon. - #[serde(rename="GA")] + #[serde(rename = "GA")] Ga, /// The code representing the country of Gambia. - #[serde(rename="GM")] + #[serde(rename = "GM")] Gm, /// The code representing the country of Georgia. - #[serde(rename="GE")] + #[serde(rename = "GE")] Ge, /// The code representing the country of Germany. - #[serde(rename="DE")] + #[serde(rename = "DE")] De, /// The code representing the country of Ghana. - #[serde(rename="GH")] + #[serde(rename = "GH")] Gh, /// The code representing the country of Gibraltar. - #[serde(rename="GI")] + #[serde(rename = "GI")] Gi, /// The code representing the country of Greece. - #[serde(rename="GR")] + #[serde(rename = "GR")] Gr, /// The code representing the country of Greenland. - #[serde(rename="GL")] + #[serde(rename = "GL")] Gl, /// The code representing the country of Grenada. - #[serde(rename="GD")] + #[serde(rename = "GD")] Gd, /// The code representing the country of Guadeloupe. - #[serde(rename="GP")] + #[serde(rename = "GP")] Gp, /// The code representing the country of Guam. - #[serde(rename="GU")] + #[serde(rename = "GU")] Gu, /// The code representing the country of Guatemala. - #[serde(rename="GT")] + #[serde(rename = "GT")] Gt, /// The code representing the country of Guernsey. - #[serde(rename="GG")] + #[serde(rename = "GG")] Gg, /// The code representing the country of Guinea. - #[serde(rename="GN")] + #[serde(rename = "GN")] Gn, /// The code representing the country of Guinea-Bissau. - #[serde(rename="GW")] + #[serde(rename = "GW")] Gw, /// The code representing the country of Guyana. - #[serde(rename="GY")] + #[serde(rename = "GY")] Gy, /// The code representing the country of Haiti. - #[serde(rename="HT")] + #[serde(rename = "HT")] Ht, /// The code representing the country of Heard Island and McDonald Islands. - #[serde(rename="HM")] + #[serde(rename = "HM")] Hm, /// The code representing the country of Holy See (Vatican City State). - #[serde(rename="VA")] + #[serde(rename = "VA")] Va, /// The code representing the country of Honduras. - #[serde(rename="HN")] + #[serde(rename = "HN")] Hn, /// The code representing the country of Hong Kong. - #[serde(rename="HK")] + #[serde(rename = "HK")] Hk, /// The code representing the country of Hungary. - #[serde(rename="HU")] + #[serde(rename = "HU")] Hu, /// The code representing the country of Iceland. - #[serde(rename="IS")] + #[serde(rename = "IS")] Is, /// The code representing the country of India. - #[serde(rename="IN")] + #[serde(rename = "IN")] In, /// The code representing the country of Indonesia. - #[serde(rename="ID")] + #[serde(rename = "ID")] Id, /// The code representing the country of Islamic Republic of Iran. - #[serde(rename="IR")] + #[serde(rename = "IR")] Ir, /// The code representing the country of Iraq. - #[serde(rename="IQ")] + #[serde(rename = "IQ")] Iq, /// The code representing the country of Ireland. - #[serde(rename="IE")] + #[serde(rename = "IE")] Ie, /// The code representing the country of Isle of Man. - #[serde(rename="IM")] + #[serde(rename = "IM")] Im, /// The code representing the country of Israel. - #[serde(rename="IL")] + #[serde(rename = "IL")] Il, /// The code representing the country of Italy. - #[serde(rename="IT")] + #[serde(rename = "IT")] It, /// The code representing the country of Jamaica. - #[serde(rename="JM")] + #[serde(rename = "JM")] Jm, /// The code representing the country of Japan. - #[serde(rename="JP")] + #[serde(rename = "JP")] Jp, /// The code representing the country of Jersey. - #[serde(rename="JE")] + #[serde(rename = "JE")] Je, /// The code representing the country of Jordan. - #[serde(rename="JO")] + #[serde(rename = "JO")] Jo, /// The code representing the country of Kazakhstan. - #[serde(rename="KZ")] + #[serde(rename = "KZ")] Kz, /// The code representing the country of Kenya. - #[serde(rename="KE")] + #[serde(rename = "KE")] Ke, /// The code representing the country of Kiribati. - #[serde(rename="KI")] + #[serde(rename = "KI")] Ki, /// The code representing the country of Democratic People's Republic ofKorea. - #[serde(rename="KP")] + #[serde(rename = "KP")] Kp, /// The code representing the country of Republic of Korea. - #[serde(rename="KR")] + #[serde(rename = "KR")] Kr, /// The code representing the country of Kuwait. - #[serde(rename="KW")] + #[serde(rename = "KW")] Kw, /// The code representing the country of Kyrgyzstan. - #[serde(rename="KG")] + #[serde(rename = "KG")] Kg, /// The code representing the country of Lao People's Democratic Republic. - #[serde(rename="LA")] + #[serde(rename = "LA")] La, /// The code representing the country of Latvia. - #[serde(rename="LV")] + #[serde(rename = "LV")] Lv, /// The code representing the country of Lebanon. - #[serde(rename="LB")] + #[serde(rename = "LB")] Lb, /// The code representing the country of Lesotho. - #[serde(rename="LS")] + #[serde(rename = "LS")] Ls, /// The code representing the country of Liberia. - #[serde(rename="LR")] + #[serde(rename = "LR")] Lr, /// The code representing the country of Libya. - #[serde(rename="LY")] + #[serde(rename = "LY")] Ly, /// The code representing the country of Liechtenstein. - #[serde(rename="LI")] + #[serde(rename = "LI")] Li, /// The code representing the country of Lithuania. - #[serde(rename="LT")] + #[serde(rename = "LT")] Lt, /// The code representing the country of Luxembourg. - #[serde(rename="LU")] + #[serde(rename = "LU")] Lu, /// The code representing the country of Macao. - #[serde(rename="MO")] + #[serde(rename = "MO")] Mo, /// The code representing the country of The Former Yugoslav Republic of Macedonia. - #[serde(rename="MK")] + #[serde(rename = "MK")] Mk, /// The code representing the country of Madagascar. - #[serde(rename="MG")] + #[serde(rename = "MG")] Mg, /// The code representing the country of Malawi. - #[serde(rename="MW")] + #[serde(rename = "MW")] Mw, /// The code representing the country of Malaysia. - #[serde(rename="MY")] + #[serde(rename = "MY")] My, /// The code representing the country of Maldives. - #[serde(rename="MV")] + #[serde(rename = "MV")] Mv, /// The code representing the country of Mali. - #[serde(rename="ML")] + #[serde(rename = "ML")] Ml, /// The code representing the country of Malta. - #[serde(rename="MT")] + #[serde(rename = "MT")] Mt, /// The code representing the country of Marshall Islands. - #[serde(rename="MH")] + #[serde(rename = "MH")] Mh, /// The code representing the country of Martinique. - #[serde(rename="MQ")] + #[serde(rename = "MQ")] Mq, /// The code representing the country of Mauritania. - #[serde(rename="MR")] + #[serde(rename = "MR")] Mr, /// The code representing the country of Mauritius. - #[serde(rename="MU")] + #[serde(rename = "MU")] Mu, /// The code representing the country of Mayotte. - #[serde(rename="YT")] + #[serde(rename = "YT")] Yt, /// The code representing the country of Mexico. - #[serde(rename="MX")] + #[serde(rename = "MX")] Mx, /// The code representing the country of Federated States ofMicronesia. - #[serde(rename="FM")] + #[serde(rename = "FM")] Fm, /// The code representing the country of Republic of Moldova. - #[serde(rename="MD")] + #[serde(rename = "MD")] Md, /// The code representing the country of Monaco. - #[serde(rename="MC")] + #[serde(rename = "MC")] Mc, /// The code representing the country of Mongolia. - #[serde(rename="MN")] + #[serde(rename = "MN")] Mn, /// The code representing the country of Montenegro. - #[serde(rename="ME")] + #[serde(rename = "ME")] Me, /// The code representing the country of Montserrat. - #[serde(rename="MS")] + #[serde(rename = "MS")] Ms, /// The code representing the country of Morocco. - #[serde(rename="MA")] + #[serde(rename = "MA")] Ma, /// The code representing the country of Mozambique. - #[serde(rename="MZ")] + #[serde(rename = "MZ")] Mz, /// The code representing the country of Myanmar. - #[serde(rename="MM")] + #[serde(rename = "MM")] Mm, /// The code representing the country of Namibia. - #[serde(rename="NA")] + #[serde(rename = "NA")] Na, /// The code representing the country of Nauru. - #[serde(rename="NR")] + #[serde(rename = "NR")] Nr, /// The code representing the country of Nepal. - #[serde(rename="NP")] + #[serde(rename = "NP")] Np, /// The code representing the country of Netherlands. - #[serde(rename="NL")] + #[serde(rename = "NL")] Nl, /// The code representing the country of New Caledonia. - #[serde(rename="NC")] + #[serde(rename = "NC")] Nc, /// The code representing the country of New Zealand. - #[serde(rename="NZ")] + #[serde(rename = "NZ")] Nz, /// The code representing the country of Nicaragua. - #[serde(rename="NI")] + #[serde(rename = "NI")] Ni, /// The code representing the country of Niger. - #[serde(rename="NE")] + #[serde(rename = "NE")] Ne, /// The code representing the country of Nigeria. - #[serde(rename="NG")] + #[serde(rename = "NG")] Ng, /// The code representing the country of Niue. - #[serde(rename="NU")] + #[serde(rename = "NU")] Nu, /// The code representing the country of Norfolk Island. - #[serde(rename="NF")] + #[serde(rename = "NF")] Nf, /// The code representing the country of Northern Mariana Islands. - #[serde(rename="MP")] + #[serde(rename = "MP")] Mp, /// The code representing the country of Norway. - #[serde(rename="NO")] + #[serde(rename = "NO")] No, /// The code representing the country of Oman. - #[serde(rename="OM")] + #[serde(rename = "OM")] Om, /// The code representing the country of Pakistan. - #[serde(rename="PK")] + #[serde(rename = "PK")] Pk, /// The code representing the country of Palau. - #[serde(rename="PW")] + #[serde(rename = "PW")] Pw, /// The code representing the country of State of Palestine. - #[serde(rename="PS")] + #[serde(rename = "PS")] Ps, /// The code representing the country of Panama. - #[serde(rename="PA")] + #[serde(rename = "PA")] Pa, /// The code representing the country of Papua New Guinea. - #[serde(rename="PG")] + #[serde(rename = "PG")] Pg, /// The code representing the country of Paraguay. - #[serde(rename="PY")] + #[serde(rename = "PY")] Py, /// The code representing the country of Peru. - #[serde(rename="PE")] + #[serde(rename = "PE")] Pe, /// The code representing the country of Philippines. - #[serde(rename="PH")] + #[serde(rename = "PH")] Ph, /// The code representing the country of Pitcairn. - #[serde(rename="PN")] + #[serde(rename = "PN")] Pn, /// The code representing the country of Poland. - #[serde(rename="PL")] + #[serde(rename = "PL")] Pl, /// The code representing the country of Portugal. - #[serde(rename="PT")] + #[serde(rename = "PT")] Pt, /// The code representing the country of Puerto Rico. - #[serde(rename="PR")] + #[serde(rename = "PR")] Pr, /// The code representing the country of Qatar. - #[serde(rename="QA")] + #[serde(rename = "QA")] Qa, /// The code representing the country of Réunion. - #[serde(rename="RE")] + #[serde(rename = "RE")] Re, /// The code representing the country of Romania. - #[serde(rename="RO")] + #[serde(rename = "RO")] Ro, /// The code representing the country of Russian Federation. - #[serde(rename="RU")] + #[serde(rename = "RU")] Ru, /// The code representing the country of Rwanda. - #[serde(rename="RW")] + #[serde(rename = "RW")] Rw, /// The code representing the country of Saint Barthélemy. - #[serde(rename="BL")] + #[serde(rename = "BL")] Bl, /// The code representing the country of Saint Helena Ascension and Tristan da Cunha. - #[serde(rename="SH")] + #[serde(rename = "SH")] Sh, /// The code representing the country of Saint Kitts and Nevis. - #[serde(rename="KN")] + #[serde(rename = "KN")] Kn, /// The code representing the country of Saint Lucia. - #[serde(rename="LC")] + #[serde(rename = "LC")] Lc, /// The code representing the country of Saint Martin (French part). - #[serde(rename="MF")] + #[serde(rename = "MF")] Mf, /// The code representing the country of Saint Pierre and Miquelon. - #[serde(rename="PM")] + #[serde(rename = "PM")] Pm, /// The code representing the country of Saint Vincent and the Grenadines. - #[serde(rename="VC")] + #[serde(rename = "VC")] Vc, /// The code representing the country of Samoa. - #[serde(rename="WS")] + #[serde(rename = "WS")] Ws, /// The code representing the country of San Marino. - #[serde(rename="SM")] + #[serde(rename = "SM")] Sm, /// The code representing the country of Sao Tome and Principe. - #[serde(rename="ST")] + #[serde(rename = "ST")] St, /// The code representing the country of Saudi Arabia. - #[serde(rename="SA")] + #[serde(rename = "SA")] Sa, /// The code representing the country of Senegal. - #[serde(rename="SN")] + #[serde(rename = "SN")] Sn, /// The code representing the country of Serbia. - #[serde(rename="RS")] + #[serde(rename = "RS")] Rs, /// The code representing the country of Seychelles. - #[serde(rename="SC")] + #[serde(rename = "SC")] Sc, /// The code representing the country of Sierra Leone. - #[serde(rename="SL")] + #[serde(rename = "SL")] Sl, /// The code representing the country of Singapore. - #[serde(rename="SG")] + #[serde(rename = "SG")] Sg, /// The code representing the country of Sint Maarten (Dutch part). - #[serde(rename="SX")] + #[serde(rename = "SX")] Sx, /// The code representing the country of Slovakia. - #[serde(rename="SK")] + #[serde(rename = "SK")] Sk, /// The code representing the country of Slovenia. - #[serde(rename="SI")] + #[serde(rename = "SI")] Si, /// The code representing the country of Solomon Islands. - #[serde(rename="SB")] + #[serde(rename = "SB")] Sb, /// The code representing the country of Somalia. - #[serde(rename="SO")] + #[serde(rename = "SO")] So, /// The code representing the country of South Africa. - #[serde(rename="ZA")] + #[serde(rename = "ZA")] Za, /// The code representing the country of South Georgia and the South Sandwich Islands. - #[serde(rename="GS")] + #[serde(rename = "GS")] Gs, /// The code representing the country of South Sudan. - #[serde(rename="SS")] + #[serde(rename = "SS")] Ss, /// The code representing the country of Spain. - #[serde(rename="ES")] + #[serde(rename = "ES")] Es, /// The code representing the country of Sri Lanka. - #[serde(rename="LK")] + #[serde(rename = "LK")] Lk, /// The code representing the country of Sudan. - #[serde(rename="SD")] + #[serde(rename = "SD")] Sd, /// The code representing the country of Suriname. - #[serde(rename="SR")] + #[serde(rename = "SR")] Sr, /// The code representing the country of Svalbard and Jan Mayen. - #[serde(rename="SJ")] + #[serde(rename = "SJ")] Sj, /// The code representing the country of Swaziland. - #[serde(rename="SZ")] + #[serde(rename = "SZ")] Sz, /// The code representing the country of Sweden. - #[serde(rename="SE")] + #[serde(rename = "SE")] Se, /// The code representing the country of Switzerland. - #[serde(rename="CH")] + #[serde(rename = "CH")] Ch, /// The code representing the country of Syrian Arab Republic. - #[serde(rename="SY")] + #[serde(rename = "SY")] Sy, /// The code representing the country of Taiwan, Province of China. - #[serde(rename="TW")] + #[serde(rename = "TW")] Tw, /// The code representing the country of Tajikistan. - #[serde(rename="TJ")] + #[serde(rename = "TJ")] Tj, /// The code representing the country of United Republic of Tanzania. - #[serde(rename="TZ")] + #[serde(rename = "TZ")] Tz, /// The code representing the country of Thailand. - #[serde(rename="TH")] + #[serde(rename = "TH")] Th, /// The code representing the country of Timor-Leste. - #[serde(rename="TL")] + #[serde(rename = "TL")] Tl, /// The code representing the country of Togo. - #[serde(rename="TG")] + #[serde(rename = "TG")] Tg, /// The code representing the country of Tokelau. - #[serde(rename="TK")] + #[serde(rename = "TK")] Tk, /// The code representing the country of Tonga. - #[serde(rename="TO")] + #[serde(rename = "TO")] To, /// The code representing the country of Trinidad and Tobago. - #[serde(rename="TT")] + #[serde(rename = "TT")] Tt, /// The code representing the country of Tunisia. - #[serde(rename="TN")] + #[serde(rename = "TN")] Tn, /// The code representing the country of Turkey. - #[serde(rename="TR")] + #[serde(rename = "TR")] Tr, /// The code representing the country of Turkmenistan. - #[serde(rename="TM")] + #[serde(rename = "TM")] Tm, /// The code representing the country of Turks and Caicos Islands. - #[serde(rename="TC")] + #[serde(rename = "TC")] Tc, /// The code representing the country of Tuvalu. - #[serde(rename="TV")] + #[serde(rename = "TV")] Tv, /// The code representing the country of Uganda. - #[serde(rename="UG")] + #[serde(rename = "UG")] Ug, /// The code representing the country of Ukraine. - #[serde(rename="UA")] + #[serde(rename = "UA")] Ua, /// The code representing the country of United Arab Emirates. - #[serde(rename="AE")] + #[serde(rename = "AE")] Ae, /// The code representing the country of United Kingdom. - #[serde(rename="GB")] + #[serde(rename = "GB")] Gb, /// The code representing the country of United States. - #[serde(rename="US")] + #[serde(rename = "US")] Us, /// The code representing the country of United States Minor Outlying Islands. - #[serde(rename="UM")] + #[serde(rename = "UM")] Um, /// The code representing the country of Uruguay. - #[serde(rename="UY")] + #[serde(rename = "UY")] Uy, /// The code representing the country of Uzbekistan. - #[serde(rename="UZ")] + #[serde(rename = "UZ")] Uz, /// The code representing the country of Vanuatu. - #[serde(rename="VU")] + #[serde(rename = "VU")] Vu, /// The code representing the country of Bolivarian Republic of Venezuela. - #[serde(rename="VE")] + #[serde(rename = "VE")] Ve, /// The code representing the country of Viet Nam. - #[serde(rename="VN")] + #[serde(rename = "VN")] Vn, /// The code representing the country of British Virgin Islands. - #[serde(rename="VG")] + #[serde(rename = "VG")] Vg, /// The code representing the country of U.S. Virgin Islands. - #[serde(rename="VI")] + #[serde(rename = "VI")] Vi, /// The code representing the country of Wallis and Futuna. - #[serde(rename="WF")] + #[serde(rename = "WF")] Wf, /// The code representing the country of Western Sahara. - #[serde(rename="EH")] + #[serde(rename = "EH")] Eh, /// The code representing the country of Yemen. - #[serde(rename="YE")] + #[serde(rename = "YE")] Ye, /// The code representing the country of Zambia. - #[serde(rename="ZM")] + #[serde(rename = "ZM")] Zm, /// The code representing the country of Zimbabwe. - #[serde(rename="ZW")] + #[serde(rename = "ZW")] Zw, /// The code representing a fake region for testing. - #[serde(rename="NN")] + #[serde(rename = "NN")] Nn, - } impl Into for RegionCode { @@ -1269,8 +1267,6 @@ impl fmt::Display for RegionCode { Self::Zm => write!(f, "ZM"), Self::Zw => write!(f, "ZW"), Self::Nn => write!(f, "NN"), - } } } - diff --git a/lightspark/src/objects/register_payment_input.rs b/lightspark/src/objects/register_payment_input.rs index ccaaf8a..152845a 100644 --- a/lightspark/src/objects/register_payment_input.rs +++ b/lightspark/src/objects/register_payment_input.rs @@ -1,32 +1,19 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; -use crate::objects::payment_direction::PaymentDirection; use crate::objects::compliance_provider::ComplianceProvider; - +use crate::objects::payment_direction::PaymentDirection; +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct RegisterPaymentInput { - /// The compliance provider that is going to screen the node. You need to be a customer of the selected provider and store the API key on the Lightspark account setting page. - pub provider: ComplianceProvider, /// The Lightspark ID of the lightning payment you want to register. It can be the id of either an OutgoingPayment or an IncomingPayment. - pub payment_id: String, /// The public key of the counterparty lightning node, which would be the public key of the recipient node if it is to register an outgoing payment, or the public key of the sender node if it is to register an incoming payment. - pub node_pubkey: String, /// Indicates whether this payment is an OutgoingPayment or an IncomingPayment. - pub direction: PaymentDirection, - } - - - - - diff --git a/lightspark/src/objects/register_payment_output.rs b/lightspark/src/objects/register_payment_output.rs index fc124e0..558f1f6 100644 --- a/lightspark/src/objects/register_payment_output.rs +++ b/lightspark/src/objects/register_payment_output.rs @@ -1,20 +1,13 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::types::entity_wrapper::EntityWrapper; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct RegisterPaymentOutput { - - #[serde(rename = "register_payment_output_payment")] pub payment: EntityWrapper, - } - - pub const FRAGMENT: &str = " fragment RegisterPaymentOutputFragment on RegisterPaymentOutput { __typename @@ -23,6 +16,3 @@ fragment RegisterPaymentOutputFragment on RegisterPaymentOutput { } } "; - - - diff --git a/lightspark/src/objects/release_channel_per_commitment_secret_input.rs b/lightspark/src/objects/release_channel_per_commitment_secret_input.rs index c972fd9..4cda76e 100644 --- a/lightspark/src/objects/release_channel_per_commitment_secret_input.rs +++ b/lightspark/src/objects/release_channel_per_commitment_secret_input.rs @@ -1,27 +1,14 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; - - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct ReleaseChannelPerCommitmentSecretInput { - /// The unique identifier of the channel. - pub channel_id: String, /// The per-commitment secret to be released. - pub per_commitment_secret: String, /// The index associated with the per-commitment secret. - pub per_commitment_index: i64, - } - - - - - diff --git a/lightspark/src/objects/release_channel_per_commitment_secret_output.rs b/lightspark/src/objects/release_channel_per_commitment_secret_output.rs index cef58d7..eaab4c3 100644 --- a/lightspark/src/objects/release_channel_per_commitment_secret_output.rs +++ b/lightspark/src/objects/release_channel_per_commitment_secret_output.rs @@ -1,20 +1,14 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::types::entity_wrapper::EntityWrapper; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct ReleaseChannelPerCommitmentSecretOutput { - /// The channel object after the per-commitment secret release operation. #[serde(rename = "release_channel_per_commitment_secret_output_channel")] pub channel: EntityWrapper, - } - - pub const FRAGMENT: &str = " fragment ReleaseChannelPerCommitmentSecretOutputFragment on ReleaseChannelPerCommitmentSecretOutput { __typename @@ -23,6 +17,3 @@ fragment ReleaseChannelPerCommitmentSecretOutputFragment on ReleaseChannelPerCom } } "; - - - diff --git a/lightspark/src/objects/release_payment_preimage_input.rs b/lightspark/src/objects/release_payment_preimage_input.rs index 4e9d6e6..899ba07 100644 --- a/lightspark/src/objects/release_payment_preimage_input.rs +++ b/lightspark/src/objects/release_payment_preimage_input.rs @@ -1,23 +1,11 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; - - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct ReleasePaymentPreimageInput { - /// The invoice the preimage belongs to. - pub invoice_id: String, /// The preimage to release. - pub payment_preimage: String, - } - - - - - diff --git a/lightspark/src/objects/release_payment_preimage_output.rs b/lightspark/src/objects/release_payment_preimage_output.rs index 722a639..09266ab 100644 --- a/lightspark/src/objects/release_payment_preimage_output.rs +++ b/lightspark/src/objects/release_payment_preimage_output.rs @@ -1,20 +1,14 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::types::entity_wrapper::EntityWrapper; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct ReleasePaymentPreimageOutput { - /// The invoice of the transaction. #[serde(rename = "release_payment_preimage_output_invoice")] pub invoice: EntityWrapper, - } - - pub const FRAGMENT: &str = " fragment ReleasePaymentPreimageOutputFragment on ReleasePaymentPreimageOutput { __typename @@ -23,6 +17,3 @@ fragment ReleasePaymentPreimageOutputFragment on ReleasePaymentPreimageOutput { } } "; - - - diff --git a/lightspark/src/objects/remote_signing_sub_event_type.rs b/lightspark/src/objects/remote_signing_sub_event_type.rs index af41a99..ad21f9d 100644 --- a/lightspark/src/objects/remote_signing_sub_event_type.rs +++ b/lightspark/src/objects/remote_signing_sub_event_type.rs @@ -1,4 +1,3 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -7,34 +6,32 @@ use std::fmt; /// This is an enum of the potential sub-event types for Remote Signing webook events. #[derive(Debug, Clone, Deserialize, Serialize)] pub enum RemoteSigningSubEventType { - - #[serde(rename="ECDH")] + #[serde(rename = "ECDH")] Ecdh, - #[serde(rename="GET_PER_COMMITMENT_POINT")] + #[serde(rename = "GET_PER_COMMITMENT_POINT")] GetPerCommitmentPoint, - #[serde(rename="RELEASE_PER_COMMITMENT_SECRET")] + #[serde(rename = "RELEASE_PER_COMMITMENT_SECRET")] ReleasePerCommitmentSecret, - #[serde(rename="SIGN_INVOICE")] + #[serde(rename = "SIGN_INVOICE")] SignInvoice, - #[serde(rename="DERIVE_KEY_AND_SIGN")] + #[serde(rename = "DERIVE_KEY_AND_SIGN")] DeriveKeyAndSign, - #[serde(rename="RELEASE_PAYMENT_PREIMAGE")] + #[serde(rename = "RELEASE_PAYMENT_PREIMAGE")] ReleasePaymentPreimage, - #[serde(rename="REQUEST_INVOICE_PAYMENT_HASH")] + #[serde(rename = "REQUEST_INVOICE_PAYMENT_HASH")] RequestInvoicePaymentHash, - #[serde(rename="REVEAL_COUNTERPARTY_PER_COMMITMENT_SECRET")] + #[serde(rename = "REVEAL_COUNTERPARTY_PER_COMMITMENT_SECRET")] RevealCounterpartyPerCommitmentSecret, - #[serde(rename="VLS_MESSAGE")] + #[serde(rename = "VLS_MESSAGE")] VlsMessage, - } impl Into for RemoteSigningSubEventType { @@ -53,10 +50,10 @@ impl fmt::Display for RemoteSigningSubEventType { Self::DeriveKeyAndSign => write!(f, "DERIVE_KEY_AND_SIGN"), Self::ReleasePaymentPreimage => write!(f, "RELEASE_PAYMENT_PREIMAGE"), Self::RequestInvoicePaymentHash => write!(f, "REQUEST_INVOICE_PAYMENT_HASH"), - Self::RevealCounterpartyPerCommitmentSecret => write!(f, "REVEAL_COUNTERPARTY_PER_COMMITMENT_SECRET"), + Self::RevealCounterpartyPerCommitmentSecret => { + write!(f, "REVEAL_COUNTERPARTY_PER_COMMITMENT_SECRET") + } Self::VlsMessage => write!(f, "VLS_MESSAGE"), - } } } - diff --git a/lightspark/src/objects/request_initiator.rs b/lightspark/src/objects/request_initiator.rs index 44775af..cb8785f 100644 --- a/lightspark/src/objects/request_initiator.rs +++ b/lightspark/src/objects/request_initiator.rs @@ -1,19 +1,15 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; use serde_json::Value; use std::fmt; - #[derive(Debug, Clone, Deserialize, Serialize)] pub enum RequestInitiator { - - #[serde(rename="CUSTOMER")] + #[serde(rename = "CUSTOMER")] Customer, - #[serde(rename="LIGHTSPARK")] + #[serde(rename = "LIGHTSPARK")] Lightspark, - } impl Into for RequestInitiator { @@ -27,8 +23,6 @@ impl fmt::Display for RequestInitiator { match self { Self::Customer => write!(f, "CUSTOMER"), Self::Lightspark => write!(f, "LIGHTSPARK"), - } } } - diff --git a/lightspark/src/objects/request_withdrawal_input.rs b/lightspark/src/objects/request_withdrawal_input.rs index a1f921b..75b2970 100644 --- a/lightspark/src/objects/request_withdrawal_input.rs +++ b/lightspark/src/objects/request_withdrawal_input.rs @@ -1,44 +1,28 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::on_chain_fee_target::OnChainFeeTarget; use crate::objects::withdrawal_mode::WithdrawalMode; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct RequestWithdrawalInput { - /// The node from which you'd like to make the withdrawal. - pub node_id: String, /// The bitcoin address where the withdrawal should be sent. - pub bitcoin_address: String, /// The amount you want to withdraw from this node in Satoshis. Use the special value -1 to withdrawal all funds from this node. - pub amount_sats: i64, /// The strategy that should be used to withdraw the funds from this node. - pub withdrawal_mode: WithdrawalMode, /// The idempotency key of the request. The same result will be returned for the same idempotency key. - pub idempotency_key: Option, /// The target of the fee that should be used when crafting the L1 transaction. You should only set `fee_target` or `sats_per_vbyte`. If neither of them is set, default value of MEDIUM will be used as `fee_target`. - pub fee_target: Option, /// A manual fee rate set in sat/vbyte that should be used when crafting the L1 transaction. You should only set `fee_target` or `sats_per_vbyte` - pub sats_per_vbyte: Option, - } - - - - - diff --git a/lightspark/src/objects/request_withdrawal_output.rs b/lightspark/src/objects/request_withdrawal_output.rs index 9b802ca..cc8b570 100644 --- a/lightspark/src/objects/request_withdrawal_output.rs +++ b/lightspark/src/objects/request_withdrawal_output.rs @@ -1,20 +1,14 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::types::entity_wrapper::EntityWrapper; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct RequestWithdrawalOutput { - /// The request that is created for this withdrawal. #[serde(rename = "request_withdrawal_output_request")] pub request: EntityWrapper, - } - - pub const FRAGMENT: &str = " fragment RequestWithdrawalOutputFragment on RequestWithdrawalOutput { __typename @@ -23,6 +17,3 @@ fragment RequestWithdrawalOutputFragment on RequestWithdrawalOutput { } } "; - - - diff --git a/lightspark/src/objects/rich_text.rs b/lightspark/src/objects/rich_text.rs index 99267d8..58a1cf5 100644 --- a/lightspark/src/objects/rich_text.rs +++ b/lightspark/src/objects/rich_text.rs @@ -1,26 +1,15 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; - - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct RichText { - - - #[serde (rename = "rich_text_text")] + #[serde(rename = "rich_text_text")] pub text: String, - } - - pub const FRAGMENT: &str = " fragment RichTextFragment on RichText { __typename rich_text_text: text } "; - - - diff --git a/lightspark/src/objects/risk_rating.rs b/lightspark/src/objects/risk_rating.rs index f726924..3e044a9 100644 --- a/lightspark/src/objects/risk_rating.rs +++ b/lightspark/src/objects/risk_rating.rs @@ -1,4 +1,3 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -7,16 +6,14 @@ use std::fmt; /// This is an enum of the potential risk ratings related to a transaction made over the Lightning Network. These risk ratings are returned from the CryptoSanctionScreeningProvider. #[derive(Debug, Clone, Deserialize, Serialize)] pub enum RiskRating { - - #[serde(rename="HIGH_RISK")] + #[serde(rename = "HIGH_RISK")] HighRisk, - #[serde(rename="LOW_RISK")] + #[serde(rename = "LOW_RISK")] LowRisk, - #[serde(rename="UNKNOWN")] + #[serde(rename = "UNKNOWN")] Unknown, - } impl Into for RiskRating { @@ -31,8 +28,6 @@ impl fmt::Display for RiskRating { Self::HighRisk => write!(f, "HIGH_RISK"), Self::LowRisk => write!(f, "LOW_RISK"), Self::Unknown => write!(f, "UNKNOWN"), - } } } - diff --git a/lightspark/src/objects/routing_transaction.rs b/lightspark/src/objects/routing_transaction.rs index ec9ff3c..247dc5c 100644 --- a/lightspark/src/objects/routing_transaction.rs +++ b/lightspark/src/objects/routing_transaction.rs @@ -1,25 +1,23 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::currency_amount::CurrencyAmount; -use crate::types::entity_wrapper::EntityWrapper; -use crate::objects::transaction_status::TransactionStatus; use crate::objects::entity::Entity; -use crate::types::get_entity::GetEntity; -use crate::types::custom_date_formats::custom_date_format_option; +use crate::objects::lightning_transaction::LightningTransaction; +use crate::objects::rich_text::RichText; use crate::objects::routing_transaction_failure_reason::RoutingTransactionFailureReason; use crate::objects::transaction::Transaction; -use crate::objects::rich_text::RichText; -use crate::objects::lightning_transaction::LightningTransaction; +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 crate::types::entity_wrapper::EntityWrapper; +use crate::types::get_entity::GetEntity; use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; /// This object represents a transaction that was forwarded through a Lightspark node on the Lightning Network, i.e., a routed transaction. You can retrieve this object to receive information about any transaction routed through your Lightspark Node. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct RoutingTransaction { - /// The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string. - #[serde (rename = "routing_transaction_id")] + #[serde(rename = "routing_transaction_id")] pub id: String, /// The date and time when this transaction was initiated. @@ -31,19 +29,22 @@ pub struct RoutingTransaction { pub updated_at: DateTime, /// The current status of this transaction. - #[serde (rename = "routing_transaction_status")] + #[serde(rename = "routing_transaction_status")] pub status: TransactionStatus, /// The date and time when this transaction was completed or failed. - #[serde(with = "custom_date_format_option", rename = "routing_transaction_resolved_at")] + #[serde( + with = "custom_date_format_option", + rename = "routing_transaction_resolved_at" + )] pub resolved_at: Option>, /// The amount of money involved in this transaction. - #[serde (rename = "routing_transaction_amount")] + #[serde(rename = "routing_transaction_amount")] pub amount: CurrencyAmount, /// The hash of this transaction, so it can be uniquely identified on the Lightning Network. - #[serde (rename = "routing_transaction_transaction_hash")] + #[serde(rename = "routing_transaction_transaction_hash")] pub transaction_hash: Option, /// If known, the channel this transaction was received from. @@ -55,36 +56,29 @@ pub struct RoutingTransaction { pub outgoing_channel: Option, /// The fees collected by the node when routing this transaction. We subtract the outgoing amount to the incoming amount to determine how much fees were collected. - #[serde (rename = "routing_transaction_fees")] + #[serde(rename = "routing_transaction_fees")] pub fees: Option, /// If applicable, user-facing error message describing why the routing failed. - #[serde (rename = "routing_transaction_failure_message")] + #[serde(rename = "routing_transaction_failure_message")] pub failure_message: Option, /// If applicable, the reason why the routing failed. - #[serde (rename = "routing_transaction_failure_reason")] + #[serde(rename = "routing_transaction_failure_reason")] pub failure_reason: Option, /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl LightningTransaction for RoutingTransaction { - - fn type_name(&self) -> &'static str { "RoutingTransaction" } } - - impl Transaction for RoutingTransaction { - /// The current status of this transaction. fn get_status(&self) -> TransactionStatus { self.status.clone() @@ -105,16 +99,12 @@ impl Transaction for RoutingTransaction { self.transaction_hash.clone() } - fn type_name(&self) -> &'static str { "RoutingTransaction" } } - - impl Entity for RoutingTransaction { - /// 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() @@ -130,16 +120,15 @@ impl Entity for RoutingTransaction { self.updated_at } - fn type_name(&self) -> &'static str { "RoutingTransaction" } } - impl GetEntity for RoutingTransaction { fn get_entity_query() -> String { - format!(" + format!( + " query GetEntity($id: ID!) {{ entity(id: $id) {{ ... on RoutingTransaction {{ @@ -148,12 +137,12 @@ impl GetEntity for RoutingTransaction { }} }} - {}", FRAGMENT) - } + {}", + FRAGMENT + ) + } } - - pub const FRAGMENT: &str = " fragment RoutingTransactionFragment on RoutingTransaction { __typename @@ -192,6 +181,3 @@ fragment RoutingTransactionFragment on RoutingTransaction { routing_transaction_failure_reason: failure_reason } "; - - - diff --git a/lightspark/src/objects/routing_transaction_failure_reason.rs b/lightspark/src/objects/routing_transaction_failure_reason.rs index c7ad72f..ea4ae75 100644 --- a/lightspark/src/objects/routing_transaction_failure_reason.rs +++ b/lightspark/src/objects/routing_transaction_failure_reason.rs @@ -1,4 +1,3 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -7,16 +6,14 @@ use std::fmt; /// This is an enum of the potential reasons that an attempted routed transaction through a Lightspark node may have failed. #[derive(Debug, Clone, Deserialize, Serialize)] pub enum RoutingTransactionFailureReason { - - #[serde(rename="INCOMING_LINK_FAILURE")] + #[serde(rename = "INCOMING_LINK_FAILURE")] IncomingLinkFailure, - #[serde(rename="OUTGOING_LINK_FAILURE")] + #[serde(rename = "OUTGOING_LINK_FAILURE")] OutgoingLinkFailure, - #[serde(rename="FORWARDING_FAILURE")] + #[serde(rename = "FORWARDING_FAILURE")] ForwardingFailure, - } impl Into for RoutingTransactionFailureReason { @@ -31,8 +28,6 @@ impl fmt::Display for RoutingTransactionFailureReason { Self::IncomingLinkFailure => write!(f, "INCOMING_LINK_FAILURE"), Self::OutgoingLinkFailure => write!(f, "OUTGOING_LINK_FAILURE"), Self::ForwardingFailure => write!(f, "FORWARDING_FAILURE"), - } } } - diff --git a/lightspark/src/objects/screen_node_input.rs b/lightspark/src/objects/screen_node_input.rs index e6749b2..571347d 100644 --- a/lightspark/src/objects/screen_node_input.rs +++ b/lightspark/src/objects/screen_node_input.rs @@ -1,23 +1,12 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::compliance_provider::ComplianceProvider; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct ScreenNodeInput { - /// The compliance provider that is going to screen the node. You need to be a customer of the selected provider and store the API key on the Lightspark account setting page. - pub provider: ComplianceProvider, /// The public key of the lightning node that needs to be screened. - pub node_pubkey: String, - } - - - - - diff --git a/lightspark/src/objects/screen_node_output.rs b/lightspark/src/objects/screen_node_output.rs index fc2bdeb..0043193 100644 --- a/lightspark/src/objects/screen_node_output.rs +++ b/lightspark/src/objects/screen_node_output.rs @@ -1,26 +1,16 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::risk_rating::RiskRating; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct ScreenNodeOutput { - - - #[serde (rename = "screen_node_output_rating")] + #[serde(rename = "screen_node_output_rating")] pub rating: RiskRating, - } - - pub const FRAGMENT: &str = " fragment ScreenNodeOutputFragment on ScreenNodeOutput { __typename screen_node_output_rating: rating } "; - - - diff --git a/lightspark/src/objects/secret.rs b/lightspark/src/objects/secret.rs index a31c168..6e33fbc 100644 --- a/lightspark/src/objects/secret.rs +++ b/lightspark/src/objects/secret.rs @@ -1,24 +1,15 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; - - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct Secret { - - - #[serde (rename = "secret_encrypted_value")] + #[serde(rename = "secret_encrypted_value")] pub encrypted_value: String, - - #[serde (rename = "secret_cipher")] + #[serde(rename = "secret_cipher")] pub cipher: String, - } - - pub const FRAGMENT: &str = " fragment SecretFragment on Secret { __typename @@ -26,6 +17,3 @@ fragment SecretFragment on Secret { secret_cipher: cipher } "; - - - diff --git a/lightspark/src/objects/send_payment_input.rs b/lightspark/src/objects/send_payment_input.rs index e807d7a..de81135 100644 --- a/lightspark/src/objects/send_payment_input.rs +++ b/lightspark/src/objects/send_payment_input.rs @@ -1,39 +1,23 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; - - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct SendPaymentInput { - /// The node from where you want to send the payment. - pub node_id: String, /// The public key of the destination node. - pub destination_public_key: String, /// The timeout in seconds that we will try to make the payment. - pub timeout_secs: i64, /// The amount you will send to the destination node, expressed in msats. - pub amount_msats: i64, /// The maximum amount of fees that you want to pay for this payment to be sent, expressed in msats. - pub maximum_fees_msats: i64, /// The idempotency key of the request. The same result will be returned for the same idempotency key. - pub idempotency_key: Option, - } - - - - - diff --git a/lightspark/src/objects/send_payment_output.rs b/lightspark/src/objects/send_payment_output.rs index 1b4b28c..a14499b 100644 --- a/lightspark/src/objects/send_payment_output.rs +++ b/lightspark/src/objects/send_payment_output.rs @@ -1,20 +1,14 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::types::entity_wrapper::EntityWrapper; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct SendPaymentOutput { - /// The payment that has been sent. #[serde(rename = "send_payment_output_payment")] pub payment: EntityWrapper, - } - - pub const FRAGMENT: &str = " fragment SendPaymentOutputFragment on SendPaymentOutput { __typename @@ -23,6 +17,3 @@ fragment SendPaymentOutputFragment on SendPaymentOutput { } } "; - - - diff --git a/lightspark/src/objects/set_invoice_payment_hash_input.rs b/lightspark/src/objects/set_invoice_payment_hash_input.rs index 3d3cfec..d09ff39 100644 --- a/lightspark/src/objects/set_invoice_payment_hash_input.rs +++ b/lightspark/src/objects/set_invoice_payment_hash_input.rs @@ -1,27 +1,14 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; - - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct SetInvoicePaymentHashInput { - /// The invoice that needs to be updated. - pub invoice_id: String, /// The 32-byte hash of the payment preimage. - pub payment_hash: String, /// The 32-byte nonce used to generate the invoice preimage if applicable. It will later be included in RELEASE_PAYMENT_PREIMAGE webhook to help recover the raw preimage. - pub preimage_nonce: Option, - } - - - - - diff --git a/lightspark/src/objects/set_invoice_payment_hash_output.rs b/lightspark/src/objects/set_invoice_payment_hash_output.rs index bea8863..05b043f 100644 --- a/lightspark/src/objects/set_invoice_payment_hash_output.rs +++ b/lightspark/src/objects/set_invoice_payment_hash_output.rs @@ -1,20 +1,13 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::types::entity_wrapper::EntityWrapper; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct SetInvoicePaymentHashOutput { - - #[serde(rename = "set_invoice_payment_hash_output_invoice")] pub invoice: EntityWrapper, - } - - pub const FRAGMENT: &str = " fragment SetInvoicePaymentHashOutputFragment on SetInvoicePaymentHashOutput { __typename @@ -23,6 +16,3 @@ fragment SetInvoicePaymentHashOutputFragment on SetInvoicePaymentHashOutput { } } "; - - - diff --git a/lightspark/src/objects/sign_invoice_input.rs b/lightspark/src/objects/sign_invoice_input.rs index cd4b8fb..aa488d8 100644 --- a/lightspark/src/objects/sign_invoice_input.rs +++ b/lightspark/src/objects/sign_invoice_input.rs @@ -1,27 +1,14 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; - - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct SignInvoiceInput { - /// The unique identifier of the invoice to be signed. - pub invoice_id: String, /// The cryptographic signature for the invoice. - pub signature: String, /// The recovery identifier for the signature. - pub recovery_id: i64, - } - - - - - diff --git a/lightspark/src/objects/sign_invoice_output.rs b/lightspark/src/objects/sign_invoice_output.rs index 43a9473..aad0cc2 100644 --- a/lightspark/src/objects/sign_invoice_output.rs +++ b/lightspark/src/objects/sign_invoice_output.rs @@ -1,20 +1,14 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::types::entity_wrapper::EntityWrapper; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct SignInvoiceOutput { - /// The signed invoice object. #[serde(rename = "sign_invoice_output_invoice")] pub invoice: EntityWrapper, - } - - pub const FRAGMENT: &str = " fragment SignInvoiceOutputFragment on SignInvoiceOutput { __typename @@ -23,6 +17,3 @@ fragment SignInvoiceOutputFragment on SignInvoiceOutput { } } "; - - - diff --git a/lightspark/src/objects/sign_messages_input.rs b/lightspark/src/objects/sign_messages_input.rs index 3a7f543..55b7bb8 100644 --- a/lightspark/src/objects/sign_messages_input.rs +++ b/lightspark/src/objects/sign_messages_input.rs @@ -1,20 +1,10 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::objects::id_and_signature::IdAndSignature; use serde::{Deserialize, Serialize}; use std::vec::Vec; -use crate::objects::id_and_signature::IdAndSignature; - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct SignMessagesInput { - /// The list of the message ids and signatures. - pub signatures: Vec, - } - - - - - diff --git a/lightspark/src/objects/sign_messages_output.rs b/lightspark/src/objects/sign_messages_output.rs index 71ee182..00d0fd7 100644 --- a/lightspark/src/objects/sign_messages_output.rs +++ b/lightspark/src/objects/sign_messages_output.rs @@ -1,21 +1,15 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::signable_payload::SignablePayload; +use serde::{Deserialize, Serialize}; use std::vec::Vec; - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct SignMessagesOutput { - /// The list of signed payloads. - #[serde (rename = "sign_messages_output_signed_payloads")] + #[serde(rename = "sign_messages_output_signed_payloads")] pub signed_payloads: Vec, - } - - pub const FRAGMENT: &str = " fragment SignMessagesOutputFragment on SignMessagesOutput { __typename @@ -24,6 +18,3 @@ fragment SignMessagesOutputFragment on SignMessagesOutput { } } "; - - - diff --git a/lightspark/src/objects/signable.rs b/lightspark/src/objects/signable.rs index fc1bf76..7a7230d 100644 --- a/lightspark/src/objects/signable.rs +++ b/lightspark/src/objects/signable.rs @@ -1,17 +1,14 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; +use crate::objects::entity::Entity; use crate::types::custom_date_formats::custom_date_format; use crate::types::get_entity::GetEntity; use chrono::{DateTime, Utc}; -use crate::objects::entity::Entity; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct Signable { - /// The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string. - #[serde (rename = "signable_id")] + #[serde(rename = "signable_id")] pub id: String, /// The date and time when the entity was first created. @@ -25,12 +22,9 @@ pub struct Signable { /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl Entity for Signable { - /// 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() @@ -46,16 +40,15 @@ impl Entity for Signable { self.updated_at } - fn type_name(&self) -> &'static str { "Signable" } } - impl GetEntity for Signable { fn get_entity_query() -> String { - format!(" + format!( + " query GetEntity($id: ID!) {{ entity(id: $id) {{ ... on Signable {{ @@ -64,12 +57,12 @@ impl GetEntity for Signable { }} }} - {}", FRAGMENT) - } + {}", + FRAGMENT + ) + } } - - pub const FRAGMENT: &str = " fragment SignableFragment on Signable { __typename @@ -78,6 +71,3 @@ fragment SignableFragment on Signable { signable_updated_at: updated_at } "; - - - diff --git a/lightspark/src/objects/signable_payload.rs b/lightspark/src/objects/signable_payload.rs index 3bb28e9..2be056a 100644 --- a/lightspark/src/objects/signable_payload.rs +++ b/lightspark/src/objects/signable_payload.rs @@ -1,19 +1,16 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; -use crate::types::entity_wrapper::EntityWrapper; use crate::objects::entity::Entity; -use crate::types::get_entity::GetEntity; use crate::objects::signable_payload_status::SignablePayloadStatus; use crate::types::custom_date_formats::custom_date_format; +use crate::types::entity_wrapper::EntityWrapper; +use crate::types::get_entity::GetEntity; use chrono::{DateTime, Utc}; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct SignablePayload { - /// The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string. - #[serde (rename = "signable_payload_id")] + #[serde(rename = "signable_payload_id")] pub id: String, /// The date and time when the entity was first created. @@ -25,23 +22,23 @@ pub struct SignablePayload { pub updated_at: DateTime, /// The payload that needs to be signed. - #[serde (rename = "signable_payload_payload")] + #[serde(rename = "signable_payload_payload")] pub payload: String, /// The consistent method for generating the same set of accounts and wallets for a given private key - #[serde (rename = "signable_payload_derivation_path")] + #[serde(rename = "signable_payload_derivation_path")] pub derivation_path: String, /// The status of the payload. - #[serde (rename = "signable_payload_status")] + #[serde(rename = "signable_payload_status")] pub status: SignablePayloadStatus, /// The tweak value to add. - #[serde (rename = "signable_payload_add_tweak")] + #[serde(rename = "signable_payload_add_tweak")] pub add_tweak: Option, /// The tweak value to multiply. - #[serde (rename = "signable_payload_mul_tweak")] + #[serde(rename = "signable_payload_mul_tweak")] pub mul_tweak: Option, /// The signable this payload belongs to. @@ -51,12 +48,9 @@ pub struct SignablePayload { /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl Entity for SignablePayload { - /// 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() @@ -72,16 +66,15 @@ impl Entity for SignablePayload { self.updated_at } - fn type_name(&self) -> &'static str { "SignablePayload" } } - impl GetEntity for SignablePayload { fn get_entity_query() -> String { - format!(" + format!( + " query GetEntity($id: ID!) {{ entity(id: $id) {{ ... on SignablePayload {{ @@ -90,12 +83,12 @@ impl GetEntity for SignablePayload { }} }} - {}", FRAGMENT) - } + {}", + FRAGMENT + ) + } } - - pub const FRAGMENT: &str = " fragment SignablePayloadFragment on SignablePayload { __typename @@ -112,6 +105,3 @@ fragment SignablePayloadFragment on SignablePayload { } } "; - - - diff --git a/lightspark/src/objects/signable_payload_status.rs b/lightspark/src/objects/signable_payload_status.rs index 0ce5435..85fedf3 100644 --- a/lightspark/src/objects/signable_payload_status.rs +++ b/lightspark/src/objects/signable_payload_status.rs @@ -1,25 +1,21 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; use serde_json::Value; use std::fmt; - #[derive(Debug, Clone, Deserialize, Serialize)] pub enum SignablePayloadStatus { - - #[serde(rename="CREATED")] + #[serde(rename = "CREATED")] Created, - #[serde(rename="SIGNED")] + #[serde(rename = "SIGNED")] Signed, - #[serde(rename="VALIDATION_FAILED")] + #[serde(rename = "VALIDATION_FAILED")] ValidationFailed, - #[serde(rename="INVALID_SIGNATURE")] + #[serde(rename = "INVALID_SIGNATURE")] InvalidSignature, - } impl Into for SignablePayloadStatus { @@ -35,8 +31,6 @@ impl fmt::Display for SignablePayloadStatus { Self::Signed => write!(f, "SIGNED"), Self::ValidationFailed => write!(f, "VALIDATION_FAILED"), Self::InvalidSignature => write!(f, "INVALID_SIGNATURE"), - } } } - diff --git a/lightspark/src/objects/transaction.rs b/lightspark/src/objects/transaction.rs index 8bdd3a7..6f652ef 100644 --- a/lightspark/src/objects/transaction.rs +++ b/lightspark/src/objects/transaction.rs @@ -1,21 +1,19 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use crate::objects::entity::Entity; -use crate::objects::currency_amount::CurrencyAmount; -use serde_json::Value; -use super::routing_transaction::RoutingTransaction; -use super::withdrawal::Withdrawal; +use super::channel_closing_transaction::ChannelClosingTransaction; use super::channel_opening_transaction::ChannelOpeningTransaction; use super::deposit::Deposit; -use super::outgoing_payment::OutgoingPayment; -use super::channel_closing_transaction::ChannelClosingTransaction; use super::incoming_payment::IncomingPayment; -use serde::{Deserialize, Deserializer, Serialize}; +use super::outgoing_payment::OutgoingPayment; +use super::routing_transaction::RoutingTransaction; +use super::withdrawal::Withdrawal; +use crate::objects::currency_amount::CurrencyAmount; +use crate::objects::entity::Entity; use crate::objects::transaction_status::TransactionStatus; use chrono::{DateTime, Utc}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_json::Value; -pub trait Transaction : Entity { - +pub trait Transaction: Entity { /// The current status of this transaction. fn get_status(&self) -> TransactionStatus; @@ -28,11 +26,9 @@ pub trait Transaction : Entity { /// The hash of this transaction, so it can be uniquely identified on the Lightning Network. fn get_transaction_hash(&self) -> Option; - -fn type_name(&self) -> &'static str; + fn type_name(&self) -> &'static str; } - #[allow(clippy::large_enum_variant)] #[derive(Debug, Clone, Serialize)] pub enum TransactionEnum { @@ -43,11 +39,8 @@ pub enum TransactionEnum { OutgoingPayment(OutgoingPayment), RoutingTransaction(RoutingTransaction), Withdrawal(Withdrawal), - } - - impl<'de> Deserialize<'de> for TransactionEnum { fn deserialize(deserializer: D) -> Result where @@ -57,60 +50,54 @@ impl<'de> Deserialize<'de> for TransactionEnum { if let Some(typename) = value.get("__typename").and_then(Value::as_str) { match typename { "ChannelClosingTransaction" => { - let obj = ChannelClosingTransaction::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = ChannelClosingTransaction::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(TransactionEnum::ChannelClosingTransaction(obj)) - }, + } "ChannelOpeningTransaction" => { - let obj = ChannelOpeningTransaction::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = ChannelOpeningTransaction::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(TransactionEnum::ChannelOpeningTransaction(obj)) - }, + } "Deposit" => { - let obj = Deposit::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = Deposit::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(TransactionEnum::Deposit(obj)) - }, + } "IncomingPayment" => { - let obj = IncomingPayment::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = IncomingPayment::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(TransactionEnum::IncomingPayment(obj)) - }, + } "OutgoingPayment" => { - let obj = OutgoingPayment::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = OutgoingPayment::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(TransactionEnum::OutgoingPayment(obj)) - }, + } "RoutingTransaction" => { - let obj = RoutingTransaction::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = RoutingTransaction::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(TransactionEnum::RoutingTransaction(obj)) - }, + } "Withdrawal" => { - let obj = Withdrawal::deserialize(value) - .map_err(|err| - serde::de::Error::custom(format!("Serde JSON Error {}", err)) - )?; + let obj = Withdrawal::deserialize(value).map_err(|err| { + serde::de::Error::custom(format!("Serde JSON Error {}", err)) + })?; Ok(TransactionEnum::Withdrawal(obj)) - }, + } _ => Err(serde::de::Error::custom("unknown typename")), } } else { - Err(serde::de::Error::custom("missing __typename field on Transaction")) + Err(serde::de::Error::custom( + "missing __typename field on Transaction", + )) } } } - diff --git a/lightspark/src/objects/transaction_failures.rs b/lightspark/src/objects/transaction_failures.rs index eeed8ec..51e20aa 100644 --- a/lightspark/src/objects/transaction_failures.rs +++ b/lightspark/src/objects/transaction_failures.rs @@ -1,25 +1,13 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; -use std::vec::Vec; use crate::objects::payment_failure_reason::PaymentFailureReason; use crate::objects::routing_transaction_failure_reason::RoutingTransactionFailureReason; +use serde::{Deserialize, Serialize}; +use std::vec::Vec; /// This object represents payment failures associated with your Lightspark Node. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct TransactionFailures { - - - pub payment_failures: Option>, - - pub routing_transaction_failures: Option>, - } - - - - - diff --git a/lightspark/src/objects/transaction_status.rs b/lightspark/src/objects/transaction_status.rs index 7cea4d9..bf0e73b 100644 --- a/lightspark/src/objects/transaction_status.rs +++ b/lightspark/src/objects/transaction_status.rs @@ -1,4 +1,3 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -9,29 +8,28 @@ use std::fmt; pub enum TransactionStatus { /// Transaction succeeded. - #[serde(rename="SUCCESS")] + #[serde(rename = "SUCCESS")] Success, /// Transaction failed. - #[serde(rename="FAILED")] + #[serde(rename = "FAILED")] Failed, /// Transaction has been initiated and is currently in-flight. - #[serde(rename="PENDING")] + #[serde(rename = "PENDING")] Pending, /// For transaction type PAYMENT_REQUEST only. No payments have been made to a payment request. - #[serde(rename="NOT_STARTED")] + #[serde(rename = "NOT_STARTED")] NotStarted, /// For transaction type PAYMENT_REQUEST only. A payment request has expired. - #[serde(rename="EXPIRED")] + #[serde(rename = "EXPIRED")] Expired, /// For transaction type PAYMENT_REQUEST only. - #[serde(rename="CANCELLED")] + #[serde(rename = "CANCELLED")] Cancelled, - } impl Into for TransactionStatus { @@ -49,8 +47,6 @@ impl fmt::Display for TransactionStatus { Self::NotStarted => write!(f, "NOT_STARTED"), Self::Expired => write!(f, "EXPIRED"), Self::Cancelled => write!(f, "CANCELLED"), - } } } - diff --git a/lightspark/src/objects/transaction_type.rs b/lightspark/src/objects/transaction_type.rs index c86de90..0097539 100644 --- a/lightspark/src/objects/transaction_type.rs +++ b/lightspark/src/objects/transaction_type.rs @@ -1,4 +1,3 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -9,45 +8,44 @@ use std::fmt; pub enum TransactionType { /// Transactions initiated from a Lightspark node on Lightning Network. - #[serde(rename="OUTGOING_PAYMENT")] + #[serde(rename = "OUTGOING_PAYMENT")] OutgoingPayment, /// Transactions received by a Lightspark node on Lightning Network. - #[serde(rename="INCOMING_PAYMENT")] + #[serde(rename = "INCOMING_PAYMENT")] IncomingPayment, /// Transactions that forwarded payments through Lightspark nodes on Lightning Network. - #[serde(rename="ROUTED")] + #[serde(rename = "ROUTED")] Routed, /// Transactions on the Bitcoin blockchain to withdraw funds from a Lightspark node to a Bitcoin wallet. - #[serde(rename="L1_WITHDRAW")] + #[serde(rename = "L1_WITHDRAW")] L1Withdraw, /// Transactions on Bitcoin blockchain to fund a Lightspark node's wallet. - #[serde(rename="L1_DEPOSIT")] + #[serde(rename = "L1_DEPOSIT")] L1Deposit, /// Transactions on Bitcoin blockchain to open a channel on Lightning Network funded by the local Lightspark node. - #[serde(rename="CHANNEL_OPEN")] + #[serde(rename = "CHANNEL_OPEN")] ChannelOpen, /// Transactions on Bitcoin blockchain to close a channel on Lightning Network where the balances are allocated back to local and remote nodes. - #[serde(rename="CHANNEL_CLOSE")] + #[serde(rename = "CHANNEL_CLOSE")] ChannelClose, /// Transactions initiated from a Lightspark node on Lightning Network. - #[serde(rename="PAYMENT")] + #[serde(rename = "PAYMENT")] Payment, /// Payment requests from a Lightspark node on Lightning Network - #[serde(rename="PAYMENT_REQUEST")] + #[serde(rename = "PAYMENT_REQUEST")] PaymentRequest, /// Transactions that forwarded payments through Lightspark nodes on Lightning Network. - #[serde(rename="ROUTE")] + #[serde(rename = "ROUTE")] Route, - } impl Into for TransactionType { @@ -69,8 +67,6 @@ impl fmt::Display for TransactionType { Self::Payment => write!(f, "PAYMENT"), Self::PaymentRequest => write!(f, "PAYMENT_REQUEST"), Self::Route => write!(f, "ROUTE"), - } } } - diff --git a/lightspark/src/objects/uma_invitation.rs b/lightspark/src/objects/uma_invitation.rs index 1281eb8..d96f723 100644 --- a/lightspark/src/objects/uma_invitation.rs +++ b/lightspark/src/objects/uma_invitation.rs @@ -1,19 +1,17 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::entity::Entity; -use crate::types::get_entity::GetEntity; -use crate::types::custom_date_formats::custom_date_format; use crate::objects::incentives_ineligibility_reason::IncentivesIneligibilityReason; -use chrono::{DateTime, Utc}; 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")] + #[serde(rename = "uma_invitation_id")] pub id: String, /// The date and time when the entity was first created. @@ -25,38 +23,35 @@ pub struct UmaInvitation { pub updated_at: DateTime, /// The code that uniquely identifies this invitation. - #[serde (rename = "uma_invitation_code")] + #[serde(rename = "uma_invitation_code")] pub code: String, /// The URL where this invitation can be claimed. - #[serde (rename = "uma_invitation_url")] + #[serde(rename = "uma_invitation_url")] pub url: String, /// The UMA of the user who created the invitation. - #[serde (rename = "uma_invitation_inviter_uma")] + #[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")] + #[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")] + #[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")] + #[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() @@ -72,16 +67,15 @@ impl Entity for UmaInvitation { self.updated_at } - fn type_name(&self) -> &'static str { "UmaInvitation" } } - impl GetEntity for UmaInvitation { fn get_entity_query() -> String { - format!(" + format!( + " query GetEntity($id: ID!) {{ entity(id: $id) {{ ... on UmaInvitation {{ @@ -90,12 +84,12 @@ impl GetEntity for UmaInvitation { }} }} - {}", FRAGMENT) - } + {}", + FRAGMENT + ) + } } - - pub const FRAGMENT: &str = " fragment UmaInvitationFragment on UmaInvitation { __typename @@ -110,6 +104,3 @@ fragment UmaInvitationFragment on UmaInvitation { uma_invitation_incentives_ineligibility_reason: incentives_ineligibility_reason } "; - - - diff --git a/lightspark/src/objects/update_channel_per_commitment_point_input.rs b/lightspark/src/objects/update_channel_per_commitment_point_input.rs index 0dc9e34..96613b8 100644 --- a/lightspark/src/objects/update_channel_per_commitment_point_input.rs +++ b/lightspark/src/objects/update_channel_per_commitment_point_input.rs @@ -1,27 +1,11 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; - - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct UpdateChannelPerCommitmentPointInput { - - - pub channel_id: String, - - pub per_commitment_point: String, - - pub per_commitment_point_index: i64, - } - - - - - diff --git a/lightspark/src/objects/update_channel_per_commitment_point_output.rs b/lightspark/src/objects/update_channel_per_commitment_point_output.rs index 25fe6ee..387c67e 100644 --- a/lightspark/src/objects/update_channel_per_commitment_point_output.rs +++ b/lightspark/src/objects/update_channel_per_commitment_point_output.rs @@ -1,20 +1,13 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::types::entity_wrapper::EntityWrapper; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct UpdateChannelPerCommitmentPointOutput { - - #[serde(rename = "update_channel_per_commitment_point_output_channel")] pub channel: EntityWrapper, - } - - pub const FRAGMENT: &str = " fragment UpdateChannelPerCommitmentPointOutputFragment on UpdateChannelPerCommitmentPointOutput { __typename @@ -23,6 +16,3 @@ fragment UpdateChannelPerCommitmentPointOutputFragment on UpdateChannelPerCommit } } "; - - - diff --git a/lightspark/src/objects/update_node_shared_secret_input.rs b/lightspark/src/objects/update_node_shared_secret_input.rs index a04bfa7..5104c7a 100644 --- a/lightspark/src/objects/update_node_shared_secret_input.rs +++ b/lightspark/src/objects/update_node_shared_secret_input.rs @@ -1,23 +1,9 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; - - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct UpdateNodeSharedSecretInput { - - - pub node_id: String, - - pub shared_secret: String, - } - - - - - diff --git a/lightspark/src/objects/update_node_shared_secret_output.rs b/lightspark/src/objects/update_node_shared_secret_output.rs index 0c60ee4..d8cc487 100644 --- a/lightspark/src/objects/update_node_shared_secret_output.rs +++ b/lightspark/src/objects/update_node_shared_secret_output.rs @@ -1,20 +1,13 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::types::entity_wrapper::EntityWrapper; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct UpdateNodeSharedSecretOutput { - - #[serde(rename = "update_node_shared_secret_output_node")] pub node: EntityWrapper, - } - - pub const FRAGMENT: &str = " fragment UpdateNodeSharedSecretOutputFragment on UpdateNodeSharedSecretOutput { __typename @@ -23,6 +16,3 @@ fragment UpdateNodeSharedSecretOutputFragment on UpdateNodeSharedSecretOutput { } } "; - - - diff --git a/lightspark/src/objects/wallet.rs b/lightspark/src/objects/wallet.rs index ce6bdbf..eea23d0 100644 --- a/lightspark/src/objects/wallet.rs +++ b/lightspark/src/objects/wallet.rs @@ -1,34 +1,32 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; +use crate::error::Error; +use crate::objects::balances::Balances; +use crate::objects::currency_amount::CurrencyAmount; +use crate::objects::entity::Entity; +use crate::objects::lightspark_node_owner::LightsparkNodeOwner; +use crate::objects::transaction_status::TransactionStatus; +use crate::objects::transaction_type::TransactionType; +use crate::objects::wallet_status::WalletStatus; use crate::objects::wallet_to_payment_requests_connection::WalletToPaymentRequestsConnection; -use serde_json::Value; +use crate::objects::wallet_to_transactions_connection::WalletToTransactionsConnection; +use crate::objects::wallet_to_withdrawal_requests_connection::WalletToWithdrawalRequestsConnection; use crate::objects::withdrawal_request_status::WithdrawalRequestStatus; +use crate::types::custom_date_formats::custom_date_format; +use crate::types::custom_date_formats::custom_date_format_option; use crate::types::entity_wrapper::EntityWrapper; -use crate::objects::wallet_status::WalletStatus; -use crate::objects::transaction_status::TransactionStatus; +use crate::types::get_entity::GetEntity; use crate::types::graphql_requester::GraphQLRequester; -use crate::objects::entity::Entity; -use crate::objects::wallet_to_transactions_connection::WalletToTransactionsConnection; -use crate::types::custom_date_formats::custom_date_format; -use crate::objects::balances::Balances; -use crate::objects::wallet_to_withdrawal_requests_connection::WalletToWithdrawalRequestsConnection; -use crate::error::Error; +use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; +use serde_json::Value; use std::collections::HashMap; use std::vec::Vec; -use crate::objects::lightspark_node_owner::LightsparkNodeOwner; -use chrono::{DateTime, Utc}; -use crate::objects::currency_amount::CurrencyAmount; -use crate::types::get_entity::GetEntity; -use crate::types::custom_date_formats::custom_date_format_option; -use crate::objects::transaction_type::TransactionType; /// This object represents a Lightspark Wallet, tied to your Lightspark account. Wallets can be used to send or receive funds over the Lightning Network. You can retrieve this object to receive information about a specific wallet tied to your Lightspark account. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct Wallet { - /// The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string. - #[serde (rename = "wallet_id")] + #[serde(rename = "wallet_id")] pub id: String, /// The date and time when the entity was first created. @@ -44,11 +42,11 @@ pub struct Wallet { pub last_login_at: Option>, /// The balances that describe the funds in this wallet. - #[serde (rename = "wallet_balances")] + #[serde(rename = "wallet_balances")] pub balances: Option, /// The unique identifier of this wallet, as provided by the Lightspark Customer during login. - #[serde (rename = "wallet_third_party_identifier")] + #[serde(rename = "wallet_third_party_identifier")] pub third_party_identifier: String, /// The account this wallet belongs to. @@ -56,28 +54,21 @@ pub struct Wallet { pub account: Option, /// The status of this wallet. - #[serde (rename = "wallet_status")] + #[serde(rename = "wallet_status")] pub status: WalletStatus, /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl LightsparkNodeOwner for Wallet { - - fn type_name(&self) -> &'static str { "Wallet" } } - - impl Entity for Wallet { - /// 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() @@ -93,16 +84,15 @@ impl Entity for Wallet { self.updated_at } - fn type_name(&self) -> &'static str { "Wallet" } } - impl GetEntity for Wallet { fn get_entity_query() -> String { - format!(" + format!( + " query GetEntity($id: ID!) {{ entity(id: $id) {{ ... on Wallet {{ @@ -111,12 +101,12 @@ impl GetEntity for Wallet { }} }} - {}", FRAGMENT) - } + {}", + FRAGMENT + ) + } } - - pub const FRAGMENT: &str = " fragment WalletFragment on Wallet { __typename @@ -159,11 +149,18 @@ fragment WalletFragment on Wallet { } "; - impl Wallet { - #[allow(clippy::too_many_arguments)] - pub async fn get_transactions(&self, requester:&impl GraphQLRequester, first: Option, after: Option, created_after_date: Option>, created_before_date: Option>, statuses: Option>, types: Option>) -> Result { + pub async fn get_transactions( + &self, + requester: &impl GraphQLRequester, + first: Option, + after: Option, + created_after_date: Option>, + created_before_date: Option>, + statuses: Option>, + types: Option>, + ) -> Result { let query = "query FetchWalletToTransactionsConnection($entity_id: ID!, $first: Int, $after: ID, $created_after_date: DateTime, $created_before_date: DateTime, $statuses: [TransactionStatus!], $types: [TransactionType!]) { entity(id: $entity_id) { ... on Wallet { @@ -735,12 +732,17 @@ impl Wallet { variables.insert("entity_id", self.id.clone().into()); variables.insert("first", first.into()); variables.insert("after", after.into()); - variables.insert("created_after_date", created_after_date.map(|dt| dt.to_rfc3339()).into()); - variables.insert("created_before_date", created_before_date.map(|dt| dt.to_rfc3339()).into()); + variables.insert( + "created_after_date", + created_after_date.map(|dt| dt.to_rfc3339()).into(), + ); + variables.insert( + "created_before_date", + created_before_date.map(|dt| dt.to_rfc3339()).into(), + ); variables.insert("statuses", statuses.into()); variables.insert("types", types.into()); - let value = serde_json::to_value(variables).map_err(|err| Error::ConversionError(err))?; let result = requester.execute_graphql(&query, Some(value)).await?; let json = result["entity"]["transactions"].clone(); @@ -748,8 +750,14 @@ impl Wallet { Ok(result) } - - pub async fn get_payment_requests(&self, requester:&impl GraphQLRequester, first: Option, after: Option, created_after_date: Option>, created_before_date: Option>) -> Result { + pub async fn get_payment_requests( + &self, + requester: &impl GraphQLRequester, + first: Option, + after: Option, + created_after_date: Option>, + created_before_date: Option>, + ) -> Result { let query = "query FetchWalletToPaymentRequestsConnection($entity_id: ID!, $first: Int, $after: ID, $created_after_date: DateTime, $created_before_date: DateTime) { entity(id: $entity_id) { ... on Wallet { @@ -1082,10 +1090,15 @@ impl Wallet { variables.insert("entity_id", self.id.clone().into()); variables.insert("first", first.into()); variables.insert("after", after.into()); - variables.insert("created_after_date", created_after_date.map(|dt| dt.to_rfc3339()).into()); - variables.insert("created_before_date", created_before_date.map(|dt| dt.to_rfc3339()).into()); + variables.insert( + "created_after_date", + created_after_date.map(|dt| dt.to_rfc3339()).into(), + ); + variables.insert( + "created_before_date", + created_before_date.map(|dt| dt.to_rfc3339()).into(), + ); - let value = serde_json::to_value(variables).map_err(|err| Error::ConversionError(err))?; let result = requester.execute_graphql(&query, Some(value)).await?; let json = result["entity"]["payment_requests"].clone(); @@ -1093,8 +1106,12 @@ impl Wallet { Ok(result) } - - pub async fn get_total_amount_received(&self, requester:&impl GraphQLRequester, created_after_date: Option>, created_before_date: Option>) -> Result { + pub async fn get_total_amount_received( + &self, + requester: &impl GraphQLRequester, + created_after_date: Option>, + created_before_date: Option>, + ) -> Result { let query = "query FetchWalletTotalAmountReceived($entity_id: ID!, $created_after_date: DateTime, $created_before_date: DateTime) { entity(id: $entity_id) { ... on Wallet { @@ -1111,10 +1128,15 @@ impl Wallet { }"; let mut variables: HashMap<&str, Value> = HashMap::new(); variables.insert("entity_id", self.id.clone().into()); - variables.insert("created_after_date", created_after_date.map(|dt| dt.to_rfc3339()).into()); - variables.insert("created_before_date", created_before_date.map(|dt| dt.to_rfc3339()).into()); + variables.insert( + "created_after_date", + created_after_date.map(|dt| dt.to_rfc3339()).into(), + ); + variables.insert( + "created_before_date", + created_before_date.map(|dt| dt.to_rfc3339()).into(), + ); - let value = serde_json::to_value(variables).map_err(|err| Error::ConversionError(err))?; let result = requester.execute_graphql(&query, Some(value)).await?; let json = result["entity"]["total_amount_received"].clone(); @@ -1122,8 +1144,15 @@ impl Wallet { Ok(result) } - - pub async fn get_withdrawal_requests(&self, requester:&impl GraphQLRequester, first: Option, after: Option, statuses: Option>, created_after_date: Option>, created_before_date: Option>) -> Result { + pub async fn get_withdrawal_requests( + &self, + requester: &impl GraphQLRequester, + first: Option, + after: Option, + statuses: Option>, + created_after_date: Option>, + created_before_date: Option>, + ) -> Result { let query = "query FetchWalletToWithdrawalRequestsConnection($entity_id: ID!, $first: Int, $after: ID, $statuses: [WithdrawalRequestStatus!], $created_after_date: DateTime, $created_before_date: DateTime) { entity(id: $entity_id) { ... on Wallet { @@ -1201,10 +1230,15 @@ impl Wallet { variables.insert("first", first.into()); variables.insert("after", after.into()); variables.insert("statuses", statuses.into()); - variables.insert("created_after_date", created_after_date.map(|dt| dt.to_rfc3339()).into()); - variables.insert("created_before_date", created_before_date.map(|dt| dt.to_rfc3339()).into()); + variables.insert( + "created_after_date", + created_after_date.map(|dt| dt.to_rfc3339()).into(), + ); + variables.insert( + "created_before_date", + created_before_date.map(|dt| dt.to_rfc3339()).into(), + ); - let value = serde_json::to_value(variables).map_err(|err| Error::ConversionError(err))?; let result = requester.execute_graphql(&query, Some(value)).await?; let json = result["entity"]["withdrawal_requests"].clone(); @@ -1212,8 +1246,12 @@ impl Wallet { Ok(result) } - - pub async fn get_total_amount_sent(&self, requester:&impl GraphQLRequester, created_after_date: Option>, created_before_date: Option>) -> Result { + pub async fn get_total_amount_sent( + &self, + requester: &impl GraphQLRequester, + created_after_date: Option>, + created_before_date: Option>, + ) -> Result { let query = "query FetchWalletTotalAmountSent($entity_id: ID!, $created_after_date: DateTime, $created_before_date: DateTime) { entity(id: $entity_id) { ... on Wallet { @@ -1230,15 +1268,19 @@ impl Wallet { }"; let mut variables: HashMap<&str, Value> = HashMap::new(); variables.insert("entity_id", self.id.clone().into()); - variables.insert("created_after_date", created_after_date.map(|dt| dt.to_rfc3339()).into()); - variables.insert("created_before_date", created_before_date.map(|dt| dt.to_rfc3339()).into()); + variables.insert( + "created_after_date", + created_after_date.map(|dt| dt.to_rfc3339()).into(), + ); + variables.insert( + "created_before_date", + created_before_date.map(|dt| dt.to_rfc3339()).into(), + ); - let value = serde_json::to_value(variables).map_err(|err| Error::ConversionError(err))?; let result = requester.execute_graphql(&query, Some(value)).await?; let json = result["entity"]["total_amount_sent"].clone(); let result = serde_json::from_value(json).map_err(|err| Error::JsonError(err))?; Ok(result) } - } diff --git a/lightspark/src/objects/wallet_status.rs b/lightspark/src/objects/wallet_status.rs index 4bf2382..8559be2 100644 --- a/lightspark/src/objects/wallet_status.rs +++ b/lightspark/src/objects/wallet_status.rs @@ -1,49 +1,47 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; use serde_json::Value; use std::fmt; -/// This is an enum of the potential statuses that your Lightspark wallet can take. +/// This is an enum of the potential statuses that your Lightspark wallet can take. #[derive(Debug, Clone, Deserialize, Serialize)] pub enum WalletStatus { /// The wallet has not been set up yet and is ready to be deployed. This is the default status after the first login. - #[serde(rename="NOT_SETUP")] + #[serde(rename = "NOT_SETUP")] NotSetup, /// The wallet is currently being deployed in the Lightspark infrastructure. - #[serde(rename="DEPLOYING")] + #[serde(rename = "DEPLOYING")] Deploying, /// The wallet has been deployed in the Lightspark infrastructure and is ready to be initialized. - #[serde(rename="DEPLOYED")] + #[serde(rename = "DEPLOYED")] Deployed, /// The wallet is currently being initialized. - #[serde(rename="INITIALIZING")] + #[serde(rename = "INITIALIZING")] Initializing, /// The wallet is available and ready to be used. - #[serde(rename="READY")] + #[serde(rename = "READY")] Ready, /// The wallet is temporarily available, due to a transient issue or a scheduled maintenance. - #[serde(rename="UNAVAILABLE")] + #[serde(rename = "UNAVAILABLE")] Unavailable, /// The wallet had an unrecoverable failure. This status is not expected to happend and will be investigated by the Lightspark team. - #[serde(rename="FAILED")] + #[serde(rename = "FAILED")] Failed, /// The wallet is being terminated. - #[serde(rename="TERMINATING")] + #[serde(rename = "TERMINATING")] Terminating, /// The wallet has been terminated and is not available in the Lightspark infrastructure anymore. It is not connected to the Lightning network and its funds can only be accessed using the Funds Recovery flow. - #[serde(rename="TERMINATED")] + #[serde(rename = "TERMINATED")] Terminated, - } impl Into for WalletStatus { @@ -64,8 +62,6 @@ impl fmt::Display for WalletStatus { Self::Failed => write!(f, "FAILED"), Self::Terminating => write!(f, "TERMINATING"), Self::Terminated => write!(f, "TERMINATED"), - } } } - diff --git a/lightspark/src/objects/wallet_to_payment_requests_connection.rs b/lightspark/src/objects/wallet_to_payment_requests_connection.rs index e42aa15..a6424e0 100644 --- a/lightspark/src/objects/wallet_to_payment_requests_connection.rs +++ b/lightspark/src/objects/wallet_to_payment_requests_connection.rs @@ -1,37 +1,31 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; -use std::vec::Vec; -use crate::objects::payment_request::PaymentRequest; use crate::objects::connection::Connection; -use crate::objects::payment_request::PaymentRequestEnum; use crate::objects::page_info::PageInfo; - +use crate::objects::payment_request::PaymentRequest; +use crate::objects::payment_request::PaymentRequestEnum; +use serde::{Deserialize, Serialize}; +use std::vec::Vec; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct WalletToPaymentRequestsConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). - #[serde (rename = "wallet_to_payment_requests_connection_count")] + #[serde(rename = "wallet_to_payment_requests_connection_count")] pub count: i64, /// An object that holds pagination information about the objects in this connection. - #[serde (rename = "wallet_to_payment_requests_connection_page_info")] + #[serde(rename = "wallet_to_payment_requests_connection_page_info")] pub page_info: PageInfo, /// The payment requests for the current page of this connection. - #[serde (rename = "wallet_to_payment_requests_connection_entities")] + #[serde(rename = "wallet_to_payment_requests_connection_entities")] pub entities: Vec, /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl Connection for WalletToPaymentRequestsConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). fn get_count(&self) -> i64 { self.count @@ -42,15 +36,11 @@ impl Connection for WalletToPaymentRequestsConnection { self.page_info.clone() } - fn type_name(&self) -> &'static str { "WalletToPaymentRequestsConnection" } } - - - pub const FRAGMENT: &str = " fragment WalletToPaymentRequestsConnectionFragment on WalletToPaymentRequestsConnection { __typename @@ -67,6 +57,3 @@ fragment WalletToPaymentRequestsConnectionFragment on WalletToPaymentRequestsCon } } "; - - - diff --git a/lightspark/src/objects/wallet_to_transactions_connection.rs b/lightspark/src/objects/wallet_to_transactions_connection.rs index c4cef74..fa99461 100644 --- a/lightspark/src/objects/wallet_to_transactions_connection.rs +++ b/lightspark/src/objects/wallet_to_transactions_connection.rs @@ -1,37 +1,31 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; -use std::vec::Vec; use crate::objects::connection::Connection; +use crate::objects::page_info::PageInfo; use crate::objects::transaction::Transaction; use crate::objects::transaction::TransactionEnum; -use crate::objects::page_info::PageInfo; - +use serde::{Deserialize, Serialize}; +use std::vec::Vec; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct WalletToTransactionsConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). - #[serde (rename = "wallet_to_transactions_connection_count")] + #[serde(rename = "wallet_to_transactions_connection_count")] pub count: i64, /// An object that holds pagination information about the objects in this connection. - #[serde (rename = "wallet_to_transactions_connection_page_info")] + #[serde(rename = "wallet_to_transactions_connection_page_info")] pub page_info: PageInfo, /// The transactions for the current page of this connection. - #[serde (rename = "wallet_to_transactions_connection_entities")] + #[serde(rename = "wallet_to_transactions_connection_entities")] pub entities: Vec, /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl Connection for WalletToTransactionsConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). fn get_count(&self) -> i64 { self.count @@ -42,15 +36,11 @@ impl Connection for WalletToTransactionsConnection { self.page_info.clone() } - fn type_name(&self) -> &'static str { "WalletToTransactionsConnection" } } - - - pub const FRAGMENT: &str = " fragment WalletToTransactionsConnectionFragment on WalletToTransactionsConnection { __typename @@ -67,6 +57,3 @@ fragment WalletToTransactionsConnectionFragment on WalletToTransactionsConnectio } } "; - - - diff --git a/lightspark/src/objects/wallet_to_withdrawal_requests_connection.rs b/lightspark/src/objects/wallet_to_withdrawal_requests_connection.rs index 51fba3c..c897d1a 100644 --- a/lightspark/src/objects/wallet_to_withdrawal_requests_connection.rs +++ b/lightspark/src/objects/wallet_to_withdrawal_requests_connection.rs @@ -1,36 +1,30 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::objects::connection::Connection; +use crate::objects::page_info::PageInfo; +use crate::objects::withdrawal_request::WithdrawalRequest; use serde::{Deserialize, Serialize}; use std::vec::Vec; -use crate::objects::withdrawal_request::WithdrawalRequest; -use crate::objects::page_info::PageInfo; -use crate::objects::connection::Connection; - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct WalletToWithdrawalRequestsConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). - #[serde (rename = "wallet_to_withdrawal_requests_connection_count")] + #[serde(rename = "wallet_to_withdrawal_requests_connection_count")] pub count: i64, /// An object that holds pagination information about the objects in this connection. - #[serde (rename = "wallet_to_withdrawal_requests_connection_page_info")] + #[serde(rename = "wallet_to_withdrawal_requests_connection_page_info")] pub page_info: PageInfo, /// The withdrawal requests for the current page of this connection. - #[serde (rename = "wallet_to_withdrawal_requests_connection_entities")] + #[serde(rename = "wallet_to_withdrawal_requests_connection_entities")] pub entities: Vec, /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl Connection for WalletToWithdrawalRequestsConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). fn get_count(&self) -> i64 { self.count @@ -41,15 +35,11 @@ impl Connection for WalletToWithdrawalRequestsConnection { self.page_info.clone() } - fn type_name(&self) -> &'static str { "WalletToWithdrawalRequestsConnection" } } - - - pub const FRAGMENT: &str = " fragment WalletToWithdrawalRequestsConnectionFragment on WalletToWithdrawalRequestsConnection { __typename @@ -66,6 +56,3 @@ fragment WalletToWithdrawalRequestsConnectionFragment on WalletToWithdrawalReque } } "; - - - diff --git a/lightspark/src/objects/webhook_event_type.rs b/lightspark/src/objects/webhook_event_type.rs index 269a105..fc0630a 100644 --- a/lightspark/src/objects/webhook_event_type.rs +++ b/lightspark/src/objects/webhook_event_type.rs @@ -1,4 +1,3 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -7,52 +6,50 @@ use std::fmt; /// This is an enum of the potential event types that can be associated with your Lightspark wallets. #[derive(Debug, Clone, Deserialize, Serialize)] pub enum WebhookEventType { - - #[serde(rename="PAYMENT_FINISHED")] + #[serde(rename = "PAYMENT_FINISHED")] PaymentFinished, - #[serde(rename="FORCE_CLOSURE")] + #[serde(rename = "FORCE_CLOSURE")] ForceClosure, - #[serde(rename="WITHDRAWAL_FINISHED")] + #[serde(rename = "WITHDRAWAL_FINISHED")] WithdrawalFinished, - #[serde(rename="FUNDS_RECEIVED")] + #[serde(rename = "FUNDS_RECEIVED")] FundsReceived, - #[serde(rename="NODE_STATUS")] + #[serde(rename = "NODE_STATUS")] NodeStatus, - #[serde(rename="UMA_INVITATION_CLAIMED")] + #[serde(rename = "UMA_INVITATION_CLAIMED")] UmaInvitationClaimed, - #[serde(rename="WALLET_STATUS")] + #[serde(rename = "WALLET_STATUS")] WalletStatus, - #[serde(rename="WALLET_OUTGOING_PAYMENT_FINISHED")] + #[serde(rename = "WALLET_OUTGOING_PAYMENT_FINISHED")] WalletOutgoingPaymentFinished, - #[serde(rename="WALLET_INCOMING_PAYMENT_FINISHED")] + #[serde(rename = "WALLET_INCOMING_PAYMENT_FINISHED")] WalletIncomingPaymentFinished, - #[serde(rename="WALLET_WITHDRAWAL_FINISHED")] + #[serde(rename = "WALLET_WITHDRAWAL_FINISHED")] WalletWithdrawalFinished, - #[serde(rename="WALLET_FUNDS_RECEIVED")] + #[serde(rename = "WALLET_FUNDS_RECEIVED")] WalletFundsReceived, - #[serde(rename="REMOTE_SIGNING")] + #[serde(rename = "REMOTE_SIGNING")] RemoteSigning, - #[serde(rename="LOW_BALANCE")] + #[serde(rename = "LOW_BALANCE")] LowBalance, - #[serde(rename="HIGH_BALANCE")] + #[serde(rename = "HIGH_BALANCE")] HighBalance, - #[serde(rename="CHANNEL_OPENING_FEES")] + #[serde(rename = "CHANNEL_OPENING_FEES")] ChannelOpeningFees, - } impl Into for WebhookEventType { @@ -79,8 +76,6 @@ impl fmt::Display for WebhookEventType { Self::LowBalance => write!(f, "LOW_BALANCE"), Self::HighBalance => write!(f, "HIGH_BALANCE"), Self::ChannelOpeningFees => write!(f, "CHANNEL_OPENING_FEES"), - } } } - diff --git a/lightspark/src/objects/withdrawal.rs b/lightspark/src/objects/withdrawal.rs index c66c0b8..3ad012b 100644 --- a/lightspark/src/objects/withdrawal.rs +++ b/lightspark/src/objects/withdrawal.rs @@ -1,24 +1,22 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::currency_amount::CurrencyAmount; -use crate::types::entity_wrapper::EntityWrapper; -use crate::objects::transaction_status::TransactionStatus; -use crate::objects::on_chain_transaction::OnChainTransaction; use crate::objects::entity::Entity; -use crate::types::get_entity::GetEntity; -use std::vec::Vec; -use crate::types::custom_date_formats::custom_date_format_option; +use crate::objects::on_chain_transaction::OnChainTransaction; use crate::objects::transaction::Transaction; +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 crate::types::entity_wrapper::EntityWrapper; +use crate::types::get_entity::GetEntity; use chrono::{DateTime, Utc}; +use serde::{Deserialize, Serialize}; +use std::vec::Vec; /// This object represents an L1 withdrawal from your Lightspark Node to any Bitcoin wallet. You can retrieve this object to receive detailed information about any L1 withdrawal associated with your Lightspark Node or account. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct Withdrawal { - /// The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string. - #[serde (rename = "withdrawal_id")] + #[serde(rename = "withdrawal_id")] pub id: String, /// The date and time when this transaction was initiated. @@ -30,7 +28,7 @@ pub struct Withdrawal { pub updated_at: DateTime, /// The current status of this transaction. - #[serde (rename = "withdrawal_status")] + #[serde(rename = "withdrawal_status")] pub status: TransactionStatus, /// The date and time when this transaction was completed or failed. @@ -38,31 +36,31 @@ pub struct Withdrawal { pub resolved_at: Option>, /// The amount of money involved in this transaction. - #[serde (rename = "withdrawal_amount")] + #[serde(rename = "withdrawal_amount")] pub amount: CurrencyAmount, /// The hash of this transaction, so it can be uniquely identified on the Lightning Network. - #[serde (rename = "withdrawal_transaction_hash")] + #[serde(rename = "withdrawal_transaction_hash")] pub transaction_hash: Option, /// The fees that were paid by the node for this transaction. - #[serde (rename = "withdrawal_fees")] + #[serde(rename = "withdrawal_fees")] pub fees: Option, /// The hash of the block that included this transaction. This will be null for unconfirmed transactions. - #[serde (rename = "withdrawal_block_hash")] + #[serde(rename = "withdrawal_block_hash")] pub block_hash: Option, /// The height of the block that included this transaction. This will be zero for unconfirmed transactions. - #[serde (rename = "withdrawal_block_height")] + #[serde(rename = "withdrawal_block_height")] pub block_height: i64, /// The Bitcoin blockchain addresses this transaction was sent to. - #[serde (rename = "withdrawal_destination_addresses")] + #[serde(rename = "withdrawal_destination_addresses")] pub destination_addresses: Vec, /// The number of blockchain confirmations for this transaction in real time. - #[serde (rename = "withdrawal_num_confirmations")] + #[serde(rename = "withdrawal_num_confirmations")] pub num_confirmations: Option, /// The Lightspark node this withdrawal originated from. @@ -72,12 +70,9 @@ pub struct Withdrawal { /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl OnChainTransaction for Withdrawal { - /// The fees that were paid by the node for this transaction. fn get_fees(&self) -> Option { self.fees.clone() @@ -103,16 +98,12 @@ impl OnChainTransaction for Withdrawal { self.num_confirmations } - fn type_name(&self) -> &'static str { "Withdrawal" } } - - impl Transaction for Withdrawal { - /// The current status of this transaction. fn get_status(&self) -> TransactionStatus { self.status.clone() @@ -133,16 +124,12 @@ impl Transaction for Withdrawal { self.transaction_hash.clone() } - fn type_name(&self) -> &'static str { "Withdrawal" } } - - impl Entity for Withdrawal { - /// 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() @@ -158,16 +145,15 @@ impl Entity for Withdrawal { self.updated_at } - fn type_name(&self) -> &'static str { "Withdrawal" } } - impl GetEntity for Withdrawal { fn get_entity_query() -> String { - format!(" + format!( + " query GetEntity($id: ID!) {{ entity(id: $id) {{ ... on Withdrawal {{ @@ -176,12 +162,12 @@ impl GetEntity for Withdrawal { }} }} - {}", FRAGMENT) - } + {}", + FRAGMENT + ) + } } - - pub const FRAGMENT: &str = " fragment WithdrawalFragment on Withdrawal { __typename @@ -216,6 +202,3 @@ fragment WithdrawalFragment on Withdrawal { } } "; - - - diff --git a/lightspark/src/objects/withdrawal_fee_estimate_input.rs b/lightspark/src/objects/withdrawal_fee_estimate_input.rs index 271c1fc..301031d 100644 --- a/lightspark/src/objects/withdrawal_fee_estimate_input.rs +++ b/lightspark/src/objects/withdrawal_fee_estimate_input.rs @@ -1,27 +1,15 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::withdrawal_mode::WithdrawalMode; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct WithdrawalFeeEstimateInput { - /// The node from which you'd like to make the withdrawal. - pub node_id: String, /// The amount you want to withdraw from this node in Satoshis. Use the special value -1 to withdrawal all funds from this node. - pub amount_sats: i64, /// The strategy that should be used to withdraw the funds from this node. - pub withdrawal_mode: WithdrawalMode, - } - - - - - diff --git a/lightspark/src/objects/withdrawal_fee_estimate_output.rs b/lightspark/src/objects/withdrawal_fee_estimate_output.rs index 5ab3f73..07fb839 100644 --- a/lightspark/src/objects/withdrawal_fee_estimate_output.rs +++ b/lightspark/src/objects/withdrawal_fee_estimate_output.rs @@ -1,20 +1,14 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; use crate::objects::currency_amount::CurrencyAmount; - +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct WithdrawalFeeEstimateOutput { - /// The estimated fee for the withdrawal. - #[serde (rename = "withdrawal_fee_estimate_output_fee_estimate")] + #[serde(rename = "withdrawal_fee_estimate_output_fee_estimate")] pub fee_estimate: CurrencyAmount, - } - - pub const FRAGMENT: &str = " fragment WithdrawalFeeEstimateOutputFragment on WithdrawalFeeEstimateOutput { __typename @@ -28,6 +22,3 @@ fragment WithdrawalFeeEstimateOutputFragment on WithdrawalFeeEstimateOutput { } } "; - - - diff --git a/lightspark/src/objects/withdrawal_mode.rs b/lightspark/src/objects/withdrawal_mode.rs index 816f3d9..7203766 100644 --- a/lightspark/src/objects/withdrawal_mode.rs +++ b/lightspark/src/objects/withdrawal_mode.rs @@ -1,4 +1,3 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -7,13 +6,11 @@ use std::fmt; /// This is an enum of the potential modes that your Bitcoin withdrawal can take. #[derive(Debug, Clone, Deserialize, Serialize)] pub enum WithdrawalMode { - - #[serde(rename="WALLET_ONLY")] + #[serde(rename = "WALLET_ONLY")] WalletOnly, - #[serde(rename="WALLET_THEN_CHANNELS")] + #[serde(rename = "WALLET_THEN_CHANNELS")] WalletThenChannels, - } impl Into for WithdrawalMode { @@ -27,8 +24,6 @@ impl fmt::Display for WithdrawalMode { match self { Self::WalletOnly => write!(f, "WALLET_ONLY"), Self::WalletThenChannels => write!(f, "WALLET_THEN_CHANNELS"), - } } } - diff --git a/lightspark/src/objects/withdrawal_request.rs b/lightspark/src/objects/withdrawal_request.rs index 280a058..6e4f48c 100644 --- a/lightspark/src/objects/withdrawal_request.rs +++ b/lightspark/src/objects/withdrawal_request.rs @@ -1,30 +1,28 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; +use crate::error::Error; use crate::objects::currency_amount::CurrencyAmount; -use crate::objects::withdrawal_request_status::WithdrawalRequestStatus; -use serde_json::Value; -use crate::types::entity_wrapper::EntityWrapper; -use crate::objects::withdrawal_request_to_channel_closing_transactions_connection::WithdrawalRequestToChannelClosingTransactionsConnection; use crate::objects::entity::Entity; +use crate::objects::request_initiator::RequestInitiator; use crate::objects::withdrawal_mode::WithdrawalMode; -use crate::error::Error; -use crate::types::get_entity::GetEntity; -use std::collections::HashMap; -use crate::types::custom_date_formats::custom_date_format_option; +use crate::objects::withdrawal_request_status::WithdrawalRequestStatus; +use crate::objects::withdrawal_request_to_channel_closing_transactions_connection::WithdrawalRequestToChannelClosingTransactionsConnection; +use crate::objects::withdrawal_request_to_channel_opening_transactions_connection::WithdrawalRequestToChannelOpeningTransactionsConnection; use crate::objects::withdrawal_request_to_withdrawals_connection::WithdrawalRequestToWithdrawalsConnection; -use crate::objects::request_initiator::RequestInitiator; use crate::types::custom_date_formats::custom_date_format; +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 crate::objects::withdrawal_request_to_channel_opening_transactions_connection::WithdrawalRequestToChannelOpeningTransactionsConnection; +use serde::{Deserialize, Serialize}; +use serde_json::Value; +use std::collections::HashMap; /// This object represents a request made for an L1 withdrawal from your Lightspark Node to any Bitcoin wallet. You can retrieve this object to receive detailed information about any withdrawal request made from your Lightspark account. #[derive(Debug, Clone, Deserialize, Serialize)] pub struct WithdrawalRequest { - /// The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string. - #[serde (rename = "withdrawal_request_id")] + #[serde(rename = "withdrawal_request_id")] pub id: String, /// The date and time when the entity was first created. @@ -36,39 +34,42 @@ pub struct WithdrawalRequest { pub updated_at: DateTime, /// The requested amount of money to be withdrawn. If the requested amount is -1, it means to withdraw all. - #[serde (rename = "withdrawal_request_requested_amount")] + #[serde(rename = "withdrawal_request_requested_amount")] pub requested_amount: CurrencyAmount, /// The amount of money that should be withdrawn in this request. - #[serde (rename = "withdrawal_request_amount")] + #[serde(rename = "withdrawal_request_amount")] pub amount: CurrencyAmount, /// If the requested amount is `-1` (i.e. everything), this field may contain an estimate of the amount for the withdrawal. - #[serde (rename = "withdrawal_request_estimated_amount")] + #[serde(rename = "withdrawal_request_estimated_amount")] pub estimated_amount: Option, /// The actual amount that is withdrawn to the bitcoin address. It will be set once the request is completed. - #[serde (rename = "withdrawal_request_amount_withdrawn")] + #[serde(rename = "withdrawal_request_amount_withdrawn")] pub amount_withdrawn: Option, /// The total fees the node paid for the withdrawal. It will be set once the request is completed. - #[serde (rename = "withdrawal_request_total_fees")] + #[serde(rename = "withdrawal_request_total_fees")] pub total_fees: Option, /// The bitcoin address where the funds should be sent. - #[serde (rename = "withdrawal_request_bitcoin_address")] + #[serde(rename = "withdrawal_request_bitcoin_address")] pub bitcoin_address: String, /// The strategy that should be used to withdraw the funds from the account. - #[serde (rename = "withdrawal_request_withdrawal_mode")] + #[serde(rename = "withdrawal_request_withdrawal_mode")] pub withdrawal_mode: WithdrawalMode, /// The current status of this withdrawal request. - #[serde (rename = "withdrawal_request_status")] + #[serde(rename = "withdrawal_request_status")] pub status: WithdrawalRequestStatus, /// The time at which this request was completed. - #[serde(with = "custom_date_format_option", rename = "withdrawal_request_completed_at")] + #[serde( + with = "custom_date_format_option", + rename = "withdrawal_request_completed_at" + )] pub completed_at: Option>, /// The withdrawal transaction that has been generated by this request. @@ -76,22 +77,19 @@ pub struct WithdrawalRequest { pub withdrawal: Option, /// The idempotency key of the withdrawal request. - #[serde (rename = "withdrawal_request_idempotency_key")] + #[serde(rename = "withdrawal_request_idempotency_key")] pub idempotency_key: Option, /// The initiator of the withdrawal. - #[serde (rename = "withdrawal_request_initiator")] + #[serde(rename = "withdrawal_request_initiator")] pub initiator: RequestInitiator, /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl Entity for WithdrawalRequest { - /// 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() @@ -107,16 +105,15 @@ impl Entity for WithdrawalRequest { self.updated_at } - fn type_name(&self) -> &'static str { "WithdrawalRequest" } } - impl GetEntity for WithdrawalRequest { fn get_entity_query() -> String { - format!(" + format!( + " query GetEntity($id: ID!) {{ entity(id: $id) {{ ... on WithdrawalRequest {{ @@ -125,12 +122,12 @@ impl GetEntity for WithdrawalRequest { }} }} - {}", FRAGMENT) - } + {}", + FRAGMENT + ) + } } - - pub const FRAGMENT: &str = " fragment WithdrawalRequestFragment on WithdrawalRequest { __typename @@ -189,11 +186,13 @@ fragment WithdrawalRequestFragment on WithdrawalRequest { } "; - impl WithdrawalRequest { - - - pub async fn get_channel_closing_transactions(&self, requester:&impl GraphQLRequester, first: Option, after: Option) -> Result { + pub async fn get_channel_closing_transactions( + &self, + requester: &impl GraphQLRequester, + first: Option, + after: Option, + ) -> Result { let query = "query FetchWithdrawalRequestToChannelClosingTransactionsConnection($entity_id: ID!, $first: Int, $after: String) { entity(id: $entity_id) { ... on WithdrawalRequest { @@ -248,7 +247,6 @@ impl WithdrawalRequest { variables.insert("first", first.into()); variables.insert("after", after.into()); - let value = serde_json::to_value(variables).map_err(|err| Error::ConversionError(err))?; let result = requester.execute_graphql(&query, Some(value)).await?; let json = result["entity"]["channel_closing_transactions"].clone(); @@ -256,8 +254,12 @@ impl WithdrawalRequest { Ok(result) } - - pub async fn get_channel_opening_transactions(&self, requester:&impl GraphQLRequester, first: Option, after: Option) -> Result { + pub async fn get_channel_opening_transactions( + &self, + requester: &impl GraphQLRequester, + first: Option, + after: Option, + ) -> Result { let query = "query FetchWithdrawalRequestToChannelOpeningTransactionsConnection($entity_id: ID!, $first: Int, $after: String) { entity(id: $entity_id) { ... on WithdrawalRequest { @@ -312,7 +314,6 @@ impl WithdrawalRequest { variables.insert("first", first.into()); variables.insert("after", after.into()); - let value = serde_json::to_value(variables).map_err(|err| Error::ConversionError(err))?; let result = requester.execute_graphql(&query, Some(value)).await?; let json = result["entity"]["channel_opening_transactions"].clone(); @@ -320,8 +321,11 @@ impl WithdrawalRequest { Ok(result) } - - pub async fn get_withdrawals(&self, requester:&impl GraphQLRequester, first: Option) -> Result { + pub async fn get_withdrawals( + &self, + requester: &impl GraphQLRequester, + first: Option, + ) -> Result { let query = "query FetchWithdrawalRequestToWithdrawalsConnection($entity_id: ID!, $first: Int) { entity(id: $entity_id) { ... on WithdrawalRequest { @@ -368,12 +372,10 @@ impl WithdrawalRequest { variables.insert("entity_id", self.id.clone().into()); variables.insert("first", first.into()); - let value = serde_json::to_value(variables).map_err(|err| Error::ConversionError(err))?; let result = requester.execute_graphql(&query, Some(value)).await?; let json = result["entity"]["withdrawals"].clone(); let result = serde_json::from_value(json).map_err(|err| Error::JsonError(err))?; Ok(result) } - } diff --git a/lightspark/src/objects/withdrawal_request_status.rs b/lightspark/src/objects/withdrawal_request_status.rs index 6aceab1..b81a601 100644 --- a/lightspark/src/objects/withdrawal_request_status.rs +++ b/lightspark/src/objects/withdrawal_request_status.rs @@ -1,4 +1,3 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -7,25 +6,23 @@ use std::fmt; /// This is an enum of the potential statuses that a Withdrawal can take. #[derive(Debug, Clone, Deserialize, Serialize)] pub enum WithdrawalRequestStatus { - - #[serde(rename="CREATING")] + #[serde(rename = "CREATING")] Creating, - #[serde(rename="CREATED")] + #[serde(rename = "CREATED")] Created, - #[serde(rename="FAILED")] + #[serde(rename = "FAILED")] Failed, - #[serde(rename="IN_PROGRESS")] + #[serde(rename = "IN_PROGRESS")] InProgress, - #[serde(rename="SUCCESSFUL")] + #[serde(rename = "SUCCESSFUL")] Successful, - #[serde(rename="PARTIALLY_SUCCESSFUL")] + #[serde(rename = "PARTIALLY_SUCCESSFUL")] PartiallySuccessful, - } impl Into for WithdrawalRequestStatus { @@ -43,8 +40,6 @@ impl fmt::Display for WithdrawalRequestStatus { Self::InProgress => write!(f, "IN_PROGRESS"), Self::Successful => write!(f, "SUCCESSFUL"), Self::PartiallySuccessful => write!(f, "PARTIALLY_SUCCESSFUL"), - } } } - diff --git a/lightspark/src/objects/withdrawal_request_to_channel_closing_transactions_connection.rs b/lightspark/src/objects/withdrawal_request_to_channel_closing_transactions_connection.rs index 3e4cc82..4fdc6eb 100644 --- a/lightspark/src/objects/withdrawal_request_to_channel_closing_transactions_connection.rs +++ b/lightspark/src/objects/withdrawal_request_to_channel_closing_transactions_connection.rs @@ -1,36 +1,30 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; -use std::vec::Vec; use crate::objects::channel_closing_transaction::ChannelClosingTransaction; -use crate::objects::page_info::PageInfo; use crate::objects::connection::Connection; - +use crate::objects::page_info::PageInfo; +use serde::{Deserialize, Serialize}; +use std::vec::Vec; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct WithdrawalRequestToChannelClosingTransactionsConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). - #[serde (rename = "withdrawal_request_to_channel_closing_transactions_connection_count")] + #[serde(rename = "withdrawal_request_to_channel_closing_transactions_connection_count")] pub count: i64, /// An object that holds pagination information about the objects in this connection. - #[serde (rename = "withdrawal_request_to_channel_closing_transactions_connection_page_info")] + #[serde(rename = "withdrawal_request_to_channel_closing_transactions_connection_page_info")] pub page_info: PageInfo, /// The channel closing transactions for the current page of this connection. - #[serde (rename = "withdrawal_request_to_channel_closing_transactions_connection_entities")] + #[serde(rename = "withdrawal_request_to_channel_closing_transactions_connection_entities")] pub entities: Vec, /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl Connection for WithdrawalRequestToChannelClosingTransactionsConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). fn get_count(&self) -> i64 { self.count @@ -41,15 +35,11 @@ impl Connection for WithdrawalRequestToChannelClosingTransactionsConnection { self.page_info.clone() } - fn type_name(&self) -> &'static str { "WithdrawalRequestToChannelClosingTransactionsConnection" } } - - - pub const FRAGMENT: &str = " fragment WithdrawalRequestToChannelClosingTransactionsConnectionFragment on WithdrawalRequestToChannelClosingTransactionsConnection { __typename @@ -66,6 +56,3 @@ fragment WithdrawalRequestToChannelClosingTransactionsConnectionFragment on With } } "; - - - diff --git a/lightspark/src/objects/withdrawal_request_to_channel_opening_transactions_connection.rs b/lightspark/src/objects/withdrawal_request_to_channel_opening_transactions_connection.rs index af0d9ea..63ab6e8 100644 --- a/lightspark/src/objects/withdrawal_request_to_channel_opening_transactions_connection.rs +++ b/lightspark/src/objects/withdrawal_request_to_channel_opening_transactions_connection.rs @@ -1,36 +1,30 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved -use serde::{Deserialize, Serialize}; -use std::vec::Vec; use crate::objects::channel_opening_transaction::ChannelOpeningTransaction; -use crate::objects::page_info::PageInfo; use crate::objects::connection::Connection; - +use crate::objects::page_info::PageInfo; +use serde::{Deserialize, Serialize}; +use std::vec::Vec; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct WithdrawalRequestToChannelOpeningTransactionsConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). - #[serde (rename = "withdrawal_request_to_channel_opening_transactions_connection_count")] + #[serde(rename = "withdrawal_request_to_channel_opening_transactions_connection_count")] pub count: i64, /// An object that holds pagination information about the objects in this connection. - #[serde (rename = "withdrawal_request_to_channel_opening_transactions_connection_page_info")] + #[serde(rename = "withdrawal_request_to_channel_opening_transactions_connection_page_info")] pub page_info: PageInfo, /// The channel opening transactions for the current page of this connection. - #[serde (rename = "withdrawal_request_to_channel_opening_transactions_connection_entities")] + #[serde(rename = "withdrawal_request_to_channel_opening_transactions_connection_entities")] pub entities: Vec, /// The typename of the object #[serde(rename = "__typename")] pub typename: String, - } - impl Connection for WithdrawalRequestToChannelOpeningTransactionsConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). fn get_count(&self) -> i64 { self.count @@ -41,15 +35,11 @@ impl Connection for WithdrawalRequestToChannelOpeningTransactionsConnection { self.page_info.clone() } - fn type_name(&self) -> &'static str { "WithdrawalRequestToChannelOpeningTransactionsConnection" } } - - - pub const FRAGMENT: &str = " fragment WithdrawalRequestToChannelOpeningTransactionsConnectionFragment on WithdrawalRequestToChannelOpeningTransactionsConnection { __typename @@ -66,6 +56,3 @@ fragment WithdrawalRequestToChannelOpeningTransactionsConnectionFragment on With } } "; - - - diff --git a/lightspark/src/objects/withdrawal_request_to_withdrawals_connection.rs b/lightspark/src/objects/withdrawal_request_to_withdrawals_connection.rs index 1d43239..e0349f3 100644 --- a/lightspark/src/objects/withdrawal_request_to_withdrawals_connection.rs +++ b/lightspark/src/objects/withdrawal_request_to_withdrawals_connection.rs @@ -1,25 +1,19 @@ - // Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +use crate::objects::withdrawal::Withdrawal; use serde::{Deserialize, Serialize}; use std::vec::Vec; -use crate::objects::withdrawal::Withdrawal; - #[derive(Debug, Clone, Deserialize, Serialize)] pub struct WithdrawalRequestToWithdrawalsConnection { - /// The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field). - #[serde (rename = "withdrawal_request_to_withdrawals_connection_count")] + #[serde(rename = "withdrawal_request_to_withdrawals_connection_count")] pub count: i64, /// The withdrawals for the current page of this connection. - #[serde (rename = "withdrawal_request_to_withdrawals_connection_entities")] + #[serde(rename = "withdrawal_request_to_withdrawals_connection_entities")] pub entities: Vec, - } - - pub const FRAGMENT: &str = " fragment WithdrawalRequestToWithdrawalsConnectionFragment on WithdrawalRequestToWithdrawalsConnection { __typename @@ -29,6 +23,3 @@ fragment WithdrawalRequestToWithdrawalsConnectionFragment on WithdrawalRequestTo } } "; - - -