AviasalesSDK 2.0.2

AviasalesSDK 2.0.2

DocsDocumented
TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Nov 2016

Maintained by Denis Chaschin, Seva Billevich.


Downloads

Total1,927
Week20
Month156

Installs

Apps92
Apps WeekApps This Week 2
Test Targets7
powered by Segment

GitHub

Stars2
Watchers10
Forks0
Issues0
Contributors4
Pull Requests0

Code

Files0
SizeIntegration Size 28,424 kb
LOCLines of Code 0


  • By
  • Aviasales iOS Team

Aviasales/Jetradar iOS SDK Core

Example

As an example, you are welcome to use our Template Project from Aviasales-iOS-SDK repo.

Installation

The easiest way is to use CocoaPods. It takes care of all required frameworks and third party dependencies:

pod 'AviasalesSDK', '~> 2.0.0'

We recommend to import AviasalesSDK.h in each file where you use objects or protocols from SDK.

#import <AviasalesSDK/AviasalesSDK.h>

Configure AviasalesSDK object before interaction with SDK like this:

AviasalesSDKInitialConfiguration *configuration = [AviasalesSDKInitialConfiguration configurationWithAPIToken:@"Your api token here"
                                                                                                    APILocale:[NSLocale currentLocale].localeIdentifier
                                                                                                partnerMarker:@"Your partner marker here"];
[AviasalesSDK setupWithConfiguration:configuration];

Don't forget to replace two placeholders in this example with the actual values.

Features

✈️ Flight Tickets Search

Specify search parameters using any object that confirms to JRSDKSearchInfo protocol. Simple implementation of this protocol available in JRSDKConfigurableSearchInfo interface, but feel free to create your own if needed. Look at the example below.

Create search info

Create simple object that describes new search:

JRSDKConfigurableSearchInfo *searchInfo = [[JRSDKConfigurableSearchInfo alloc] init];

Set necessary parameters for the search (adults = 2 and travelClass = Business means that two adults would like to travel in business class):

searchInfo.adults = 2;
searchInfo.travelClass = JRSDKTravelClassBusiness;

Set travel dates and airports (using airports storage from the SDK):

JRSDKConfigurableTravelSegment *firstTravelSegment = [[JRSDKConfigurableTravelSegment alloc] init];
firstTravelSegment.departureDate = [NSDate date];
firstTravelSegment.originAirport = [[AviasalesSDK sharedInstance].airportsStorage findAnythingByIATA:@"LED"];
firstTravelSegment.destinationAirport = [[AviasalesSDK sharedInstance].airportsStorage findAnythingByIATA:@"MOW"];

Save that travel segment to the search info:

searchInfo.travelSegments = [NSOrderedSet orderedSetWithObject:firstTravelSegment];

That's it. Search info is ready for search.

Perform search request

To perform search request use SearchPerformer received from the SDK and send search info to it. Don't forget to store this performer somewhere during the search process.

JRSDKSearchPerformer *searchPerformer = [[AviasalesSDK sharedInstance] createSearchPerformer];

To retrieve live and final search results set delegate (JRSDKSearchPerformerDelegate) to this search performer:

searchPerformer.delegate = self;

This delegate requires to implement three methods: first one needed to receive live search results

- (void)searchPerformer:(JRSDKSearchPerformer *)searchPerformer didFinishRegularSearch:(id<JRSDKSearchInfo>)searchInfo withResult:(id<JRSDKSearchResult>)result;

Second needed to receive error if it occures during the search

- (void)searchPerformer:(JRSDKSearchPerformer *)searchPerformer didFailSearchWithError:(NSError *)error connection:(JRServerAPIConnection *)connection;

And the third one needed to understand when the process is finished. After its call, you can release search performer because it is not recyclable.

- (void)searchPerformer:(JRSDKSearchPerformer *)searchPerformer didFinalizeSearchWithInfo:(id<JRSDKSearchInfo>)searchInfo error:(NSError *)error;

Start search performing:

[searchPerformer performSearchWithSearchInfo:searchInfo
                             includeResultsInEnglish:YES];

Parsing search result

Search result is provided with id<JRSDKSearchResult> object.

Property Description
searchID this parameter is necessary in purchase process
strictSearchTickets tickets that found exactly between requested airports
searchTickets tickets that found between cities (metropolitan areas) that is near to requested airports

💸 Tickets purchase

AviasalesSDKPurchasePerformer is object used to perform ticket purchase. Each ticket contains different prices, you should use one of them as an input parameter. Create performer using price and searchId that was returned with the search result.

- (instancetype)initWithPrice:(id <JRSDKPrice>)price
                     searchId:(NSString *)searchId;

and start purchase using a method

- (void)performWithDelegate:(id <AviasalesSDKPurchasePerformerDelegate>)delegate;

Open link received by delegate in browser to provide user purchase form.

📺 Advertisement

Aviasales SDK allows you to generate additional revenue by displaying advertisements to your users. Use AviasalesSDKAdsManager object received like:

[AviasalesSDK sharedInstance].adsManager

to load information for the waiting screen

- (void)loadAdsViewForWaitingScreenWithSearchInfo:(id <JRSDKSearchInfo>)searchInfo completion:(AviasalesSDKAdsManagerCompletion)completion;

or for the search results list with your search info.

- (void)loadAdsViewForSearchResultsWithSearchInfo:(id <JRSDKSearchInfo>)searchInfo completion:(AviasalesSDKAdsManagerCompletion)completion;

After appropriate method call you will receive AviasalesSDKAdsView with ads.

Other Utils by SDK

Name How to retrieve object Description
Airports storage [AviasalesSDK sharedInstance].airportsStorage Finds airport by IATA, provides a list of airports
AviasalesAirportsSearchPerformer [[AviasalesAirportsSearchPerformer alloc] init] Finds airports by string
AviasalesNearestAirportsManager [AviasalesSDK sharedInstance].nearestAirportsManager Finds nearest airports to the current user.
AviasalesSDKAdsManager [AviasalesSDK sharedInstance].adsManager Loads and displays advertisement according to search parameters
JRSDKModelUtils [JRSDKModelUtils <method name here>] Util methods that help you to work with SDK objects