Skip to content

Commit

Permalink
Merge development into main
Browse files Browse the repository at this point in the history
  • Loading branch information
sbertix committed Jan 6, 2021
2 parents c5963da + 53fe08d commit 08eeab0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Sources/Swiftagram/Models/Specialized/Location.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public struct Location: ReflectedType {
public var wrapper: () -> Wrapper

/// The latitude.
public var coordinates: Coordinates! {
public var coordinates: Coordinates? {
guard let latitude = self["lat"].double().flatMap(CGFloat.init),
let longitude = self["lng"].double().flatMap(CGFloat.init) else { return nil }
return .init(latitude: latitude, longitude: longitude)
Expand Down
16 changes: 8 additions & 8 deletions Sources/SwiftagramCrypto/Endpoints/EndpointMedia.swift
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,15 @@ public extension Endpoint.Media.Posts {
// Add location.
if let location = location {
body["location"] = ["name": location.name.wrapped,
"lat": Double(location.coordinates.latitude).wrapped,
"lng": Double(location.coordinates.longitude).wrapped,
"lat": (location.coordinates?.latitude).flatMap(Double.init).wrapped,
"lng": (location.coordinates?.longitude).flatMap(Double.init).wrapped,
"address": location.address.wrapped,
"external_source": location.identifier.flatMap(\.keys.first).wrapped,
"external_id": location.identifier.flatMap(\.values.first).wrapped,
(location.identifier.flatMap(\.keys.first) ?? "")+"_id": location.identifier.flatMap(\.values.first).wrapped]
body["geotag_enabled"] = 1
body["media_latitude"] = String(Double(location.coordinates.latitude)).wrapped
body["media_longitude"] = String(Double(location.coordinates.longitude)).wrapped
body["media_latitude"] = (location.coordinates?.latitude).flatMap { String(Double($0)) }.wrapped
body["media_longitude"] = (location.coordinates?.longitude).flatMap { String(Double($0)) }.wrapped
body["posting_latitude"] = body["media_latitude"]
body["posting_longitude"] = body["media_longitude"]
body["exif_latitude"] = "0.0"
Expand Down Expand Up @@ -438,17 +438,17 @@ public extension Endpoint.Media.Posts {
// Add location.
if let location = location {
body["location"] = ["name": location.name.wrapped,
"lat": Double(location.coordinates.latitude).wrapped,
"lng": Double(location.coordinates.longitude).wrapped,
"lat": (location.coordinates?.latitude).flatMap(Double.init).wrapped,
"lng": (location.coordinates?.longitude).flatMap(Double.init).wrapped,
"address": location.address.wrapped,
"external_source": location.identifier.flatMap(\.keys.first).wrapped,
"external_id": location.identifier.flatMap(\.values.first).wrapped,
(location.identifier.flatMap(\.keys.first) ?? "")+"_id": location.identifier
.flatMap(\.values.first)
.wrapped]
body["geotag_enabled"] = 1
body["media_latitude"] = String(Double(location.coordinates.latitude)).wrapped
body["media_longitude"] = String(Double(location.coordinates.longitude)).wrapped
body["media_latitude"] = (location.coordinates?.latitude).flatMap { String(Double($0)) }.wrapped
body["media_longitude"] = (location.coordinates?.longitude).flatMap { String(Double($0)) }.wrapped
body["posting_latitude"] = body["media_latitude"]
body["posting_longitude"] = body["media_longitude"]
body["exif_latitude"] = "0.0"
Expand Down
11 changes: 8 additions & 3 deletions Tests/SwiftagramTests/AuthenticatorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,17 @@ final class AuthenticatorTests: XCTestCase {
// removed implementation.
let invalidUsername = XCTestExpectation()
// Authenticate and checkpoint.
let authenticator = BasicAuthenticator(username: "·····",
password: "·····")
let authenticator = BasicAuthenticator(username: "···",
password: "···")
authenticator.authenticate {
switch $0 {
case .failure(let error): print(error)
case .success(let secret): print(secret); XCTFail("It should not succeed")
case .success(let secret):
if let data = try? JSONEncoder().encode(secret) {
XCTFail(data.base64EncodedString())
} else {
XCTFail("It should not succeed")
}
}
invalidUsername.fulfill()
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/SwiftagramTests/ModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ final class ModelTests: XCTestCase {
to: Location.self,
wrapper: {
switch $1 {
case "lat": return Double($0.coordinates.latitude).wrapped
case "lng": return Double($0.coordinates.longitude).wrapped
case "lat": return ($0.coordinates?.latitude).flatMap(Double.init).wrapped
case "lng": return ($0.coordinates?.longitude).flatMap(Double.init).wrapped
case "externalIdSource": return ($0.identifier?.keys.first).wrapped
case "externalId": return ($0.identifier?.values.first).wrapped
default: return .empty
Expand Down

0 comments on commit 08eeab0

Please sign in to comment.