1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
use crate::resources::common::object::Object; use crate::resources::common::path::{UrlPath}; use crate::resources::core::events::EventType; use crate::util::{Deleted, List}; use crate::{Client}; use serde::Serialize; #[derive(Serialize, Deserialize, Debug, PartialEq)] pub struct WebhookEndpoints { pub id: String, pub object: Object, pub api_version: String, pub application: String, pub created: i64, pub enabled_events: Vec<EventType>, pub livemode: bool, pub status: EndpointStatus, pub url: String, pub secret: Option<String>, } #[derive(Serialize, Deserialize, Debug, PartialEq)] #[serde(rename_all = "lowercase")] pub enum EndpointStatus { Enabled, Disabled, } #[derive(Serialize, Debug, PartialEq)] pub struct WebhookEndpointsParams<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub enabled_events: Option<Vec<&'a str>>, #[serde(skip_serializing_if = "Option::is_none")] pub url: Option<&'a str>, #[serde(skip_serializing_if = "Option::is_none")] pub api_version: Option<&'a str>, #[serde(skip_serializing_if = "Option::is_none")] pub connect: Option<bool>, } #[derive(Default, Serialize, Debug, PartialEq)] pub struct WebhookEndpointsListParams<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub ending_before: Option<&'a str>, #[serde(skip_serializing_if = "Option::is_none")] pub limit: Option<i64>, #[serde(skip_serializing_if = "Option::is_none")] pub starting_after: Option<&'a str>, } impl WebhookEndpoints { pub fn create<S: Serialize>(client: &Client, param: S) -> crate::Result<Self> { client.post(UrlPath::WebhookEndpoints, vec![], param) } pub fn retrieve(client: &Client, id: &str) -> crate::Result<Self> { client.get(UrlPath::WebhookEndpoints, vec![id], serde_json::Map::new()) } pub fn update<S: Serialize>(client: &Client, id: &str, param: S) -> crate::Result<Self> { client.post(UrlPath::WebhookEndpoints, vec![id], param) } pub fn list<S: Serialize>(client: &Client, param: S) -> crate::Result<List<Self>> { client.get(UrlPath::WebhookEndpoints, vec![], param) } pub fn delete(client: &Client, id: &str) -> crate::Result<Deleted> { client.get(UrlPath::WebhookEndpoints, vec![id], serde_json::Map::new()) } }