|
| 1 | +use crate::models::{AppInfo, UserInfo}; |
1 | 2 | use crate::openapi::apis::configuration::Configuration;
|
2 | 3 | use crate::openapi::apis::{
|
3 | 4 | apps_api, authenticate_api, transactions_api, user_devices_api, users_api,
|
4 | 5 | };
|
5 |
| -use crate::openapi::models; |
6 | 6 | use crate::Error;
|
7 |
| -use models::{AppInfo, UserInfo}; |
8 | 7 |
|
9 | 8 | pub struct PassageFlex {
|
10 | 9 | app_id: String,
|
@@ -86,7 +85,13 @@ impl PassageFlex {
|
86 | 85 | pub async fn get_app(&self) -> Result<Box<AppInfo>, Error> {
|
87 | 86 | apps_api::get_app(&self.configuration)
|
88 | 87 | .await
|
89 |
| - .map(|response| response.app) |
| 88 | + .map(|response| { |
| 89 | + Box::new(AppInfo { |
| 90 | + auth_origin: response.app.auth_origin, |
| 91 | + id: response.app.id, |
| 92 | + name: response.app.name, |
| 93 | + }) |
| 94 | + }) |
90 | 95 | .map_err(Into::into)
|
91 | 96 | }
|
92 | 97 |
|
@@ -126,7 +131,7 @@ impl PassageFlex {
|
126 | 131 | ) -> Result<String, Error> {
|
127 | 132 | transactions_api::create_register_transaction(
|
128 | 133 | &self.configuration,
|
129 |
| - models::CreateTransactionRegisterRequest { |
| 134 | + crate::openapi::models::CreateTransactionRegisterRequest { |
130 | 135 | external_id,
|
131 | 136 | passkey_display_name,
|
132 | 137 | },
|
@@ -169,7 +174,7 @@ impl PassageFlex {
|
169 | 174 | ) -> Result<String, Error> {
|
170 | 175 | transactions_api::create_authenticate_transaction(
|
171 | 176 | &self.configuration,
|
172 |
| - models::CreateTransactionAuthenticateRequest { external_id }, |
| 177 | + crate::openapi::models::CreateTransactionAuthenticateRequest { external_id }, |
173 | 178 | )
|
174 | 179 | .await
|
175 | 180 | .map(|response| response.transaction_id)
|
@@ -206,10 +211,13 @@ impl PassageFlex {
|
206 | 211 | /// }
|
207 | 212 | /// ```
|
208 | 213 | pub async fn verify_nonce(&self, nonce: String) -> Result<String, Error> {
|
209 |
| - authenticate_api::authenticate_verify_nonce(&self.configuration, models::Nonce { nonce }) |
210 |
| - .await |
211 |
| - .map(|response| response.external_id) |
212 |
| - .map_err(Into::into) |
| 214 | + authenticate_api::authenticate_verify_nonce( |
| 215 | + &self.configuration, |
| 216 | + crate::openapi::models::Nonce { nonce }, |
| 217 | + ) |
| 218 | + .await |
| 219 | + .map(|response| response.external_id) |
| 220 | + .map_err(Into::into) |
213 | 221 | }
|
214 | 222 |
|
215 | 223 | /// Get a user's ID in Passage by their external ID
|
@@ -303,7 +311,7 @@ impl PassageFlex {
|
303 | 311 | pub async fn get_devices(
|
304 | 312 | &self,
|
305 | 313 | external_id: String,
|
306 |
| - ) -> Result<Vec<models::WebAuthnDevices>, Error> { |
| 314 | + ) -> Result<Vec<crate::openapi::models::WebAuthnDevices>, Error> { |
307 | 315 | let user_id = self.get_id(external_id).await?;
|
308 | 316 | user_devices_api::list_user_devices(&self.configuration, &user_id)
|
309 | 317 | .await
|
@@ -386,7 +394,21 @@ impl PassageFlex {
|
386 | 394 | pub async fn get_user_by_id(&self, user_id: String) -> Result<Box<UserInfo>, Error> {
|
387 | 395 | users_api::get_user(&self.configuration, &user_id)
|
388 | 396 | .await
|
389 |
| - .map(|response| response.user) |
| 397 | + .map(|response| { |
| 398 | + Box::new(UserInfo { |
| 399 | + created_at: response.user.created_at, |
| 400 | + external_id: response.user.external_id, |
| 401 | + id: response.user.id, |
| 402 | + last_login_at: response.user.last_login_at, |
| 403 | + login_count: response.user.login_count, |
| 404 | + status: response.user.status, |
| 405 | + updated_at: response.user.updated_at, |
| 406 | + user_metadata: response.user.user_metadata, |
| 407 | + webauthn: response.user.webauthn, |
| 408 | + webauthn_devices: response.user.webauthn_devices, |
| 409 | + webauthn_types: response.user.webauthn_types, |
| 410 | + }) |
| 411 | + }) |
390 | 412 | .map_err(Into::into)
|
391 | 413 | }
|
392 | 414 | }
|
|
0 commit comments