-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #222 from lalwani/api
Created request and response objects for sdk 2.x
- Loading branch information
Showing
10 changed files
with
247 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
authentication/src/main/kotlin/com/uber/sdk2/auth/api/exception/AuthException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright (C) 2024. Uber Technologies | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.uber.sdk2.auth.api.exception | ||
|
||
/** Represents the exception that occurred during the authentication request. */ | ||
sealed class AuthException(override val message: String) : RuntimeException(message) { | ||
/** Represents the exception that occurred due to server error. */ | ||
data class ServerError(override val message: String) : AuthException(message) | ||
|
||
/** Represents the exception that occurred due to client error. */ | ||
data class ClientError(override val message: String) : AuthException(message) | ||
|
||
/** Represents the exception that occurred due to network error. */ | ||
data class NetworkError(override val message: String) : AuthException(message) | ||
} |
31 changes: 31 additions & 0 deletions
31
authentication/src/main/kotlin/com/uber/sdk2/auth/api/request/AuthContext.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (C) 2024. Uber Technologies | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.uber.sdk2.auth.api.request | ||
|
||
/** | ||
* Represents the context of the authentication request needed for Uber to authenticate the user. | ||
* | ||
* @param authDestination The destination app to authenticate the user. | ||
* @param authType The type of authentication to perform. | ||
* @param prefillInfo The prefill information to be used for the authentication. | ||
* @param scopes The scopes to request for the authentication. | ||
*/ | ||
data class AuthContext( | ||
val authDestination: AuthDestination, | ||
val authType: AuthType, | ||
val prefillInfo: PrefillInfo?, | ||
val scopes: String?, | ||
) |
33 changes: 33 additions & 0 deletions
33
authentication/src/main/kotlin/com/uber/sdk2/auth/api/request/AuthDestination.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (C) 2024. Uber Technologies | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.uber.sdk2.auth.api.request | ||
|
||
/** Represents the destination app to authenticate the user. */ | ||
sealed class AuthDestination { | ||
/** | ||
* Authenticating within the same app by using a system webview, a.k.a Custom Tabs. If custom tabs | ||
* are unavailable the authentication flow will be launched in the system browser app. | ||
*/ | ||
data object InApp : AuthDestination() | ||
|
||
/** | ||
* Authenticating via one of the family of Uber apps using the Single Sign-On (SSO) flow in the | ||
* order of priority mentioned. | ||
* | ||
* @param appPriority The order of the apps to use for the SSO flow. | ||
*/ | ||
data class CrossAppSso(val appPriority: List<CrossApp>) : AuthDestination() | ||
} |
29 changes: 29 additions & 0 deletions
29
authentication/src/main/kotlin/com/uber/sdk2/auth/api/request/AuthType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright (C) 2024. Uber Technologies | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.uber.sdk2.auth.api.request | ||
|
||
/** | ||
* Represents the type of authentication to perform. | ||
* | ||
* @see AuthContext | ||
*/ | ||
sealed class AuthType { | ||
/** The authorization code flow. */ | ||
data object AuthCode : AuthType() | ||
|
||
/** The proof key for code exchange (PKCE) flow. This is the recommended flow for mobile apps. */ | ||
data object PKCE : AuthType() | ||
} |
28 changes: 28 additions & 0 deletions
28
authentication/src/main/kotlin/com/uber/sdk2/auth/api/request/CrossApp.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright (C) 2024. Uber Technologies | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.uber.sdk2.auth.api.request | ||
|
||
/** Provides different apps that could be used for authentication using SSO flow. */ | ||
sealed class CrossApp { | ||
/** The Eats app. */ | ||
data object Eats : CrossApp() | ||
|
||
/** The Rider app. */ | ||
data object Rider : CrossApp() | ||
|
||
/** The Driver app. */ | ||
data object Driver : CrossApp() | ||
} |
31 changes: 31 additions & 0 deletions
31
authentication/src/main/kotlin/com/uber/sdk2/auth/api/request/PrefillInfo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (C) 2024. Uber Technologies | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.uber.sdk2.auth.api.request | ||
|
||
/** | ||
* Provides a way to prefill the user's information in the authentication flow. | ||
* | ||
* @param email The email to prefill. | ||
* @param firstName The first name to prefill. | ||
* @param lastName The last name to prefill. | ||
* @param phoneNumber The phone number to prefill. | ||
*/ | ||
data class PrefillInfo( | ||
val email: String, | ||
val firstName: String, | ||
val lastName: String, | ||
val phoneNumber: String, | ||
) |
19 changes: 19 additions & 0 deletions
19
authentication/src/main/kotlin/com/uber/sdk2/auth/api/response/AccessToken.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright (C) 2024. Uber Technologies | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.uber.sdk2.auth.api.response | ||
|
||
/** Holds the access token that is returned after a successful authentication request. */ | ||
data class AccessToken(val token: String, val scope: String, val expiresIn: Long) |
27 changes: 27 additions & 0 deletions
27
authentication/src/main/kotlin/com/uber/sdk2/auth/api/response/AuthResult.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (C) 2024. Uber Technologies | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.uber.sdk2.auth.api.response | ||
|
||
import com.uber.sdk2.auth.api.exception.AuthException | ||
|
||
/** Represents the response from the authentication request. */ | ||
sealed class AuthResult { | ||
/** Represents the success response from the authentication request. */ | ||
data class Success(val authCode: String, val accessToken: AccessToken) : AuthResult() | ||
|
||
/** Represents the error response from the authentication request. */ | ||
data class Error(val authException: AuthException) : AuthResult() | ||
} |
19 changes: 19 additions & 0 deletions
19
authentication/src/main/kotlin/com/uber/sdk2/auth/api/response/OAuthToken.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright (C) 2024. Uber Technologies | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.uber.sdk2.auth.api.response | ||
|
||
/** Holds the OAuth token that is returned after a successful authentication request. */ | ||
data class OAuthToken(val accessToken: AccessToken, val refreshToken: String) |