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

Commit 6b543c9

Browse files
authored
Merge pull request #10 from AnderGoig/develop
Version 1.0.5
2 parents 1063a68 + 8689916 commit 6b543c9

Some content is hidden

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

63 files changed

+942
-228
lines changed

.codebeatignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
Sources/Helpers/KeychainSwiftDistrib.swift
12
docs/**

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
[submodule "Carthage/Checkouts/xcconfigs"]
22
path = Carthage/Checkouts/xcconfigs
33
url = https://github.com/jspahrsummers/xcconfigs.git
4+
ignore = dirty
45
[submodule "Carthage/Checkouts/Nimble"]
56
path = Carthage/Checkouts/Nimble
67
url = https://github.com/Quick/Nimble.git
8+
ignore = dirty
79
[submodule "Carthage/Checkouts/Quick"]
810
path = Carthage/Checkouts/Quick
911
url = https://github.com/Quick/Quick.git
12+
ignore = dirty

.jazzy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Run jazzy from the current directory to generate documentation
22

33
module: SwiftInstagram
4-
module_version: 1.0.0
4+
module_version: 1.0.5
55
author: Ander Goig
66
github_url: https://github.com/AnderGoig/SwiftInstagram
77
exclude:

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
## [Unreleased]
88

9+
## [1.0.5] - 2017-10-18
10+
### Changed
11+
- The `Success` and `Failure` handlers, for all the API endpoints, are no longer nullable.
12+
### Fixed
13+
- Fixed the bug parsing `InstagramMedia` objects with a `location` property (#7).
14+
915
## [1.0.4] - 2017-10-10
1016
### Added
1117
- 100% documented code.
@@ -44,7 +50,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
4450
### Added
4551
- Initial release.
4652

47-
[Unreleased]: https://github.com/AnderGoig/SwiftInstagram/compare/v1.0.4...develop
53+
[Unreleased]: https://github.com/AnderGoig/SwiftInstagram/compare/v1.0.5...develop
54+
[1.0.5]: https://github.com/AnderGoig/SwiftInstagram/compare/v1.0.4...v1.0.5
4855
[1.0.4]: https://github.com/AnderGoig/SwiftInstagram/compare/v1.0.3...v1.0.4
4956
[1.0.3]: https://github.com/AnderGoig/SwiftInstagram/compare/v1.0.2...v1.0.3
5057
[1.0.2]: https://github.com/AnderGoig/SwiftInstagram/compare/v1.0.1...v1.0.2

Cartfile.resolved

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
github "Quick/Nimble" "v7.0.2"
22
github "Quick/Quick" "v1.2.0"
3-
github "jspahrsummers/xcconfigs" "4ac967d12f72c2ccc7f34d163268d09296923a7c"
3+
github "jspahrsummers/xcconfigs" "40f9bcc63752cdd95deee267d2fbf9da09a9f6f2"

Carthage/Checkouts/Nimble

Submodule Nimble updated 70 files

Carthage/Checkouts/Quick

Submodule Quick updated 46 files

Carthage/Checkouts/xcconfigs

Sources/Instagram.swift

Lines changed: 50 additions & 50 deletions
Large diffs are not rendered by default.

Sources/Models/InstagramClient.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ struct InstagramClient {
1212
let redirectURI: String?
1313
var scopes: [InstagramScope] = [.basic]
1414

15+
var stringScopes: String {
16+
return scopes.map({ "\($0.rawValue)" }).joined(separator: "+")
17+
}
18+
1519
init(clientId: String?, redirectURI: String?) {
1620
self.clientId = clientId
1721
self.redirectURI = redirectURI

Sources/Models/InstagramMedia.swift

Lines changed: 25 additions & 1 deletion
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
/// The struct containing an Instagram media.
1012

1113
public struct InstagramMedia: Decodable {
@@ -51,7 +53,7 @@ public struct InstagramMedia: Decodable {
5153
public let link: String
5254

5355
/// The location of the media.
54-
public let location: InstagramLocation?
56+
public let location: MediaLocation?
5557

5658
/// A list of users and their position on the image.
5759
public let usersInPhoto: [UserInPhoto]
@@ -123,6 +125,28 @@ public struct InstagramMedia: Decodable {
123125
}
124126
}
125127

128+
/// A struct containing the location of the media.
129+
public struct MediaLocation: Codable {
130+
131+
/// The location identifier.
132+
public let id: Int
133+
134+
/// The location name.
135+
public let name: String
136+
137+
/// The location coordinates (latitude and logitude).
138+
public var coordinates: CLLocationCoordinate2D {
139+
return CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
140+
}
141+
142+
private let latitude: Double
143+
private let longitude: Double
144+
145+
private enum CodingKeys: String, CodingKey {
146+
case id, name, latitude, longitude
147+
}
148+
}
149+
126150
/// A struct containing the user and its position on the image.
127151
public struct UserInPhoto: Decodable {
128152

Sources/Utils/Operator++.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// Operator++.swift
3+
// SwiftInstagram
4+
//
5+
// Created by Ander Goig on 12/10/17.
6+
// Copyright © 2017 Ander Goig. All rights reserved.
7+
//
8+
9+
infix operator ??=: AssignmentPrecedence
10+
11+
func ??= <T>(lhs: inout T?, rhs: T?) {
12+
guard let rhs = rhs else {
13+
return
14+
}
15+
16+
lhs = rhs
17+
}

Sources/Views/InstagramLoginViewController.swift

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class InstagramLoginViewController: UIViewController {
3131
fatalError("init(coder:) has not been implemented")
3232
}
3333

34-
init(client: InstagramClient, success: SuccessHandler? = nil, failure: FailureHandler? = nil) {
34+
init(client: InstagramClient, success: SuccessHandler?, failure: FailureHandler?) {
3535
self.client = client
3636
self.success = success
3737
self.failure = failure
@@ -92,38 +92,38 @@ class InstagramLoginViewController: UIViewController {
9292
webView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
9393
webView.navigationDelegate = self
9494

95-
webViewObservation = webView.observe(\.estimatedProgress) { (view, _ change) in
96-
self.progressView.alpha = 1.0
97-
self.progressView.setProgress(Float(view.estimatedProgress), animated: true)
98-
if view.estimatedProgress >= 1.0 {
99-
UIView.animate(withDuration: 0.3, delay: 0.1, options: .curveEaseInOut, animations: {
100-
self.progressView.alpha = 0.0
101-
}, completion: { (_ finished) in
102-
self.progressView.progress = 0
103-
})
104-
}
105-
}
95+
webViewObservation = webView.observe(\.estimatedProgress, changeHandler: progressViewChangeHandler)
10696

10797
view.addSubview(webView)
10898

10999
return webView
110100
}
111101

102+
private func progressViewChangeHandler<Value>(webView: WKWebView, change: NSKeyValueObservedChange<Value>) {
103+
progressView.alpha = 1.0
104+
progressView.setProgress(Float(webView.estimatedProgress), animated: true)
105+
106+
if webView.estimatedProgress >= 1.0 {
107+
UIView.animate(withDuration: 0.3, delay: 0.1, options: .curveEaseInOut, animations: {
108+
self.progressView.alpha = 0.0
109+
}, completion: { (_ finished) in
110+
self.progressView.progress = 0
111+
})
112+
}
113+
}
114+
112115
// MARK: -
113116

114117
func loadAuthorizationURL(webView: WKWebView) {
115-
let authorizationURL = URL(string: "https://api.instagram.com/oauth/authorize/")
116-
117-
var components = URLComponents(url: authorizationURL!, resolvingAgainstBaseURL: false)!
118+
var components = URLComponents(string: "https://api.instagram.com/oauth/authorize/")!
118119
components.queryItems = [
119120
URLQueryItem(name: "client_id", value: client.clientId),
120121
URLQueryItem(name: "redirect_uri", value: client.redirectURI),
121122
URLQueryItem(name: "response_type", value: "token"),
122-
URLQueryItem(name: "scope", value: client.scopes.map({ "\($0.rawValue)" }).joined(separator: "+"))
123+
URLQueryItem(name: "scope", value: client.stringScopes)
123124
]
124125

125-
let request = URLRequest(url: components.url!, cachePolicy: .reloadIgnoringLocalAndRemoteCacheData)
126-
webView.load(request)
126+
webView.load(URLRequest(url: components.url!, cachePolicy: .reloadIgnoringLocalAndRemoteCacheData))
127127
}
128128

129129
}
@@ -141,8 +141,7 @@ extension InstagramLoginViewController: WKNavigationDelegate {
141141
let urlString = navigationAction.request.url!.absoluteString
142142

143143
if let range = urlString.range(of: "#access_token=") {
144-
let location = range.upperBound
145-
let accessToken = urlString[location...]
144+
let accessToken = urlString[range.upperBound...]
146145
decisionHandler(.cancel)
147146
DispatchQueue.main.async {
148147
self.success?(String(accessToken))

SwiftInstagram.podspec

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
Pod::Spec.new do |s|
2-
s.name = 'SwiftInstagram'
3-
s.version = '1.0.4'
4-
s.license = { :type => "MIT", :file => "LICENSE" }
5-
s.summary = 'A Swift wrapper for the Instagram API'
6-
s.description = <<-DESC
7-
SwiftInstagram is a wrapper for the Instagram API written in Swift. It allows
8-
you to authenticate users and request data from Instagram effortlessly.
9-
DESC
10-
s.homepage = 'https://github.com/AnderGoig/SwiftInstagram'
11-
s.author = { "Ander Goig" => "goig.ander@gmail.com" }
12-
s.source = { :git => "https://github.com/AnderGoig/SwiftInstagram.git", :tag => "v"+s.version.to_s }
13-
s.platforms = { :ios => "9.0" }
14-
s.requires_arc = true
2+
s.name = 'SwiftInstagram'
3+
s.version = '1.0.5'
4+
s.cocoapods_version = '>= 1.1.0'
5+
s.authors = { 'Ander Goig' => 'goig.ander@gmail.com' }
6+
s.license = { :type => 'MIT', :file => 'LICENSE' }
7+
s.homepage = 'https://github.com/AnderGoig/SwiftInstagram'
8+
s.source = { :git => 'https://github.com/AnderGoig/SwiftInstagram.git',
9+
:tag => "v#{s.version}" }
10+
s.summary = 'An Instagram API client written in Swift.'
11+
s.description = <<-DESC
12+
SwiftInstagram is a wrapper for the Instagram API written in Swift. It allows
13+
you to authenticate users and request data from Instagram effortlessly.
14+
DESC
15+
s.documentation_url = 'https://andergoig.github.io/SwiftInstagram/'
1516

16-
s.default_subspec = "Core"
17-
s.subspec "Core" do |ss|
18-
ss.source_files = "Sources/*.swift", "Sources/**/*.swift"
19-
ss.framework = "Foundation"
17+
s.platform = :ios, '9.0'
18+
19+
s.default_subspec = 'Core'
20+
s.subspec 'Core' do |ss|
21+
ss.framework = 'Foundation'
22+
ss.source_files = 'Sources/*.swift', 'Sources/**/*.swift'
2023
end
2124

2225
end

SwiftInstagram.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
778AF5F61F6E7F35005AC284 /* InstagramTag.swift in Sources */ = {isa = PBXBuildFile; fileRef = 778AF5D71F6E7F35005AC284 /* InstagramTag.swift */; };
2626
778AF5FA1F6E7F35005AC284 /* InstagramMedia.swift in Sources */ = {isa = PBXBuildFile; fileRef = 778AF5D81F6E7F35005AC284 /* InstagramMedia.swift */; };
2727
77B8E4181F869EBE0035C229 /* InstagramScope.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77B8E4171F869EBE0035C229 /* InstagramScope.swift */; };
28+
77DF0B6C1F8FEB6600BE7F66 /* Operator++.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77DF0B6B1F8FEB6600BE7F66 /* Operator++.swift */; };
2829
/* End PBXBuildFile section */
2930

3031
/* Begin PBXContainerItemProxy section */
@@ -213,6 +214,7 @@
213214
778AF5D81F6E7F35005AC284 /* InstagramMedia.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstagramMedia.swift; sourceTree = "<group>"; };
214215
778AF6511F6ED417005AC284 /* OnePasswordExtension.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OnePasswordExtension.framework; path = Carthage/Build/iOS/OnePasswordExtension.framework; sourceTree = "<group>"; };
215216
77B8E4171F869EBE0035C229 /* InstagramScope.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstagramScope.swift; sourceTree = "<group>"; };
217+
77DF0B6B1F8FEB6600BE7F66 /* Operator++.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Operator++.swift"; sourceTree = "<group>"; };
216218
/* End PBXFileReference section */
217219

218220
/* Begin PBXFrameworksBuildPhase section */
@@ -425,6 +427,7 @@
425427
77B8E4161F869E8A0035C229 /* Utils */ = {
426428
isa = PBXGroup;
427429
children = (
430+
77DF0B6B1F8FEB6600BE7F66 /* Operator++.swift */,
428431
77B8E4171F869EBE0035C229 /* InstagramScope.swift */,
429432
);
430433
path = Utils;
@@ -719,6 +722,7 @@
719722
778AF5E61F6E7F35005AC284 /* InstagramRelationship.swift in Sources */,
720723
778AF5EA1F6E7F35005AC284 /* InstagramLocation.swift in Sources */,
721724
778AF5F61F6E7F35005AC284 /* InstagramTag.swift in Sources */,
725+
77DF0B6C1F8FEB6600BE7F66 /* Operator++.swift in Sources */,
722726
778AF5E21F6E7F35005AC284 /* InstagramComment.swift in Sources */,
723727
778AF5DE1F6E7F35005AC284 /* InstagramError.swift in Sources */,
724728
778AF5FA1F6E7F35005AC284 /* InstagramMedia.swift in Sources */,

docs/Classes.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@
9292
<li class="nav-group-task">
9393
<a class="nav-group-task-link" href="Structs/InstagramMedia/Videos.html">– Videos</a>
9494
</li>
95+
<li class="nav-group-task">
96+
<a class="nav-group-task-link" href="Structs/InstagramMedia/MediaLocation.html">– MediaLocation</a>
97+
</li>
9598
<li class="nav-group-task">
9699
<a class="nav-group-task-link" href="Structs/InstagramMedia/UserInPhoto.html">– UserInPhoto</a>
97100
</li>
@@ -164,7 +167,7 @@ <h4>Declaration</h4>
164167
</article>
165168
</div>
166169
<section class="footer">
167-
<p>&copy; 2017 <a class="link" href="https://github.com/AnderGoig/SwiftInstagram" target="_blank" rel="external">Ander Goig</a>. All rights reserved. (Last updated: 2017-10-14)</p>
170+
<p>&copy; 2017 <a class="link" href="https://github.com/AnderGoig/SwiftInstagram" target="_blank" rel="external">Ander Goig</a>. All rights reserved. (Last updated: 2017-10-18)</p>
168171
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.4</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
169172
</section>
170173
</body>

0 commit comments

Comments
 (0)