space_traders_api/models/contract.rs
1/*
2 * SpaceTraders API
3 *
4 * SpaceTraders is an open-universe game and learning platform that offers a set of HTTP endpoints to control a fleet of ships and explore a multiplayer universe. The API is documented using [OpenAPI](https://github.com/SpaceTradersAPI/api-docs). You can send your first request right here in your browser to check the status of the game server. ```json http { \"method\": \"GET\", \"url\": \"https://api.spacetraders.io/v2\", } ``` Unlike a traditional game, SpaceTraders does not have a first-party client or app to play the game. Instead, you can use the API to build your own client, write a script to automate your ships, or try an app built by the community. We have a [Discord channel](https://discord.com/invite/jh6zurdWk5) where you can share your projects, ask questions, and get help from other players.
5 *
6 * The version of the OpenAPI document: 2.3.0
7 * Contact: joel@spacetraders.io
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14/// Contract : Contract details.
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct Contract {
17 /// ID of the contract.
18 #[serde(rename = "id")]
19 pub id: String,
20 /// The symbol of the faction that this contract is for.
21 #[serde(rename = "factionSymbol")]
22 pub faction_symbol: String,
23 /// Type of contract.
24 #[serde(rename = "type")]
25 pub r#type: Type,
26 #[serde(rename = "terms")]
27 pub terms: Box<models::ContractTerms>,
28 /// Whether the contract has been accepted by the agent
29 #[serde(rename = "accepted")]
30 pub accepted: bool,
31 /// Whether the contract has been fulfilled
32 #[serde(rename = "fulfilled")]
33 pub fulfilled: bool,
34 /// Deprecated in favor of deadlineToAccept
35 #[serde(rename = "expiration")]
36 pub expiration: String,
37 /// The time at which the contract is no longer available to be accepted
38 #[serde(rename = "deadlineToAccept", skip_serializing_if = "Option::is_none")]
39 pub deadline_to_accept: Option<String>,
40}
41
42impl Contract {
43 /// Contract details.
44 pub fn new(id: String, faction_symbol: String, r#type: Type, terms: models::ContractTerms, accepted: bool, fulfilled: bool, expiration: String) -> Contract {
45 Contract {
46 id,
47 faction_symbol,
48 r#type,
49 terms: Box::new(terms),
50 accepted,
51 fulfilled,
52 expiration,
53 deadline_to_accept: None,
54 }
55 }
56}
57/// Type of contract.
58#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
59pub enum Type {
60 #[serde(rename = "PROCUREMENT")]
61 Procurement,
62 #[serde(rename = "TRANSPORT")]
63 Transport,
64 #[serde(rename = "SHUTTLE")]
65 Shuttle,
66}
67
68impl Default for Type {
69 fn default() -> Type {
70 Self::Procurement
71 }
72}
73