1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug)]
pub struct Environments {
    pub environments: Vec<Environment>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct SingleEnvironment {
    pub environment: Environment,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct Environment {
    pub id: String,
    pub name: String,
    #[serde(rename = "createdAt")]
    pub created_at: String,
    #[serde(rename = "updatedAt")]
    pub updated_at: String,
    pub owner: String,
    #[serde(rename = "isPublic")]
    pub is_public: Option<bool>,
    pub uid: Option<String>,
    pub values: Option<Vec<EnvironmentValue>>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct EnvironmentValue {
    pub key: String,
    pub value: String,
    pub enabled: bool,
    #[serde(rename = "type")]
    pub secret_type: Option<String>,
}

#[derive(Serialize, Deserialize)]
pub struct ApiResponse {
    pub collection: Collection,
}

/// Top level layer of a Postman collection
#[derive(Serialize, Deserialize)]
pub struct Collection {
    /// Name and description of the collection
    pub info: Info,
    /// Can be a folder, request or response
    pub item: Vec<Item>,
    /// The authentication method used
    pub auth: Auth,
    pub event: Vec<Event>,
    pub variable: Option<Vec<Variable>>,
}

#[derive(Serialize, Deserialize)]
pub struct Info {
    pub name: String,
    pub description: String,
}

#[derive(Serialize, Deserialize)]
pub struct Item {
    pub description: Option<String>,
    pub name: String,
    pub item: Option<Vec<Item>>,
    pub request: Option<Request>,
    #[serde(rename = "response")]
    pub responses: Option<Vec<Response>>,
}

#[derive(Serialize, Deserialize)]
pub struct Request {
    pub method: String,
    pub header: Vec<Header>,
    pub body: Option<Body>,
    pub description: Option<String>,
    pub url: Url,
}

#[derive(Serialize, Deserialize)]
pub struct Response {
    pub name: String,
    #[serde(rename = "originalRequest")]
    pub original_request: Request,
    pub status: String,
    pub code: i32,
    #[serde(rename = "_postman_previewlanguage")]
    pub preview_language: String,
    pub header: Vec<Header>,
    pub cookie: Vec<Cookie>,
    pub body: String,
}

#[derive(Serialize, Deserialize)]
pub struct Cookie {
    name: String,
}

#[derive(Serialize, Deserialize)]
pub struct Body {
    pub mode: String,
    pub raw: String,
    pub options: Option<Options>,
}

#[derive(Serialize, Deserialize)]
pub struct Options {
    pub raw: Option<Raw>,
}

#[derive(Serialize, Deserialize)]
pub struct Raw {
    pub language: String,
}

#[derive(Serialize, Deserialize)]
pub struct Header {
    pub description: Option<String>,
    pub key: String,
    pub value: String,
}

#[derive(Serialize, Deserialize)]
pub struct Url {
    pub raw: String,
    pub host: Vec<String>,
    pub path: Vec<String>,
    pub query: Option<Vec<Query>>,
}

#[derive(Serialize, Deserialize)]
pub struct Query {
    pub key: String,
    pub value: String,
}

#[derive(Serialize, Deserialize)]
pub struct Auth {
    #[serde(rename = "type")]
    pub auth_type: String,
    pub bearer: Vec<Bearer>,
}

#[derive(Serialize, Deserialize)]
pub struct Bearer {
    pub key: String,
    pub value: String,
    #[serde(rename = "type")]
    pub bearer_type: String,
}

#[derive(Serialize, Deserialize)]
pub struct Event {
    pub listen: String,
    pub script: Script,
}

#[derive(Serialize, Deserialize)]
pub struct Script {
    #[serde(rename = "type")]
    script_type: String,
    exec: Vec<String>,
}

#[derive(Serialize, Deserialize)]
pub struct Variable {
    pub key: String,
    pub value: String,
}