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 Request Details API #22

Open
wants to merge 16 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.
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
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
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
34 changes: 34 additions & 0 deletions UberKit/Model/UberRequest.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// UberRequest.m
// Pods
//
// Created by Zhouboli on 15/7/10.
//
//

#import "UberRequest.h"

@implementation UberRequest

- (instancetype) initWithDictionary:(NSDictionary *)dictionary
{
self = [super init];
if (self) {
_request_id = dictionary[@"request_id"];
_status = dictionary[@"status"];
if (![dictionary[@"driver"] isEqual:[NSNull null]]) {
_driver = [[UberDriver alloc] initWithDictionary:dictionary[@"driver"]];
}
if (![dictionary[@"vehicle"] isEqual:[NSNull null]]) {
_vehicle = [[UberVehicle alloc] initWithDictionary:dictionary[@"vehicle"]];
}
if (![dictionary[@"location"] isEqual:[NSNull null]]) {
_location = [[UberLocation alloc] initWithDictionary:dictionary[@"location"]];
}
_eta = [dictionary[@"eta"] integerValue];
_surge_multiplier = [dictionary[@"surge_multiplier"] floatValue];
}
return self;
}

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

#import <Foundation/Foundation.h>

@interface UberSurgeConfirmation : NSObject

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

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

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

#import "UberSurgeConfirmation.h"

@implementation UberSurgeConfirmation

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

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

#import <Foundation/Foundation.h>

@interface UberSurgeError : NSObject

@property (strong, nonatomic) NSString *status;
@property (strong, nonatomic) NSString *code;
@property (strong, nonatomic) NSString *title;

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

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

#import "UberSurgeError.h"

@implementation UberSurgeError

- (instancetype) initWithDictionary:(NSDictionary *)dictionary
{
self = [super init];
if (self) {
_status = [dictionary objectForKey:@"status"];
_code = [dictionary objectForKey:@"code"];
_title = [dictionary objectForKey:@"title"];
}
return self;
}

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

#import <Foundation/Foundation.h>
#import "UberSurgeConfirmation.h"
#import "UberSurgeError.h"

@interface UberSurgeErrorResponse : NSObject

@property (strong, nonatomic) UberSurgeConfirmation *surge_confirmation;
@property (strong, nonatomic) NSMutableArray *errors;

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

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

#import "UberSurgeErrorResponse.h"

@implementation UberSurgeErrorResponse

- (instancetype)initWithDictionary:(NSDictionary *)dictionary
{
self = [super init];
if (self) {
if (![dictionary[@"meta"] isEqual:[NSNull null]]) {
if (![dictionary[@"meta"][@"surge_confirmation"] isEqual:[NSNull null]]) {
_surge_confirmation = dictionary[@"meta"][@"surge_confirmation"];
}
}
if (![[dictionary objectForKey:@"errors"] isEqual:[NSNull null]]) {
for (NSDictionary *error in [dictionary objectForKey:@"errors"]) {
UberSurgeError *surgeError = [[UberSurgeError alloc] initWithDictionary:error];
[_errors addObject:surgeError];
}
}
}
return self;
}

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

#import <Foundation/Foundation.h>

@interface UberVehicle : NSObject

@property (strong, nonatomic) NSString *make; //The vehicle make or brand.
@property (strong, nonatomic) NSString *model; //The vehicle model or type.
@property (strong, nonatomic) NSString *license_plate; //The license plate number of the vehicle.
@property (strong, nonatomic) NSString *picture_url; //The URL to a stock photo of the vehicle (may be null).

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

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

#import "UberVehicle.h"

@implementation UberVehicle

- (instancetype) initWithDictionary:(NSDictionary *)dictionary
{
self = [super init];
if (self) {
_make = dictionary[@"make"];
_model = dictionary[@"model"];
_license_plate = dictionary[@"license_plate"];
_picture_url = dictionary[@"picture_url"];
}
return self;
}

@end
10 changes: 10 additions & 0 deletions UberKit/UberKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#import "UberActivity.h"
#import "UberProfile.h"
#import "UberPromotion.h"
#import "UberRequest.h"

@class UberKit;

Expand All @@ -45,6 +46,7 @@
typedef void (^CompletionHandler) (NSArray *resultsArray, NSURLResponse *response, NSError *error);
typedef void (^ProfileHandler) (UberProfile *profile, NSURLResponse *response, NSError *error);
typedef void (^PromotionHandler) (UberPromotion *promotion, NSURLResponse *response, NSError *error);
typedef void (^RequestHandler) (UberRequest *requestResult, UberSurgeErrorResponse *surgeErrorResponse, NSURLResponse *response, NSError *error);

@interface UberKit : NSObject <UIWebViewDelegate>

Expand Down Expand Up @@ -98,4 +100,12 @@ typedef void (^PromotionHandler) (UberPromotion *promotion, NSURLResponse *respo

- (void) openUberApp;

#pragma mark - Request

- (void) getResponseForRequestWithParameters:(NSDictionary *)params withCompletionHandler:(RequestHandler)handler;

#pragma mark - Request Details

- (void) getDetailsForRequestId:(NSString *)requestId withCompletionHandler:(RequestHandler)handler;

@end
Loading