use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum WebhookType {
MinedTransaction,
DroppedTransaction,
AddressActivity,
NftActivity,
NftMetadataUpdate,
Graphql,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum WebhookNetwork {
EthMainnet,
EthSepolia,
EthHolesky,
PolygonMainnet,
PolygonAmoy,
ArbMainnet,
ArbSepolia,
OptMainnet,
OptSepolia,
BaseMainnet,
BaseSepolia,
ZksyncMainnet,
ZksyncSepolia,
#[serde(other)]
Other,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum WebhookStatus {
Active,
Inactive,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Webhook {
pub id: String,
pub network: WebhookNetwork,
pub webhook_type: WebhookType,
pub webhook_url: String,
pub is_active: bool,
pub signing_key: Option<String>,
pub version: Option<String>,
pub time_created: Option<String>,
pub app_id: Option<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ListWebhooksResponse {
pub data: Vec<Webhook>,
pub total_count: Option<u64>,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CreateWebhookRequest {
pub network: WebhookNetwork,
pub webhook_type: WebhookType,
pub webhook_url: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub addresses: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub graphql_query: Option<String>,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct UpdateWebhookAddressesRequest {
pub webhook_id: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub addresses_to_add: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub addresses_to_remove: Option<Vec<String>>,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ReplaceWebhookAddressesRequest {
pub webhook_id: String,
pub addresses: Vec<String>,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct UpdateWebhookRequest {
pub webhook_id: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub webhook_url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub is_active: Option<bool>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct NftFilter {
pub contract_address: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub token_id: Option<String>,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct UpdateNftFiltersRequest {
pub webhook_id: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub nft_filters_to_add: Option<Vec<NftFilter>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub nft_filters_to_remove: Option<Vec<NftFilter>>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ListAddressesResponse {
pub data: Vec<String>,
pub pagination: Option<PaginationInfo>,
pub total_count: Option<u64>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PaginationInfo {
pub cursors: Option<Cursors>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Cursors {
pub after: Option<String>,
pub before: Option<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ListNftFiltersResponse {
pub data: Vec<NftFilter>,
pub pagination: Option<PaginationInfo>,
pub total_count: Option<u64>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct GraphqlVariable {
pub name: String,
pub values: Vec<String>,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct GraphqlVariableRequest {
pub variable: String,
pub values: Vec<String>,
}
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PatchGraphqlVariableRequest {
#[serde(skip_serializing_if = "Option::is_none")]
pub values_to_add: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub values_to_remove: Option<Vec<String>>,
}