Skip to content
This repository was archived by the owner on Oct 14, 2018. It is now read-only.

Commit 0037741

Browse files
authored
Merge pull request #22 from AnderGoig/develop
Version 1.1.0
2 parents 6e4abdc + eef8574 commit 0037741

File tree

90 files changed

+1600
-1336
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+1600
-1336
lines changed

.swiftlint.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,35 @@
11
disabled_rules:
22
- file_length
3+
- force_try
34
- nesting
45
opt_in_rules:
6+
- array_init
57
- attributes
68
- closure_end_indentation
79
- closure_spacing
8-
- conditional_returns_on_newline
910
- contains_over_first_not_nil
11+
- empty_count
1012
- explicit_init
1113
- fatal_error_message
1214
- file_header
1315
- first_where
1416
- implicit_return
1517
- joined_default_parameter
1618
- let_var_whitespace
19+
- literal_expression_end_indentation
1720
- number_separator
1821
- operator_usage_whitespace
1922
- overridden_super_call
2023
- pattern_matching_keywords
24+
- private_action
2125
- private_outlet
2226
- prohibited_super_call
2327
- redundant_nil_coalescing
24-
- statement_position
25-
- switch_case_on_newline
28+
- sorted_first_last
29+
- trailing_closure
2630
- unneeded_parentheses_in_closure_argument
27-
- vertical_parameter_alignment
2831
- vertical_parameter_alignment_on_call
32+
- yoda_condition
2933
included:
3034
- Sources
3135
- Tests

CHANGELOG.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22

33
## [Unreleased]
44

5+
## [1.1.0] (2017-01-21)
6+
[Full Changelog](https://github.com/AnderGoig/SwiftInstagram/compare/v1.0.6...v1.1.0)
7+
### Added
8+
- Search media and location by latitude and longitude:
9+
- `func searchMedia(latitude: Double? = nil, longitude: Double? = nil, ...)`
10+
- `func searchLocation(latitude: Double? = nil, longitude: Double? = nil, ...)`
11+
- New option to get all the permissions on `login(..., withScopes: [.all], ...)` method.
12+
### Changed
13+
- `retrieveAccessToken()` method is now public (#15).
14+
- `storeAccessToken()` is also public (#17).
15+
### Fixed
16+
- Problem with all the POST requests (e.g. #20).
17+
518
## [1.0.6] (2017-11-03)
619
[Full Changelog](https://github.com/AnderGoig/SwiftInstagram/compare/v1.0.5...v1.0.6)
720
### Added
@@ -62,7 +75,8 @@
6275
### Added
6376
- Initial release.
6477

65-
[Unreleased]: https://github.com/AnderGoig/SwiftInstagram/compare/v1.0.6...develop
78+
[Unreleased]: https://github.com/AnderGoig/SwiftInstagram/compare/v1.1.0...develop
79+
[1.1.0]: https://github.com/AnderGoig/SwiftInstagram/tree/v1.1.0
6680
[1.0.6]: https://github.com/AnderGoig/SwiftInstagram/tree/v1.0.6
6781
[1.0.5]: https://github.com/AnderGoig/SwiftInstagram/tree/v1.0.5
6882
[1.0.4]: https://github.com/AnderGoig/SwiftInstagram/tree/v1.0.4

Cartfile.resolved

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
github "Quick/Nimble" "v7.0.2"
1+
github "Quick/Nimble" "v7.0.3"
22
github "Quick/Quick" "v1.2.0"
3-
github "jspahrsummers/xcconfigs" "40f9bcc63752cdd95deee267d2fbf9da09a9f6f2"
3+
github "jspahrsummers/xcconfigs" "94d261a58a034f70fe207298fffb8ee790c4bbd9"

Carthage/Checkouts/Nimble

Submodule Nimble updated 48 files

Carthage/Checkouts/xcconfigs

Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source "https://rubygems.org"
2+
3+
gem "fastlane"

Sources/Endpoints/Comments.swift

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ extension Instagram {
1717
/// - parameter failure: The callback called after an incorrect retrieval.
1818
///
1919
/// - important: It requires *public_content* scope for media that does not belong to your own user.
20-
2120
public func comments(fromMedia mediaId: String, success: SuccessHandler<[InstagramComment]>?, failure: FailureHandler?) {
22-
request("/media/\(mediaId)/comments", success: success, failure: failure)
21+
request("/media/\(mediaId)/comments", success: { data in success?(data!) }, failure: failure)
2322
}
2423

2524
/// Create a comment on a media object.
@@ -28,21 +27,15 @@ extension Instagram {
2827
/// - parameter text: Text to post as a comment on the media object as specified in `mediaId`.
2928
/// - parameter failure: The callback called after an incorrect creation.
3029
///
31-
/// - important: It requires *comments* scope. Also, *public_content* scope is required for media that does not
32-
/// belong to your own user.
30+
/// - important: It requires *comments* scope. Also, *public_content* scope is required for media that does not belong to your own user.
3331
///
3432
/// - note:
3533
/// - The total length of the comment cannot exceed 300 characters.
3634
/// - The comment cannot contain more than 4 hashtags.
3735
/// - The comment cannot contain more than 1 URL.
3836
/// - The comment cannot consist of all capital letters.
39-
40-
public func createComment(onMedia mediaId: String, text: String, failure: FailureHandler?) {
41-
var parameters = Parameters()
42-
43-
parameters["text"] = text
44-
45-
request("/media/\(mediaId)/comments", method: .post, parameters: parameters, success: { (_: InstagramResponse<Any?>) in return }, failure: failure)
37+
public func createComment(onMedia mediaId: String, text: String, success: SuccessHandler<InstagramComment>?, failure: FailureHandler?) {
38+
request("/media/\(mediaId)/comments", method: .post, parameters: ["text": text], success: { data in success?(data!) }, failure: failure)
4639
}
4740

4841
/// Remove a comment either on the authenticated user's media object or authored by the authenticated user.
@@ -51,11 +44,8 @@ extension Instagram {
5144
/// - parameter mediaId: The ID of the media object to reference.
5245
/// - parameter failure: The callback called after an incorrect deletion.
5346
///
54-
/// - important: It requires *comments* scope. Also, *public_content* scope is required for media that does not
55-
/// belong to your own user.
56-
57-
public func deleteComment(_ commentId: String, onMedia mediaId: String, failure: FailureHandler?) {
58-
request("/media/\(mediaId)/comments/\(commentId)", method: .delete, success: { (_: InstagramResponse<Any?>) in return }, failure: failure)
47+
/// - important: It requires *comments* scope. Also, *public_content* scope is required for media that does not belong to your own user.
48+
public func deleteComment(_ commentId: String, onMedia mediaId: String, success: EmptySuccessHandler?, failure: FailureHandler?) {
49+
request("/media/\(mediaId)/comments/\(commentId)", method: .delete, success: { (_: InstagramEmptyResponse!) in success?() }, failure: failure)
5950
}
60-
6151
}

Sources/Endpoints/Likes.swift

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,27 @@ extension Instagram {
1717
/// - parameter failure: The callback called after an incorrect retrieval.
1818
///
1919
/// - important: It requires *public_content* scope for media that does not belong to your own user.
20-
2120
public func likes(inMedia mediaId: String, success: SuccessHandler<[InstagramUser]>?, failure: FailureHandler?) {
22-
request("/media/\(mediaId)/likes", success: success, failure: failure)
21+
request("/media/\(mediaId)/likes", success: { data in success?(data!) }, failure: failure)
2322
}
2423

2524
/// Set a like on this media by the currently authenticated user.
2625
///
2726
/// - parameter mediaId: The ID of the media object to reference.
2827
/// - parameter failure: The callback called after an incorrect like.
2928
///
30-
/// - important: It requires *likes* scope. Also, *public_content* scope is required for media that does not belong
31-
/// to your own user.
32-
33-
public func like(media mediaId: String, failure: FailureHandler?) {
34-
request("/media/\(mediaId)/likes", method: .post, success: { (_: InstagramResponse<Any?>) in return }, failure: failure)
29+
/// - important: It requires *likes* scope. Also, *public_content* scope is required for media that does not belong to your own user.
30+
public func like(media mediaId: String, success: EmptySuccessHandler?, failure: FailureHandler?) {
31+
request("/media/\(mediaId)/likes", method: .post, success: { (_: InstagramEmptyResponse!) in success?() }, failure: failure)
3532
}
3633

3734
/// Remove a like on this media by the currently authenticated user.
3835
///
3936
/// - parameter Parameter mediaId: The ID of the media object to reference.
4037
/// - parameter failure: The callback called after an incorrect deletion.
4138
///
42-
/// - important: It requires *likes* scope. Also, *public_content* scope is required for media that does not belong
43-
/// to your own user.
44-
45-
public func unlike(media mediaId: String, failure: FailureHandler?) {
46-
request("/media/\(mediaId)/likes", method: .delete, success: { (_: InstagramResponse<Any?>) in return }, failure: failure)
39+
/// - important: It requires *likes* scope. Also, *public_content* scope is required for media that does not belong to your own user.
40+
public func unlike(media mediaId: String, success: EmptySuccessHandler?, failure: FailureHandler?) {
41+
request("/media/\(mediaId)/likes", method: .delete, success: { (_: InstagramEmptyResponse!) in success?() }, failure: failure)
4742
}
48-
4943
}

Sources/Endpoints/Locations.swift

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ extension Instagram {
1919
/// - parameter failure: The callback called after an incorrect retrieval.
2020
///
2121
/// - important: It requires *public_content* scope.
22-
2322
public func location(_ locationId: String, success: SuccessHandler<InstagramLocation<String>>?, failure: FailureHandler?) {
24-
request("/locations/\(locationId)", success: success, failure: failure)
23+
request("/locations/\(locationId)", success: { data in success?(data!) }, failure: failure)
2524
}
2625

2726
/// Get a list of recent media objects from a given location.
@@ -33,43 +32,63 @@ extension Instagram {
3332
/// - parameter failure: The callback called after an incorrect retrieval.
3433
///
3534
/// - important: It requires *public_content* scope.
36-
3735
public func recentMedia(forLocation locationId: String,
3836
maxId: String? = nil,
3937
minId: String? = nil,
4038
success: SuccessHandler<[InstagramMedia]>?,
4139
failure: FailureHandler?) {
40+
4241
var parameters = Parameters()
4342

4443
parameters["max_id"] ??= maxId
4544
parameters["min_id"] ??= minId
4645

47-
request("/locations/\(locationId)/media/recent", parameters: parameters, success: success, failure: failure)
46+
request("/locations/\(locationId)/media/recent", parameters: parameters, success: { data in success?(data!) }, failure: failure)
4847
}
4948

5049
/// Search for a location by geographic coordinate.
5150
///
52-
/// - parameter coordinates: Latitude and longitude of the center search coordinates.
51+
/// - parameter latitude: Latitude of the center search coordinate. If used, `longitude` is required.
52+
/// - parameter longitude: Longitude of the center search coordinate. If used, `latitude` is required.
5353
/// - parameter distance: Default is 500m, max distance is 750.
5454
/// - parameter facebookPlacesId: Returns a location mapped off of a Facebook places id. If used, `coordinates` is not required.
5555
/// - parameter success: The callback called after a correct retrieval.
5656
/// - parameter failure: The callback called after an incorrect retrieval.
5757
///
5858
/// - important: It requires *public_content* scope.
59-
60-
public func searchLocation(coordinates: CLLocationCoordinate2D? = nil,
59+
public func searchLocation(latitude: Double? = nil,
60+
longitude: Double? = nil,
6161
distance: Int? = nil,
6262
facebookPlacesId: String? = nil,
6363
success: SuccessHandler<[InstagramLocation<String>]>?,
6464
failure: FailureHandler?) {
65+
6566
var parameters = Parameters()
6667

67-
parameters["lat"] ??= coordinates?.latitude
68-
parameters["lng"] ??= coordinates?.longitude
68+
parameters["lat"] ??= latitude
69+
parameters["lng"] ??= longitude
6970
parameters["distance"] ??= distance
7071
parameters["facebook_places_id"] ??= facebookPlacesId
7172

72-
request("/locations/search", parameters: parameters, success: success, failure: failure)
73+
request("/locations/search", parameters: parameters, success: { data in success?(data!) }, failure: failure)
7374
}
7475

76+
/// Search for a location by geographic coordinate.
77+
///
78+
/// - parameter coordinates: Latitude and longitude of the center search coordinates.
79+
/// - parameter distance: Default is 500m, max distance is 750.
80+
/// - parameter facebookPlacesId: Returns a location mapped off of a Facebook places id. If used, `coordinates` is not required.
81+
/// - parameter success: The callback called after a correct retrieval.
82+
/// - parameter failure: The callback called after an incorrect retrieval.
83+
///
84+
/// - important: It requires *public_content* scope.
85+
public func searchLocation(coordinates: CLLocationCoordinate2D? = nil,
86+
distance: Int? = nil,
87+
facebookPlacesId: String? = nil,
88+
success: SuccessHandler<[InstagramLocation<String>]>?,
89+
failure: FailureHandler?) {
90+
91+
searchLocation(latitude: coordinates?.latitude, longitude: coordinates?.longitude,
92+
distance: distance, facebookPlacesId: facebookPlacesId, success: success, failure: failure)
93+
}
7594
}

Sources/Endpoints/Media.swift

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
// Copyright © 2017 Ander Goig. All rights reserved.
77
//
88

9+
import CoreLocation
10+
911
extension Instagram {
1012

1113
// MARK: - Media Endpoints
@@ -17,9 +19,8 @@ extension Instagram {
1719
/// - parameter failure: The callback called after an incorrect retrieval.
1820
///
1921
/// - important: It requires *public_content* scope.
20-
2122
public func media(withId id: String, success: SuccessHandler<InstagramMedia>?, failure: FailureHandler?) {
22-
request("/media/\(id)", success: success, failure: failure)
23+
request("/media/\(id)", success: { data in success?(data!) }, failure: failure)
2324
}
2425

2526
/// Get information about a media object.
@@ -32,33 +33,47 @@ extension Instagram {
3233
///
3334
/// - note: A media object's shortcode can be found in its shortlink URL.
3435
/// An example shortlink is http://instagram.com/p/tsxp1hhQTG/. Its corresponding shortcode is tsxp1hhQTG.
35-
3636
public func media(withShortcode shortcode: String, success: SuccessHandler<InstagramMedia>?, failure: FailureHandler?) {
37-
request("/media/shortcode/\(shortcode)", success: success, failure: failure)
37+
request("/media/shortcode/\(shortcode)", success: { data in success?(data!) }, failure: failure)
3838
}
3939

4040
/// Search for recent media in a given area.
4141
///
42-
/// - parameter lat: Latitude of the center search coordinate. If used, `lng` is required.
43-
/// - parameter lng: Longitude of the center search coordinate. If used, `lat` is required.
42+
/// - parameter latitude: Latitude of the center search coordinate. If used, `longitude` is required.
43+
/// - parameter longitude: Longitude of the center search coordinate. If used, `latitude` is required.
4444
/// - parameter distance: Default is 1km (1000m), max distance is 5km.
4545
/// - parameter success: The callback called after a correct retrieval.
4646
/// - parameter failure: The callback called after an incorrect retrieval.
4747
///
4848
/// - important: It requires *public_content* scope.
49-
50-
public func searchMedia(lat: Double? = nil,
51-
lng: Double? = nil,
49+
public func searchMedia(latitude: Double? = nil,
50+
longitude: Double? = nil,
5251
distance: Int? = nil,
5352
success: SuccessHandler<[InstagramMedia]>?,
5453
failure: FailureHandler?) {
54+
5555
var parameters = Parameters()
5656

57-
parameters["lat"] ??= lat
58-
parameters["lng"] ??= lng
57+
parameters["lat"] ??= latitude
58+
parameters["lng"] ??= longitude
5959
parameters["distance"] ??= distance
6060

61-
request("/media/search", parameters: parameters, success: success, failure: failure)
61+
request("/media/search", parameters: parameters, success: { data in success?(data!) }, failure: failure)
6262
}
6363

64+
/// Search for recent media in a given area.
65+
///
66+
/// - parameter coordinates: Latitude and longitude of the center search coordinates.
67+
/// - parameter distance: Default is 1km (1000m), max distance is 5km.
68+
/// - parameter success: The callback called after a correct retrieval.
69+
/// - parameter failure: The callback called after an incorrect retrieval.
70+
///
71+
/// - important: It requires *public_content* scope.
72+
public func searchMedia(coordinates: CLLocationCoordinate2D? = nil,
73+
distance: Int? = nil,
74+
success: SuccessHandler<[InstagramMedia]>?,
75+
failure: FailureHandler?) {
76+
77+
searchMedia(latitude: coordinates?.latitude, longitude: coordinates?.longitude, distance: distance, success: success, failure: failure)
78+
}
6479
}

0 commit comments

Comments
 (0)