TruckerPathKit
简介
欢迎来到官方 Trucker Path Swift 库
Trucker Path SDK 为我们的合作伙伴提供了一种简单、可控和高效的方式,以获取信息和与 Trucker Path 服务(包括卡车停靠站、停车场、称重站、加油站等地点的综合信息)进行交互的能力。
示例
要运行示例项目,首先克隆该仓库,然后再从示例目录运行 pod install
。
要求
我们的 master 分支和我们的发布版本现在都在 Swift 5 上。
部署目标:iOS12.0
安装
TruckerPathKit 通过 CocoaPods 可用。要安装,请在 Podfile 中添加以下行:
pod 'TruckerPathKit'
初始化和用法
集成
将 TruckerPathKit 导入 AppDelegate.swift,并在 application:didFinishLaunchingWithOptions:
中初始化 TruckerPath。
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
TruckerPath.sharedInstance().setApiKey("TruckerPath_ApiKey")
}
使用方法
-
搜索地点
TruckerPath.sharedInstance().getExtendedPlaceByDistance(from: CLLocationCoordinate2D, inRadius: radius)
-
使用现有控件更新状态
TPPUpdateStatusManager.sharedInstance.showUpdateView(place){ (updateSuccessed) in if updateSuccessed { print("Update status succeeded") } else { print("Update status Failed") } }
-
使用 API 更新状态
//update Truck Stop status api, status can be: "free", "some", "full" TruckerPath.sharedInstance().updateTruckStopStatus(withPlaceID:placeId, status: status) { (error) in if error == nil { print("Update status succeeded") } } //update Weigh Station status api, status can be: "closed", "open", "monitor" TruckerPath.sharedInstance().updateWeighStationStatus(withPlaceID:placeId, status: status) { (error) in if error == nil { print("Update status succeeded") } }
-
获取柴油价格
//Get Diesel price of FuelStations //placeIDs: array of placeId, Support one or more TruckerPath.sharedInstance().getDieselPrices(withPlaceIDs: [1, 2]) { (object, error) in }
-
添加评论
//Add a new Review under Place //text: Content of Review //rating: Rating the Place (1-5 stars) //placeID: Target Place.id TruckerPath.sharedInstance().addReview(text, rating: rating, placeID: placeId) { (object, error) in }
-
移除评论
//Remove a Review with ReviewID //reviewId: Target ReviewID TruckerPath.sharedInstance().removeReview(withReviewId: reviewId) { (object, error) in }
-
获取评论
//Get Reviews of Place //placeID: Target Place.id //limit: Review Count per Page //page: Current Page number TruckerPath.sharedInstance().getReviews(placeId, limit: limit, page: page) { (object, error) in } //Get Reviews of yourself TruckerPath.sharedInstance().getMyReviews { (object, error) in }
作者
Trucker Path Inc.
许可协议
TruckerPathKit 可在 MIT 许可下使用。更多信息请参阅 LICENSE 文件。