|
1 | 1 | package io.swagger.client.api
|
2 | 2 |
|
| 3 | +import io.swagger.client.model.Pet |
3 | 4 | import java.io.File
|
| 5 | +import io.swagger.client._ |
| 6 | +import scala.concurrent.{ Future, Await } |
| 7 | +import scala.concurrent.duration._ |
| 8 | +import collection.mutable |
4 | 9 |
|
5 |
| -import scala.collection.mutable |
6 |
| -import scala.concurrent.Future |
| 10 | + class PetApi(client: TransportClient, config: SwaggerConfig) extends ApiClient(client, config) { |
7 | 11 |
|
8 |
| -class PetApi(client: TransportClient, config: SwaggerConfig) extends ApiClient(client, config) { |
| 12 | + |
| 13 | + def updatePet(body: Pet)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[Pet]): Future[Unit] = { |
| 14 | + // create path and map variables |
| 15 | + val path = (addFmt("/pet")) |
9 | 16 |
|
| 17 | + // query params |
| 18 | + val queryParams = new mutable.HashMap[String, String] |
| 19 | + val headerParams = new mutable.HashMap[String, String] |
10 | 20 |
|
11 |
| - def updatePet(body: Pet)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[Pet]): Future[Unit] = { |
12 |
| - // create path and map variables |
13 |
| - val path = (addFmt("/pet")) |
| 21 | + |
14 | 22 |
|
15 |
| - // query params |
16 |
| - val queryParams = new mutable.HashMap[String, String] |
17 |
| - val headerParams = new mutable.HashMap[String, String] |
| 23 | + |
18 | 24 |
|
| 25 | + |
19 | 26 |
|
| 27 | + val resFuture = client.submit("PUT", path, queryParams.toMap, headerParams.toMap, writer.write(body)) |
| 28 | + resFuture flatMap { resp => |
| 29 | + process(reader.read(resp)) |
| 30 | + } |
| 31 | + } |
20 | 32 |
|
| 33 | + |
| 34 | + def addPet(body: Pet)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[Pet]): Future[Unit] = { |
| 35 | + // create path and map variables |
| 36 | + val path = (addFmt("/pet")) |
21 | 37 |
|
| 38 | + // query params |
| 39 | + val queryParams = new mutable.HashMap[String, String] |
| 40 | + val headerParams = new mutable.HashMap[String, String] |
22 | 41 |
|
| 42 | + |
23 | 43 |
|
| 44 | + |
24 | 45 |
|
25 |
| - val resFuture = client.submit("PUT", path, queryParams.toMap, headerParams.toMap, writer.write(body)) |
26 |
| - resFuture flatMap { resp => |
27 |
| - process(reader.read(resp)) |
28 |
| - } |
29 |
| - } |
30 |
| - |
31 |
| - |
32 |
| - def addPet(body: Pet)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[Pet]): Future[Unit] = { |
33 |
| - // create path and map variables |
34 |
| - val path = (addFmt("/pet")) |
35 |
| - |
36 |
| - // query params |
37 |
| - val queryParams = new mutable.HashMap[String, String] |
38 |
| - val headerParams = new mutable.HashMap[String, String] |
39 |
| - |
40 |
| - |
41 |
| - |
42 |
| - |
43 |
| - |
44 |
| - |
45 |
| - |
46 |
| - val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body)) |
47 |
| - resFuture flatMap { resp => |
48 |
| - process(reader.read(resp)) |
49 |
| - } |
50 |
| - } |
| 46 | + |
51 | 47 |
|
| 48 | + val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body)) |
| 49 | + resFuture flatMap { resp => |
| 50 | + process(reader.read(resp)) |
| 51 | + } |
| 52 | + } |
52 | 53 |
|
53 |
| - def findPetsByStatus(status: List[String])(implicit reader: ClientResponseReader[List[Pet]]): Future[List[Pet]] = { |
54 |
| - // create path and map variables |
55 |
| - val path = (addFmt("/pet/findByStatus")) |
| 54 | + |
| 55 | + def findPetsByStatus(status: List[String] = available)(implicit reader: ClientResponseReader[List[Pet]]): Future[List[Pet]] = { |
| 56 | + // create path and map variables |
| 57 | + val path = (addFmt("/pet/findByStatus")) |
56 | 58 |
|
57 |
| - // query params |
58 |
| - val queryParams = new mutable.HashMap[String, String] |
59 |
| - val headerParams = new mutable.HashMap[String, String] |
| 59 | + // query params |
| 60 | + val queryParams = new mutable.HashMap[String, String] |
| 61 | + val headerParams = new mutable.HashMap[String, String] |
60 | 62 |
|
| 63 | + |
61 | 64 |
|
| 65 | + |
| 66 | + if(status != null) queryParams += "status" -> status.toString |
62 | 67 |
|
| 68 | + |
63 | 69 |
|
64 |
| - if (status != null) queryParams += "status" -> status.toString |
| 70 | + val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "") |
| 71 | + resFuture flatMap { resp => |
| 72 | + process(reader.read(resp)) |
| 73 | + } |
| 74 | + } |
65 | 75 |
|
| 76 | + |
| 77 | + def findPetsByTags(tags: List[String])(implicit reader: ClientResponseReader[List[Pet]]): Future[List[Pet]] = { |
| 78 | + // create path and map variables |
| 79 | + val path = (addFmt("/pet/findByTags")) |
66 | 80 |
|
| 81 | + // query params |
| 82 | + val queryParams = new mutable.HashMap[String, String] |
| 83 | + val headerParams = new mutable.HashMap[String, String] |
67 | 84 |
|
68 |
| - val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "") |
69 |
| - resFuture flatMap { resp => |
70 |
| - process(reader.read(resp)) |
71 |
| - } |
72 |
| - } |
| 85 | + |
73 | 86 |
|
| 87 | + |
| 88 | + if(tags != null) queryParams += "tags" -> tags.toString |
74 | 89 |
|
75 |
| - def findPetsByTags(tags: List[String])(implicit reader: ClientResponseReader[List[Pet]]): Future[List[Pet]] = { |
76 |
| - // create path and map variables |
77 |
| - val path = (addFmt("/pet/findByTags")) |
| 90 | + |
78 | 91 |
|
79 |
| - // query params |
80 |
| - val queryParams = new mutable.HashMap[String, String] |
81 |
| - val headerParams = new mutable.HashMap[String, String] |
| 92 | + val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "") |
| 93 | + resFuture flatMap { resp => |
| 94 | + process(reader.read(resp)) |
| 95 | + } |
| 96 | + } |
82 | 97 |
|
| 98 | + |
| 99 | + def getPetById(petId: Long)(implicit reader: ClientResponseReader[Pet]): Future[Pet] = { |
| 100 | + // create path and map variables |
| 101 | + val path = (addFmt("/pet/{petId}") |
| 102 | + replaceAll ("\\{" + "petId" + "\\}",petId.toString)) |
83 | 103 |
|
| 104 | + // query params |
| 105 | + val queryParams = new mutable.HashMap[String, String] |
| 106 | + val headerParams = new mutable.HashMap[String, String] |
84 | 107 |
|
| 108 | + |
85 | 109 |
|
86 |
| - if (tags != null) queryParams += "tags" -> tags.toString |
| 110 | + |
87 | 111 |
|
| 112 | + |
88 | 113 |
|
| 114 | + val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "") |
| 115 | + resFuture flatMap { resp => |
| 116 | + process(reader.read(resp)) |
| 117 | + } |
| 118 | + } |
89 | 119 |
|
90 |
| - val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "") |
91 |
| - resFuture flatMap { resp => |
92 |
| - process(reader.read(resp)) |
93 |
| - } |
94 |
| - } |
95 |
| - |
| 120 | + |
| 121 | + def updatePetWithForm(petId: String, |
| 122 | + name: String, |
| 123 | + status: String)(implicit reader: ClientResponseReader[Unit]): Future[Unit] = { |
| 124 | + // create path and map variables |
| 125 | + val path = (addFmt("/pet/{petId}") |
| 126 | + replaceAll ("\\{" + "petId" + "\\}",petId.toString)) |
96 | 127 |
|
97 |
| - def getPetById(petId: Long)(implicit reader: ClientResponseReader[Pet]): Future[Pet] = { |
98 |
| - // create path and map variables |
99 |
| - val path = (addFmt("/pet/{petId}") |
100 |
| - replaceAll("\\{" + "petId" + "\\}", petId.toString)) |
| 128 | + // query params |
| 129 | + val queryParams = new mutable.HashMap[String, String] |
| 130 | + val headerParams = new mutable.HashMap[String, String] |
101 | 131 |
|
102 |
| - // query params |
103 |
| - val queryParams = new mutable.HashMap[String, String] |
104 |
| - val headerParams = new mutable.HashMap[String, String] |
| 132 | + |
105 | 133 |
|
| 134 | + |
106 | 135 |
|
| 136 | + |
107 | 137 |
|
| 138 | + val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, "") |
| 139 | + resFuture flatMap { resp => |
| 140 | + process(reader.read(resp)) |
| 141 | + } |
| 142 | + } |
108 | 143 |
|
| 144 | + |
| 145 | + def deletePet(apiKey: String, |
| 146 | + petId: Long)(implicit reader: ClientResponseReader[Unit]): Future[Unit] = { |
| 147 | + // create path and map variables |
| 148 | + val path = (addFmt("/pet/{petId}") |
| 149 | + replaceAll ("\\{" + "petId" + "\\}",petId.toString)) |
109 | 150 |
|
| 151 | + // query params |
| 152 | + val queryParams = new mutable.HashMap[String, String] |
| 153 | + val headerParams = new mutable.HashMap[String, String] |
110 | 154 |
|
| 155 | + |
111 | 156 |
|
112 |
| - val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "") |
113 |
| - resFuture flatMap { resp => |
114 |
| - process(reader.read(resp)) |
115 |
| - } |
116 |
| - } |
| 157 | + |
117 | 158 |
|
| 159 | + headerParams += "api_key" -> apiKey.toString |
118 | 160 |
|
119 |
| - def updatePetWithForm(petId: String, |
120 |
| - name: String, |
121 |
| - status: String)(implicit reader: ClientResponseReader[Unit]): Future[Unit] = { |
122 |
| - // create path and map variables |
123 |
| - val path = (addFmt("/pet/{petId}") |
124 |
| - replaceAll("\\{" + "petId" + "\\}", petId.toString)) |
| 161 | + val resFuture = client.submit("DELETE", path, queryParams.toMap, headerParams.toMap, "") |
| 162 | + resFuture flatMap { resp => |
| 163 | + process(reader.read(resp)) |
| 164 | + } |
| 165 | + } |
125 | 166 |
|
126 |
| - // query params |
127 |
| - val queryParams = new mutable.HashMap[String, String] |
128 |
| - val headerParams = new mutable.HashMap[String, String] |
| 167 | + |
| 168 | + def uploadFile(petId: Long, |
| 169 | + additionalMetadata: String, |
| 170 | + file: File)(implicit reader: ClientResponseReader[Unit]): Future[Unit] = { |
| 171 | + // create path and map variables |
| 172 | + val path = (addFmt("/pet/{petId}/uploadImage") |
| 173 | + replaceAll ("\\{" + "petId" + "\\}",petId.toString)) |
129 | 174 |
|
| 175 | + // query params |
| 176 | + val queryParams = new mutable.HashMap[String, String] |
| 177 | + val headerParams = new mutable.HashMap[String, String] |
130 | 178 |
|
| 179 | + |
131 | 180 |
|
| 181 | + |
132 | 182 |
|
| 183 | + |
133 | 184 |
|
| 185 | + val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, "") |
| 186 | + resFuture flatMap { resp => |
| 187 | + process(reader.read(resp)) |
| 188 | + } |
| 189 | + } |
134 | 190 |
|
| 191 | + |
135 | 192 |
|
136 |
| - val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, "") |
137 |
| - resFuture flatMap { resp => |
138 |
| - process(reader.read(resp)) |
139 | 193 | }
|
140 |
| - } |
141 |
| - |
142 |
| - |
143 |
| - def deletePet(api_key: String, |
144 |
| - petId: Long)(implicit reader: ClientResponseReader[Unit]): Future[Unit] = { |
145 |
| - // create path and map variables |
146 |
| - val path = (addFmt("/pet/{petId}") |
147 |
| - replaceAll("\\{" + "petId" + "\\}", petId.toString)) |
148 |
| - |
149 |
| - // query params |
150 |
| - val queryParams = new mutable.HashMap[String, String] |
151 |
| - val headerParams = new mutable.HashMap[String, String] |
152 |
| - |
153 |
| - |
154 |
| - |
155 |
| - |
156 |
| - |
157 |
| - headerParams += "api_key" -> api_key.toString |
158 |
| - |
159 |
| - val resFuture = client.submit("DELETE", path, queryParams.toMap, headerParams.toMap, "") |
160 |
| - resFuture flatMap { resp => |
161 |
| - process(reader.read(resp)) |
162 |
| - } |
163 |
| - } |
164 |
| - |
165 |
| - |
166 |
| - def uploadFile(petId: Long, |
167 |
| - additionalMetadata: String, |
168 |
| - file: File)(implicit reader: ClientResponseReader[Unit]): Future[Unit] = { |
169 |
| - // create path and map variables |
170 |
| - val path = (addFmt("/pet/{petId}/uploadImage") |
171 |
| - replaceAll("\\{" + "petId" + "\\}", petId.toString)) |
172 |
| - |
173 |
| - // query params |
174 |
| - val queryParams = new mutable.HashMap[String, String] |
175 |
| - val headerParams = new mutable.HashMap[String, String] |
176 |
| - |
177 |
| - |
178 |
| - |
179 |
| - |
180 |
| - |
181 |
| - |
182 |
| - |
183 |
| - val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, "") |
184 |
| - resFuture flatMap { resp => |
185 |
| - process(reader.read(resp)) |
186 |
| - } |
187 |
| - } |
188 |
| - |
189 |
| - |
190 |
| -} |
|
0 commit comments