Last active
February 19, 2022 08:56
-
-
Save SangSuantak/35f16fc3cfdc38e0b0aa84d91fe12bdf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
public interface IAPIProvider | |
{ | |
void SearchHotels(); | |
void GetHotelDetails(); | |
void GetRoomDetails(); | |
void GetCancellationPolicies(); | |
void GetExtraGuestChargeDetails(); | |
void BlockRoom(); | |
void BookRoom(); | |
void GetBookingDetails(); | |
void CancelBooking(); | |
} | |
public class ConcreteProviderA : IAPIProvider | |
{ | |
public void BlockRoom() | |
{ | |
//call api | |
} | |
public void BookRoom() | |
{ | |
//call api | |
} | |
public void CancelBooking() | |
{ | |
//call api | |
} | |
public void GetBookingDetails() | |
{ | |
//call api | |
} | |
public void GetCancellationPolicies() | |
{ | |
//call api | |
} | |
public void GetExtraGuestChargeDetails() | |
{ | |
//call api | |
} | |
public void GetHotelDetails() | |
{ | |
//call api | |
} | |
public void GetRoomDetails() | |
{ | |
//call api | |
} | |
public void SearchHotels() | |
{ | |
//call api | |
} | |
} | |
public class ConcreteProviderB : IAPIProvider | |
{ | |
public void BlockRoom() | |
{ | |
throw new NotImplementedException(); | |
} | |
public void BookRoom() | |
{ | |
//call api | |
} | |
public void CancelBooking() | |
{ | |
//call api | |
} | |
public void GetBookingDetails() | |
{ | |
//call api | |
} | |
public void GetCancellationPolicies() | |
{ | |
throw new NotImplementedException(); | |
} | |
public void GetExtraGuestChargeDetails() | |
{ | |
throw new NotImplementedException(); | |
} | |
public void GetHotelDetails() | |
{ | |
//call api | |
} | |
public void GetRoomDetails() | |
{ | |
//call api | |
} | |
public void SearchHotels() | |
{ | |
//call api | |
} | |
} | |
/// <summary> | |
/// Request from web/mobile will land in this class | |
/// </summary> | |
public class Client | |
{ | |
public void SearchHotel() | |
{ | |
//get active providers from database & instantiate them | |
List<IAPIProvider> providers = new List<IAPIProvider>(); | |
foreach(var provider in providers) | |
{ | |
//search hotels from each API provider | |
provider.SearchHotels(); | |
} | |
} | |
public void GetHotelDetails(int hotelId, int hotelProviderId) | |
{ | |
IAPIProvider provider = null; | |
//here, resolve the correct API provider using the input parameters | |
//fetch hotel details from the resolved API provider | |
provider.GetHotelDetails(); | |
} | |
//Other methods | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment