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

Version 1.1.0 #22

Merged
merged 26 commits into from
Jan 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
disabled_rules:
- file_length
- force_try
- nesting
opt_in_rules:
- array_init
- attributes
- closure_end_indentation
- closure_spacing
- conditional_returns_on_newline
- contains_over_first_not_nil
- empty_count
- explicit_init
- fatal_error_message
- file_header
- first_where
- implicit_return
- joined_default_parameter
- let_var_whitespace
- literal_expression_end_indentation
- number_separator
- operator_usage_whitespace
- overridden_super_call
- pattern_matching_keywords
- private_action
- private_outlet
- prohibited_super_call
- redundant_nil_coalescing
- statement_position
- switch_case_on_newline
- sorted_first_last
- trailing_closure
- unneeded_parentheses_in_closure_argument
- vertical_parameter_alignment
- vertical_parameter_alignment_on_call
- yoda_condition
included:
- Sources
- Tests
Expand Down
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

## [Unreleased]

## [1.1.0] (2017-01-21)
[Full Changelog](https://github.com/AnderGoig/SwiftInstagram/compare/v1.0.6...v1.1.0)
### Added
- Search media and location by latitude and longitude:
- `func searchMedia(latitude: Double? = nil, longitude: Double? = nil, ...)`
- `func searchLocation(latitude: Double? = nil, longitude: Double? = nil, ...)`
- New option to get all the permissions on `login(..., withScopes: [.all], ...)` method.
### Changed
- `retrieveAccessToken()` method is now public (#15).
- `storeAccessToken()` is also public (#17).
### Fixed
- Problem with all the POST requests (e.g. #20).

## [1.0.6] (2017-11-03)
[Full Changelog](https://github.com/AnderGoig/SwiftInstagram/compare/v1.0.5...v1.0.6)
### Added
Expand Down Expand Up @@ -62,7 +75,8 @@
### Added
- Initial release.

[Unreleased]: https://github.com/AnderGoig/SwiftInstagram/compare/v1.0.6...develop
[Unreleased]: https://github.com/AnderGoig/SwiftInstagram/compare/v1.1.0...develop
[1.1.0]: https://github.com/AnderGoig/SwiftInstagram/tree/v1.1.0
[1.0.6]: https://github.com/AnderGoig/SwiftInstagram/tree/v1.0.6
[1.0.5]: https://github.com/AnderGoig/SwiftInstagram/tree/v1.0.5
[1.0.4]: https://github.com/AnderGoig/SwiftInstagram/tree/v1.0.4
Expand Down
4 changes: 2 additions & 2 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
github "Quick/Nimble" "v7.0.2"
github "Quick/Nimble" "v7.0.3"
github "Quick/Quick" "v1.2.0"
github "jspahrsummers/xcconfigs" "40f9bcc63752cdd95deee267d2fbf9da09a9f6f2"
github "jspahrsummers/xcconfigs" "94d261a58a034f70fe207298fffb8ee790c4bbd9"
2 changes: 1 addition & 1 deletion Carthage/Checkouts/Nimble
Submodule Nimble updated 48 files
+9 −1 .gitignore
+1 −1 .swiftlint.yml
+8 −0 .travis.yml
+1 −0 Cartfile.private
+2 −0 Cartfile.resolved
+13 −0 Carthage/Checkouts/CwlCatchException/LICENSE.txt
+9 −0 Carthage/Checkouts/CwlCatchException/Package.swift
+46 −0 Carthage/Checkouts/CwlCatchException/README.md
+3 −3 Carthage/Checkouts/CwlCatchException/Sources/CwlCatchException/CwlCatchException.swift
+0 −0 Carthage/Checkouts/CwlCatchException/Sources/CwlCatchExceptionSupport/CwlCatchException.m
+0 −1 Carthage/Checkouts/CwlCatchException/Sources/CwlCatchExceptionSupport/include/CwlCatchException.h
+13 −0 Carthage/Checkouts/CwlPreconditionTesting/LICENSE.txt
+19 −0 Carthage/Checkouts/CwlPreconditionTesting/Package.swift
+73 −0 Carthage/Checkouts/CwlPreconditionTesting/README.md
+0 −0 Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/CwlMachBadInstructionHandler.m
+1 −1 ...heckouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/include/CwlMachBadInstructionHandler.h
+0 −0 Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/mach_excServer.c
+0 −0 Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlMachBadInstructionHandler/mach_excServer.h
+0 −0 Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlBadInstructionException.swift
+18 −22 Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlCatchBadInstruction.swift
+0 −0 Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlCatchBadInstructionPosix.swift
+0 −0 Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/CwlDarwinDefinitions.swift
+0 −0 Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/Mach/CwlPreconditionTesting.h
+2 −2 Carthage/Checkouts/CwlPreconditionTesting/Sources/CwlPreconditionTesting/Posix/CwlPreconditionTesting_POSIX.h
+17 −14 Nimble.podspec
+154 −144 Nimble.xcodeproj/project.pbxproj
+0 −41 Nimble.xcodeproj/project.xcworkspace/xcshareddata/Nimble.xccheckout
+0 −1 Package.swift
+22 −0 [email protected]
+0 −80 Sources/Lib/CwlPreconditionTesting/README.md
+1 −1 Sources/Nimble/Matchers/BeLessThanOrEqual.swift
+13 −13 Sources/Nimble/Matchers/MatcherProtocols.swift
+30 −2 Sources/Nimble/Matchers/PostNotification.swift
+5 −1 Sources/Nimble/Nimble.h
+1 −1 Tests/NimbleTests/Helpers/utils.swift
+3 −3 Tests/NimbleTests/Matchers/BeAKindOfTest.swift
+3 −3 Tests/NimbleTests/Matchers/BeAnInstanceOfTest.swift
+4 −4 Tests/NimbleTests/Matchers/BeCloseToTest.swift
+2 −2 Tests/NimbleTests/Matchers/BeEmptyTest.swift
+5 −5 Tests/NimbleTests/Matchers/BeGreaterThanOrEqualToTest.swift
+6 −6 Tests/NimbleTests/Matchers/BeGreaterThanTest.swift
+5 −5 Tests/NimbleTests/Matchers/BeIdenticalToTest.swift
+4 −4 Tests/NimbleTests/Matchers/BeLessThanOrEqualToTest.swift
+10 −10 Tests/NimbleTests/Matchers/BeLessThanTest.swift
+1 −1 Tests/NimbleTests/Matchers/ContainTest.swift
+5 −5 Tests/NimbleTests/Matchers/EqualTest.swift
+1 −1 Tests/NimbleTests/Matchers/RaisesExceptionTest.swift
+2 −2 Tests/NimbleTests/Matchers/ThrowErrorTest.swift
2 changes: 1 addition & 1 deletion Carthage/Checkouts/xcconfigs
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source "https://rubygems.org"

gem "fastlane"
24 changes: 7 additions & 17 deletions Sources/Endpoints/Comments.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ extension Instagram {
/// - parameter failure: The callback called after an incorrect retrieval.
///
/// - important: It requires *public_content* scope for media that does not belong to your own user.

public func comments(fromMedia mediaId: String, success: SuccessHandler<[InstagramComment]>?, failure: FailureHandler?) {
request("/media/\(mediaId)/comments", success: success, failure: failure)
request("/media/\(mediaId)/comments", success: { data in success?(data!) }, failure: failure)
}

/// Create a comment on a media object.
Expand All @@ -28,21 +27,15 @@ extension Instagram {
/// - parameter text: Text to post as a comment on the media object as specified in `mediaId`.
/// - parameter failure: The callback called after an incorrect creation.
///
/// - important: It requires *comments* scope. Also, *public_content* scope is required for media that does not
/// belong to your own user.
/// - important: It requires *comments* scope. Also, *public_content* scope is required for media that does not belong to your own user.
///
/// - note:
/// - The total length of the comment cannot exceed 300 characters.
/// - The comment cannot contain more than 4 hashtags.
/// - The comment cannot contain more than 1 URL.
/// - The comment cannot consist of all capital letters.

public func createComment(onMedia mediaId: String, text: String, failure: FailureHandler?) {
var parameters = Parameters()

parameters["text"] = text

request("/media/\(mediaId)/comments", method: .post, parameters: parameters, success: { (_: InstagramResponse<Any?>) in return }, failure: failure)
public func createComment(onMedia mediaId: String, text: String, success: SuccessHandler<InstagramComment>?, failure: FailureHandler?) {
request("/media/\(mediaId)/comments", method: .post, parameters: ["text": text], success: { data in success?(data!) }, failure: failure)
}

/// Remove a comment either on the authenticated user's media object or authored by the authenticated user.
Expand All @@ -51,11 +44,8 @@ extension Instagram {
/// - parameter mediaId: The ID of the media object to reference.
/// - parameter failure: The callback called after an incorrect deletion.
///
/// - important: It requires *comments* scope. Also, *public_content* scope is required for media that does not
/// belong to your own user.

public func deleteComment(_ commentId: String, onMedia mediaId: String, failure: FailureHandler?) {
request("/media/\(mediaId)/comments/\(commentId)", method: .delete, success: { (_: InstagramResponse<Any?>) in return }, failure: failure)
/// - important: It requires *comments* scope. Also, *public_content* scope is required for media that does not belong to your own user.
public func deleteComment(_ commentId: String, onMedia mediaId: String, success: EmptySuccessHandler?, failure: FailureHandler?) {
request("/media/\(mediaId)/comments/\(commentId)", method: .delete, success: { (_: InstagramEmptyResponse!) in success?() }, failure: failure)
}

}
20 changes: 7 additions & 13 deletions Sources/Endpoints/Likes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,27 @@ extension Instagram {
/// - parameter failure: The callback called after an incorrect retrieval.
///
/// - important: It requires *public_content* scope for media that does not belong to your own user.

public func likes(inMedia mediaId: String, success: SuccessHandler<[InstagramUser]>?, failure: FailureHandler?) {
request("/media/\(mediaId)/likes", success: success, failure: failure)
request("/media/\(mediaId)/likes", success: { data in success?(data!) }, failure: failure)
}

/// Set a like on this media by the currently authenticated user.
///
/// - parameter mediaId: The ID of the media object to reference.
/// - parameter failure: The callback called after an incorrect like.
///
/// - important: It requires *likes* scope. Also, *public_content* scope is required for media that does not belong
/// to your own user.

public func like(media mediaId: String, failure: FailureHandler?) {
request("/media/\(mediaId)/likes", method: .post, success: { (_: InstagramResponse<Any?>) in return }, failure: failure)
/// - important: It requires *likes* scope. Also, *public_content* scope is required for media that does not belong to your own user.
public func like(media mediaId: String, success: EmptySuccessHandler?, failure: FailureHandler?) {
request("/media/\(mediaId)/likes", method: .post, success: { (_: InstagramEmptyResponse!) in success?() }, failure: failure)
}

/// Remove a like on this media by the currently authenticated user.
///
/// - parameter Parameter mediaId: The ID of the media object to reference.
/// - parameter failure: The callback called after an incorrect deletion.
///
/// - important: It requires *likes* scope. Also, *public_content* scope is required for media that does not belong
/// to your own user.

public func unlike(media mediaId: String, failure: FailureHandler?) {
request("/media/\(mediaId)/likes", method: .delete, success: { (_: InstagramResponse<Any?>) in return }, failure: failure)
/// - important: It requires *likes* scope. Also, *public_content* scope is required for media that does not belong to your own user.
public func unlike(media mediaId: String, success: EmptySuccessHandler?, failure: FailureHandler?) {
request("/media/\(mediaId)/likes", method: .delete, success: { (_: InstagramEmptyResponse!) in success?() }, failure: failure)
}

}
39 changes: 29 additions & 10 deletions Sources/Endpoints/Locations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ extension Instagram {
/// - parameter failure: The callback called after an incorrect retrieval.
///
/// - important: It requires *public_content* scope.

public func location(_ locationId: String, success: SuccessHandler<InstagramLocation<String>>?, failure: FailureHandler?) {
request("/locations/\(locationId)", success: success, failure: failure)
request("/locations/\(locationId)", success: { data in success?(data!) }, failure: failure)
}

/// Get a list of recent media objects from a given location.
Expand All @@ -33,43 +32,63 @@ extension Instagram {
/// - parameter failure: The callback called after an incorrect retrieval.
///
/// - important: It requires *public_content* scope.

public func recentMedia(forLocation locationId: String,
maxId: String? = nil,
minId: String? = nil,
success: SuccessHandler<[InstagramMedia]>?,
failure: FailureHandler?) {

var parameters = Parameters()

parameters["max_id"] ??= maxId
parameters["min_id"] ??= minId

request("/locations/\(locationId)/media/recent", parameters: parameters, success: success, failure: failure)
request("/locations/\(locationId)/media/recent", parameters: parameters, success: { data in success?(data!) }, failure: failure)
}

/// Search for a location by geographic coordinate.
///
/// - parameter coordinates: Latitude and longitude of the center search coordinates.
/// - parameter latitude: Latitude of the center search coordinate. If used, `longitude` is required.
/// - parameter longitude: Longitude of the center search coordinate. If used, `latitude` is required.
/// - parameter distance: Default is 500m, max distance is 750.
/// - parameter facebookPlacesId: Returns a location mapped off of a Facebook places id. If used, `coordinates` is not required.
/// - parameter success: The callback called after a correct retrieval.
/// - parameter failure: The callback called after an incorrect retrieval.
///
/// - important: It requires *public_content* scope.

public func searchLocation(coordinates: CLLocationCoordinate2D? = nil,
public func searchLocation(latitude: Double? = nil,
longitude: Double? = nil,
distance: Int? = nil,
facebookPlacesId: String? = nil,
success: SuccessHandler<[InstagramLocation<String>]>?,
failure: FailureHandler?) {

var parameters = Parameters()

parameters["lat"] ??= coordinates?.latitude
parameters["lng"] ??= coordinates?.longitude
parameters["lat"] ??= latitude
parameters["lng"] ??= longitude
parameters["distance"] ??= distance
parameters["facebook_places_id"] ??= facebookPlacesId

request("/locations/search", parameters: parameters, success: success, failure: failure)
request("/locations/search", parameters: parameters, success: { data in success?(data!) }, failure: failure)
}

/// Search for a location by geographic coordinate.
///
/// - parameter coordinates: Latitude and longitude of the center search coordinates.
/// - parameter distance: Default is 500m, max distance is 750.
/// - parameter facebookPlacesId: Returns a location mapped off of a Facebook places id. If used, `coordinates` is not required.
/// - parameter success: The callback called after a correct retrieval.
/// - parameter failure: The callback called after an incorrect retrieval.
///
/// - important: It requires *public_content* scope.
public func searchLocation(coordinates: CLLocationCoordinate2D? = nil,
distance: Int? = nil,
facebookPlacesId: String? = nil,
success: SuccessHandler<[InstagramLocation<String>]>?,
failure: FailureHandler?) {

searchLocation(latitude: coordinates?.latitude, longitude: coordinates?.longitude,
distance: distance, facebookPlacesId: facebookPlacesId, success: success, failure: failure)
}
}
39 changes: 27 additions & 12 deletions Sources/Endpoints/Media.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
// Copyright © 2017 Ander Goig. All rights reserved.
//

import CoreLocation

extension Instagram {

// MARK: - Media Endpoints
Expand All @@ -17,9 +19,8 @@ extension Instagram {
/// - parameter failure: The callback called after an incorrect retrieval.
///
/// - important: It requires *public_content* scope.

public func media(withId id: String, success: SuccessHandler<InstagramMedia>?, failure: FailureHandler?) {
request("/media/\(id)", success: success, failure: failure)
request("/media/\(id)", success: { data in success?(data!) }, failure: failure)
}

/// Get information about a media object.
Expand All @@ -32,33 +33,47 @@ extension Instagram {
///
/// - note: A media object's shortcode can be found in its shortlink URL.
/// An example shortlink is http://instagram.com/p/tsxp1hhQTG/. Its corresponding shortcode is tsxp1hhQTG.

public func media(withShortcode shortcode: String, success: SuccessHandler<InstagramMedia>?, failure: FailureHandler?) {
request("/media/shortcode/\(shortcode)", success: success, failure: failure)
request("/media/shortcode/\(shortcode)", success: { data in success?(data!) }, failure: failure)
}

/// Search for recent media in a given area.
///
/// - parameter lat: Latitude of the center search coordinate. If used, `lng` is required.
/// - parameter lng: Longitude of the center search coordinate. If used, `lat` is required.
/// - parameter latitude: Latitude of the center search coordinate. If used, `longitude` is required.
/// - parameter longitude: Longitude of the center search coordinate. If used, `latitude` is required.
/// - parameter distance: Default is 1km (1000m), max distance is 5km.
/// - parameter success: The callback called after a correct retrieval.
/// - parameter failure: The callback called after an incorrect retrieval.
///
/// - important: It requires *public_content* scope.

public func searchMedia(lat: Double? = nil,
lng: Double? = nil,
public func searchMedia(latitude: Double? = nil,
longitude: Double? = nil,
distance: Int? = nil,
success: SuccessHandler<[InstagramMedia]>?,
failure: FailureHandler?) {

var parameters = Parameters()

parameters["lat"] ??= lat
parameters["lng"] ??= lng
parameters["lat"] ??= latitude
parameters["lng"] ??= longitude
parameters["distance"] ??= distance

request("/media/search", parameters: parameters, success: success, failure: failure)
request("/media/search", parameters: parameters, success: { data in success?(data!) }, failure: failure)
}

/// Search for recent media in a given area.
///
/// - parameter coordinates: Latitude and longitude of the center search coordinates.
/// - parameter distance: Default is 1km (1000m), max distance is 5km.
/// - parameter success: The callback called after a correct retrieval.
/// - parameter failure: The callback called after an incorrect retrieval.
///
/// - important: It requires *public_content* scope.
public func searchMedia(coordinates: CLLocationCoordinate2D? = nil,
distance: Int? = nil,
success: SuccessHandler<[InstagramMedia]>?,
failure: FailureHandler?) {

searchMedia(latitude: coordinates?.latitude, longitude: coordinates?.longitude, distance: distance, success: success, failure: failure)
}
}
Loading