Skip to content

Commit 7cacf19

Browse files
committed
feat(places): add getObject method
1 parent d743cdc commit 7cacf19

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

Source/PlacesClient.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,15 @@ import Foundation
8989
let request = ["params": params.build()]
9090
return performHTTPQuery(path: "1/places/query", method: .POST, body: request, hostnames: self.readHosts, isSearchQuery: true, completionHandler: completionHandler)
9191
}
92+
93+
/// Get a place by its objectID.
94+
///
95+
/// - parameter objectID: Identifier of the object to retrieve.
96+
/// - parameter completionHandler: Completion handler to be notified of the request's outcome.
97+
/// - returns: A cancellable operation.
98+
///
99+
@objc
100+
@discardableResult public func getObject(withID objectID: String, completionHandler: @escaping CompletionHandler) -> Operation {
101+
return performHTTPQuery(path: "1/places/\(objectID.urlEncodedPathComponent())", method: .GET, body: nil, hostnames: self.readHosts, completionHandler: completionHandler)
102+
}
92103
}

Tests/PlacesClientTests.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,15 @@ class PlacesClientTests: XCTestCase {
5757
}
5858
self.waitForExpectations(timeout: expectationTimeout, handler: nil)
5959
}
60+
61+
func testGetObject() {
62+
let expectation = self.expectation(description: #function)
63+
64+
places.getObject(withID: "171457082_7444") { (content, error) in
65+
XCTAssertEqual("171457082_7444", content!["objectID"] as! String)
66+
expectation.fulfill()
67+
}
68+
69+
self.waitForExpectations(timeout: expectationTimeout, handler: nil)
70+
}
6071
}

0 commit comments

Comments
 (0)