//
// WebService.h
// GoToBus
//
// Created by haibara on 10/8/14.
//
//

#import <Foundation/Foundation.h>
#import <RestKit/RestKit.h>
#import "CartEntry.h"
#import "Area.h"
#import "CreditCard.h"
#import "FlightInfo.h"
#import "Passport.h"
#import "SoldStock.h"
#import "Sales.h"
#import "Resource.h"

@interface WebService : NSObject <Resource>

@property (nonatomic, strong)NSString *apiUid;
@property (nonatomic, strong) NSString *apiPassword;
@property (nonatomic, assign) NSInteger apiVersion;
@property (nonatomic, assign) NSInteger domainId;
@property (nonatomic, strong) NSString *accessToken;

- (NSString *)innerXML;

+ (NSArray *)travelerDetailsWithCartEntries:(NSArray *)cartEntries;
+ (NSArray *)transferredOutWithCartEntry:(CartEntry *)cartEntry;
+ (NSArray *)transferredOutWithCartEntry:(CartEntry *)cartEntry reason:(NSInteger)reason service_fee:(CGFloat)service_fee penalty:(CGFloat)penalty;
+ (NSArray *)transferredInWithCartEntry:(CartEntry *)cartEntry;

@end

@interface WebServiceResponse : NSObject
@property (nonatomic, assign) NSInteger error_code;
@property (nonatomic, strong) NSString *error_message;
@end

@interface WebServiceResponseJsonMapper : NSObject

@property (nonatomic, strong) id response;
@property (nonatomic, strong) RKObjectMapping *objectMapping;

- (instancetype)initWithClass:(Class)class;
- (NSError *)parseWithJSONObject:(id)jsonObject;

@end

@interface GetSearchDataSource : WebService
@property (nonatomic, strong)NSString *typeName;
@end

@interface FacebookLogin : WebService
@property (nonatomic, strong)NSString *tokenString;
@property (nonatomic, strong) NSString *deviceIdentifier;
@property (nonatomic, strong) NSDictionary *userDetails;
@property (nonatomic, assign) BOOL shouldLink;
@property (nonatomic, strong) NSString *username;
@property (nonatomic, strong) NSString *password;
@end

@interface FacebookLoginResponse : WebServiceResponse
@property (nonatomic, assign) BOOL shouldLink;
@property (nonatomic, assign) BOOL emailExisted;
@property (nonatomic, strong) Vendor *user;
@end

@interface Registration : WebService
@property (nonatomic, strong)NSString *userId;
@property(nonatomic, strong) NSString *deviceIdentifier;
@property (nonatomic, strong) NSString *password;
@property (nonatomic, strong) NSString *firstName;
@property (nonatomic, strong) NSString *lastName;
@property (nonatomic, strong) NSString *email;
@property (nonatomic, strong) NSString *phone;
@property (nonatomic, strong) NSString *country;
@property (nonatomic, strong) NSString *zipcode;
@property (nonatomic, assign) BOOL subscription;
@end

@interface RegistrationResponse : WebServiceResponse
@property (nonatomic, strong)Vendor *user;
@end

@interface ChangePassword : WebService
@property (nonatomic, assign) BOOL isLogin;
@property (nonatomic, strong) NSString *oldPassword;
@property (nonatomic, strong, getter = theNewPassword) NSString *newPassword;
@property (nonatomic, strong, getter = theNewPasswordConfirm) NSString *newPasswordConfirm;
@end

@interface GetProductOptions : WebService
@property (nonatomic, strong)NSString *scheduleId;
@property (nonatomic, strong) NSString *tourCode;
@end

@interface GetProductOptionsResponsePeopleType : NSObject
@property (nonatomic, strong)NSString *name;
@property (nonatomic, assign) NSInteger ageFrom;
@property (nonatomic, assign) NSInteger ageTo;
@property (nonatomic, assign) CGFloat peoplePrice;
@end

@interface GetProductOptionsResponse : WebServiceResponse
@property (nonatomic, strong)NSArray *peopleTypes;
@property (nonatomic, strong) NSArray *labels;
@end

@interface _Passenger : NSObject

@property (nonatomic, assign) NSInteger passengerNo;
@property (nonatomic, strong) NSString *type;
@property (nonatomic, strong) NSString *name;
@property (nonatomic, assign) NSInteger age;
@property (nonatomic, strong) NSString *gender;
@property (nonatomic, strong) NSDictionary *option;
@property (nonatomic, strong) Passport *passport;

- (NSString *)innerXML;

@end

@interface _Room : NSObject

@property (nonatomic, assign) NSInteger room_no;
@property (nonatomic, strong) _Passenger *checkInGuest;
@property (nonatomic, strong) NSMutableArray *passengers;

- (NSString *)innerXML;

@end

@interface _Entry : NSObject

@property (nonatomic, assign) BOOL isBusHotelPackage;
@property (nonatomic, assign) NSInteger pid;
@property (nonatomic, strong) NSString *scheduleId;
@property (nonatomic, strong) NSString *tourCode;
@property (nonatomic, strong) NSDictionary *option;
@property (nonatomic, strong) NSArray *rooms;
@property (nonatomic, strong) NSArray *passengers;

@property (nonatomic, assign) CGFloat total_charge;
@property (nonatomic, assign) CGFloat service_fee_and_tax;
@property (nonatomic, assign) CGFloat roundtrip_discount;
@property (nonatomic, assign) CGFloat coupon_discount;
@property (nonatomic, assign) CGFloat bus_hotel_package_saving;
@property (nonatomic, assign) BOOL is_dynamic_price;
@property (nonatomic, assign) BOOL non_refundable;
@property (nonatomic, assign) BOOL paid_separately;

@property (nonatomic, strong) NSArray *people_types;

@property (nonatomic, assign) NSInteger reason;
@property (nonatomic, assign) CGFloat service_fee;
@property (nonatomic, assign) CGFloat penalty;

- (NSString *)innerXML;

@end

@interface _PaypalPayment : NSObject

@property (nonatomic, strong)NSString *payment_id;
@property (nonatomic, strong) NSString *out_trade_no;
@property (nonatomic, assign) BOOL sandbox;
@property (nonatomic, assign) BOOL live_testing;

- (NSString *)innerXML;

@end

@interface Unifiedorder2Prepay : NSObject
@property (nonatomic, strong)NSString *appid;
@property (nonatomic, strong) NSString *partnerid;
@property (nonatomic, strong) NSString *prepayid;
@property (nonatomic, strong) NSString *package;
@property (nonatomic, strong) NSString *noncestr;
@property (nonatomic, assign) UInt32 timestamp;
@property (nonatomic, strong) NSString *sign;
@end

@interface _WechatpayPayment : NSObject

@property (nonatomic, strong)Unifiedorder2Prepay *unifiedorder_prepay;
@property (nonatomic, strong) NSString *out_trade_no;
@property (nonatomic, assign) BOOL live_testing;

- (NSString *)innerXML;

@end

@interface _AlipayPayment : NSObject

@property (nonatomic, strong)NSString *orderString;
@property (nonatomic, strong) NSString *out_trade_no;
@property (nonatomic, assign) BOOL live_testing;

- (NSString *)innerXML;

@end

@interface _UnionpayPayment : NSObject

@property (nonatomic, strong)NSString *tn;
@property (nonatomic, strong) NSString *out_trade_no;
@property (nonatomic, assign) BOOL sandbox;
@property (nonatomic, assign) BOOL live_testing;

- (NSString *)innerXML;

@end

@interface _RefundTransaction : NSObject

@property (nonatomic, assign) BOOL not_credit_card;
@property (nonatomic, strong) NSString *merchant;
@property (nonatomic, assign) CGFloat refund_amount;
@property (nonatomic, strong) NSString *card_number;
@property (nonatomic, assign) NSInteger last_digits_length;
@property (nonatomic, strong) NSString *transaction_key;
@property (nonatomic, strong) NSString *last_digits;

- (NSString *)innerXML;

@end

@interface _PaymentInfo : NSObject

@property (nonatomic, assign) CGFloat total_charge;
@property (nonatomic, strong) NSString *currency_code;

@property (nonatomic, assign) NSInteger payment_type;
@property (nonatomic, strong) CreditCard *credit_card;
@property (nonatomic, strong) _PaypalPayment *paypal_payment;
@property (nonatomic, strong) _WechatpayPayment *wechatpay_payment;
@property (nonatomic, strong) _AlipayPayment *alipay_payment;
@property (nonatomic, strong) _UnionpayPayment *unionpay_payment;

@property (nonatomic, strong) NSString *charge_message;
@property (nonatomic, strong) NSString *global_refund_alert;
@property (nonatomic, strong) NSString *total_refund_message;
@property (nonatomic, strong) NSArray<_RefundTransaction *> *refund_transactions;

- (NSString *)innerXML;

@end

@interface CheckAvailabilityAndPrices : WebService
@property (nonatomic, strong)NSArray *travelerDetails;
@property (nonatomic, strong) Address *contactInfo;
@property (nonatomic, strong) NSString *couponCode;
@end

@interface _Coupon : NSObject
@property (nonatomic, strong)NSString *code_number;
@property (nonatomic, assign) BOOL applied;
@property (nonatomic, strong) NSString *message;
@end

@interface CheckAvailabilityAndPricesResponse : WebServiceResponse

@property (nonatomic, assign) BOOL isDuplicated;
@property (nonatomic, strong) NSString *default_currency_code;
@property (nonatomic, assign) CGFloat default_currency_charge;
@property (nonatomic, strong) NSString *second_currency_code;
@property (nonatomic, assign) CGFloat second_currency_rate;
@property (nonatomic, assign) CGFloat second_currency_charge;
@property (nonatomic, assign) CGFloat second_currency_discount;
@property (nonatomic, assign) CGFloat app_first_purchase_discount_rate;
@property (nonatomic, assign) CGFloat app_first_purchase_discount;
@property (nonatomic, strong) NSArray *entries;
@property (nonatomic, strong) NSArray<_Coupon *> *coupons;
@property (nonatomic, assign) BOOL disable_paypal;
@property (nonatomic, assign) BOOL disable_coupon;
@property (nonatomic, assign) BOOL not_need_pay;
@property (nonatomic, assign) BOOL need_x_card_code;

@property (nonatomic, assign, readonly) CGFloat total_charge;

@property (nonatomic, strong, readonly) NSString *secondCurrencyDiscountText;
@property (nonatomic, assign, readonly) CGFloat busTotalFare;
@property (nonatomic, assign, readonly) CGFloat busRoundtripDiscount;
@property (nonatomic, assign, readonly) CGFloat hotelTotalFare;
@property (nonatomic, assign, readonly) CGFloat busHotelPackageSaving;
@property (nonatomic, assign, readonly) NSArray<NSString *> *appliedCouponCodes;
@property (nonatomic, assign, readonly) NSArray<NSString *> *couponErrorMessages;

- (NSString *)currencyTextFromNumber:(CGFloat)currencyNumber currencyCode:(NSString *)currencyCode;
- (CGFloat)totalFareNumberWithCurrencyCode:(NSString *)currencyCode;
- (NSString *)totalFareTextWithCurrencyCode:(NSString *)currencyCode;

@end

@interface _ETicket : NSObject
@property (nonatomic, strong)NSString *html;
@property (nonatomic, strong) NSString *name;
@property (nonatomic, strong) NSString *date;
@end

@interface GetETicketsResponse : WebServiceResponse
@property (nonatomic, strong)_ETicket *order_summary;
@property (nonatomic, strong) NSArray *etickets;
@end

@interface CheckDuplicatedBooking : WebService
@property (nonatomic, strong)NSArray *travelerDetails;
@property (nonatomic, strong) Address *contactInfo;
@end

@interface CheckDuplicatedBookingResponse : WebServiceResponse
@property (nonatomic, assign) BOOL isDuplicated;
@end

@interface BookGoods : WebService
@property (nonatomic, strong)NSArray *travelerDetails;
@property (nonatomic, strong) Address *contactInfo;
@property (nonatomic, strong) NSString *couponCode;
@property (nonatomic, strong) _PaymentInfo *paymentInfo;
@property (nonatomic, assign) BOOL ignoreDuplicated;
@end

@interface BookGoodsResponse : GetETicketsResponse
@property (nonatomic, assign) BOOL isDuplicated;
@property (nonatomic, assign) BOOL priceChanged;
@property (nonatomic, strong) _PaypalPayment *paypal_payment;
@property (nonatomic, strong) _WechatpayPayment *wechatpay_payment;
@property (nonatomic, strong) _AlipayPayment *alipay_payment;
@property (nonatomic, strong) _UnionpayPayment *unionpay_payment;
@property (nonatomic, strong) NSString *order_code;
@property (nonatomic, assign) BOOL payment_accepted;
@property (nonatomic, assign) BOOL need_verify_credit_card;
@property (nonatomic, strong) NSString *post_sale_html;
@end

@interface ExecuteReservation : WebService
@property (nonatomic, strong)NSString *outTradeNo;
@end

@interface VerifyCreditCard : WebService
@property (nonatomic, strong)NSString *orderCode;
@property (nonatomic, strong) NSString *cardFront;
@property (nonatomic, strong) NSString *photoId;
@property (nonatomic, strong) NSString *signature;
@end

@interface VoidOrder : WebService
@property (nonatomic, strong)NSString *orderCode;
@end

@interface GetPageContent : WebService
@property (nonatomic, assign) NSInteger pageId;
@property (nonatomic, strong) NSString *pageUrl;
@property (nonatomic, assign) BOOL noCache;
@end

@interface GetPageContentResponse : WebServiceResponse <NSCoding>
@property (nonatomic, strong) NSString *page_url;
@property (nonatomic, strong) NSString *page_title;
@property (nonatomic, strong)NSString *base_url;
@property (nonatomic, strong)NSString *product_id;
@property (nonatomic, strong) NSString *html_string;
@property (nonatomic, assign) BOOL page_existed;
@end

@interface UpdateAddress : WebService
@property (nonatomic, strong)Address *addressDetails;
@end

@interface UpdateAddressResponse : WebServiceResponse
@property (nonatomic, assign) NSInteger aid;
@property (nonatomic, assign) NSInteger default_aid;
@end

@interface RemoveAddress : WebService
@property (nonatomic, assign) NSInteger aid;
@end

@interface RemoveAddressResponse : WebServiceResponse
@property (nonatomic, assign) NSInteger default_aid;
@end

@interface UpdateCreditCard : WebService
@property (nonatomic, strong)CreditCard *creditCardDetails;
@end

@interface UpdateCreditCardResponse : WebServiceResponse
@property (nonatomic, assign) NSInteger ccid;
@property (nonatomic, assign) NSInteger default_ccid;
@end

@interface RemoveCreditCard : WebService
@property (nonatomic, assign) NSInteger ccid;
@end

@interface RemoveCreditCardResponse : WebServiceResponse
@property (nonatomic, assign) NSInteger default_ccid;
@end

@interface GetOrderSummaryByOrder : WebService
@property (nonatomic, strong)NSString *order_code;
@end

@interface GetETicketByEntry : WebService
@property (nonatomic, assign) NSInteger entry_id;
@end

@interface GetClientPolicy : WebService
@property (nonatomic, assign) NSInteger vid;
@end

@interface GetClientPolicyResponse : WebServiceResponse
@property (nonatomic, strong)NSString *policy;
@end

@interface GetItineraryById : WebService
@property (nonatomic, strong) NSString *itineraryId;
@end

@interface GetItineraryByIdResponse : WebServiceResponse
@property (nonatomic, strong)NSArray *orders;
@property (nonatomic, strong) NSArray *bus_status_infos;
@property (nonatomic, strong) NSArray *products;
@property (nonatomic, strong) NSArray *vendors;
@property (nonatomic, strong) NSArray *bus_stations;
@property (nonatomic, strong) NSArray *airports;
@property (nonatomic, strong) NSArray *destinations;
@end

@interface GetTourSearchSourceResponse : WebServiceResponse
@property(nonatomic, strong) NSArray *departures;
@property(nonatomic, strong) NSArray *destinations;
@property(nonatomic, strong) NSArray *object_list;
@end

@interface GetsSearchDataSource : WebService
@property (nonatomic, strong) NSString *destinations;
@property (nonatomic, strong) NSString *dep_ids;
@property (nonatomic, strong) NSString *duration;
@property (nonatomic, strong) NSString *start_dates;
@property (nonatomic, strong) NSString *keywords;
@end

@interface GetsSearchDataSourceResponse : WebServiceResponse
@property (nonatomic, strong)NSString *policy;
@end

