space_traders/models/
contract.rs

1//! Generated by: <https://openapi-generator.tech>
2//!
3//! Version of specification: `2.0.0`
4
5use serde::{Deserialize, Serialize};
6
7/// Contract details.
8#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
9pub struct Contract {
10    /// ID of the contract.
11    #[serde(rename = "id")]
12    pub id: String,
13    /// The symbol of the faction that this contract is for.
14    #[serde(rename = "factionSymbol")]
15    pub faction_symbol: String,
16    /// Type of contract.
17    #[serde(rename = "type")]
18    pub r#type: Type,
19    #[serde(rename = "terms")]
20    pub terms: crate::models::ContractTerms,
21    /// Whether the contract has been accepted by the agent
22    #[serde(rename = "accepted")]
23    pub accepted: bool,
24    /// Whether the contract has been fulfilled
25    #[serde(rename = "fulfilled")]
26    pub fulfilled: bool,
27    /// Deprecated in favor of deadlineToAccept
28    #[serde(rename = "expiration")]
29    pub expiration: String,
30    /// The time at which the contract is no longer available to be accepted
31    #[serde(rename = "deadlineToAccept", skip_serializing_if = "Option::is_none")]
32    pub deadline_to_accept: Option<String>,
33}
34
35impl Contract {
36    /// Create value with optional fields set to `None`.
37    #[allow(clippy::too_many_arguments)]
38    pub fn new(
39        id: String,
40        faction_symbol: String,
41        r#type: Type,
42        terms: crate::models::ContractTerms,
43        accepted: bool,
44        fulfilled: bool,
45        expiration: String,
46    ) -> Contract {
47        Contract {
48            id,
49            faction_symbol,
50            r#type,
51            terms,
52            accepted,
53            fulfilled,
54            expiration,
55            deadline_to_accept: None,
56        }
57    }
58}
59
60/// Type of contract.
61#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
62pub enum Type {
63    #[serde(rename = "PROCUREMENT")]
64    Procurement,
65    #[serde(rename = "TRANSPORT")]
66    Transport,
67    #[serde(rename = "SHUTTLE")]
68    Shuttle,
69}
70
71impl Default for Type {
72    fn default() -> Type {
73        Self::Procurement
74    }
75}