mirror of
				https://github.com/AdrianKuta/android-challange-adrian-kuta.git
				synced 2025-10-31 05:53:39 +01:00 
			
		
		
		
	feat: Implement flight search functionality
This commit introduces the ability to search for flights based on user-defined criteria.
Key changes:
- Added `GetFlightsSearchContentUseCase` interface in the domain layer and its implementation `GetFlightsSearchContentUseCaseImpl` in the repository layer to handle flight search logic.
- Implemented `FlightDomainMapper` to map `FlightResponse` from the API to the domain `Flight` model.
- Updated `NetworkModule`:
    - Introduced `ServicesAPI` and `NativeAppsAPI` qualifiers to differentiate between Retrofit instances for different Ryanair APIs.
    - Configured a new Retrofit instance for the `nativeapps.ryanair.com` base URL.
    - Modified `FlightService` to use the `nativeapps.ryanair.com` base URL.
- Updated `FlightService` endpoint to `api/v4/en-gb/Availability`.
- Integrated `GetFlightsSearchContentUseCase` into `HomeScreenViewModel` to trigger flight searches.
- Created `SearchOptions` data class in the domain layer to encapsulate search parameters.
- Added `GetFlightsSearchContentUseCaseModule` to provide the use case implementation via Hilt.
			
			
This commit is contained in:
		| @@ -12,7 +12,7 @@ interface FlightService { | ||||
|         "client: android", | ||||
|         "client-version: 3.300.0", | ||||
|     ) | ||||
|     @GET("v4/en-gb/Availability") | ||||
|     @GET("api/v4/en-gb/Availability") | ||||
|     @Suppress("LongParameterList") | ||||
|     suspend fun getFlights( | ||||
|         @Query("dateout") date: String, | ||||
|   | ||||
| @@ -12,6 +12,7 @@ import okhttp3.OkHttpClient | ||||
| import okhttp3.logging.HttpLoggingInterceptor | ||||
| import retrofit2.Retrofit | ||||
| import retrofit2.converter.moshi.MoshiConverterFactory | ||||
| import javax.inject.Qualifier | ||||
| import javax.inject.Singleton | ||||
|  | ||||
| @Module | ||||
| @@ -37,7 +38,8 @@ class NetworkModule { | ||||
|  | ||||
|     @Singleton | ||||
|     @Provides | ||||
|     fun provideRetrofit(client: OkHttpClient, moshi: Moshi): Retrofit = Retrofit.Builder() | ||||
|     @ServicesAPI | ||||
|     fun provideServicesRetrofit(client: OkHttpClient, moshi: Moshi): Retrofit = Retrofit.Builder() | ||||
|         // TODO("add URL provided in the task instructions") | ||||
|         .baseUrl("https://services-api.ryanair.com") | ||||
|         .addConverterFactory(MoshiConverterFactory.create(moshi)) | ||||
| @@ -46,16 +48,34 @@ class NetworkModule { | ||||
|  | ||||
|     @Singleton | ||||
|     @Provides | ||||
|     fun provideAirportService(retrofit: Retrofit): AirportService = | ||||
|     @NativeAppsAPI | ||||
|     fun provideNativeAppsRetrofit(client: OkHttpClient, moshi: Moshi): Retrofit = Retrofit.Builder() | ||||
|         // TODO("add URL provided in the task instructions") | ||||
|         .baseUrl("https://nativeapps.ryanair.com") | ||||
|         .addConverterFactory(MoshiConverterFactory.create(moshi)) | ||||
|         .client(client) | ||||
|         .build() | ||||
|  | ||||
|     @Singleton | ||||
|     @Provides | ||||
|     fun provideAirportService(@ServicesAPI retrofit: Retrofit): AirportService = | ||||
|         retrofit.create(AirportService::class.java) | ||||
|  | ||||
|     @Singleton | ||||
|     @Provides | ||||
|     fun provideRoutesService(retrofit: Retrofit): RoutesService = | ||||
|     fun provideRoutesService(@ServicesAPI retrofit: Retrofit): RoutesService = | ||||
|         retrofit.create(RoutesService::class.java) | ||||
|  | ||||
|     @Singleton | ||||
|     @Provides | ||||
|     fun provideFlightService(retrofit: Retrofit): FlightService = | ||||
|     fun provideFlightService(@NativeAppsAPI retrofit: Retrofit): FlightService = | ||||
|         retrofit.create(FlightService::class.java) | ||||
| } | ||||
|  | ||||
| @Qualifier | ||||
| @Retention(AnnotationRetention.BINARY) | ||||
| annotation class ServicesAPI | ||||
|  | ||||
| @Qualifier | ||||
| @Retention(AnnotationRetention.BINARY) | ||||
| annotation class NativeAppsAPI | ||||
|   | ||||
		Reference in New Issue
	
	Block a user