Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added APIs for Request Estimate, Cancel, Map and Receipt #23

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Binary file added UberKit/.DS_Store
Binary file not shown.
Binary file added UberKit/Model/.DS_Store
Binary file not shown.
19 changes: 19 additions & 0 deletions UberKit/Model/UberCharge.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// UberCharge.h
// Bobo
//
// Created by Zhouboli on 15/7/12.
// Copyright (c) 2015年 Zhouboli. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface UberCharge : NSObject

@property (strong, nonatomic) NSString *name;
@property (strong, nonatomic) NSString *type;
@property (nonatomic) float amount;

- (instancetype) initWithDictionary:(NSDictionary *)dictionary;

@end
24 changes: 24 additions & 0 deletions UberKit/Model/UberCharge.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// UberCharge.m
// Bobo
//
// Created by Zhouboli on 15/7/12.
// Copyright (c) 2015年 Zhouboli. All rights reserved.
//

#import "UberCharge.h"

@implementation UberCharge

- (instancetype) initWithDictionary:(NSDictionary *)dictionary
{
self = [super init];
if (self) {
_name = [dictionary objectForKey:@"name"];
_amount = [[dictionary objectForKey:@"amount"] floatValue];
_type = [dictionary objectForKey:@"type"];
}
return self;
}

@end
20 changes: 20 additions & 0 deletions UberKit/Model/UberDriver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// UberDriver.h
// Pods
//
// Created by Zhouboli on 15/7/10.
//
//

#import <Foundation/Foundation.h>

@interface UberDriver : NSObject

@property (strong, nonatomic) NSString *phone_number; //The formatted phone number for contacting the driver.
@property (strong, nonatomic) NSString *picture_url; //The URL to the photo of the driver.
@property (strong, nonatomic) NSString *name; //The first name of the driver.
@property (nonatomic) float rating; //The driver's star rating out of 5 stars.

- (instancetype) initWithDictionary:(NSDictionary *)dictionary;

@end
25 changes: 25 additions & 0 deletions UberKit/Model/UberDriver.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// UberDriver.m
// Pods
//
// Created by Zhouboli on 15/7/10.
//
//

#import "UberDriver.h"

@implementation UberDriver

- (instancetype) initWithDictionary:(NSDictionary *)dictionary
{
self = [super init];
if (self) {
_phone_number = dictionary[@"phone_number"];
_picture_url = dictionary[@"picture_url"];
_name = dictionary[@"name"];
_rating = [dictionary[@"rating"] floatValue];
}
return self;
}

@end
21 changes: 21 additions & 0 deletions UberKit/Model/UberEstimate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// UberEstimate.h
// Bobo
//
// Created by Zhouboli on 15/7/12.
// Copyright (c) 2015年 Zhouboli. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "UberTrip.h"
#import "UberEstimatedPrice.h"

@interface UberEstimate : NSObject

@property (strong, nonatomic) UberTrip *trip;
@property (strong, nonatomic) UberEstimatedPrice *price;
@property (nonatomic) NSInteger pickup_estimate;

- (instancetype) initWithDictionary:(NSDictionary *)dictionary;

@end
28 changes: 28 additions & 0 deletions UberKit/Model/UberEstimate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// UberEstimate.m
// Bobo
//
// Created by Zhouboli on 15/7/12.
// Copyright (c) 2015年 Zhouboli. All rights reserved.
//

#import "UberEstimate.h"

@implementation UberEstimate

- (instancetype) initWithDictionary:(NSDictionary *)dictionary
{
self = [super init];
if (self) {
if (![dictionary[@"price"] isEqual:[NSNull null]]) {
_price = [[UberEstimatedPrice alloc] initWithDictionary:dictionary[@"price"]];
}
if (![dictionary[@"trip"] isEqual:[NSNull null]]) {
_trip = [[UberTrip alloc] initWithDictionary:dictionary[@"trip"]];
}
_pickup_estimate = [[dictionary objectForKey:@"pickup_estimate"] integerValue];
}
return self;
}

@end
24 changes: 24 additions & 0 deletions UberKit/Model/UberEstimatedPrice.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// UberEstimatedPrice.h
// Bobo
//
// Created by Zhouboli on 15/7/12.
// Copyright (c) 2015年 Zhouboli. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface UberEstimatedPrice : NSObject

@property (strong, nonatomic) NSString *surge_confirmation_href;
@property (strong, nonatomic) NSString *surge_confirmation_id;
@property (strong, nonatomic) NSString *currency_code;
@property (strong, nonatomic) NSString *display;
@property (nonatomic) NSInteger high_estimate;
@property (nonatomic) NSInteger low_estimate;
@property (nonatomic) NSInteger minimum;
@property (nonatomic) float surge_multiplier;

- (instancetype) initWithDictionary:(NSDictionary *)dictionary;

@end
29 changes: 29 additions & 0 deletions UberKit/Model/UberEstimatedPrice.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// UberEstimatedPrice.m
// Bobo
//
// Created by Zhouboli on 15/7/12.
// Copyright (c) 2015年 Zhouboli. All rights reserved.
//

#import "UberEstimatedPrice.h"

@implementation UberEstimatedPrice

- (instancetype) initWithDictionary:(NSDictionary *)dictionary
{
self = [super init];
if (self) {
_surge_confirmation_href = [dictionary objectForKey:@"surge_confirmation_href"];
_high_estimate = [[dictionary objectForKey:@"high_estimate"] integerValue];
_surge_confirmation_id = [dictionary objectForKey:@"surge_confirmation_id"];
_minimum = [[dictionary objectForKey:@"minimum"] integerValue];
_low_estimate = [[dictionary objectForKey:@"low_estimate"] integerValue];
_surge_multiplier = [[dictionary objectForKey:@"surge_multiplier"] floatValue];
_display = [dictionary objectForKey:@"display"];
_currency_code = [dictionary objectForKey:@"currency_code"];
}
return self;
}

@end
19 changes: 19 additions & 0 deletions UberKit/Model/UberLocation.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// UberLocation.h
// Pods
//
// Created by Zhouboli on 15/7/10.
//
//

#import <Foundation/Foundation.h>

@interface UberLocation : NSObject

@property (nonatomic) float latitude;
@property (nonatomic) float longitude;
@property (nonatomic) NSInteger bearing; //The current bearing of the vehicle in degrees (0-359).

- (instancetype) initWithDictionary:(NSDictionary *)dictionary;

@end
24 changes: 24 additions & 0 deletions UberKit/Model/UberLocation.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// UberLocation.m
// Pods
//
// Created by Zhouboli on 15/7/10.
//
//

#import "UberLocation.h"

@implementation UberLocation

- (instancetype) initWithDictionary:(NSDictionary *)dictionary
{
self = [super init];
if (self) {
_latitude = [dictionary[@"latitude"] floatValue];
_longitude = [dictionary[@"longitude"] floatValue];
_bearing = [dictionary[@"bearing"] integerValue];
}
return self;
}

@end
18 changes: 18 additions & 0 deletions UberKit/Model/UberMap.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// UberMap.h
// Bobo
//
// Created by Zhouboli on 15/7/12.
// Copyright (c) 2015年 Zhouboli. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface UberMap : NSObject

@property (strong, nonatomic) NSString *request_id;
@property (strong, nonatomic) NSString *href;

- (instancetype) initWithDictionary:(NSDictionary *)dictionary;

@end
23 changes: 23 additions & 0 deletions UberKit/Model/UberMap.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// UberMap.m
// Bobo
//
// Created by Zhouboli on 15/7/12.
// Copyright (c) 2015年 Zhouboli. All rights reserved.
//

#import "UberMap.h"

@implementation UberMap

- (instancetype) initWithDictionary:(NSDictionary *)dictionary
{
self = [super init];
if (self) {
_request_id = [dictionary objectForKey:@"request_id"];
_href = [dictionary objectForKey:@"href"];
}
return self;
}

@end
31 changes: 31 additions & 0 deletions UberKit/Model/UberReceipt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// UberReceipt.h
// Bobo
//
// Created by Zhouboli on 15/7/12.
// Copyright (c) 2015年 Zhouboli. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "UberCharge.h"

@interface UberReceipt : NSObject

@property (strong, nonatomic) NSString *request_id;
@property (strong, nonatomic) NSString *duration;
@property (strong, nonatomic) NSString *distance;
@property (strong, nonatomic) NSString *distance_label;
@property (strong, nonatomic) NSString *currency_code;

@property (strong, nonatomic) NSMutableArray *charges;
@property (strong, nonatomic) NSMutableArray *charge_adjustments;
@property (strong, nonatomic) UberCharge *surge_charge;

@property (nonatomic) float normal_fare;
@property (nonatomic) float subtotal;
@property (nonatomic) float total_charged;
@property (nonatomic) float total_owed;

- (instancetype) initWithDictionary:(NSDictionary *)dictionary;

@end
40 changes: 40 additions & 0 deletions UberKit/Model/UberReceipt.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// UberReceipt.m
// Bobo
//
// Created by Zhouboli on 15/7/12.
// Copyright (c) 2015年 Zhouboli. All rights reserved.
//

#import "UberReceipt.h"

@implementation UberReceipt

- (instancetype) initWithDictionary:(NSDictionary *)dictionary
{
self = [super init];
if (self) {
_request_id = [dictionary objectForKey:@"request_id"];
_normal_fare = [[dictionary objectForKey:@"normal_fare"] floatValue];
_subtotal = [[dictionary objectForKey:@"subtotal"] floatValue];
_total_charged = [[dictionary objectForKey:@"total_charged"] floatValue];
_total_owed = [[dictionary objectForKey:@"total_owed"] floatValue];
_currency_code = [dictionary objectForKey:@"currency_code"];
_duration = [dictionary objectForKey:@"duration"];
_distance = [dictionary objectForKey:@"distance"];
_distance_label = [dictionary objectForKey:@"distance_label"];
if (![dictionary[@"charges"] isEqual:[NSNull null]]) {
for (UberCharge *charge in [dictionary objectForKey:@"charges"]) {
[_charges addObject:charge];
}
}
if (![dictionary[@"charge_adjustments"] isEqual:[NSNull null]]) {
for (UberCharge *charge in [dictionary objectForKey:@"charge_adjustments"]) {
[_charge_adjustments addObject:charge];
}
}
}
return self;
}

@end
26 changes: 26 additions & 0 deletions UberKit/Model/UberRequest.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// UberRequest.h
// Pods
//
// Created by Zhouboli on 15/7/10.
//
//

#import <Foundation/Foundation.h>
#import "UberDriver.h"
#import "UberLocation.h"
#import "UberVehicle.h"

@interface UberRequest : NSObject

@property (strong, nonatomic) NSString *request_id; //The unique ID of the Request.
@property (strong, nonatomic) NSString *status; //The status of the Request indicating state.
@property (strong, nonatomic) UberDriver *driver; //The object that contains driver details.
@property (strong, nonatomic) UberVehicle *vehicle; //The object that contains vehicle details.
@property (strong, nonatomic) UberLocation *location; //The object that contains the location information of the vehicle and driver.
@property (nonatomic) NSInteger eta; //The estimated time of vehicle arrival in minutes.
@property (nonatomic) float surge_multiplier; //The surge pricing multiplier used to calculate the increased price of a Request. A multiplier of 1.0 means surge pricing is not in effect.

- (instancetype) initWithDictionary:(NSDictionary *)dictionary;

@end
Loading