#import "MyCoreData.h"
#import <PINCache/PINCache.h>

@interface MyCoreData()
@property(nonatomic, strong) PINDiskCache *calendarPriceCache;

@end

@implementation MyCoreData

-(NSString *)guestCheckoutPromotionText{
	return (NSString *)[[PINDiskCache sharedCache] objectForKey:NSStringFromSelector(@selector(guestCheckoutPromotionText))];
}

-(void)setGuestCheckoutPromotionText:(NSString *)guestCheckoutPromotionText{
	[[PINDiskCache sharedCache] setObject:guestCheckoutPromotionText forKey:NSStringFromSelector(@selector(guestCheckoutPromotionText))];
}


- (NSDictionary *)busSearchDataSource {
	return [[PINCache sharedCache] objectForKey:NSStringFromSelector(@selector(busSearchDataSource))];
}

- (void)setBusSearchDataSource:(NSDictionary *)busSearchDataSource {
	if (busSearchDataSource) {
		[[PINCache sharedCache] setObject:busSearchDataSource forKey:NSStringFromSelector(@selector(busSearchDataSource))];
	} else {
		[[PINCache sharedCache] removeObjectForKey:NSStringFromSelector(@selector(busSearchDataSource))];
	}
}

- (NSDictionary *)hotelSearchDataSource {
	return [[PINCache sharedCache] objectForKey:NSStringFromSelector(@selector(hotelSearchDataSource))];
}

- (void)setHotelSearchDataSource:(NSDictionary *)hotelSearchDataSource {
	if (hotelSearchDataSource) {
		[[PINCache sharedCache] setObject:hotelSearchDataSource forKey:NSStringFromSelector(@selector(hotelSearchDataSource))];
	} else {
		[[PINCache sharedCache] removeObjectForKey:NSStringFromSelector(@selector(hotelSearchDataSource))];
	}
}

- (NSArray *)mostPopularFaqs {
	return [[PINCache sharedCache] objectForKey:NSStringFromSelector(@selector(mostPopularFaqs))];
}

- (void)setMostPopularFaqs:(NSArray *)mostPopularFaqs {
	if (mostPopularFaqs) {
		[[PINCache sharedCache] setObject:mostPopularFaqs forKey:NSStringFromSelector(@selector(mostPopularFaqs))];
	} else {
		[[PINCache sharedCache] removeObjectForKey:NSStringFromSelector(@selector(mostPopularFaqs))];
	}
}

- (NSDictionary *)busDepartureArrivalPairs {
	return self.busSearchDataSource[@"pairs"];
}

- (PINDiskCache *)calendarPriceCache{
	if (!_calendarPriceCache) {
		_calendarPriceCache = [[PINDiskCache alloc] initWithName:NSStringFromSelector(@selector(calendarPriceCache))];
		_calendarPriceCache.ageLimit = 24 * 3600;
		_calendarPriceCache.ttlCache = YES;
	}
	return _calendarPriceCache;
}

- (void)setCalendarPrice:(id)calendarPrice withKey:(NSString *)key{
	if (calendarPrice) {
		[self.calendarPriceCache setObject:calendarPrice forKey:key];
	}else{
		[self.calendarPriceCache removeObjectForKey:key];
	}
}

-(id)getCalendarPriceWithKey:(NSString *)key{
	return [self.calendarPriceCache objectForKey:key];
}

@end
