space_traders/models/
contract.rs1use serde::{Deserialize, Serialize};
6
7#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
9pub struct Contract {
10 #[serde(rename = "id")]
12 pub id: String,
13 #[serde(rename = "factionSymbol")]
15 pub faction_symbol: String,
16 #[serde(rename = "type")]
18 pub r#type: Type,
19 #[serde(rename = "terms")]
20 pub terms: crate::models::ContractTerms,
21 #[serde(rename = "accepted")]
23 pub accepted: bool,
24 #[serde(rename = "fulfilled")]
26 pub fulfilled: bool,
27 #[serde(rename = "expiration")]
29 pub expiration: String,
30 #[serde(rename = "deadlineToAccept", skip_serializing_if = "Option::is_none")]
32 pub deadline_to_accept: Option<String>,
33}
34
35impl Contract {
36 #[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#[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}