dodopayments_rust 2.2.2

Rust SDK for Dodo Payments API
Documentation
/*
 * public
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 1.87.0
 * 
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

/// CreateLedgerEntryRequest : Request to create a ledger entry (credit or debit)
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct CreateLedgerEntryRequest {
    /// Amount to credit or debit
    #[serde(rename = "amount")]
    pub amount: String,
    /// Entry type: credit or debit
    #[serde(rename = "entry_type")]
    pub entry_type: models::LedgerEntryType,
    /// Expiration for credited amount (only for credit type)
    #[serde(rename = "expires_at", skip_serializing_if = "Option::is_none")]
    pub expires_at: Option<String>,
    /// Idempotency key to prevent duplicate entries
    #[serde(rename = "idempotency_key", skip_serializing_if = "Option::is_none")]
    pub idempotency_key: Option<String>,
    /// Optional metadata (max 50 key-value pairs, key max 40 chars, value max 500 chars)
    #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")]
    pub metadata: Option<std::collections::HashMap<String, String>>,
    /// Human-readable reason for the entry
    #[serde(rename = "reason", skip_serializing_if = "Option::is_none")]
    pub reason: Option<String>,
}

impl CreateLedgerEntryRequest {
    /// Request to create a ledger entry (credit or debit)
    pub fn new(amount: String, entry_type: models::LedgerEntryType) -> CreateLedgerEntryRequest {
        CreateLedgerEntryRequest {
            amount,
            entry_type,
            expires_at: None,
            idempotency_key: None,
            metadata: None,
            reason: None,
        }
    }
}