Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
username0x0a committed Jan 2, 2019
2 parents 33b7d8c + ecf4fbe commit ea30d34
Show file tree
Hide file tree
Showing 95 changed files with 14,458 additions and 1,248 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "fmdb"]
path = fmdb
url = https://github.com/ccgus/fmdb.git
126 changes: 126 additions & 0 deletions Documentation/content_pages/Examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# Examples

## Places module

### Get place detail

```objc
// Get and print the name and description of Eiffel Tower (poi:530)
TKPlacesManager *manager = [[TravelKit sharedKit] places];

[manager detailedPlaceWithID: @"poi:530" completion:^(TKDetailedPlace * _Nullable place, NSError * _Nullable error) {
if (place) {
NSString *description = place.detail.fullDescription.text;
if (description) NSLog(@"Description of %@ is: %@", place.name, description);
else NSLog(@"Something went wrong :/");
}
}];
```
```swift
// Get and print the name and description of Eiffel Tower (poi:530)
TravelKit.shared.places.detailedPlace(withID: "poi:530", completion:{ (detailedPlace, err) in
if let description = detailedPlace?.detail?.fullDescription?.text {
print("Description of \(detailedPlace.name) is: \(description)")
}
else {
print("Something went wrong :/")
}
})
```

### Get place media

```objc
// Besides main media, we can get all media available for a certain place
TKPlacesManager *manager = [[TravelKit sharedKit] places];

[manager mediaForPlaceWithID:@"poi:530" completion:^(NSArray<TKMedium *> * _Nullable media, NSError * _Nullable error) {
for (TKMedium *m in media) {
NSString *title = m.title;
// Print medium title if it has one
if (title) NSLog(@"Title: %@", title);
else NSLog(@"no title");
}
// To get the actual image from URL with certain size, we use method in TKMedium
TKMedium *first = media.firstObject;
[first displayableImageURLForSize:CGSizeMake(first.width, first.height)];
}];
```
```swift
// Besides main media, we can get all media available for a certain place
TravelKit.shared.places.mediaForPlace(withID: "poi:530", completion: { (media, err) in
if let media = media, let first = media.first {
// Print medium title if it has one
for m in media {
print("Title: \(m.title ?? "no title")")
}
// To get the actual image from URL with certain size, we use method in TKMedium
first.displayableImageURL(for: CGSize(width: first.width, height: first.height))
}
})
```

## Tours module

### Get tours

```objc
// Create query to to get 12 tours in London that take longer than 1 hour
TKToursGYGQuery *query = [TKToursGYGQuery new];
query.parentID = @"city:1";
query.minimalDuration = [NSNumber numberWithInt: 3600];
query.count = [NSNumber numberWithInt: 12];

TKToursManager *manager = [[TravelKit sharedKit] _tours];

// Perform query and print a message containing tour's title
[manager toursForGYGQuery:query completion:^(NSArray<TKTour *> * _Nullable tours, NSError * _Nullable error) {
for (TKTour *t in tours) {
NSString * title = t.title;
if (title) NSLog(@"%@", title);
else NSLog(@"no title");
}
}];
```
```swift
// Create query to to get 12 tours in London that take longer than 1 hour
let query = TKToursGYGQuery()
query.parentID = "city:1"
query.minimalDuration = 3600
query.count = 12
// Perform query and print a message containing tour's title
TravelKit.shared._tours.tours(for: query) { (tours, err) in
if let tours = tours {
for tour in tours {
print("\(tour.title)")
}
}
}
```

## Favorites module

### Favorite & unfavorite places

```objc
TKFavoritesManager *manager = [[TravelKit sharedKit] favorites];
// Add Eiffel Tower to favorites
[manager updateFavoritePlaceID:@"poi:530" setFavorite:TRUE];
// Get your favorites and print their IDs
NSLog(@"%@", [manager favoritePlaceIDs]);
// Remove Eiffel Tower from favorites
[manager updateFavoritePlaceID:@"poi:530" setFavorite:FALSE];
```
```swift
// Add Eiffel Tower to favorites
TravelKit.shared.favorites.updateFavoritePlaceID("poi:530", setFavorite: true)
// Get your favorites and print their IDs
print(TravelKit.shared.favorites.favoritePlaceIDs())
// Remove Eiffel Tower from favorites
TravelKit.shared.favorites.updateFavoritePlaceID("poi:530", setFavorite: false)
```
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,11 @@ Class | Description
:-------------------|:---------------------
**`TravelKit`** | Singleton instance for fetching data
**`TKPlace`** | Basic `Place` entity
**`TKPlaceDetail`** | Detailed object including additional `Place` properties
**`TKPlacesQuery`** | Entity used when querying for `Places`
**`TKTrip`** | Primary `Trip` entity with detailed properties
**`TKTour`** | Basic `Tour` entity
**`TKToursQuery`** | Entity used when querying for `Tours`
**`TKToursViatorQuery`** | Entity used when querying for `Tours` from _Viator_
**`TKToursGYGQuery`** | Entity used when querying for `Tours` from _GetYourGuide_
**`TKMedium`** | Basic `Medium` entity
**`TKReference`** | External `Reference` link

Expand Down
10 changes: 5 additions & 5 deletions TravelKit.playground/Contents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true

// Assign a shared instance to work with
let travelKit = TravelKit.shared()
let travelKit = TravelKit.shared

// Create a lock used for results printing sync
let printLock = NSLock()
Expand All @@ -40,7 +40,7 @@ let destinationsQuery = TKPlacesQuery()
destinationsQuery.levels = [ .city, .town ]
destinationsQuery.limit = 5

travelKit.places(for: destinationsQuery) { (places, error) in
travelKit.places.places(for: destinationsQuery) { (places, error) in
printLock.lock()
print("\nTop Destinations:\n")
places?.forEach({ (place) in
Expand All @@ -61,7 +61,7 @@ sightsQuery.levels = .POI
sightsQuery.categories = [.sightseeing]
sightsQuery.limit = 10

travelKit.places(for: sightsQuery) { (places, error) in
travelKit.places.places(for: sightsQuery) { (places, error) in
printLock.lock()
print("\nTop Sights in London:\n")
places?.forEach({ (place) in
Expand All @@ -76,12 +76,12 @@ travelKit.places(for: sightsQuery) { (places, error) in
Querying for some Tours users would like to attend is very easy as well:
*/

let toursQuery = TKToursQuery()
let toursQuery = TKToursViatorQuery()
toursQuery.parentID = "city:1"
toursQuery.sortingType = .price
toursQuery.descendingSortingOrder = true

travelKit.tours(for: toursQuery) { (tours, error) in
travelKit._tours.tours(for: toursQuery) { (tours, error) in
printLock.lock()
print("\nMost Expensive Tours in London:\n")
tours?.forEach({ (tour) in
Expand Down
4 changes: 2 additions & 2 deletions TravelKit.podspec
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Pod::Spec.new do |spec|
spec.name = 'TravelKit'
spec.version = '1.0.3'
spec.version = '2.0'
spec.license = 'MIT'
spec.homepage = 'https://github.com/sygic-travel/apple-sdk'
spec.authors = 'Tripomatic s.r.o.', 'Michal Zelinka'
spec.summary = 'Travel SDK for travelling projects'
spec.source = { :http => 'https://github.com/sygic-travel/apple-sdk/releases/download/v1.0.3/TravelKit-1.0.3-iOS.zip' }
spec.source = { :http => 'https://github.com/sygic-travel/apple-sdk/releases/download/v2.0/TravelKit-2.0-iOS.zip' }
spec.documentation_url = 'http://docs.sygictravelapi.com/apple-sdk/latest'
spec.module_name = 'TravelKit'

Expand Down
Loading

0 comments on commit ea30d34

Please sign in to comment.