//
// PerlWS.m
// LiveProject
//
// Created by haibara on 9/18/15.
//
//

#import "PerlWS.h"
#import "SDK.h"
#import "BeanUtils.h"
#import "CocoaUtils.h"
#import "Vars.h"

@implementation PerlWS
@end

@implementation AppInfoResponse
@end

@interface TourSearchImage () <NSCoding>
@end

@implementation TourSearchImage

- (void)encodeWithCoder:(NSCoder *)aCoder {
	[aCoder encodeObject:self.title forKey:NSStringFromSelector(@selector(title))];
	[aCoder encodeObject:self.url forKey:NSStringFromSelector(@selector(url))];
	[aCoder encodeObject:self.params forKey:NSStringFromSelector(@selector(params))];
}

- (id)initWithCoder:(NSCoder *)aDecoder {
	self = [super init];
	if (self) {
		self.title = [aDecoder decodeObjectForKey:NSStringFromSelector(@selector(title))];
		self.url = [aDecoder decodeObjectForKey:NSStringFromSelector(@selector(url))];
		self.params = [aDecoder decodeObjectForKey:NSStringFromSelector(@selector(params))];
	}
	return self;
}

@end

@implementation GetTourDetails

#pragma mark - Public

- (NSString *)innerXML {
	NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:[BeanUtils describeAccessibleSimple:self]];
	if ([Vars is_cn_website]) {
		dict[@"notReturnUnicode"] = @YES;
	}
	return [CocoaUtils xmlStringWithProperties:dict];
}

@end

@implementation GetTourDetailsResponseDailyTrip
@end

@implementation GetTourDetailsResponseData
@end

@implementation GetTourDetailsResponse
@end

@implementation GetTourOptions

- (instancetype)init {
	if (self = [super init]) {
		self.apiVersion = 3;
	}
	return self;
}

@end

@implementation variable
@end

@implementation Formula
@end

@implementation LabelEntry
@end

@implementation GetTourOptionsResponseLabel

#pragma mark - Public

- (NSArray *)currentTuples {
	if ([self.alias isEqualToString:@"departure"]) {
		return self.departs;
	} else if ([self.alias isEqualToString:@"arrival"]) {
		return self.arrivals;
	}
	return nil;
}

- (BOOL)isKindAsStop {
	return [super isKindAsStop] && self.currentTuples;
}

@end

@implementation GetTourOptionsResponseRoomRestriction
@end

@implementation GetTourOptionsResponseLocationTuple
@end

@implementation GetTourOptionsResponse
@end

@implementation BookTour
@end

@implementation EditFlightInfo

#pragma mark - Public

- (NSString *)innerXML {
	NSMutableString *string = [NSMutableString string];
	[string im_appendString:[CocoaUtils xmlStringWithProperties:[BeanUtils describeAccessibleSimple:self]]];
	if (self.flightInfo) {
		[string im_appendString:[CocoaUtils xmlStringWithValue:[self.flightInfo innerXML] forElement:@"flightInfo"]];
	}
	return [NSString stringWithString:string];
}

@end

@implementation RecordFlightInfo
@end

@implementation GetTourReviews
@end

@implementation GetTourReviewsResponse
@end

@implementation PostTourReview

#pragma mark - Public

- (NSString *)innerXML {
	NSMutableString *string = [NSMutableString string];
	[string im_appendString:[CocoaUtils xmlStringWithProperties:[BeanUtils describeAccessibleSimple:self]]];
	return [string im_stringByAppendingString:[CocoaUtils xmlStringWithValue:[self.reviewDetails innerXML] forElement:@"reviewDetails"]];
}

@end
