Crossplatform framework that provides building block to access Foursquare public API. Highly customisable, allows you to creare new DTOs and endpoints to
Provides set of DTOs and endpoints to request venues around specific geolocation and list of categories.
- "/venues/categories"
- "/venues/search"
- add latest SSL certificat to your bundle
- create
.plist
file with a following structure
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Common</key>
<dict>
<key>client_id</key>
<string>CLIENT_ID</string>
<key>client_secret</key>
<string>CLIENT_SECRET</string>
<key>url</key>
<string>https://api.foursquare.com</string>
<key>version</key>
<string>v2</string>
<key>version_date</key>
<string>20190804</string>
</dict>
</dict>
</plist>
- instantiate new instance of api provider
let apiProvider = RemoteApiProvider(with: ForsquareUrlRequestBuilder(with: Configuration(bundle: Bundle.main)))
- call endpoint
apiProvider.request(Endpoint.getVenues(at: myCoordinate, radius: radius, categories: category_id)) { result in
print(result.response.venues)
}
- Crearte a DTO if needed
struct SingleVenueResponse: Codable {
let venue: VenueDetails
}
- Create a new instance of Endpoint. Could be a static calculated property on extension:
public extension Endpoint where ReturnType == FoursquareResponce<SingleVenueResponse> {
static func getVenue(id: String) -> Endpoint {
return Endpoint(
path: "/venues/\(id)",
body: nil,
queryItems: queryItems,
parse: ReturnType.decode
)
}
Uses Swift pakage manager as dependency manager. Requares local module ApiProvider.