-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: add bridging utils for core-rest packages communication #166
Merged
+1,018
−58
Conversation
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
anssari1
previously approved these changes
Jan 30, 2025
...-sdk-rest/src/main/kotlin/com/expediagroup/sdk/rest/extension/OperationToRequestExtension.kt
Show resolved
Hide resolved
...ain/kotlin/com/expediagroup/sdk/rest/serialization/DefaultJacksonBasedOperationDataMapper.kt
Outdated
Show resolved
Hide resolved
anssari1
reviewed
Jan 30, 2025
...-sdk-rest/src/main/kotlin/com/expediagroup/sdk/rest/extension/OperationToRequestExtension.kt
Outdated
Show resolved
Hide resolved
...-sdk-rest/src/main/kotlin/com/expediagroup/sdk/rest/extension/OperationToRequestExtension.kt
Outdated
Show resolved
Hide resolved
...oup-sdk-rest/src/main/kotlin/com/expediagroup/sdk/rest/extension/SDKCoreResponseExtension.kt
Show resolved
Hide resolved
...ain/kotlin/com/expediagroup/sdk/rest/serialization/DefaultJacksonBasedOperationDataMapper.kt
Outdated
Show resolved
Hide resolved
...-sdk-rest/src/main/kotlin/com/expediagroup/sdk/rest/extension/OperationToRequestExtension.kt
Outdated
Show resolved
Hide resolved
...-sdk-rest/src/main/kotlin/com/expediagroup/sdk/rest/extension/OperationToRequestExtension.kt
Show resolved
Hide resolved
...-sdk-rest/src/main/kotlin/com/expediagroup/sdk/rest/extension/OperationToRequestExtension.kt
Outdated
Show resolved
Hide resolved
...-sdk-rest/src/main/kotlin/com/expediagroup/sdk/rest/extension/OperationToRequestExtension.kt
Show resolved
Hide resolved
...-sdk-rest/src/main/kotlin/com/expediagroup/sdk/rest/extension/OperationToRequestExtension.kt
Outdated
Show resolved
Hide resolved
...-sdk-rest/src/main/kotlin/com/expediagroup/sdk/rest/extension/OperationToRequestExtension.kt
Show resolved
Hide resolved
...oup-sdk-rest/src/main/kotlin/com/expediagroup/sdk/rest/extension/SDKCoreResponseExtension.kt
Show resolved
Hide resolved
...oup-sdk-rest/src/main/kotlin/com/expediagroup/sdk/rest/extension/SDKCoreResponseExtension.kt
Show resolved
Hide resolved
...ain/kotlin/com/expediagroup/sdk/rest/serialization/DefaultJacksonBasedOperationDataMapper.kt
Outdated
Show resolved
Hide resolved
...-sdk-rest/src/main/kotlin/com/expediagroup/sdk/rest/trait/operation/OperationRequestTrait.kt
Outdated
Show resolved
Hide resolved
...-sdk-rest/src/main/kotlin/com/expediagroup/sdk/rest/extension/OperationToRequestExtension.kt
Outdated
Show resolved
Hide resolved
...-sdk-rest/src/main/kotlin/com/expediagroup/sdk/rest/extension/OperationToRequestExtension.kt
Outdated
Show resolved
Hide resolved
...-sdk-rest/src/main/kotlin/com/expediagroup/sdk/rest/extension/OperationToRequestExtension.kt
Outdated
Show resolved
Hide resolved
...-sdk-rest/src/main/kotlin/com/expediagroup/sdk/rest/extension/OperationToRequestExtension.kt
Outdated
Show resolved
Hide resolved
...-sdk-rest/src/main/kotlin/com/expediagroup/sdk/rest/extension/OperationToRequestExtension.kt
Show resolved
Hide resolved
...oup-sdk-rest/src/main/kotlin/com/expediagroup/sdk/rest/extension/SDKCoreResponseExtension.kt
Show resolved
Hide resolved
...oup-sdk-rest/src/main/kotlin/com/expediagroup/sdk/rest/extension/SDKCoreResponseExtension.kt
Show resolved
Hide resolved
...p-sdk-rest/src/main/kotlin/com/expediagroup/sdk/rest/serialization/JacksonOperationMapper.kt
Outdated
Show resolved
Hide resolved
...ain/kotlin/com/expediagroup/sdk/rest/serialization/DefaultJacksonBasedOperationDataMapper.kt
Outdated
Show resolved
Hide resolved
…t/extension/OperationToRequestExtension.kt Co-authored-by: Mohammad Dwairi <[email protected]>
…t/extension/OperationToRequestExtension.kt Co-authored-by: Mohammad Dwairi <[email protected]>
…t/extension/OperationToRequestExtension.kt Co-authored-by: Mohammad Dwairi <[email protected]>
anssari1
reviewed
Feb 3, 2025
...-sdk-rest/src/main/kotlin/com/expediagroup/sdk/rest/extension/OperationToRequestExtension.kt
Show resolved
Hide resolved
Mohammad-Dwairi
approved these changes
Feb 4, 2025
anssari1
approved these changes
Feb 4, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Situation
This is the third pull request of a sequence (#158, #164) following up on our new architectural decisions. This pull request addresses the need for utilities that ease communication with the
sdk-core
package.The
sdk-core
package speaks the language of raw requests and responses, and is not involved in any serialization, deserialization, end-user API modeling or other web-based API specific needs. In order for thesdk-rest
extension package to communicate with thesdk-core
, a translation layer needs to be put in-place.Task
1- Serialization & Deserialization
Build utilities and tools that can transform different data formats (support
json
for now) into POJOs and vice versa.2- Request Translation
Build utilities and tools that translate Operations API-based requests into raw
sdk-core
requests. Translation includes:3- Response Translation
Build utilities and tools that translate raw
sdk-core
responses into oursdk-rest
models. Translation includes:Action
1- Serialization & Deserialization
Created a new
DefaultJacksonBasedOperationDataMapper
class which acts as wrapper for Jackson'sObjectMapper
instances. The class adheres to theSerializeRequestBodyTrait
andDeserializeResponseBodyTrait
contracts.Instances of this class or any other
SerializeRequestBodyTrait
andDeserializeResponseBodyTrait
compliants are passed based on their traits (abstractions or interfaces), and are consumed later on.2- Request Translation
Since traits can serve as markers that tell what data an operation instance holds, we made use of the Kotlin/Java typing system by associating extension-helper methods with the traits themselves.
By assigning extension functions to trait types, we ensure a decoupled request translation system, and achieve a more compile-time code-safety since these functions and the data they consume will be blocked unless a trait-type check is performed.
Of course, we have created an entry-point extension method that handles all the checks required, and calls other extension methods for you.
It is also worth mentioning that all extension methods act as a guard for the
sdk-core
package by carrying any required checks that ensure data validity before moving forward with delegation to thesdk-core
. These extension methods also follow a dependency injection model where dependencies such as serializers/deserializers are passed as params, adding more flexibility and extensibility to the workflow.3- Response Translation
Response translation is designed around the same concepts used in request translation. Extension methods are designed and associated with trait types. Extension methods also handle any checks required before returning a response to the end-user.
Testing
Changed Files
OperationToRequestExtension.kt
OperationToRequestExtensionTest
:SDKCoreResponseExtension.kt
SDKCoreResponseExtensionTest
:Response.kt
ResponseTest
:DefaultJacksonBasedOperationDataMapper.kt
DefaultJacksonBasedOperationDataMapperTest
:InputStream
.InputStream
to specified types.OperationRequestTrait.kt
OperationResponseTrait.kt
Coverage Report
Results
Utilities that enable seamless communication with
sdk-core
package are now available for usage. Most of these utilities will be consumed in future pull requests.Notes
Based on a conversation with @Mohammad-Dwairi, the logic for building and verifying URLs can be moved to the
sdk-core
package. We shall follow up on that in the future.