use serde::{Serialize, Deserialize};
use super::{PlaidError, WebhookEnvironmentValues};
///Fired when Asset Report generation has failed. The resulting `error` will have an `error_type` of `ASSET_REPORT_ERROR`.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AssetsErrorWebhook {
///The ID associated with the Asset Report.
pub asset_report_id: String,
///The Plaid environment the webhook was sent from
pub environment: WebhookEnvironmentValues,
///Errors are identified by `error_code` and categorized by `error_type`. Use these in preference to HTTP status codes to identify and handle specific errors. HTTP status codes are set and provide the broadest categorization of errors: 4xx codes are for developer- or user-related errors, and 5xx codes are for Plaid-related errors, and the status will be 2xx in non-error cases. An Item with a non-`null` error object will only be part of an API response when calling `/item/get` to view Item status. Otherwise, error fields will be `null` if no error has occurred; if an error has occurred, an error code will be returned instead.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub error: Option<PlaidError>,
///The `user_id` corresponding to the User ID the webhook has fired for.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub user_id: Option<String>,
///`ERROR`
pub webhook_code: String,
///`ASSETS`
pub webhook_type: String,
}
impl std::fmt::Display for AssetsErrorWebhook {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
write!(f, "{}", serde_json::to_string(self).unwrap())
}
}