From 79367c99e889481dc1a76982e04d6184e016a74c Mon Sep 17 00:00:00 2001 From: Nelson LeDuc Date: Wed, 1 Apr 2015 05:06:10 -0500 Subject: [PATCH 01/17] Update scopes to the current ones used by the API --- Classes/BDKAutomatic.m | 21 ++++++++++----------- Classes/BDKAutomaticScopes.h | 21 ++++++++++----------- Classes/BDKAutomaticScopes.m | 21 ++++++++++----------- 3 files changed, 30 insertions(+), 33 deletions(-) diff --git a/Classes/BDKAutomatic.m b/Classes/BDKAutomatic.m index 8203fe7..a4f8c02 100644 --- a/Classes/BDKAutomatic.m +++ b/Classes/BDKAutomatic.m @@ -50,18 +50,17 @@ - (void)setToken:(BDKAutomaticToken *)token { #pragma mark - Authentication and authorization - (NSURLRequest *)authenticationRequestForAllScopes { - NSArray *scopes = @[BDKAutomaticScopeIgnitionOff, - BDKAutomaticScopeIgnitionOn, + NSArray *scopes = @[BDKAutomaticScopePublic, + BDKAutomaticScopeUserProfile, + BDKAutomaticScopeUserFollow, BDKAutomaticScopeLocation, - BDKAutomaticScopeMILOff, - BDKAutomaticScopeMILOn, - BDKAutomaticScopeNotificationHardAcceleration, - BDKAutomaticScopeNotificationHardBrake, - BDKAutomaticScopeNotificationSpeeding, - BDKAutomaticScopeParkingChanged, - BDKAutomaticScopeRegionChanged, - BDKAutomaticScopeTripSummary, - BDKAutomaticScopeVehicle, + BDKAutomaticScopeCurrentLocation, + BDKAutomaticScopeVehicleProfile, + BDKAutomaticScopeVehicleEvents, + BDKAutomaticScopeVehicleVIN, + BDKAutomaticScopeTrip, + BDKAutomaticScopeBehavior, + BDKAutomaticScopeAdapterBasic ]; return [self authenticationRequestForScopes:scopes]; } diff --git a/Classes/BDKAutomaticScopes.h b/Classes/BDKAutomaticScopes.h index da76c9e..4d33752 100644 --- a/Classes/BDKAutomaticScopes.h +++ b/Classes/BDKAutomaticScopes.h @@ -8,15 +8,14 @@ @import Foundation; +extern NSString * const BDKAutomaticScopePublic; +extern NSString * const BDKAutomaticScopeUserProfile; +extern NSString * const BDKAutomaticScopeUserFollow; extern NSString * const BDKAutomaticScopeLocation; -extern NSString * const BDKAutomaticScopeVehicle; -extern NSString * const BDKAutomaticScopeTripSummary; -extern NSString * const BDKAutomaticScopeIgnitionOn; -extern NSString * const BDKAutomaticScopeIgnitionOff; -extern NSString * const BDKAutomaticScopeNotificationSpeeding; -extern NSString * const BDKAutomaticScopeNotificationHardBrake; -extern NSString * const BDKAutomaticScopeNotificationHardAcceleration; -extern NSString * const BDKAutomaticScopeRegionChanged; -extern NSString * const BDKAutomaticScopeParkingChanged; -extern NSString * const BDKAutomaticScopeMILOn; -extern NSString * const BDKAutomaticScopeMILOff; \ No newline at end of file +extern NSString * const BDKAutomaticScopeCurrentLocation; +extern NSString * const BDKAutomaticScopeVehicleProfile; +extern NSString * const BDKAutomaticScopeVehicleEvents; +extern NSString * const BDKAutomaticScopeVehicleVIN; +extern NSString * const BDKAutomaticScopeTrip; +extern NSString * const BDKAutomaticScopeBehavior; +extern NSString * const BDKAutomaticScopeAdapterBasic; diff --git a/Classes/BDKAutomaticScopes.m b/Classes/BDKAutomaticScopes.m index ba4a41e..58c6a4c 100644 --- a/Classes/BDKAutomaticScopes.m +++ b/Classes/BDKAutomaticScopes.m @@ -8,15 +8,14 @@ #import "BDKAutomaticScopes.h" +NSString * const BDKAutomaticScopePublic = @"scope:public"; +NSString * const BDKAutomaticScopeUserProfile = @"scope:user:profile"; +NSString * const BDKAutomaticScopeUserFollow = @"scope:user:follow"; NSString * const BDKAutomaticScopeLocation = @"scope:location"; -NSString * const BDKAutomaticScopeVehicle = @"scope:vehicle"; -NSString * const BDKAutomaticScopeTripSummary = @"scope:trip:summary"; -NSString * const BDKAutomaticScopeIgnitionOn = @"scope:ignition:on"; -NSString * const BDKAutomaticScopeIgnitionOff = @"scope:ignition:off"; -NSString * const BDKAutomaticScopeNotificationSpeeding = @"scope:notification:speeding"; -NSString * const BDKAutomaticScopeNotificationHardBrake = @"scope:notification:hard_brake"; -NSString * const BDKAutomaticScopeNotificationHardAcceleration = @"scope:notification:hard_accel"; -NSString * const BDKAutomaticScopeRegionChanged = @"scope:region:changed"; -NSString * const BDKAutomaticScopeParkingChanged = @"scope:parking:changed"; -NSString * const BDKAutomaticScopeMILOn = @"scope:mil:on"; -NSString * const BDKAutomaticScopeMILOff = @"scope:mil:off"; \ No newline at end of file +NSString * const BDKAutomaticScopeCurrentLocation = @"scope:current_location"; +NSString * const BDKAutomaticScopeVehicleProfile = @"scope:vehicle:profile"; +NSString * const BDKAutomaticScopeVehicleEvents = @"scope:vehicle:events"; +NSString * const BDKAutomaticScopeVehicleVIN = @"scope:vehicle:vin"; +NSString * const BDKAutomaticScopeTrip = @"scope:trip"; +NSString * const BDKAutomaticScopeBehavior = @"scope:behavior"; +NSString * const BDKAutomaticScopeAdapterBasic = @"scope:adapter:basic"; From 808a2bfd01b5794b62598cc796ed5f4b86e92e7c Mon Sep 17 00:00:00 2001 From: Nelson LeDuc Date: Wed, 1 Apr 2015 05:09:31 -0500 Subject: [PATCH 02/17] Fix podspec to support the correct AFNetworking --- BDKAutomatic.podspec | 3 +- .../BDKAutomatic.xcodeproj/project.pbxproj | 32 +++++++++++------ .../xcshareddata/BDKAutomatic.xccheckout | 10 +++--- Project/Podfile.lock | 35 ++++++++++--------- 4 files changed, 46 insertions(+), 34 deletions(-) diff --git a/BDKAutomatic.podspec b/BDKAutomatic.podspec index 573f1d1..767759f 100644 --- a/BDKAutomatic.podspec +++ b/BDKAutomatic.podspec @@ -13,8 +13,7 @@ Pod::Spec.new do |s| s.subspec 'Adapter' do |sub| sub.source_files = 'Classes/*.{h,m}' - sub.dependency 'AFNetworking/Serialization', '>= 2.0.0' - sub.dependency 'AFNetworking/NSURLSession', '>= 2.0.0' + sub.dependency 'AFNetworking/NSURLConnection', '~> 2.0' end s.subspec 'MKPolyline' do |sub| diff --git a/Project/BDKAutomatic.xcodeproj/project.pbxproj b/Project/BDKAutomatic.xcodeproj/project.pbxproj index a3590e9..713f5eb 100644 --- a/Project/BDKAutomatic.xcodeproj/project.pbxproj +++ b/Project/BDKAutomatic.xcodeproj/project.pbxproj @@ -41,7 +41,7 @@ /* Begin PBXFileReference section */ 02AB4A0C5C4A49C9A6CF5B50 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 5A6E3BC3E34B4B1480D24EF3 /* Pods-Specs.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Specs.xcconfig"; path = "Pods/Pods-Specs.xcconfig"; sourceTree = ""; }; + 70EB720583C2358271A8F2EC /* Pods-Specs.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Specs.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Specs/Pods-Specs.debug.xcconfig"; sourceTree = ""; }; B52A0D18188DED6C00C21D6C /* BDKAutomatic.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BDKAutomatic.app; sourceTree = BUILT_PRODUCTS_DIR; }; B52A0D1B188DED6C00C21D6C /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; B52A0D1D188DED6C00C21D6C /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; @@ -66,7 +66,9 @@ B5AA05DA189EE2E700F516D4 /* BDKTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BDKTableViewController.m; sourceTree = ""; }; B5B3F54C18A12FA00043E3CE /* BDKMapViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BDKMapViewController.h; sourceTree = ""; }; B5B3F54D18A12FA00043E3CE /* BDKMapViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BDKMapViewController.m; sourceTree = ""; }; - ED02175D452F4A59AE76AD72 /* Pods.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.xcconfig; path = Pods/Pods.xcconfig; sourceTree = ""; }; + DAA188196C9D81BE0DB0A0CB /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; + E93DE9D0A47914EF61C0E278 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; }; + F3F51D676EFA11B4330A349B /* Pods-Specs.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Specs.release.xcconfig"; path = "Pods/Target Support Files/Pods-Specs/Pods-Specs.release.xcconfig"; sourceTree = ""; }; FF614AE7C9B74202A6CD5D32 /* libPods-Specs.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Specs.a"; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -97,6 +99,17 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 08A565A7B3D8E0E4FA3AF060 /* Pods */ = { + isa = PBXGroup; + children = ( + E93DE9D0A47914EF61C0E278 /* Pods.debug.xcconfig */, + DAA188196C9D81BE0DB0A0CB /* Pods.release.xcconfig */, + 70EB720583C2358271A8F2EC /* Pods-Specs.debug.xcconfig */, + F3F51D676EFA11B4330A349B /* Pods-Specs.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; B52A0D0F188DED6B00C21D6C = { isa = PBXGroup; children = ( @@ -104,8 +117,7 @@ B52A0D1A188DED6C00C21D6C /* Frameworks */, B52A0D19188DED6C00C21D6C /* Products */, B536C10E188DED9C00C02470 /* Specs */, - ED02175D452F4A59AE76AD72 /* Pods.xcconfig */, - 5A6E3BC3E34B4B1480D24EF3 /* Pods-Specs.xcconfig */, + 08A565A7B3D8E0E4FA3AF060 /* Pods */, ); sourceTree = ""; }; @@ -288,7 +300,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Pods-resources.sh\"\n"; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n"; showEnvVarsInLog = 0; }; 8FFD181ED77E463B942022A1 /* Check Pods Manifest.lock */ = { @@ -318,7 +330,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Pods-Specs-resources.sh\"\n"; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Specs/Pods-Specs-resources.sh\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -448,7 +460,7 @@ }; B52A0D45188DED6C00C21D6C /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = ED02175D452F4A59AE76AD72 /* Pods.xcconfig */; + baseConfigurationReference = E93DE9D0A47914EF61C0E278 /* Pods.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; @@ -463,7 +475,7 @@ }; B52A0D46188DED6C00C21D6C /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = ED02175D452F4A59AE76AD72 /* Pods.xcconfig */; + baseConfigurationReference = DAA188196C9D81BE0DB0A0CB /* Pods.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; @@ -478,7 +490,7 @@ }; B52A0D48188DED6C00C21D6C /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 5A6E3BC3E34B4B1480D24EF3 /* Pods-Specs.xcconfig */; + baseConfigurationReference = 70EB720583C2358271A8F2EC /* Pods-Specs.debug.xcconfig */; buildSettings = { ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/BDKAutomatic.app/BDKAutomatic"; @@ -502,7 +514,7 @@ }; B52A0D49188DED6C00C21D6C /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 5A6E3BC3E34B4B1480D24EF3 /* Pods-Specs.xcconfig */; + baseConfigurationReference = F3F51D676EFA11B4330A349B /* Pods-Specs.release.xcconfig */; buildSettings = { ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/BDKAutomatic.app/BDKAutomatic"; diff --git a/Project/BDKAutomatic.xcworkspace/xcshareddata/BDKAutomatic.xccheckout b/Project/BDKAutomatic.xcworkspace/xcshareddata/BDKAutomatic.xccheckout index c1d5ca6..65d380f 100644 --- a/Project/BDKAutomatic.xcworkspace/xcshareddata/BDKAutomatic.xccheckout +++ b/Project/BDKAutomatic.xcworkspace/xcshareddata/BDKAutomatic.xccheckout @@ -10,29 +10,29 @@ BDKAutomatic IDESourceControlProjectOriginsDictionary - F4EF800C-BF02-422C-A4FE-BCDB47669C37 + 3CC2F2072B5DF56FA0EB852FD2A76AA6EC0162CF ssh://github.com/kreeger/BDKAutomatic.git IDESourceControlProjectPath Project/BDKAutomatic.xcworkspace IDESourceControlProjectRelativeInstallPathDictionary - F4EF800C-BF02-422C-A4FE-BCDB47669C37 + 3CC2F2072B5DF56FA0EB852FD2A76AA6EC0162CF ../.. IDESourceControlProjectURL ssh://github.com/kreeger/BDKAutomatic.git IDESourceControlProjectVersion - 110 + 111 IDESourceControlProjectWCCIdentifier - F4EF800C-BF02-422C-A4FE-BCDB47669C37 + 3CC2F2072B5DF56FA0EB852FD2A76AA6EC0162CF IDESourceControlProjectWCConfigurations IDESourceControlRepositoryExtensionIdentifierKey public.vcs.git IDESourceControlWCCIdentifierKey - F4EF800C-BF02-422C-A4FE-BCDB47669C37 + 3CC2F2072B5DF56FA0EB852FD2A76AA6EC0162CF IDESourceControlWCCName BDKAutomatic diff --git a/Project/Podfile.lock b/Project/Podfile.lock index 6d5f201..d11eb32 100644 --- a/Project/Podfile.lock +++ b/Project/Podfile.lock @@ -1,19 +1,20 @@ PODS: - - AFNetworking/NSURLConnection (2.0.3): + - AFNetworking/NSURLConnection (2.5.2): - AFNetworking/Reachability - AFNetworking/Security - AFNetworking/Serialization - - AFNetworking/NSURLSession (2.0.3): - - AFNetworking/NSURLConnection - - AFNetworking/Reachability (2.0.3) - - AFNetworking/Security (2.0.3) - - AFNetworking/Serialization (2.0.3) + - AFNetworking/Reachability (2.5.2) + - AFNetworking/Security (2.5.2) + - AFNetworking/Serialization (2.5.2) - BDKAutomatic (0.1.0): - - AFNetworking/NSURLSession (~> 2.0.0) - - AFNetworking/Serialization (~> 2.0.0) - - Expecta (HEAD based on 0.2.3) - - Reveal-iOS-SDK (1.0.3) - - Specta (HEAD based on 0.2.1) + - BDKAutomatic/Adapter (= 0.1.0) + - BDKAutomatic/MKPolyline (= 0.1.0) + - BDKAutomatic/Adapter (0.1.0): + - AFNetworking/NSURLConnection (~> 2.0) + - BDKAutomatic/MKPolyline (0.1.0) + - Expecta (HEAD based on 0.3.2) + - Reveal-iOS-SDK (1.5.1) + - Specta (HEAD based on 0.4.0) DEPENDENCIES: - BDKAutomatic (from `../BDKAutomatic.podspec`) @@ -26,10 +27,10 @@ EXTERNAL SOURCES: :path: ../BDKAutomatic.podspec SPEC CHECKSUMS: - AFNetworking: e499052cbf3d743e9bb727bb37adb9dc2547ba15 - BDKAutomatic: 6cec6aadfd72ed1b2c3de04fc30bbeb3ae64348a - Expecta: dbc4a27fabb853bdd2e907e33f11ee43a9a47d0c - Reveal-iOS-SDK: f2525cb560a564fdc086316e89ec45ced6977fd3 - Specta: 2d06220591110c6d9757d8be8ecf8e63aa40dc2a + AFNetworking: fefbce9660acb17f48ae0011292d4da0f457bf36 + BDKAutomatic: 773b5a584d4fcbe399e06cc0cc7cf9f2e0508244 + Expecta: 8c507baf13211207b1e9d0a741480600e6b4ed15 + Reveal-iOS-SDK: c9c55cad2729c85f6ced415f1b21857c9a2d8ef9 + Specta: a353759f073ffcc0a365b782fe4aaeac064c03c6 -COCOAPODS: 0.29.0 +COCOAPODS: 0.36.0 From f58ff9319056ba7bbe75793478fd52f0a96ebc1d Mon Sep 17 00:00:00 2001 From: Nelson LeDuc Date: Wed, 1 Apr 2015 05:09:59 -0500 Subject: [PATCH 03/17] Add convenience method for standard scopes since all is no longer the default --- Classes/BDKAutomatic.h | 1 + Classes/BDKAutomatic.m | 13 +++++++++++++ Project/Classes/BDKAuthViewController.m | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Classes/BDKAutomatic.h b/Classes/BDKAutomatic.h index e3a3e75..e3d49e8 100644 --- a/Classes/BDKAutomatic.h +++ b/Classes/BDKAutomatic.h @@ -36,6 +36,7 @@ typedef void(^BDKAutomaticTokenCompletionBlock)(NSError *error, BDKAutomaticToke #pragma mark - Authentication and authorization - (NSURLRequest *)authenticationRequestForAllScopes; +- (NSURLRequest *)authenticationRequestForStandardScopes; - (NSURLRequest *)authenticationRequestForScopes:(NSArray *)scopes; - (void)getAccessTokenForCode:(NSString *)code completion:(BDKAutomaticTokenCompletionBlock)completion; diff --git a/Classes/BDKAutomatic.m b/Classes/BDKAutomatic.m index a4f8c02..13f9309 100644 --- a/Classes/BDKAutomatic.m +++ b/Classes/BDKAutomatic.m @@ -65,6 +65,19 @@ - (NSURLRequest *)authenticationRequestForAllScopes { return [self authenticationRequestForScopes:scopes]; } +- (NSURLRequest *)authenticationRequestForStandardScopes +{ + NSArray *scopes = @[BDKAutomaticScopePublic, + BDKAutomaticScopeUserProfile, + BDKAutomaticScopeLocation, + BDKAutomaticScopeVehicleProfile, + BDKAutomaticScopeVehicleEvents, + BDKAutomaticScopeTrip, + BDKAutomaticScopeBehavior, + ]; + return [self authenticationRequestForScopes:scopes]; +} + - (NSURLRequest *)authenticationRequestForScopes:(NSArray *)scopes { NSDictionary *params = @{@"client_id": self.clientId, @"scope": [scopes componentsJoinedByString:@" "], diff --git a/Project/Classes/BDKAuthViewController.m b/Project/Classes/BDKAuthViewController.m index 71ba7ed..dd47389 100644 --- a/Project/Classes/BDKAuthViewController.m +++ b/Project/Classes/BDKAuthViewController.m @@ -37,7 +37,7 @@ - (void)viewDidLoad { [super viewDidLoad]; self.title = @"Login to Automatic"; - NSURLRequest *request = [self.automatic authenticationRequestForAllScopes]; + NSURLRequest *request = [self.automatic authenticationRequestForStandardScopes]; [self.webView loadRequest:request]; } From d1333e75bbebb97f784e967ebcbb3cd38b3f5801 Mon Sep 17 00:00:00 2001 From: Nelson LeDuc Date: Wed, 1 Apr 2015 05:18:31 -0500 Subject: [PATCH 04/17] Update to use the correct endpoints for the authentication --- Classes/BDKAutomatic.m | 9 ++++++--- .../BDKAutomatic.xcworkspace/contents.xcworkspacedata | 11 ++++++++++- .../xcshareddata/BDKAutomatic.xccheckout | 6 +++--- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Classes/BDKAutomatic.m b/Classes/BDKAutomatic.m index 13f9309..2cd1e00 100644 --- a/Classes/BDKAutomatic.m +++ b/Classes/BDKAutomatic.m @@ -10,6 +10,9 @@ #import "BDKAutomaticTrip.h" +static NSString * const kAutomaticAPIBaseURLString = @"https://api.automatic.com"; +static NSString * const kAutomaticAuthBaseURLString = @"https://accounts.automatic.com/oauth"; + @implementation BDKAutomatic @synthesize clientId = _clientId; @@ -28,7 +31,7 @@ - (instancetype)initWithClientId:(NSString *)clientId clientSecret:(NSString *)clientSecret redirectUrl:(NSURL *)redirectUrl token:(BDKAutomaticToken *)token { - self = [super initWithBaseURL:[NSURL URLWithString:@"https://api.automatic.com"]]; + self = [super initWithBaseURL:[NSURL URLWithString:kAutomaticAPIBaseURLString]]; if (!self) return nil; _clientId = clientId; @@ -89,7 +92,7 @@ - (NSURLRequest *)authenticationRequestForScopes:(NSArray *)scopes { [components addObject:[NSString stringWithFormat:@"%@=%@", key, value]]; }]; NSString *joinedParams = [components componentsJoinedByString:@"&"]; - NSString *baseURL = @"https://www.automatic.com/oauth/authorize"; + NSString *baseURL = [NSString stringWithFormat:@"%@/%@", kAutomaticAuthBaseURLString, @"authorize"]; NSString *fullUrl = [NSString stringWithFormat:@"%@?%@", baseURL, joinedParams]; NSLog(@"Generated URL %@", fullUrl); NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:fullUrl]]; @@ -97,7 +100,7 @@ - (NSURLRequest *)authenticationRequestForScopes:(NSArray *)scopes { } - (void)getAccessTokenForCode:(NSString *)code completion:(BDKAutomaticTokenCompletionBlock)completion { - NSString *url = @"https://www.automatic.com/oauth/access_token"; + NSString *url = [NSString stringWithFormat:@"%@/%@", kAutomaticAuthBaseURLString, @"access_token"]; NSDictionary *params = @{@"client_id": self.clientId, @"client_secret": self.clientSecret, @"code": code, diff --git a/Project/BDKAutomatic.xcworkspace/contents.xcworkspacedata b/Project/BDKAutomatic.xcworkspace/contents.xcworkspacedata index 54a9af6..01550a5 100644 --- a/Project/BDKAutomatic.xcworkspace/contents.xcworkspacedata +++ b/Project/BDKAutomatic.xcworkspace/contents.xcworkspacedata @@ -1 +1,10 @@ - \ No newline at end of file + + + + + + + diff --git a/Project/BDKAutomatic.xcworkspace/xcshareddata/BDKAutomatic.xccheckout b/Project/BDKAutomatic.xcworkspace/xcshareddata/BDKAutomatic.xccheckout index 65d380f..1092305 100644 --- a/Project/BDKAutomatic.xcworkspace/xcshareddata/BDKAutomatic.xccheckout +++ b/Project/BDKAutomatic.xcworkspace/xcshareddata/BDKAutomatic.xccheckout @@ -5,13 +5,13 @@ IDESourceControlProjectFavoriteDictionaryKey IDESourceControlProjectIdentifier - BD12A5E5-5D5A-4CFE-A6E4-762BB892EBD2 + 1D47559F-68FE-4535-A615-5DDC995BFEEF IDESourceControlProjectName BDKAutomatic IDESourceControlProjectOriginsDictionary 3CC2F2072B5DF56FA0EB852FD2A76AA6EC0162CF - ssh://github.com/kreeger/BDKAutomatic.git + github.com:NelsonLeDuc/BDKAutomatic.git IDESourceControlProjectPath Project/BDKAutomatic.xcworkspace @@ -21,7 +21,7 @@ ../.. IDESourceControlProjectURL - ssh://github.com/kreeger/BDKAutomatic.git + github.com:NelsonLeDuc/BDKAutomatic.git IDESourceControlProjectVersion 111 IDESourceControlProjectWCCIdentifier From d7fd614ab9e4f96477f54df949eb870851ecc97e Mon Sep 17 00:00:00 2001 From: Nelson LeDuc Date: Wed, 1 Apr 2015 18:21:23 -0500 Subject: [PATCH 05/17] Change to composition instead of subclassing --- Classes/BDKAutomatic.h | 12 +++++------- Classes/BDKAutomatic.m | 32 ++++++++++++++++++++++---------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/Classes/BDKAutomatic.h b/Classes/BDKAutomatic.h index e3d49e8..f4f2d31 100644 --- a/Classes/BDKAutomatic.h +++ b/Classes/BDKAutomatic.h @@ -8,20 +8,18 @@ @import Foundation; -#import - #import "BDKAutomaticScopes.h" #import "BDKAutomaticToken.h" typedef void(^BDKAutomaticCompletionBlock)(NSError *error, id responseObject); typedef void(^BDKAutomaticTokenCompletionBlock)(NSError *error, BDKAutomaticToken *token); -@interface BDKAutomatic : AFHTTPRequestOperationManager +@interface BDKAutomatic : NSObject -@property (readonly) NSString *clientId; -@property (readonly) NSString *clientSecret; -@property (readonly) NSURL *redirectUrl; -@property (strong, nonatomic) BDKAutomaticToken *token; +@property (nonatomic, strong, readonly) NSString *clientId; +@property (nonatomic, strong, readonly) NSString *clientSecret; +@property (nonatomic, strong, readonly) NSURL *redirectUrl; +@property (nonatomic, strong) BDKAutomaticToken *token; #pragma mark - Lifecycle diff --git a/Classes/BDKAutomatic.m b/Classes/BDKAutomatic.m index 2cd1e00..5fba489 100644 --- a/Classes/BDKAutomatic.m +++ b/Classes/BDKAutomatic.m @@ -9,10 +9,20 @@ #import "BDKAutomatic.h" #import "BDKAutomaticTrip.h" +#import static NSString * const kAutomaticAPIBaseURLString = @"https://api.automatic.com"; static NSString * const kAutomaticAuthBaseURLString = @"https://accounts.automatic.com/oauth"; +@interface BDKAutomatic () + +@property (nonatomic, strong, readwrite) NSString *clientId; +@property (nonatomic, strong, readwrite) NSString *clientSecret; +@property (nonatomic, strong, readwrite) NSURL *redirectUrl; +@property (nonatomic, strong) AFHTTPRequestOperationManager *operationManager; + +@end + @implementation BDKAutomatic @synthesize clientId = _clientId; @@ -31,13 +41,15 @@ - (instancetype)initWithClientId:(NSString *)clientId clientSecret:(NSString *)clientSecret redirectUrl:(NSURL *)redirectUrl token:(BDKAutomaticToken *)token { - self = [super initWithBaseURL:[NSURL URLWithString:kAutomaticAPIBaseURLString]]; - if (!self) return nil; - - _clientId = clientId; - _clientSecret = clientSecret; - _redirectUrl = redirectUrl; - [self setToken:token]; + self = [super init]; + if (self) + { + _operationManager = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:[NSURL URLWithString:kAutomaticAPIBaseURLString]]; + _clientId = clientId; + _clientSecret = clientSecret; + _redirectUrl = redirectUrl; + [self setToken:token]; + } return self; } @@ -47,7 +59,7 @@ - (instancetype)initWithClientId:(NSString *)clientId - (void)setToken:(BDKAutomaticToken *)token { _token = token; NSString *value = token ? [NSString stringWithFormat:@"token %@", token.accessToken] : @""; - [self.requestSerializer setValue:value forHTTPHeaderField:@"Authorization"]; + [self.operationManager.requestSerializer setValue:value forHTTPHeaderField:@"Authorization"]; } #pragma mark - Authentication and authorization @@ -105,7 +117,7 @@ - (void)getAccessTokenForCode:(NSString *)code completion:(BDKAutomaticTokenComp @"client_secret": self.clientSecret, @"code": code, @"grant_type": @"authorization_code"}; - [self POST:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { + [self.operationManager POST:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { self.token = [BDKAutomaticToken tokenWithDictionary:responseObject]; if (completion) { completion(nil, self.token); @@ -122,7 +134,7 @@ - (void)getAccessTokenForCode:(NSString *)code completion:(BDKAutomaticTokenComp - (void)getTrips:(BDKAutomaticCompletionBlock)completion { NSString *url = @"/v1/trips"; NSDictionary *params = @{}; - [self GET:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { + [self.operationManager GET:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { NSMutableArray *mResults = [NSMutableArray array]; [responseObject enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { [mResults addObject:[[BDKAutomaticTrip alloc] initWithAPIObject:obj]]; From 6b6545b9707fb4f07efbd587a7d27d01fff437d6 Mon Sep 17 00:00:00 2001 From: Nelson LeDuc Date: Wed, 1 Apr 2015 18:27:44 -0500 Subject: [PATCH 06/17] Add support for getting individual trips --- Classes/BDKAutomatic.h | 1 + Classes/BDKAutomatic.m | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/Classes/BDKAutomatic.h b/Classes/BDKAutomatic.h index f4f2d31..c249ba2 100644 --- a/Classes/BDKAutomatic.h +++ b/Classes/BDKAutomatic.h @@ -41,6 +41,7 @@ typedef void(^BDKAutomaticTokenCompletionBlock)(NSError *error, BDKAutomaticToke #pragma mark - Trip data - (void)getTrips:(BDKAutomaticCompletionBlock)completion; +- (void)getTripForId:(NSString *)identifier completion:(BDKAutomaticCompletionBlock)completion; @end diff --git a/Classes/BDKAutomatic.m b/Classes/BDKAutomatic.m index 5fba489..adb46f7 100644 --- a/Classes/BDKAutomatic.m +++ b/Classes/BDKAutomatic.m @@ -149,6 +149,22 @@ - (void)getTrips:(BDKAutomaticCompletionBlock)completion { }]; } +- (void)getTripForId:(NSString *)identifier completion:(BDKAutomaticCompletionBlock)completion +{ + NSString *url = [NSString stringWithFormat:@"%@%@", @"/v1/trips/", identifier]; + NSDictionary *params = @{}; + [self.operationManager GET:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { + BDKAutomaticTrip *trip = [[BDKAutomaticTrip alloc] initWithAPIObject:responseObject]; + if (completion) { + completion(nil, trip); + } + } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + if (completion) { + completion(error, operation.responseObject); + } + }]; +} + @end From 84d94cbecced509fa8bca421e728270af8f3c336 Mon Sep 17 00:00:00 2001 From: Nelson LeDuc Date: Wed, 1 Apr 2015 18:34:52 -0500 Subject: [PATCH 07/17] Move v1 into the base url --- Classes/BDKAutomatic.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Classes/BDKAutomatic.m b/Classes/BDKAutomatic.m index adb46f7..4ba74e4 100644 --- a/Classes/BDKAutomatic.m +++ b/Classes/BDKAutomatic.m @@ -11,7 +11,7 @@ #import "BDKAutomaticTrip.h" #import -static NSString * const kAutomaticAPIBaseURLString = @"https://api.automatic.com"; +static NSString * const kAutomaticAPIBaseURLString = @"https://api.automatic.com/v1"; static NSString * const kAutomaticAuthBaseURLString = @"https://accounts.automatic.com/oauth"; @interface BDKAutomatic () @@ -132,7 +132,7 @@ - (void)getAccessTokenForCode:(NSString *)code completion:(BDKAutomaticTokenComp #pragma mark - Trip data - (void)getTrips:(BDKAutomaticCompletionBlock)completion { - NSString *url = @"/v1/trips"; + NSString *url = @"trips"; NSDictionary *params = @{}; [self.operationManager GET:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { NSMutableArray *mResults = [NSMutableArray array]; @@ -151,7 +151,7 @@ - (void)getTrips:(BDKAutomaticCompletionBlock)completion { - (void)getTripForId:(NSString *)identifier completion:(BDKAutomaticCompletionBlock)completion { - NSString *url = [NSString stringWithFormat:@"%@%@", @"/v1/trips/", identifier]; + NSString *url = [NSString stringWithFormat:@"%@/%@", @"trips", identifier]; NSDictionary *params = @{}; [self.operationManager GET:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { BDKAutomaticTrip *trip = [[BDKAutomaticTrip alloc] initWithAPIObject:responseObject]; From 497911347bf9667e6ac463745ab0f7d9f170cfbf Mon Sep 17 00:00:00 2001 From: Nelson LeDuc Date: Wed, 1 Apr 2015 18:48:56 -0500 Subject: [PATCH 08/17] Fix the trip userId not getting set correctly --- Classes/BDKAutomaticObject.m | 2 +- Classes/BDKAutomaticTrip.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Classes/BDKAutomaticObject.m b/Classes/BDKAutomaticObject.m index 6cfddf8..ca3450d 100644 --- a/Classes/BDKAutomaticObject.m +++ b/Classes/BDKAutomaticObject.m @@ -48,7 +48,7 @@ - (void)updateWithAPIObject:(NSDictionary *)apiObject { } } } - id remoteValue = [apiObject valueForKey:value]; + id remoteValue = [apiObject valueForKeyPath:value]; if (remoteValue && ![remoteValue isEqual:[NSNull null]]) { [self setValue:remoteValue forKey:localName]; } diff --git a/Classes/BDKAutomaticTrip.h b/Classes/BDKAutomaticTrip.h index 8962c7b..9c0940d 100644 --- a/Classes/BDKAutomaticTrip.h +++ b/Classes/BDKAutomaticTrip.h @@ -30,7 +30,7 @@ @property (strong, nonatomic) NSDate *startTime; @property (strong, nonatomic) NSString *startTimeZone; @property (strong, nonatomic) NSURL *uri; -@property (strong, nonatomic) NSNumber *userId; +@property (strong, nonatomic) NSString *userId; @property (strong, nonatomic) BDKAutomaticVehicle *vehicle; @end From cc9a46eb61cce9555ec02139be456831ebe76714 Mon Sep 17 00:00:00 2001 From: Nelson LeDuc Date: Wed, 1 Apr 2015 18:49:26 -0500 Subject: [PATCH 09/17] Add support for getting the current user --- Classes/BDKAutomatic.h | 4 ++++ Classes/BDKAutomatic.m | 19 +++++++++++++++++++ Classes/BDKAutomaticUser.h | 18 ++++++++++++++++++ Classes/BDKAutomaticUser.m | 21 +++++++++++++++++++++ 4 files changed, 62 insertions(+) create mode 100644 Classes/BDKAutomaticUser.h create mode 100644 Classes/BDKAutomaticUser.m diff --git a/Classes/BDKAutomatic.h b/Classes/BDKAutomatic.h index c249ba2..823160d 100644 --- a/Classes/BDKAutomatic.h +++ b/Classes/BDKAutomatic.h @@ -43,6 +43,10 @@ typedef void(^BDKAutomaticTokenCompletionBlock)(NSError *error, BDKAutomaticToke - (void)getTrips:(BDKAutomaticCompletionBlock)completion; - (void)getTripForId:(NSString *)identifier completion:(BDKAutomaticCompletionBlock)completion; +#pragma mark - User data + +- (void)getUser:(BDKAutomaticCompletionBlock)completion; + @end diff --git a/Classes/BDKAutomatic.m b/Classes/BDKAutomatic.m index 4ba74e4..edd0b2c 100644 --- a/Classes/BDKAutomatic.m +++ b/Classes/BDKAutomatic.m @@ -9,6 +9,7 @@ #import "BDKAutomatic.h" #import "BDKAutomaticTrip.h" +#import "BDKAutomaticUser.h" #import static NSString * const kAutomaticAPIBaseURLString = @"https://api.automatic.com/v1"; @@ -165,6 +166,24 @@ - (void)getTripForId:(NSString *)identifier completion:(BDKAutomaticCompletionBl }]; } +#pragma mark - User data + +- (void)getUser:(BDKAutomaticCompletionBlock)completion +{ + NSString *url = @"user"; + NSDictionary *params = @{}; + [self.operationManager GET:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { + BDKAutomaticUser *user = [[BDKAutomaticUser alloc] initWithAPIObject:responseObject]; + if (completion) { + completion(nil, user); + } + } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + if (completion) { + completion(error, operation.responseObject); + } + }]; +} + @end diff --git a/Classes/BDKAutomaticUser.h b/Classes/BDKAutomaticUser.h new file mode 100644 index 0000000..633b4b6 --- /dev/null +++ b/Classes/BDKAutomaticUser.h @@ -0,0 +1,18 @@ +// +// BDKAutomaticUser.h +// Pods +// +// Created by Nelson LeDuc on 4/1/15. +// +// + +#import "BDKAutomaticObject.h" + +@interface BDKAutomaticUser : BDKAutomaticObject + +@property (nonatomic, strong) NSString *identifier; +@property (nonatomic, strong) NSString *firstName; +@property (nonatomic, strong) NSString *lastName; +@property (nonatomic, strong) NSString *email; + +@end diff --git a/Classes/BDKAutomaticUser.m b/Classes/BDKAutomaticUser.m new file mode 100644 index 0000000..aa54808 --- /dev/null +++ b/Classes/BDKAutomaticUser.m @@ -0,0 +1,21 @@ +// +// BDKAutomaticUser.m +// Pods +// +// Created by Nelson LeDuc on 4/1/15. +// +// + +#import "BDKAutomaticUser.h" + +@implementation BDKAutomaticUser + ++ (NSDictionary *)attributeMap { + return @{@"identifier": @"id", + @"firstName": @"first_name", + @"lastName": @"last_name", + @"email": @"email" + }; +} + +@end From dc03b6668bbb4b956a134c90a9a33eafc6424d68 Mon Sep 17 00:00:00 2001 From: Nelson LeDuc Date: Wed, 1 Apr 2015 18:56:11 -0500 Subject: [PATCH 10/17] Add support for getting users vehicles, all of them and by id. Add missing fields to the vehicle object --- Classes/BDKAutomatic.h | 5 +++++ Classes/BDKAutomatic.m | 38 +++++++++++++++++++++++++++++++++++ Classes/BDKAutomaticVehicle.h | 2 ++ Classes/BDKAutomaticVehicle.m | 2 ++ 4 files changed, 47 insertions(+) diff --git a/Classes/BDKAutomatic.h b/Classes/BDKAutomatic.h index 823160d..db8de31 100644 --- a/Classes/BDKAutomatic.h +++ b/Classes/BDKAutomatic.h @@ -47,6 +47,11 @@ typedef void(^BDKAutomaticTokenCompletionBlock)(NSError *error, BDKAutomaticToke - (void)getUser:(BDKAutomaticCompletionBlock)completion; +#pragma mark - Vehicle data + +- (void)getVehicles:(BDKAutomaticCompletionBlock)completion; +- (void)getVehicleForId:(NSString *)identifier completion:(BDKAutomaticCompletionBlock)completion; + @end diff --git a/Classes/BDKAutomatic.m b/Classes/BDKAutomatic.m index edd0b2c..4d84963 100644 --- a/Classes/BDKAutomatic.m +++ b/Classes/BDKAutomatic.m @@ -10,6 +10,7 @@ #import "BDKAutomaticTrip.h" #import "BDKAutomaticUser.h" +#import "BDKAutomaticVehicle.h" #import static NSString * const kAutomaticAPIBaseURLString = @"https://api.automatic.com/v1"; @@ -184,6 +185,43 @@ - (void)getUser:(BDKAutomaticCompletionBlock)completion }]; } +#pragma mark - Vehicle data + +- (void)getVehicles:(BDKAutomaticCompletionBlock)completion +{ + NSString *url = @"vehicles"; + NSDictionary *params = @{}; + [self.operationManager GET:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { + NSMutableArray *mResults = [NSMutableArray array]; + [responseObject enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + [mResults addObject:[[BDKAutomaticVehicle alloc] initWithAPIObject:obj]]; + }]; + if (completion) { + completion(nil, [mResults copy]); + } + } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + if (completion) { + completion(error, operation.responseObject); + } + }]; +} + +- (void)getVehicleForId:(NSString *)identifier completion:(BDKAutomaticCompletionBlock)completion +{ + NSString *url = [NSString stringWithFormat:@"%@/%@", @"vehicles", identifier]; + NSDictionary *params = @{}; + [self.operationManager GET:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { + BDKAutomaticVehicle *vehicle = [[BDKAutomaticVehicle alloc] initWithAPIObject:responseObject]; + if (completion) { + completion(nil, vehicle); + } + } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + if (completion) { + completion(error, operation.responseObject); + } + }]; +} + @end diff --git a/Classes/BDKAutomaticVehicle.h b/Classes/BDKAutomaticVehicle.h index 4d57f02..0efd6bb 100644 --- a/Classes/BDKAutomaticVehicle.h +++ b/Classes/BDKAutomaticVehicle.h @@ -15,5 +15,7 @@ @property (strong, nonatomic) NSString *make; @property (strong, nonatomic) NSString *model; @property (strong, nonatomic) NSNumber *year; +@property (strong, nonatomic) NSURL *uri; +@property (strong, nonatomic) NSString *color; @end diff --git a/Classes/BDKAutomaticVehicle.m b/Classes/BDKAutomaticVehicle.m index 79166af..f44e37a 100644 --- a/Classes/BDKAutomaticVehicle.m +++ b/Classes/BDKAutomaticVehicle.m @@ -18,6 +18,8 @@ + (NSDictionary *)attributeMap { @"make": @"make", @"model": @"model", @"year": @"year", + @"uri": @"uri", + @"color": @"color" }; } From 2b7d015a3ba5eebb55dfd122dd9aa9f6dc9dc1a8 Mon Sep 17 00:00:00 2001 From: Nelson LeDuc Date: Wed, 1 Apr 2015 22:22:12 -0500 Subject: [PATCH 11/17] Add support for promises --- BDKAutomatic.podspec | 5 ++ Classes/Promise/BDKAutomatic+Promise.h | 29 +++++++++++ Classes/Promise/BDKAutomatic+Promise.m | 66 ++++++++++++++++++++++++++ 3 files changed, 100 insertions(+) create mode 100644 Classes/Promise/BDKAutomatic+Promise.h create mode 100644 Classes/Promise/BDKAutomatic+Promise.m diff --git a/BDKAutomatic.podspec b/BDKAutomatic.podspec index 767759f..c605e51 100644 --- a/BDKAutomatic.podspec +++ b/BDKAutomatic.podspec @@ -20,4 +20,9 @@ Pod::Spec.new do |s| sub.source_files = 'Classes/MapKit/*.{h,m}' sub.frameworks = 'MapKit' end + + s.subspec 'Promise' do |sub| + sub.source_files = 'Classes/Promise/*.{h,m}' + sub.dependency 'PromiseKit/Promise' + end end diff --git a/Classes/Promise/BDKAutomatic+Promise.h b/Classes/Promise/BDKAutomatic+Promise.h new file mode 100644 index 0000000..e30160c --- /dev/null +++ b/Classes/Promise/BDKAutomatic+Promise.h @@ -0,0 +1,29 @@ +// +// BDKAutomatic+Promise.h +// Pods +// +// Created by Nelson LeDuc on 4/1/15. +// +// + +#import "BDKAutomatic.h" + +@class PMKPromise; + +@interface BDKAutomatic (Promise) + +#pragma mark - Trip data + +- (PMKPromise *)getTrips; +- (PMKPromise *)getTripForId:(NSString *)identifier; + +#pragma mark - User data + +- (PMKPromise *)getUser; + +#pragma mark - Vehicle data + +- (PMKPromise *)getVehicles; +- (PMKPromise *)getVehicleForId:(NSString *)identifier; + +@end diff --git a/Classes/Promise/BDKAutomatic+Promise.m b/Classes/Promise/BDKAutomatic+Promise.m new file mode 100644 index 0000000..92a6777 --- /dev/null +++ b/Classes/Promise/BDKAutomatic+Promise.m @@ -0,0 +1,66 @@ +// +// BDKAutomatic+Promise.m +// Pods +// +// Created by Nelson LeDuc on 4/1/15. +// +// + +#import "BDKAutomatic+Promise.h" + +#import + +@implementation BDKAutomatic (Promise) + +#pragma mark - Trip data + +- (PMKPromise *)getTrips +{ + return [PMKPromise promiseWithResolver:^(PMKResolver resolve) { + [self getTrips:^(NSError *error, id responseObject) { + resolve(responseObject ?: error); + }]; + }]; +} + +- (PMKPromise *)getTripForId:(NSString *)identifier +{ + return [PMKPromise promiseWithResolver:^(PMKResolver resolve) { + [self getTripForId:identifier completion:^(NSError *error, id responseObject) { + resolve(responseObject ?: error); + }]; + }]; +} + +#pragma mark - User data + +- (PMKPromise *)getUser +{ + return [PMKPromise promiseWithResolver:^(PMKResolver resolve) { + [self getUser:^(NSError *error, id responseObject) { + resolve(responseObject ?: error); + }]; + }]; +} + +#pragma mark - Vehicle data + +- (PMKPromise *)getVehicles +{ + return [PMKPromise promiseWithResolver:^(PMKResolver resolve) { + [self getVehicles:^(NSError *error, id responseObject) { + resolve(responseObject ?: error); + }]; + }]; +} + +- (PMKPromise *)getVehicleForId:(NSString *)identifier +{ + return [PMKPromise promiseWithResolver:^(PMKResolver resolve) { + [self getVehicleForId:identifier completion:^(NSError *error, id responseObject) { + resolve(responseObject ?: error); + }]; + }]; +} + +@end From d5d640080c0ab551183c41fb5ed957b3ab507f98 Mon Sep 17 00:00:00 2001 From: Nelson LeDuc Date: Sat, 4 Apr 2015 04:58:07 -0500 Subject: [PATCH 12/17] Change the prefix for all the files --- Classes/BDKAutomaticScopes.h | 21 ---- Classes/BDKAutomaticScopes.m | 21 ---- ...dString.h => MKPolyline+NLEncodedString.h} | 2 +- ...dString.m => MKPolyline+NLEncodedString.m} | 4 +- Classes/{BDKAutomatic.h => NLAutomatic.h} | 30 +++--- Classes/{BDKAutomatic.m => NLAutomatic.m} | 80 +++++++-------- ...KAutomaticObject.h => NLAutomaticObject.h} | 4 +- ...KAutomaticObject.m => NLAutomaticObject.m} | 8 +- Classes/NLAutomaticScopes.h | 21 ++++ Classes/NLAutomaticScopes.m | 21 ++++ ...omaticTerminus.h => NLAutomaticTerminus.h} | 6 +- ...omaticTerminus.m => NLAutomaticTerminus.m} | 8 +- ...BDKAutomaticToken.h => NLAutomaticToken.h} | 4 +- ...BDKAutomaticToken.m => NLAutomaticToken.m} | 8 +- .../{BDKAutomaticTrip.h => NLAutomaticTrip.h} | 14 +-- .../{BDKAutomaticTrip.m => NLAutomaticTrip.m} | 14 +-- .../{BDKAutomaticUser.h => NLAutomaticUser.h} | 6 +- .../{BDKAutomaticUser.m => NLAutomaticUser.m} | 6 +- ...utomaticVehicle.h => NLAutomaticVehicle.h} | 6 +- ...utomaticVehicle.m => NLAutomaticVehicle.m} | 8 +- ...omatic+Promise.h => NLAutomatic+Promise.h} | 6 +- ...omatic+Promise.m => NLAutomatic+Promise.m} | 6 +- BDKAutomatic.podspec => NLAutomatic.podspec | 8 +- .../contents.xcworkspacedata | 2 +- Project/Classes/BDKAuthViewController.h | 20 ---- .../Classes/BDKAutomaticSecrets.plist.example | 12 --- Project/Classes/BDKMapViewController.h | 15 --- Project/Classes/Info.plist | 2 +- .../{BDKAppDelegate.h => NLAppDelegate.h} | 10 +- .../{BDKAppDelegate.m => NLAppDelegate.m} | 48 ++++----- Project/Classes/NLAuthViewController.h | 20 ++++ ...iewController.m => NLAuthViewController.m} | 18 ++-- Project/Classes/NLMapViewController.h | 15 +++ ...ViewController.m => NLMapViewController.m} | 16 +-- ...ewController.h => NLTableViewController.h} | 12 +-- ...ewController.m => NLTableViewController.m} | 26 ++--- Project/Classes/main.m | 6 +- .../project.pbxproj | 98 +++++++++---------- .../contents.xcworkspacedata | 0 .../xcschemes/NLAutomatic.xcscheme} | 34 ++++--- Project/Podfile | 4 +- Project/Podfile.lock | 29 +++--- ...BDKAutomaticTests.m => NLAutomaticTests.m} | 8 +- 43 files changed, 348 insertions(+), 359 deletions(-) delete mode 100644 Classes/BDKAutomaticScopes.h delete mode 100644 Classes/BDKAutomaticScopes.m rename Classes/MapKit/{MKPolyline+BDKEncodedString.h => MKPolyline+NLEncodedString.h} (79%) rename Classes/MapKit/{MKPolyline+BDKEncodedString.m => MKPolyline+NLEncodedString.m} (95%) rename Classes/{BDKAutomatic.h => NLAutomatic.h} (55%) rename Classes/{BDKAutomatic.m => NLAutomatic.m} (75%) rename Classes/{BDKAutomaticObject.h => NLAutomaticObject.h} (79%) rename Classes/{BDKAutomaticObject.m => NLAutomaticObject.m} (93%) create mode 100644 Classes/NLAutomaticScopes.h create mode 100644 Classes/NLAutomaticScopes.m rename Classes/{BDKAutomaticTerminus.h => NLAutomaticTerminus.h} (71%) rename Classes/{BDKAutomaticTerminus.m => NLAutomaticTerminus.m} (79%) rename Classes/{BDKAutomaticToken.h => NLAutomaticToken.h} (86%) rename Classes/{BDKAutomaticToken.m => NLAutomaticToken.m} (94%) rename Classes/{BDKAutomaticTrip.h => NLAutomaticTrip.h} (73%) rename Classes/{BDKAutomaticTrip.m => NLAutomaticTrip.m} (81%) rename Classes/{BDKAutomaticUser.h => NLAutomaticUser.h} (72%) rename Classes/{BDKAutomaticUser.m => NLAutomaticUser.m} (75%) rename Classes/{BDKAutomaticVehicle.h => NLAutomaticVehicle.h} (78%) rename Classes/{BDKAutomaticVehicle.m => NLAutomaticVehicle.m} (82%) rename Classes/Promise/{BDKAutomatic+Promise.h => NLAutomatic+Promise.h} (80%) rename Classes/Promise/{BDKAutomatic+Promise.m => NLAutomatic+Promise.m} (93%) rename BDKAutomatic.podspec => NLAutomatic.podspec (69%) delete mode 100644 Project/Classes/BDKAuthViewController.h delete mode 100644 Project/Classes/BDKAutomaticSecrets.plist.example delete mode 100644 Project/Classes/BDKMapViewController.h rename Project/Classes/{BDKAppDelegate.h => NLAppDelegate.h} (51%) rename Project/Classes/{BDKAppDelegate.m => NLAppDelegate.m} (61%) create mode 100644 Project/Classes/NLAuthViewController.h rename Project/Classes/{BDKAuthViewController.m => NLAuthViewController.m} (85%) create mode 100644 Project/Classes/NLMapViewController.h rename Project/Classes/{BDKMapViewController.m => NLMapViewController.m} (91%) rename Project/Classes/{BDKTableViewController.h => NLTableViewController.h} (50%) rename Project/Classes/{BDKTableViewController.m => NLTableViewController.m} (89%) rename Project/{BDKAutomatic.xcodeproj => NLAutomatic.xcodeproj}/project.pbxproj (82%) rename Project/{BDKAutomatic.xcodeproj => NLAutomatic.xcodeproj}/project.xcworkspace/contents.xcworkspacedata (100%) rename Project/{BDKAutomatic.xcodeproj/xcshareddata/xcschemes/BDKAutomatic.xcscheme => NLAutomatic.xcodeproj/xcshareddata/xcschemes/NLAutomatic.xcscheme} (76%) rename Project/Specs/{BDKAutomaticTests.m => NLAutomaticTests.m} (81%) diff --git a/Classes/BDKAutomaticScopes.h b/Classes/BDKAutomaticScopes.h deleted file mode 100644 index 4d33752..0000000 --- a/Classes/BDKAutomaticScopes.h +++ /dev/null @@ -1,21 +0,0 @@ -// -// BDKAutomaticScopes.h -// Pods -// -// Created by Ben Kreeger on 2/2/14. -// Copyright (c) 2014 Ben Kreeger. All rights reserved. -// - -@import Foundation; - -extern NSString * const BDKAutomaticScopePublic; -extern NSString * const BDKAutomaticScopeUserProfile; -extern NSString * const BDKAutomaticScopeUserFollow; -extern NSString * const BDKAutomaticScopeLocation; -extern NSString * const BDKAutomaticScopeCurrentLocation; -extern NSString * const BDKAutomaticScopeVehicleProfile; -extern NSString * const BDKAutomaticScopeVehicleEvents; -extern NSString * const BDKAutomaticScopeVehicleVIN; -extern NSString * const BDKAutomaticScopeTrip; -extern NSString * const BDKAutomaticScopeBehavior; -extern NSString * const BDKAutomaticScopeAdapterBasic; diff --git a/Classes/BDKAutomaticScopes.m b/Classes/BDKAutomaticScopes.m deleted file mode 100644 index 58c6a4c..0000000 --- a/Classes/BDKAutomaticScopes.m +++ /dev/null @@ -1,21 +0,0 @@ -// -// BDKAutomaticScopes.m -// Pods -// -// Created by Ben Kreeger on 2/2/14. -// Copyright (c) 2014 Ben Kreeger. All rights reserved. -// - -#import "BDKAutomaticScopes.h" - -NSString * const BDKAutomaticScopePublic = @"scope:public"; -NSString * const BDKAutomaticScopeUserProfile = @"scope:user:profile"; -NSString * const BDKAutomaticScopeUserFollow = @"scope:user:follow"; -NSString * const BDKAutomaticScopeLocation = @"scope:location"; -NSString * const BDKAutomaticScopeCurrentLocation = @"scope:current_location"; -NSString * const BDKAutomaticScopeVehicleProfile = @"scope:vehicle:profile"; -NSString * const BDKAutomaticScopeVehicleEvents = @"scope:vehicle:events"; -NSString * const BDKAutomaticScopeVehicleVIN = @"scope:vehicle:vin"; -NSString * const BDKAutomaticScopeTrip = @"scope:trip"; -NSString * const BDKAutomaticScopeBehavior = @"scope:behavior"; -NSString * const BDKAutomaticScopeAdapterBasic = @"scope:adapter:basic"; diff --git a/Classes/MapKit/MKPolyline+BDKEncodedString.h b/Classes/MapKit/MKPolyline+NLEncodedString.h similarity index 79% rename from Classes/MapKit/MKPolyline+BDKEncodedString.h rename to Classes/MapKit/MKPolyline+NLEncodedString.h index 001c4e5..5af4494 100644 --- a/Classes/MapKit/MKPolyline+BDKEncodedString.h +++ b/Classes/MapKit/MKPolyline+NLEncodedString.h @@ -1,6 +1,6 @@ @import MapKit; -@interface MKPolyline (BDKEncodedString) +@interface MKPolyline (NLEncodedString) /** Praise be to http://stackoverflow.com/a/9219856/194869 diff --git a/Classes/MapKit/MKPolyline+BDKEncodedString.m b/Classes/MapKit/MKPolyline+NLEncodedString.m similarity index 95% rename from Classes/MapKit/MKPolyline+BDKEncodedString.m rename to Classes/MapKit/MKPolyline+NLEncodedString.m index cbd41fd..04c6ddb 100644 --- a/Classes/MapKit/MKPolyline+BDKEncodedString.m +++ b/Classes/MapKit/MKPolyline+NLEncodedString.m @@ -1,6 +1,6 @@ -#import "MKPolyline+BDKEncodedString.h" +#import "MKPolyline+NLEncodedString.h" -@implementation MKPolyline (BDKEncodedString) +@implementation MKPolyline (NLEncodedString) + (MKPolyline *)polylineWithEncodedString:(NSString *)encodedString { const char *bytes = [encodedString UTF8String]; diff --git a/Classes/BDKAutomatic.h b/Classes/NLAutomatic.h similarity index 55% rename from Classes/BDKAutomatic.h rename to Classes/NLAutomatic.h index db8de31..3c77bec 100644 --- a/Classes/BDKAutomatic.h +++ b/Classes/NLAutomatic.h @@ -1,6 +1,6 @@ // -// BDKAutomatic.h -// BDKAutomatic +// NLAutomatic.h +// NLAutomatic // // Created by Ben Kreeger on 1/20/14. // Copyright (c) 2014 Ben Kreeger. All rights reserved. @@ -8,18 +8,18 @@ @import Foundation; -#import "BDKAutomaticScopes.h" -#import "BDKAutomaticToken.h" +#import "NLAutomaticScopes.h" +#import "NLAutomaticToken.h" -typedef void(^BDKAutomaticCompletionBlock)(NSError *error, id responseObject); -typedef void(^BDKAutomaticTokenCompletionBlock)(NSError *error, BDKAutomaticToken *token); +typedef void(^NLAutomaticCompletionBlock)(NSError *error, id responseObject); +typedef void(^NLAutomaticTokenCompletionBlock)(NSError *error, NLAutomaticToken *token); -@interface BDKAutomatic : NSObject +@interface NLAutomatic : NSObject @property (nonatomic, strong, readonly) NSString *clientId; @property (nonatomic, strong, readonly) NSString *clientSecret; @property (nonatomic, strong, readonly) NSURL *redirectUrl; -@property (nonatomic, strong) BDKAutomaticToken *token; +@property (nonatomic, strong) NLAutomaticToken *token; #pragma mark - Lifecycle @@ -29,28 +29,28 @@ typedef void(^BDKAutomaticTokenCompletionBlock)(NSError *error, BDKAutomaticToke - (instancetype)initWithClientId:(NSString *)clientId clientSecret:(NSString *)clientSecret redirectUrl:(NSURL *)redirectUrl - token:(BDKAutomaticToken *)token; + token:(NLAutomaticToken *)token; #pragma mark - Authentication and authorization - (NSURLRequest *)authenticationRequestForAllScopes; - (NSURLRequest *)authenticationRequestForStandardScopes; - (NSURLRequest *)authenticationRequestForScopes:(NSArray *)scopes; -- (void)getAccessTokenForCode:(NSString *)code completion:(BDKAutomaticTokenCompletionBlock)completion; +- (void)getAccessTokenForCode:(NSString *)code completion:(NLAutomaticTokenCompletionBlock)completion; #pragma mark - Trip data -- (void)getTrips:(BDKAutomaticCompletionBlock)completion; -- (void)getTripForId:(NSString *)identifier completion:(BDKAutomaticCompletionBlock)completion; +- (void)getTrips:(NLAutomaticCompletionBlock)completion; +- (void)getTripForId:(NSString *)identifier completion:(NLAutomaticCompletionBlock)completion; #pragma mark - User data -- (void)getUser:(BDKAutomaticCompletionBlock)completion; +- (void)getUser:(NLAutomaticCompletionBlock)completion; #pragma mark - Vehicle data -- (void)getVehicles:(BDKAutomaticCompletionBlock)completion; -- (void)getVehicleForId:(NSString *)identifier completion:(BDKAutomaticCompletionBlock)completion; +- (void)getVehicles:(NLAutomaticCompletionBlock)completion; +- (void)getVehicleForId:(NSString *)identifier completion:(NLAutomaticCompletionBlock)completion; @end diff --git a/Classes/BDKAutomatic.m b/Classes/NLAutomatic.m similarity index 75% rename from Classes/BDKAutomatic.m rename to Classes/NLAutomatic.m index 4d84963..80ff363 100644 --- a/Classes/BDKAutomatic.m +++ b/Classes/NLAutomatic.m @@ -1,22 +1,22 @@ // -// BDKAutomatic.m -// BDKAutomatic +// NLAutomatic.m +// NLAutomatic // // Created by Ben Kreeger on 1/20/14. // Copyright (c) 2014 Ben Kreeger. All rights reserved. // -#import "BDKAutomatic.h" +#import "NLAutomatic.h" -#import "BDKAutomaticTrip.h" -#import "BDKAutomaticUser.h" -#import "BDKAutomaticVehicle.h" +#import "NLAutomaticTrip.h" +#import "NLAutomaticUser.h" +#import "NLAutomaticVehicle.h" #import static NSString * const kAutomaticAPIBaseURLString = @"https://api.automatic.com/v1"; static NSString * const kAutomaticAuthBaseURLString = @"https://accounts.automatic.com/oauth"; -@interface BDKAutomatic () +@interface NLAutomatic () @property (nonatomic, strong, readwrite) NSString *clientId; @property (nonatomic, strong, readwrite) NSString *clientSecret; @@ -25,7 +25,7 @@ @interface BDKAutomatic () @end -@implementation BDKAutomatic +@implementation NLAutomatic @synthesize clientId = _clientId; @synthesize clientSecret = _clientSecret; @@ -42,7 +42,7 @@ - (instancetype)initWithClientId:(NSString *)clientId - (instancetype)initWithClientId:(NSString *)clientId clientSecret:(NSString *)clientSecret redirectUrl:(NSURL *)redirectUrl - token:(BDKAutomaticToken *)token { + token:(NLAutomaticToken *)token { self = [super init]; if (self) { @@ -58,7 +58,7 @@ - (instancetype)initWithClientId:(NSString *)clientId #pragma mark - Properties -- (void)setToken:(BDKAutomaticToken *)token { +- (void)setToken:(NLAutomaticToken *)token { _token = token; NSString *value = token ? [NSString stringWithFormat:@"token %@", token.accessToken] : @""; [self.operationManager.requestSerializer setValue:value forHTTPHeaderField:@"Authorization"]; @@ -67,30 +67,30 @@ - (void)setToken:(BDKAutomaticToken *)token { #pragma mark - Authentication and authorization - (NSURLRequest *)authenticationRequestForAllScopes { - NSArray *scopes = @[BDKAutomaticScopePublic, - BDKAutomaticScopeUserProfile, - BDKAutomaticScopeUserFollow, - BDKAutomaticScopeLocation, - BDKAutomaticScopeCurrentLocation, - BDKAutomaticScopeVehicleProfile, - BDKAutomaticScopeVehicleEvents, - BDKAutomaticScopeVehicleVIN, - BDKAutomaticScopeTrip, - BDKAutomaticScopeBehavior, - BDKAutomaticScopeAdapterBasic + NSArray *scopes = @[NLAutomaticScopePublic, + NLAutomaticScopeUserProfile, + NLAutomaticScopeUserFollow, + NLAutomaticScopeLocation, + NLAutomaticScopeCurrentLocation, + NLAutomaticScopeVehicleProfile, + NLAutomaticScopeVehicleEvents, + NLAutomaticScopeVehicleVIN, + NLAutomaticScopeTrip, + NLAutomaticScopeBehavior, + NLAutomaticScopeAdapterBasic ]; return [self authenticationRequestForScopes:scopes]; } - (NSURLRequest *)authenticationRequestForStandardScopes { - NSArray *scopes = @[BDKAutomaticScopePublic, - BDKAutomaticScopeUserProfile, - BDKAutomaticScopeLocation, - BDKAutomaticScopeVehicleProfile, - BDKAutomaticScopeVehicleEvents, - BDKAutomaticScopeTrip, - BDKAutomaticScopeBehavior, + NSArray *scopes = @[NLAutomaticScopePublic, + NLAutomaticScopeUserProfile, + NLAutomaticScopeLocation, + NLAutomaticScopeVehicleProfile, + NLAutomaticScopeVehicleEvents, + NLAutomaticScopeTrip, + NLAutomaticScopeBehavior, ]; return [self authenticationRequestForScopes:scopes]; } @@ -113,14 +113,14 @@ - (NSURLRequest *)authenticationRequestForScopes:(NSArray *)scopes { return request; } -- (void)getAccessTokenForCode:(NSString *)code completion:(BDKAutomaticTokenCompletionBlock)completion { +- (void)getAccessTokenForCode:(NSString *)code completion:(NLAutomaticTokenCompletionBlock)completion { NSString *url = [NSString stringWithFormat:@"%@/%@", kAutomaticAuthBaseURLString, @"access_token"]; NSDictionary *params = @{@"client_id": self.clientId, @"client_secret": self.clientSecret, @"code": code, @"grant_type": @"authorization_code"}; [self.operationManager POST:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { - self.token = [BDKAutomaticToken tokenWithDictionary:responseObject]; + self.token = [NLAutomaticToken tokenWithDictionary:responseObject]; if (completion) { completion(nil, self.token); } @@ -133,13 +133,13 @@ - (void)getAccessTokenForCode:(NSString *)code completion:(BDKAutomaticTokenComp #pragma mark - Trip data -- (void)getTrips:(BDKAutomaticCompletionBlock)completion { +- (void)getTrips:(NLAutomaticCompletionBlock)completion { NSString *url = @"trips"; NSDictionary *params = @{}; [self.operationManager GET:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { NSMutableArray *mResults = [NSMutableArray array]; [responseObject enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - [mResults addObject:[[BDKAutomaticTrip alloc] initWithAPIObject:obj]]; + [mResults addObject:[[NLAutomaticTrip alloc] initWithAPIObject:obj]]; }]; if (completion) { completion(nil, [mResults copy]); @@ -151,12 +151,12 @@ - (void)getTrips:(BDKAutomaticCompletionBlock)completion { }]; } -- (void)getTripForId:(NSString *)identifier completion:(BDKAutomaticCompletionBlock)completion +- (void)getTripForId:(NSString *)identifier completion:(NLAutomaticCompletionBlock)completion { NSString *url = [NSString stringWithFormat:@"%@/%@", @"trips", identifier]; NSDictionary *params = @{}; [self.operationManager GET:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { - BDKAutomaticTrip *trip = [[BDKAutomaticTrip alloc] initWithAPIObject:responseObject]; + NLAutomaticTrip *trip = [[NLAutomaticTrip alloc] initWithAPIObject:responseObject]; if (completion) { completion(nil, trip); } @@ -169,12 +169,12 @@ - (void)getTripForId:(NSString *)identifier completion:(BDKAutomaticCompletionBl #pragma mark - User data -- (void)getUser:(BDKAutomaticCompletionBlock)completion +- (void)getUser:(NLAutomaticCompletionBlock)completion { NSString *url = @"user"; NSDictionary *params = @{}; [self.operationManager GET:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { - BDKAutomaticUser *user = [[BDKAutomaticUser alloc] initWithAPIObject:responseObject]; + NLAutomaticUser *user = [[NLAutomaticUser alloc] initWithAPIObject:responseObject]; if (completion) { completion(nil, user); } @@ -187,14 +187,14 @@ - (void)getUser:(BDKAutomaticCompletionBlock)completion #pragma mark - Vehicle data -- (void)getVehicles:(BDKAutomaticCompletionBlock)completion +- (void)getVehicles:(NLAutomaticCompletionBlock)completion { NSString *url = @"vehicles"; NSDictionary *params = @{}; [self.operationManager GET:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { NSMutableArray *mResults = [NSMutableArray array]; [responseObject enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - [mResults addObject:[[BDKAutomaticVehicle alloc] initWithAPIObject:obj]]; + [mResults addObject:[[NLAutomaticVehicle alloc] initWithAPIObject:obj]]; }]; if (completion) { completion(nil, [mResults copy]); @@ -206,12 +206,12 @@ - (void)getVehicles:(BDKAutomaticCompletionBlock)completion }]; } -- (void)getVehicleForId:(NSString *)identifier completion:(BDKAutomaticCompletionBlock)completion +- (void)getVehicleForId:(NSString *)identifier completion:(NLAutomaticCompletionBlock)completion { NSString *url = [NSString stringWithFormat:@"%@/%@", @"vehicles", identifier]; NSDictionary *params = @{}; [self.operationManager GET:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { - BDKAutomaticVehicle *vehicle = [[BDKAutomaticVehicle alloc] initWithAPIObject:responseObject]; + NLAutomaticVehicle *vehicle = [[NLAutomaticVehicle alloc] initWithAPIObject:responseObject]; if (completion) { completion(nil, vehicle); } diff --git a/Classes/BDKAutomaticObject.h b/Classes/NLAutomaticObject.h similarity index 79% rename from Classes/BDKAutomaticObject.h rename to Classes/NLAutomaticObject.h index 652446f..ad9587f 100644 --- a/Classes/BDKAutomaticObject.h +++ b/Classes/NLAutomaticObject.h @@ -1,5 +1,5 @@ // -// BDKAutomaticObject.h +// NLAutomaticObject.h // Pods // // Created by Ben Kreeger on 2/4/14. @@ -8,7 +8,7 @@ @import Foundation; -@interface BDKAutomaticObject : NSObject +@interface NLAutomaticObject : NSObject + (NSDictionary *)attributeMap; diff --git a/Classes/BDKAutomaticObject.m b/Classes/NLAutomaticObject.m similarity index 93% rename from Classes/BDKAutomaticObject.m rename to Classes/NLAutomaticObject.m index ca3450d..74e4f4a 100644 --- a/Classes/BDKAutomaticObject.m +++ b/Classes/NLAutomaticObject.m @@ -1,16 +1,16 @@ // -// BDKAutomaticObject.m +// NLAutomaticObject.m // Pods // // Created by Ben Kreeger on 2/4/14. // // -#import "BDKAutomaticObject.h" +#import "NLAutomaticObject.h" #import -@implementation BDKAutomaticObject +@implementation NLAutomaticObject #pragma mark - Class methods @@ -33,7 +33,7 @@ - (void)updateWithAPIObject:(NSDictionary *)apiObject { id remoteValue = [apiObject valueForKey:value[@"key"]]; if (value[@"type"]) { Class remoteClass = NSClassFromString(value[@"type"]); - if ([remoteClass isSubclassOfClass:[BDKAutomaticObject class]]) { + if ([remoteClass isSubclassOfClass:[NLAutomaticObject class]]) { id instanceOfRemoteClass = [[remoteClass alloc] initWithAPIObject:remoteValue]; [self setValue:instanceOfRemoteClass forKey:localName]; } diff --git a/Classes/NLAutomaticScopes.h b/Classes/NLAutomaticScopes.h new file mode 100644 index 0000000..6c2b3d9 --- /dev/null +++ b/Classes/NLAutomaticScopes.h @@ -0,0 +1,21 @@ +// +// NLAutomaticScopes.h +// Pods +// +// Created by Ben Kreeger on 2/2/14. +// Copyright (c) 2014 Ben Kreeger. All rights reserved. +// + +@import Foundation; + +extern NSString * const NLAutomaticScopePublic; +extern NSString * const NLAutomaticScopeUserProfile; +extern NSString * const NLAutomaticScopeUserFollow; +extern NSString * const NLAutomaticScopeLocation; +extern NSString * const NLAutomaticScopeCurrentLocation; +extern NSString * const NLAutomaticScopeVehicleProfile; +extern NSString * const NLAutomaticScopeVehicleEvents; +extern NSString * const NLAutomaticScopeVehicleVIN; +extern NSString * const NLAutomaticScopeTrip; +extern NSString * const NLAutomaticScopeBehavior; +extern NSString * const NLAutomaticScopeAdapterBasic; diff --git a/Classes/NLAutomaticScopes.m b/Classes/NLAutomaticScopes.m new file mode 100644 index 0000000..1b0aa8d --- /dev/null +++ b/Classes/NLAutomaticScopes.m @@ -0,0 +1,21 @@ +// +// NLAutomaticScopes.m +// Pods +// +// Created by Ben Kreeger on 2/2/14. +// Copyright (c) 2014 Ben Kreeger. All rights reserved. +// + +#import "NLAutomaticScopes.h" + +NSString * const NLAutomaticScopePublic = @"scope:public"; +NSString * const NLAutomaticScopeUserProfile = @"scope:user:profile"; +NSString * const NLAutomaticScopeUserFollow = @"scope:user:follow"; +NSString * const NLAutomaticScopeLocation = @"scope:location"; +NSString * const NLAutomaticScopeCurrentLocation = @"scope:current_location"; +NSString * const NLAutomaticScopeVehicleProfile = @"scope:vehicle:profile"; +NSString * const NLAutomaticScopeVehicleEvents = @"scope:vehicle:events"; +NSString * const NLAutomaticScopeVehicleVIN = @"scope:vehicle:vin"; +NSString * const NLAutomaticScopeTrip = @"scope:trip"; +NSString * const NLAutomaticScopeBehavior = @"scope:behavior"; +NSString * const NLAutomaticScopeAdapterBasic = @"scope:adapter:basic"; diff --git a/Classes/BDKAutomaticTerminus.h b/Classes/NLAutomaticTerminus.h similarity index 71% rename from Classes/BDKAutomaticTerminus.h rename to Classes/NLAutomaticTerminus.h index 8b105a4..4b8a46f 100644 --- a/Classes/BDKAutomaticTerminus.h +++ b/Classes/NLAutomaticTerminus.h @@ -1,14 +1,14 @@ // -// BDKAutomaticTerminus.h +// NLAutomaticTerminus.h // Pods // // Created by Ben Kreeger on 2/4/14. // // -#import "BDKAutomaticObject.h" +#import "NLAutomaticObject.h" -@interface BDKAutomaticTerminus : BDKAutomaticObject +@interface NLAutomaticTerminus : NLAutomaticObject @property (strong, nonatomic) NSNumber *accuracyInMeters; @property (strong, nonatomic) NSNumber *latitude; diff --git a/Classes/BDKAutomaticTerminus.m b/Classes/NLAutomaticTerminus.m similarity index 79% rename from Classes/BDKAutomaticTerminus.m rename to Classes/NLAutomaticTerminus.m index a53bce6..f1f7d6e 100644 --- a/Classes/BDKAutomaticTerminus.m +++ b/Classes/NLAutomaticTerminus.m @@ -1,16 +1,16 @@ // -// BDKAutomaticTerminus.m +// NLAutomaticTerminus.m // Pods // // Created by Ben Kreeger on 2/4/14. // // -#import "BDKAutomaticTerminus.h" +#import "NLAutomaticTerminus.h" -@implementation BDKAutomaticTerminus +@implementation NLAutomaticTerminus -#pragma mark - BDKAutomaticObject +#pragma mark - NLAutomaticObject + (NSDictionary *)attributeMap { return @{@"accuracyInMeters": @"accuracy_m", diff --git a/Classes/BDKAutomaticToken.h b/Classes/NLAutomaticToken.h similarity index 86% rename from Classes/BDKAutomaticToken.h rename to Classes/NLAutomaticToken.h index 62d5657..1867c0f 100644 --- a/Classes/BDKAutomaticToken.h +++ b/Classes/NLAutomaticToken.h @@ -1,5 +1,5 @@ // -// BDKAutomaticToken.h +// NLAutomaticToken.h // Pods // // Created by Ben Kreeger on 2/2/14. @@ -8,7 +8,7 @@ #import -@interface BDKAutomaticToken : NSObject +@interface NLAutomaticToken : NSObject @property (strong, nonatomic) NSString *accessToken; @property (strong, nonatomic) NSDate *expiresAt; diff --git a/Classes/BDKAutomaticToken.m b/Classes/NLAutomaticToken.m similarity index 94% rename from Classes/BDKAutomaticToken.m rename to Classes/NLAutomaticToken.m index 208cda5..35c2cd6 100644 --- a/Classes/BDKAutomaticToken.m +++ b/Classes/NLAutomaticToken.m @@ -1,20 +1,20 @@ // -// BDKAutomaticToken.m +// NLAutomaticToken.m // Pods // // Created by Ben Kreeger on 2/2/14. // // -#import "BDKAutomaticToken.h" +#import "NLAutomaticToken.h" -@interface BDKAutomaticToken () +@interface NLAutomaticToken () - (instancetype)initWithDictionary:(NSDictionary *)dictionary; @end -@implementation BDKAutomaticToken +@implementation NLAutomaticToken #pragma mark - Lifecycle diff --git a/Classes/BDKAutomaticTrip.h b/Classes/NLAutomaticTrip.h similarity index 73% rename from Classes/BDKAutomaticTrip.h rename to Classes/NLAutomaticTrip.h index 9c0940d..6e129e5 100644 --- a/Classes/BDKAutomaticTrip.h +++ b/Classes/NLAutomaticTrip.h @@ -1,23 +1,23 @@ // -// BDKAutomaticTrip.h +// NLAutomaticTrip.h // Pods // // Created by Ben Kreeger on 2/4/14. // // -#import "BDKAutomaticObject.h" +#import "NLAutomaticObject.h" -@class BDKAutomaticTerminus, BDKAutomaticVehicle; +@class NLAutomaticTerminus, NLAutomaticVehicle; -@interface BDKAutomaticTrip : BDKAutomaticObject +@interface NLAutomaticTrip : NLAutomaticObject @property (strong, nonatomic) NSNumber *averageMpg; @property (strong, nonatomic) NSNumber *distanceInMeters; @property (strong, nonatomic) NSNumber *durationOver70MPH; @property (strong, nonatomic) NSNumber *durationOver75MPH; @property (strong, nonatomic) NSNumber *durationOver80MPH; -@property (strong, nonatomic) BDKAutomaticTerminus *endLocation; +@property (strong, nonatomic) NLAutomaticTerminus *endLocation; @property (strong, nonatomic) NSDate *endTime; @property (strong, nonatomic) NSString *endTimeZone; @property (strong, nonatomic) NSNumber *fuelCostInUSD; @@ -26,11 +26,11 @@ @property (strong, nonatomic) NSNumber *hardBrakes; @property (strong, nonatomic) NSString *identifier; @property (strong, nonatomic) NSString *path; -@property (strong, nonatomic) BDKAutomaticTerminus *startLocation; +@property (strong, nonatomic) NLAutomaticTerminus *startLocation; @property (strong, nonatomic) NSDate *startTime; @property (strong, nonatomic) NSString *startTimeZone; @property (strong, nonatomic) NSURL *uri; @property (strong, nonatomic) NSString *userId; -@property (strong, nonatomic) BDKAutomaticVehicle *vehicle; +@property (strong, nonatomic) NLAutomaticVehicle *vehicle; @end diff --git a/Classes/BDKAutomaticTrip.m b/Classes/NLAutomaticTrip.m similarity index 81% rename from Classes/BDKAutomaticTrip.m rename to Classes/NLAutomaticTrip.m index af99823..e556a90 100644 --- a/Classes/BDKAutomaticTrip.m +++ b/Classes/NLAutomaticTrip.m @@ -1,16 +1,16 @@ // -// BDKAutomaticTrip.m +// NLAutomaticTrip.m // Pods // // Created by Ben Kreeger on 2/4/14. // // -#import "BDKAutomaticTrip.h" +#import "NLAutomaticTrip.h" -@implementation BDKAutomaticTrip +@implementation NLAutomaticTrip -#pragma mark - BDKAutomaticObject +#pragma mark - NLAutomaticObject + (NSDictionary *)attributeMap { return @{@"averageMpg": @"average_mpg", @@ -18,7 +18,7 @@ + (NSDictionary *)attributeMap { @"durationOver70MPH": @"duration_over_70_s", @"durationOver75MPH": @"duration_over_75_s", @"durationOver80MPH": @"duration_over_80_s", - @"endLocation": @{@"type": @"BDKAutomaticTerminus", + @"endLocation": @{@"type": @"NLAutomaticTerminus", @"key": @"end_location",}, @"endTime": @{@"via": @"timeInterval", @"key": @"end_time",}, @@ -29,14 +29,14 @@ + (NSDictionary *)attributeMap { @"hardBrakes": @"hard_brakes", @"identifier": @"id", @"path": @"path", - @"startLocation": @{@"type": @"BDKAutomaticTerminus", + @"startLocation": @{@"type": @"NLAutomaticTerminus", @"key": @"start_location",}, @"startTime": @{@"via": @"timeInterval", @"key": @"start_time",}, @"startTimeZone": @"start_time_zone", @"uri": @"uri", @"userId": @"user.id", - @"vehicle": @{@"type": @"BDKAutomaticVehicle", + @"vehicle": @{@"type": @"NLAutomaticVehicle", @"key": @"vehicle",}, }; } diff --git a/Classes/BDKAutomaticUser.h b/Classes/NLAutomaticUser.h similarity index 72% rename from Classes/BDKAutomaticUser.h rename to Classes/NLAutomaticUser.h index 633b4b6..ce74383 100644 --- a/Classes/BDKAutomaticUser.h +++ b/Classes/NLAutomaticUser.h @@ -1,14 +1,14 @@ // -// BDKAutomaticUser.h +// NLAutomaticUser.h // Pods // // Created by Nelson LeDuc on 4/1/15. // // -#import "BDKAutomaticObject.h" +#import "NLAutomaticObject.h" -@interface BDKAutomaticUser : BDKAutomaticObject +@interface NLAutomaticUser : NLAutomaticObject @property (nonatomic, strong) NSString *identifier; @property (nonatomic, strong) NSString *firstName; diff --git a/Classes/BDKAutomaticUser.m b/Classes/NLAutomaticUser.m similarity index 75% rename from Classes/BDKAutomaticUser.m rename to Classes/NLAutomaticUser.m index aa54808..a90884c 100644 --- a/Classes/BDKAutomaticUser.m +++ b/Classes/NLAutomaticUser.m @@ -1,14 +1,14 @@ // -// BDKAutomaticUser.m +// NLAutomaticUser.m // Pods // // Created by Nelson LeDuc on 4/1/15. // // -#import "BDKAutomaticUser.h" +#import "NLAutomaticUser.h" -@implementation BDKAutomaticUser +@implementation NLAutomaticUser + (NSDictionary *)attributeMap { return @{@"identifier": @"id", diff --git a/Classes/BDKAutomaticVehicle.h b/Classes/NLAutomaticVehicle.h similarity index 78% rename from Classes/BDKAutomaticVehicle.h rename to Classes/NLAutomaticVehicle.h index 0efd6bb..12dd0a2 100644 --- a/Classes/BDKAutomaticVehicle.h +++ b/Classes/NLAutomaticVehicle.h @@ -1,14 +1,14 @@ // -// BDKAutomaticVehicle.h +// NLAutomaticVehicle.h // Pods // // Created by Ben Kreeger on 2/4/14. // // -#import "BDKAutomaticObject.h" +#import "NLAutomaticObject.h" -@interface BDKAutomaticVehicle : BDKAutomaticObject +@interface NLAutomaticVehicle : NLAutomaticObject @property (strong, nonatomic) NSString *displayName; @property (strong, nonatomic) NSNumber *identifier; diff --git a/Classes/BDKAutomaticVehicle.m b/Classes/NLAutomaticVehicle.m similarity index 82% rename from Classes/BDKAutomaticVehicle.m rename to Classes/NLAutomaticVehicle.m index f44e37a..179370c 100644 --- a/Classes/BDKAutomaticVehicle.m +++ b/Classes/NLAutomaticVehicle.m @@ -1,16 +1,16 @@ // -// BDKAutomaticVehicle.m +// NLAutomaticVehicle.m // Pods // // Created by Ben Kreeger on 2/4/14. // // -#import "BDKAutomaticVehicle.h" +#import "NLAutomaticVehicle.h" -@implementation BDKAutomaticVehicle +@implementation NLAutomaticVehicle -#pragma mark - BDKAutomaticObject +#pragma mark - NLAutomaticObject + (NSDictionary *)attributeMap { return @{@"displayName": @"display_name", diff --git a/Classes/Promise/BDKAutomatic+Promise.h b/Classes/Promise/NLAutomatic+Promise.h similarity index 80% rename from Classes/Promise/BDKAutomatic+Promise.h rename to Classes/Promise/NLAutomatic+Promise.h index e30160c..0a18446 100644 --- a/Classes/Promise/BDKAutomatic+Promise.h +++ b/Classes/Promise/NLAutomatic+Promise.h @@ -1,16 +1,16 @@ // -// BDKAutomatic+Promise.h +// NLAutomatic+Promise.h // Pods // // Created by Nelson LeDuc on 4/1/15. // // -#import "BDKAutomatic.h" +#import "NLAutomatic.h" @class PMKPromise; -@interface BDKAutomatic (Promise) +@interface NLAutomatic (Promise) #pragma mark - Trip data diff --git a/Classes/Promise/BDKAutomatic+Promise.m b/Classes/Promise/NLAutomatic+Promise.m similarity index 93% rename from Classes/Promise/BDKAutomatic+Promise.m rename to Classes/Promise/NLAutomatic+Promise.m index 92a6777..1b6ee85 100644 --- a/Classes/Promise/BDKAutomatic+Promise.m +++ b/Classes/Promise/NLAutomatic+Promise.m @@ -1,16 +1,16 @@ // -// BDKAutomatic+Promise.m +// NLAutomatic+Promise.m // Pods // // Created by Nelson LeDuc on 4/1/15. // // -#import "BDKAutomatic+Promise.h" +#import "NLAutomatic+Promise.h" #import -@implementation BDKAutomatic (Promise) +@implementation NLAutomatic (Promise) #pragma mark - Trip data diff --git a/BDKAutomatic.podspec b/NLAutomatic.podspec similarity index 69% rename from BDKAutomatic.podspec rename to NLAutomatic.podspec index c605e51..20c0c8d 100644 --- a/BDKAutomatic.podspec +++ b/NLAutomatic.podspec @@ -1,11 +1,11 @@ Pod::Spec.new do |s| - s.name = "BDKAutomatic" + s.name = "NLAutomatic" s.version = "0.1.0" s.summary = "A framework for talking to the Automatic API." - s.homepage = "https://github.com/kreeger/BDKAutomatic" + s.homepage = "https://github.com/nelsonleduc/NLAutomatic" s.license = 'MIT' - s.author = { "Ben Kreeger" => "ben@kree.gr" } - s.source = { :git => "https://github.com/kreeger/BDKAutomatic.git", :tag => "v#{s.version}" } + s.author = { "Nelson LeDuc" => "nelson.leduc@jumpspaceapps.com" } + s.source = { :git => "https://github.com/nelsonleduc/NLAutomatic.git", :tag => "#{s.version}" } s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.8' diff --git a/Project/BDKAutomatic.xcworkspace/contents.xcworkspacedata b/Project/BDKAutomatic.xcworkspace/contents.xcworkspacedata index 01550a5..5d1d7cb 100644 --- a/Project/BDKAutomatic.xcworkspace/contents.xcworkspacedata +++ b/Project/BDKAutomatic.xcworkspace/contents.xcworkspacedata @@ -2,7 +2,7 @@ + location = "group:NLAutomatic.xcodeproj"> diff --git a/Project/Classes/BDKAuthViewController.h b/Project/Classes/BDKAuthViewController.h deleted file mode 100644 index 2d5cf30..0000000 --- a/Project/Classes/BDKAuthViewController.h +++ /dev/null @@ -1,20 +0,0 @@ -// -// BDKAuthViewController.h -// BDKAutomatic -// -// Created by Ben Kreeger on 2/2/14. -// Copyright (c) 2014 Ben Kreeger. All rights reserved. -// - -@import UIKit; - -@class BDKAutomatic, BDKAutomaticToken; - -@interface BDKAuthViewController : UIViewController - -@property (readonly, nonatomic) BDKAutomatic *automatic; -@property (copy, nonatomic) void (^userAuthenticated)(BDKAutomaticToken *token); - -+ (instancetype)viewControllerWithAutomaticAdapter:(BDKAutomatic *)adapter; - -@end diff --git a/Project/Classes/BDKAutomaticSecrets.plist.example b/Project/Classes/BDKAutomaticSecrets.plist.example deleted file mode 100644 index 49159d0..0000000 --- a/Project/Classes/BDKAutomaticSecrets.plist.example +++ /dev/null @@ -1,12 +0,0 @@ - - - - - BDKAutomaticClientId - - BDKAutomaticClientSecret - - BDKAutomaticRedirectUrl - - - diff --git a/Project/Classes/BDKMapViewController.h b/Project/Classes/BDKMapViewController.h deleted file mode 100644 index 8c6eea9..0000000 --- a/Project/Classes/BDKMapViewController.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// BDKMapViewController.h -// BDKAutomatic -// -// Created by Ben Kreeger on 2/4/14. -// Copyright (c) 2014 Ben Kreeger. All rights reserved. -// - -@class BDKAutomaticTrip; - -@interface BDKMapViewController : UIViewController - -@property (strong, nonatomic) BDKAutomaticTrip *trip; - -@end diff --git a/Project/Classes/Info.plist b/Project/Classes/Info.plist index b237af6..2261168 100644 --- a/Project/Classes/Info.plist +++ b/Project/Classes/Info.plist @@ -9,7 +9,7 @@ CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIdentifier - gr.kree.${PRODUCT_NAME:rfc1034identifier} + com.nelsonleduc.$(PRODUCT_NAME:rfc1034identifier) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/Project/Classes/BDKAppDelegate.h b/Project/Classes/NLAppDelegate.h similarity index 51% rename from Project/Classes/BDKAppDelegate.h rename to Project/Classes/NLAppDelegate.h index 07a289f..481056c 100644 --- a/Project/Classes/BDKAppDelegate.h +++ b/Project/Classes/NLAppDelegate.h @@ -1,6 +1,6 @@ // -// BDKAppDelegate.h -// BDKAutomatic +// NLAppDelegate.h +// NLAutomatic // // Created by Ben Kreeger on 1/20/14. // Copyright (c) 2014 Ben Kreeger. All rights reserved. @@ -8,11 +8,11 @@ @import UIKit; -@class BDKAutomatic; +@class NLAutomatic; -@interface BDKAppDelegate : UIResponder +@interface NLAppDelegate : UIResponder @property (strong, nonatomic) UIWindow *window; -@property (readonly) BDKAutomatic *automatic; +@property (readonly) NLAutomatic *automatic; @end diff --git a/Project/Classes/BDKAppDelegate.m b/Project/Classes/NLAppDelegate.m similarity index 61% rename from Project/Classes/BDKAppDelegate.m rename to Project/Classes/NLAppDelegate.m index 423100d..9c2eae4 100644 --- a/Project/Classes/BDKAppDelegate.m +++ b/Project/Classes/NLAppDelegate.m @@ -1,24 +1,24 @@ // -// BDKAppDelegate.m -// BDKAutomatic +// NLAppDelegate.m +// NLAutomatic // // Created by Ben Kreeger on 1/20/14. // Copyright (c) 2014 Ben Kreeger. All rights reserved. // -#import "BDKAppDelegate.h" -#import "BDKAuthViewController.h" -#import "BDKTableViewController.h" +#import "NLAppDelegate.h" +#import "NLAuthViewController.h" +#import "NLTableViewController.h" -#import +#import -@interface BDKAppDelegate () +@interface NLAppDelegate () - (void)setupAutomaticAPI; @end -@implementation BDKAppDelegate +@implementation NLAppDelegate @synthesize automatic = _automatic; @@ -35,33 +35,33 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( } - (void)setupAutomaticAPI { - NSString *path = [[NSBundle mainBundle] pathForResource:@"BDKAutomaticSecrets" ofType:@"plist"]; - NSAssert(path, @"You must copy BDKAutomaticSecrets.plist.example to BDKAutomaticSecrets.plist and fill out your\ + NSString *path = [[NSBundle mainBundle] pathForResource:@"NLAutomaticSecrets" ofType:@"plist"]; + NSAssert(path, @"You must copy NLAutomaticSecrets.plist.example to NLAutomaticSecrets.plist and fill out your\ information."); NSDictionary *secrets = [NSDictionary dictionaryWithContentsOfFile:path]; - NSString *clientId = secrets[@"BDKAutomaticClientId"]; - NSAssert(clientId, @"Must fill in Automatic API Client ID in BDKAutomaticSecrets.plist."); - NSString *clientSecret = secrets[@"BDKAutomaticClientSecret"]; - NSAssert(clientSecret, @"Must fill in Automatic API Client Secret in BDKAutomaticSecrets.plist."); - NSString *redirectUrlString = secrets[@"BDKAutomaticRedirectUrl"]; - NSAssert(redirectUrlString, @"Must fill in Automatic API Redirect URL in BDKAutomaticSecrets.plist."); + NSString *clientId = secrets[@"NLAutomaticClientId"]; + NSAssert(clientId, @"Must fill in Automatic API Client ID in NLAutomaticSecrets.plist."); + NSString *clientSecret = secrets[@"NLAutomaticClientSecret"]; + NSAssert(clientSecret, @"Must fill in Automatic API Client Secret in NLAutomaticSecrets.plist."); + NSString *redirectUrlString = secrets[@"NLAutomaticRedirectUrl"]; + NSAssert(redirectUrlString, @"Must fill in Automatic API Redirect URL in NLAutomaticSecrets.plist."); NSURL *redirectUrl = [NSURL URLWithString:redirectUrlString]; - _automatic = [[BDKAutomatic alloc] initWithClientId:clientId clientSecret:clientSecret redirectUrl:redirectUrl]; + _automatic = [[NLAutomatic alloc] initWithClientId:clientId clientSecret:clientSecret redirectUrl:redirectUrl]; - NSData *tokenData = [[NSUserDefaults standardUserDefaults] objectForKey:@"BDKAutomaticToken"]; + NSData *tokenData = [[NSUserDefaults standardUserDefaults] objectForKey:@"NLAutomaticToken"]; if (tokenData) { - BDKAutomaticToken *token = [NSKeyedUnarchiver unarchiveObjectWithData:tokenData]; + NLAutomaticToken *token = [NSKeyedUnarchiver unarchiveObjectWithData:tokenData]; _automatic.token = token; } } - (void)showAuthenticatedFlow { - BDKTableViewController *tableVC = [BDKTableViewController viewControllerWithAutomaticAdapter:self.automatic]; + NLTableViewController *tableVC = [NLTableViewController viewControllerWithAutomaticAdapter:self.automatic]; tableVC.userDidLogout = ^{ self.automatic.token = nil; - [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"BDKAutomaticToken"]; + [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"NLAutomaticToken"]; [[NSUserDefaults standardUserDefaults] synchronize]; [self showUnauthenticatedFlow]; @@ -71,11 +71,11 @@ - (void)showAuthenticatedFlow { } - (void)showUnauthenticatedFlow { - BDKAuthViewController *authVC = [BDKAuthViewController viewControllerWithAutomaticAdapter:self.automatic]; - authVC.userAuthenticated = ^(BDKAutomaticToken *token) { + NLAuthViewController *authVC = [NLAuthViewController viewControllerWithAutomaticAdapter:self.automatic]; + authVC.userAuthenticated = ^(NLAutomaticToken *token) { // Save it to defaults; in your real app, PLEASE save this data to Keychain instead. NSData *data = [NSKeyedArchiver archivedDataWithRootObject:token]; - [[NSUserDefaults standardUserDefaults] setObject:data forKey:@"BDKAutomaticToken"]; + [[NSUserDefaults standardUserDefaults] setObject:data forKey:@"NLAutomaticToken"]; [[NSUserDefaults standardUserDefaults] synchronize]; [self showAuthenticatedFlow]; diff --git a/Project/Classes/NLAuthViewController.h b/Project/Classes/NLAuthViewController.h new file mode 100644 index 0000000..c33f525 --- /dev/null +++ b/Project/Classes/NLAuthViewController.h @@ -0,0 +1,20 @@ +// +// NLAuthViewController.h +// NLAutomatic +// +// Created by Ben Kreeger on 2/2/14. +// Copyright (c) 2014 Ben Kreeger. All rights reserved. +// + +@import UIKit; + +@class NLAutomatic, NLAutomaticToken; + +@interface NLAuthViewController : UIViewController + +@property (readonly, nonatomic, weak) NLAutomatic *automatic; +@property (copy, nonatomic) void (^userAuthenticated)(NLAutomaticToken *token); + ++ (instancetype)viewControllerWithAutomaticAdapter:(NLAutomatic *)adapter; + +@end diff --git a/Project/Classes/BDKAuthViewController.m b/Project/Classes/NLAuthViewController.m similarity index 85% rename from Project/Classes/BDKAuthViewController.m rename to Project/Classes/NLAuthViewController.m index dd47389..041f0ac 100644 --- a/Project/Classes/BDKAuthViewController.m +++ b/Project/Classes/NLAuthViewController.m @@ -1,27 +1,27 @@ // -// BDKAuthViewController.m -// BDKAutomatic +// NLAuthViewController.m +// NLAutomatic // // Created by Ben Kreeger on 2/2/14. // Copyright (c) 2014 Ben Kreeger. All rights reserved. // -#import "BDKAuthViewController.h" +#import "NLAuthViewController.h" -#import +#import -@interface BDKAuthViewController () +@interface NLAuthViewController () @property (strong, nonatomic) UIWebView *webView; -@property (weak, nonatomic) BDKAutomatic *automatic; +@property (weak, nonatomic) NLAutomatic *automatic; - (void)handleAutomaticAuthenticationQueryString:(NSString *)queryString; @end -@implementation BDKAuthViewController +@implementation NLAuthViewController -+ (instancetype)viewControllerWithAutomaticAdapter:(BDKAutomatic *)adapter { ++ (instancetype)viewControllerWithAutomaticAdapter:(NLAutomatic *)adapter { id instance = [self new]; [instance setAutomatic:adapter]; return instance; @@ -62,7 +62,7 @@ - (void)handleAutomaticAuthenticationQueryString:(NSString *)queryString { params[key] = value ?: [NSNull null]; }]; - [self.automatic getAccessTokenForCode:params[@"code"] completion:^(NSError *error, BDKAutomaticToken *token) { + [self.automatic getAccessTokenForCode:params[@"code"] completion:^(NSError *error, NLAutomaticToken *token) { if (self.userAuthenticated) { self.userAuthenticated(token); } diff --git a/Project/Classes/NLMapViewController.h b/Project/Classes/NLMapViewController.h new file mode 100644 index 0000000..ad7f474 --- /dev/null +++ b/Project/Classes/NLMapViewController.h @@ -0,0 +1,15 @@ +// +// NLMapViewController.h +// NLAutomatic +// +// Created by Ben Kreeger on 2/4/14. +// Copyright (c) 2014 Ben Kreeger. All rights reserved. +// + +@class NLAutomaticTrip; + +@interface NLMapViewController : UIViewController + +@property (strong, nonatomic) NLAutomaticTrip *trip; + +@end diff --git a/Project/Classes/BDKMapViewController.m b/Project/Classes/NLMapViewController.m similarity index 91% rename from Project/Classes/BDKMapViewController.m rename to Project/Classes/NLMapViewController.m index ff6b0f7..1b546cc 100644 --- a/Project/Classes/BDKMapViewController.m +++ b/Project/Classes/NLMapViewController.m @@ -1,19 +1,19 @@ // -// BDKMapViewController.m -// BDKAutomatic +// NLMapViewController.m +// NLAutomatic // // Created by Ben Kreeger on 2/4/14. // Copyright (c) 2014 Ben Kreeger. All rights reserved. // -#import "BDKMapViewController.h" +#import "NLMapViewController.h" @import MapKit; -#import -#import +#import +#import -@interface BDKMapViewController () +@interface NLMapViewController () @property (strong, nonatomic) MKMapView *mapView; @property (strong, nonatomic) MKPolyline *mapPath; @@ -23,7 +23,7 @@ - (void)segmentedControlChanged:(UISegmentedControl *)sender; @end -@implementation BDKMapViewController +@implementation NLMapViewController - (void)loadView { self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; @@ -79,7 +79,7 @@ - (UISegmentedControl *)segmentedControl { return _segmentedControl; } -- (void)setTrip:(BDKAutomaticTrip *)trip { +- (void)setTrip:(NLAutomaticTrip *)trip { self.title = [NSString stringWithFormat:@"%@", trip.identifier]; self.mapPath = [MKPolyline polylineWithEncodedString:trip.path]; } diff --git a/Project/Classes/BDKTableViewController.h b/Project/Classes/NLTableViewController.h similarity index 50% rename from Project/Classes/BDKTableViewController.h rename to Project/Classes/NLTableViewController.h index f3dc78c..cbb2ed0 100644 --- a/Project/Classes/BDKTableViewController.h +++ b/Project/Classes/NLTableViewController.h @@ -1,6 +1,6 @@ // -// BDKTableViewController.h -// BDKAutomatic +// NLTableViewController.h +// NLAutomatic // // Created by Ben Kreeger on 2/2/14. // Copyright (c) 2014 Ben Kreeger. All rights reserved. @@ -8,14 +8,14 @@ @import UIKit; -@class BDKAutomatic; +@class NLAutomatic; -@interface BDKTableViewController : UIViewController +@interface NLTableViewController : UIViewController -@property (readonly) BDKAutomatic *automatic; +@property (readonly, weak) NLAutomatic *automatic; @property (readonly, nonatomic) UITableView *tableView; @property (copy, nonatomic) void(^userDidLogout)(void); -+ (instancetype)viewControllerWithAutomaticAdapter:(BDKAutomatic *)adapter; ++ (instancetype)viewControllerWithAutomaticAdapter:(NLAutomatic *)adapter; @end diff --git a/Project/Classes/BDKTableViewController.m b/Project/Classes/NLTableViewController.m similarity index 89% rename from Project/Classes/BDKTableViewController.m rename to Project/Classes/NLTableViewController.m index 4418a2f..132dba6 100644 --- a/Project/Classes/BDKTableViewController.m +++ b/Project/Classes/NLTableViewController.m @@ -1,24 +1,24 @@ // -// BDKTableViewController.m -// BDKAutomatic +// NLTableViewController.m +// NLAutomatic // // Created by Ben Kreeger on 2/2/14. // Copyright (c) 2014 Ben Kreeger. All rights reserved. // -#import "BDKTableViewController.h" +#import "NLTableViewController.h" -#import "BDKMapViewController.h" +#import "NLMapViewController.h" -#import -#import +#import +#import -@interface BDKTableViewController () +@interface NLTableViewController () @property (strong, nonatomic) UITableView *tableView; @property (strong, nonatomic) UIRefreshControl *refreshControl; @property (strong, nonatomic) NSDateFormatter *dateFormatter; -@property (weak, nonatomic) BDKAutomatic *automatic; +@property (weak, nonatomic) NLAutomatic *automatic; @property (strong, nonatomic) NSDictionary *tripDict; @property (strong, nonatomic) NSArray *sectionKeys; @@ -28,11 +28,11 @@ - (void)logoutButtonTapped:(UIBarButtonItem *)sender; @end -@implementation BDKTableViewController +@implementation NLTableViewController #pragma mark - Lifecycle -+ (instancetype)viewControllerWithAutomaticAdapter:(BDKAutomatic *)adapter { ++ (instancetype)viewControllerWithAutomaticAdapter:(NLAutomatic *)adapter { id instance = [self new]; [instance setAutomatic:adapter]; return instance; @@ -106,7 +106,7 @@ - (void)tableViewDidPullToRefresh:(UIRefreshControl *)control { [sectionDF setDateFormat:@"yyyy-MM-dd"]; NSDateFormatter *titleDF = [NSDateFormatter new]; [titleDF setDateFormat:@"MMMM d, yyyy"]; - [responseObject enumerateObjectsUsingBlock:^(BDKAutomaticTrip *trip, NSUInteger idx, BOOL *stop) { + [responseObject enumerateObjectsUsingBlock:^(NLAutomaticTrip *trip, NSUInteger idx, BOOL *stop) { NSString *sectionString = [sectionDF stringFromDate:trip.startTime]; [orderedKeys addObject:sectionString]; if (mTrips[sectionString]) { @@ -154,7 +154,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"Cell"]; } NSString *title = self.sectionKeys[indexPath.section]; - BDKAutomaticTrip *trip = self.tripDict[title][@"trips"][indexPath.row]; + NLAutomaticTrip *trip = self.tripDict[title][@"trips"][indexPath.row]; cell.textLabel.text = [self.dateFormatter stringFromDate:trip.startTime]; cell.textLabel.font = [UIFont systemFontOfSize:15]; cell.detailTextLabel.text = [NSString stringWithFormat:@"%.2f km", [trip.distanceInMeters floatValue] / 1000]; @@ -164,7 +164,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N #pragma mark - UITableViewDelegate - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - BDKMapViewController *mapVC = [BDKMapViewController new]; + NLMapViewController *mapVC = [NLMapViewController new]; NSString *title = self.sectionKeys[indexPath.section]; mapVC.trip = self.tripDict[title][@"trips"][indexPath.row]; [self.navigationController pushViewController:mapVC animated:YES]; diff --git a/Project/Classes/main.m b/Project/Classes/main.m index 5e27ec9..4db99d9 100644 --- a/Project/Classes/main.m +++ b/Project/Classes/main.m @@ -1,6 +1,6 @@ // // main.m -// BDKAutomatic +// NLAutomatic // // Created by Ben Kreeger on 1/20/14. // Copyright (c) 2014 Ben Kreeger. All rights reserved. @@ -8,11 +8,11 @@ #import -#import "BDKAppDelegate.h" +#import "NLAppDelegate.h" int main(int argc, char * argv[]) { @autoreleasepool { - return UIApplicationMain(argc, argv, nil, NSStringFromClass([BDKAppDelegate class])); + return UIApplicationMain(argc, argv, nil, NSStringFromClass([NLAppDelegate class])); } } diff --git a/Project/BDKAutomatic.xcodeproj/project.pbxproj b/Project/NLAutomatic.xcodeproj/project.pbxproj similarity index 82% rename from Project/BDKAutomatic.xcodeproj/project.pbxproj rename to Project/NLAutomatic.xcodeproj/project.pbxproj index 713f5eb..4e22e64 100644 --- a/Project/BDKAutomatic.xcodeproj/project.pbxproj +++ b/Project/NLAutomatic.xcodeproj/project.pbxproj @@ -15,18 +15,18 @@ B52A0D35188DED6C00C21D6C /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B52A0D34188DED6C00C21D6C /* XCTest.framework */; }; B52A0D36188DED6C00C21D6C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B52A0D1B188DED6C00C21D6C /* Foundation.framework */; }; B52A0D37188DED6C00C21D6C /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B52A0D1F188DED6C00C21D6C /* UIKit.framework */; }; - B536C109188DED9400C02470 /* BDKAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B536C102188DED9400C02470 /* BDKAppDelegate.m */; }; + B536C109188DED9400C02470 /* NLAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B536C102188DED9400C02470 /* NLAppDelegate.m */; }; B536C10B188DED9400C02470 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = B536C105188DED9400C02470 /* InfoPlist.strings */; }; B536C10C188DED9400C02470 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B536C107188DED9400C02470 /* Images.xcassets */; }; B536C10D188DED9400C02470 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = B536C108188DED9400C02470 /* main.m */; }; B536C113188DED9C00C02470 /* Specs-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B536C10F188DED9C00C02470 /* Specs-Info.plist */; }; - B536C114188DED9C00C02470 /* BDKAutomaticTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B536C110188DED9C00C02470 /* BDKAutomaticTests.m */; }; + B536C114188DED9C00C02470 /* NLAutomaticTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B536C110188DED9C00C02470 /* NLAutomaticTests.m */; }; B536C115188DED9C00C02470 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = B536C111188DED9C00C02470 /* InfoPlist.strings */; }; B58FEB2B18A1F319009A6F62 /* MapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B58FEB2A18A1F319009A6F62 /* MapKit.framework */; }; - B5AA05CE189ED0DA00F516D4 /* BDKAuthViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B5AA05CD189ED0DA00F516D4 /* BDKAuthViewController.m */; }; - B5AA05D8189EDC8C00F516D4 /* BDKAutomaticSecrets.plist in Resources */ = {isa = PBXBuildFile; fileRef = B5AA05D7189EDC8C00F516D4 /* BDKAutomaticSecrets.plist */; }; - B5AA05DB189EE2E700F516D4 /* BDKTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B5AA05DA189EE2E700F516D4 /* BDKTableViewController.m */; }; - B5B3F54E18A12FA00043E3CE /* BDKMapViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B5B3F54D18A12FA00043E3CE /* BDKMapViewController.m */; }; + B5AA05CE189ED0DA00F516D4 /* NLAuthViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B5AA05CD189ED0DA00F516D4 /* NLAuthViewController.m */; }; + B5AA05D8189EDC8C00F516D4 /* NLAutomaticSecrets.plist in Resources */ = {isa = PBXBuildFile; fileRef = B5AA05D7189EDC8C00F516D4 /* NLAutomaticSecrets.plist */; }; + B5AA05DB189EE2E700F516D4 /* NLTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B5AA05DA189EE2E700F516D4 /* NLTableViewController.m */; }; + B5B3F54E18A12FA00043E3CE /* NLMapViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B5B3F54D18A12FA00043E3CE /* NLMapViewController.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -42,30 +42,30 @@ /* Begin PBXFileReference section */ 02AB4A0C5C4A49C9A6CF5B50 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; 70EB720583C2358271A8F2EC /* Pods-Specs.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Specs.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Specs/Pods-Specs.debug.xcconfig"; sourceTree = ""; }; - B52A0D18188DED6C00C21D6C /* BDKAutomatic.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BDKAutomatic.app; sourceTree = BUILT_PRODUCTS_DIR; }; + B52A0D18188DED6C00C21D6C /* NLAutomatic.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NLAutomatic.app; sourceTree = BUILT_PRODUCTS_DIR; }; B52A0D1B188DED6C00C21D6C /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; B52A0D1D188DED6C00C21D6C /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; B52A0D1F188DED6C00C21D6C /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; B52A0D33188DED6C00C21D6C /* Specs.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Specs.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; B52A0D34188DED6C00C21D6C /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; - B536C101188DED9400C02470 /* BDKAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BDKAppDelegate.h; sourceTree = ""; }; - B536C102188DED9400C02470 /* BDKAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BDKAppDelegate.m; sourceTree = ""; }; + B536C101188DED9400C02470 /* NLAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NLAppDelegate.h; sourceTree = ""; }; + B536C102188DED9400C02470 /* NLAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NLAppDelegate.m; sourceTree = ""; }; B536C103188DED9400C02470 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; B536C104188DED9400C02470 /* Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = ""; }; B536C106188DED9400C02470 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; B536C107188DED9400C02470 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; B536C108188DED9400C02470 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; B536C10F188DED9C00C02470 /* Specs-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Specs-Info.plist"; sourceTree = ""; }; - B536C110188DED9C00C02470 /* BDKAutomaticTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BDKAutomaticTests.m; sourceTree = ""; }; + B536C110188DED9C00C02470 /* NLAutomaticTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NLAutomaticTests.m; sourceTree = ""; }; B536C112188DED9C00C02470 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; B58FEB2A18A1F319009A6F62 /* MapKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MapKit.framework; path = System/Library/Frameworks/MapKit.framework; sourceTree = SDKROOT; }; - B5AA05CC189ED0DA00F516D4 /* BDKAuthViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BDKAuthViewController.h; sourceTree = ""; }; - B5AA05CD189ED0DA00F516D4 /* BDKAuthViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BDKAuthViewController.m; sourceTree = ""; }; - B5AA05D7189EDC8C00F516D4 /* BDKAutomaticSecrets.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = BDKAutomaticSecrets.plist; sourceTree = ""; }; - B5AA05D9189EE2E700F516D4 /* BDKTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BDKTableViewController.h; sourceTree = ""; }; - B5AA05DA189EE2E700F516D4 /* BDKTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BDKTableViewController.m; sourceTree = ""; }; - B5B3F54C18A12FA00043E3CE /* BDKMapViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BDKMapViewController.h; sourceTree = ""; }; - B5B3F54D18A12FA00043E3CE /* BDKMapViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BDKMapViewController.m; sourceTree = ""; }; + B5AA05CC189ED0DA00F516D4 /* NLAuthViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NLAuthViewController.h; sourceTree = ""; }; + B5AA05CD189ED0DA00F516D4 /* NLAuthViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NLAuthViewController.m; sourceTree = ""; }; + B5AA05D7189EDC8C00F516D4 /* NLAutomaticSecrets.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = NLAutomaticSecrets.plist; sourceTree = ""; }; + B5AA05D9189EE2E700F516D4 /* NLTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NLTableViewController.h; sourceTree = ""; }; + B5AA05DA189EE2E700F516D4 /* NLTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NLTableViewController.m; sourceTree = ""; }; + B5B3F54C18A12FA00043E3CE /* NLMapViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NLMapViewController.h; sourceTree = ""; }; + B5B3F54D18A12FA00043E3CE /* NLMapViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NLMapViewController.m; sourceTree = ""; }; DAA188196C9D81BE0DB0A0CB /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; E93DE9D0A47914EF61C0E278 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; }; F3F51D676EFA11B4330A349B /* Pods-Specs.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Specs.release.xcconfig"; path = "Pods/Target Support Files/Pods-Specs/Pods-Specs.release.xcconfig"; sourceTree = ""; }; @@ -124,7 +124,7 @@ B52A0D19188DED6C00C21D6C /* Products */ = { isa = PBXGroup; children = ( - B52A0D18188DED6C00C21D6C /* BDKAutomatic.app */, + B52A0D18188DED6C00C21D6C /* NLAutomatic.app */, B52A0D33188DED6C00C21D6C /* Specs.xctest */, ); name = Products; @@ -147,15 +147,15 @@ B536C100188DED9400C02470 /* Classes */ = { isa = PBXGroup; children = ( - B536C101188DED9400C02470 /* BDKAppDelegate.h */, - B536C102188DED9400C02470 /* BDKAppDelegate.m */, - B5AA05CC189ED0DA00F516D4 /* BDKAuthViewController.h */, - B5AA05CD189ED0DA00F516D4 /* BDKAuthViewController.m */, - B5B3F54C18A12FA00043E3CE /* BDKMapViewController.h */, - B5B3F54D18A12FA00043E3CE /* BDKMapViewController.m */, - B5AA05D9189EE2E700F516D4 /* BDKTableViewController.h */, - B5AA05DA189EE2E700F516D4 /* BDKTableViewController.m */, - B5AA05D7189EDC8C00F516D4 /* BDKAutomaticSecrets.plist */, + B536C101188DED9400C02470 /* NLAppDelegate.h */, + B536C102188DED9400C02470 /* NLAppDelegate.m */, + B5AA05CC189ED0DA00F516D4 /* NLAuthViewController.h */, + B5AA05CD189ED0DA00F516D4 /* NLAuthViewController.m */, + B5B3F54C18A12FA00043E3CE /* NLMapViewController.h */, + B5B3F54D18A12FA00043E3CE /* NLMapViewController.m */, + B5AA05D9189EE2E700F516D4 /* NLTableViewController.h */, + B5AA05DA189EE2E700F516D4 /* NLTableViewController.m */, + B5AA05D7189EDC8C00F516D4 /* NLAutomaticSecrets.plist */, B536C103188DED9400C02470 /* Info.plist */, B536C104188DED9400C02470 /* Prefix.pch */, B536C105188DED9400C02470 /* InfoPlist.strings */, @@ -169,7 +169,7 @@ isa = PBXGroup; children = ( B536C10F188DED9C00C02470 /* Specs-Info.plist */, - B536C110188DED9C00C02470 /* BDKAutomaticTests.m */, + B536C110188DED9C00C02470 /* NLAutomaticTests.m */, B536C111188DED9C00C02470 /* InfoPlist.strings */, ); path = Specs; @@ -178,9 +178,9 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - B52A0D17188DED6C00C21D6C /* BDKAutomatic */ = { + B52A0D17188DED6C00C21D6C /* NLAutomatic */ = { isa = PBXNativeTarget; - buildConfigurationList = B52A0D44188DED6C00C21D6C /* Build configuration list for PBXNativeTarget "BDKAutomatic" */; + buildConfigurationList = B52A0D44188DED6C00C21D6C /* Build configuration list for PBXNativeTarget "NLAutomatic" */; buildPhases = ( 337D016C90B84EE79DAC83FE /* Check Pods Manifest.lock */, B52A0D14188DED6C00C21D6C /* Sources */, @@ -192,9 +192,9 @@ ); dependencies = ( ); - name = BDKAutomatic; + name = NLAutomatic; productName = BDKAutomatic; - productReference = B52A0D18188DED6C00C21D6C /* BDKAutomatic.app */; + productReference = B52A0D18188DED6C00C21D6C /* NLAutomatic.app */; productType = "com.apple.product-type.application"; }; B52A0D32188DED6C00C21D6C /* Specs */ = { @@ -224,7 +224,7 @@ isa = PBXProject; attributes = { CLASSPREFIX = BDK; - LastUpgradeCheck = 0500; + LastUpgradeCheck = 0630; ORGANIZATIONNAME = "Ben Kreeger"; TargetAttributes = { B52A0D32188DED6C00C21D6C = { @@ -232,7 +232,7 @@ }; }; }; - buildConfigurationList = B52A0D13188DED6B00C21D6C /* Build configuration list for PBXProject "BDKAutomatic" */; + buildConfigurationList = B52A0D13188DED6B00C21D6C /* Build configuration list for PBXProject "NLAutomatic" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 0; @@ -244,7 +244,7 @@ projectDirPath = ""; projectRoot = ""; targets = ( - B52A0D17188DED6C00C21D6C /* BDKAutomatic */, + B52A0D17188DED6C00C21D6C /* NLAutomatic */, B52A0D32188DED6C00C21D6C /* Specs */, ); }; @@ -256,7 +256,7 @@ buildActionMask = 2147483647; files = ( B536C10C188DED9400C02470 /* Images.xcassets in Resources */, - B5AA05D8189EDC8C00F516D4 /* BDKAutomaticSecrets.plist in Resources */, + B5AA05D8189EDC8C00F516D4 /* NLAutomaticSecrets.plist in Resources */, B536C10B188DED9400C02470 /* InfoPlist.strings in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -340,11 +340,11 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - B5B3F54E18A12FA00043E3CE /* BDKMapViewController.m in Sources */, - B5AA05CE189ED0DA00F516D4 /* BDKAuthViewController.m in Sources */, + B5B3F54E18A12FA00043E3CE /* NLMapViewController.m in Sources */, + B5AA05CE189ED0DA00F516D4 /* NLAuthViewController.m in Sources */, B536C10D188DED9400C02470 /* main.m in Sources */, - B536C109188DED9400C02470 /* BDKAppDelegate.m in Sources */, - B5AA05DB189EE2E700F516D4 /* BDKTableViewController.m in Sources */, + B536C109188DED9400C02470 /* NLAppDelegate.m in Sources */, + B5AA05DB189EE2E700F516D4 /* NLTableViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -352,7 +352,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - B536C114188DED9C00C02470 /* BDKAutomaticTests.m in Sources */, + B536C114188DED9C00C02470 /* NLAutomaticTests.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -361,7 +361,7 @@ /* Begin PBXTargetDependency section */ B52A0D39188DED6C00C21D6C /* PBXTargetDependency */ = { isa = PBXTargetDependency; - target = B52A0D17188DED6C00C21D6C /* BDKAutomatic */; + target = B52A0D17188DED6C00C21D6C /* NLAutomatic */; targetProxy = B52A0D38188DED6C00C21D6C /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ @@ -390,7 +390,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -429,7 +428,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -467,7 +465,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = Classes/Prefix.pch; INFOPLIST_FILE = "$(SRCROOT)/Classes/Info.plist"; - PRODUCT_NAME = "$(TARGET_NAME)"; + PRODUCT_NAME = NLAutomatic; TARGETED_DEVICE_FAMILY = 1; WRAPPER_EXTENSION = app; }; @@ -482,7 +480,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = Classes/Prefix.pch; INFOPLIST_FILE = "$(SRCROOT)/Classes/Info.plist"; - PRODUCT_NAME = "$(TARGET_NAME)"; + PRODUCT_NAME = NLAutomatic; TARGETED_DEVICE_FAMILY = 1; WRAPPER_EXTENSION = app; }; @@ -492,8 +490,6 @@ isa = XCBuildConfiguration; baseConfigurationReference = 70EB720583C2358271A8F2EC /* Pods-Specs.debug.xcconfig */; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; - BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/BDKAutomatic.app/BDKAutomatic"; FRAMEWORK_SEARCH_PATHS = ( "$(SDKROOT)/Developer/Library/Frameworks", "$(inherited)", @@ -516,8 +512,6 @@ isa = XCBuildConfiguration; baseConfigurationReference = F3F51D676EFA11B4330A349B /* Pods-Specs.release.xcconfig */; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; - BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/BDKAutomatic.app/BDKAutomatic"; FRAMEWORK_SEARCH_PATHS = ( "$(SDKROOT)/Developer/Library/Frameworks", "$(inherited)", @@ -535,7 +529,7 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - B52A0D13188DED6B00C21D6C /* Build configuration list for PBXProject "BDKAutomatic" */ = { + B52A0D13188DED6B00C21D6C /* Build configuration list for PBXProject "NLAutomatic" */ = { isa = XCConfigurationList; buildConfigurations = ( B52A0D42188DED6C00C21D6C /* Debug */, @@ -544,7 +538,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - B52A0D44188DED6C00C21D6C /* Build configuration list for PBXNativeTarget "BDKAutomatic" */ = { + B52A0D44188DED6C00C21D6C /* Build configuration list for PBXNativeTarget "NLAutomatic" */ = { isa = XCConfigurationList; buildConfigurations = ( B52A0D45188DED6C00C21D6C /* Debug */, diff --git a/Project/BDKAutomatic.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Project/NLAutomatic.xcodeproj/project.xcworkspace/contents.xcworkspacedata similarity index 100% rename from Project/BDKAutomatic.xcodeproj/project.xcworkspace/contents.xcworkspacedata rename to Project/NLAutomatic.xcodeproj/project.xcworkspace/contents.xcworkspacedata diff --git a/Project/BDKAutomatic.xcodeproj/xcshareddata/xcschemes/BDKAutomatic.xcscheme b/Project/NLAutomatic.xcodeproj/xcshareddata/xcschemes/NLAutomatic.xcscheme similarity index 76% rename from Project/BDKAutomatic.xcodeproj/xcshareddata/xcschemes/BDKAutomatic.xcscheme rename to Project/NLAutomatic.xcodeproj/xcshareddata/xcschemes/NLAutomatic.xcscheme index b2db8d0..b2cda49 100644 --- a/Project/BDKAutomatic.xcodeproj/xcshareddata/xcschemes/BDKAutomatic.xcscheme +++ b/Project/NLAutomatic.xcodeproj/xcshareddata/xcschemes/NLAutomatic.xcscheme @@ -1,6 +1,6 @@ + BuildableName = "NLAutomatic.app" + BlueprintName = "NLAutomatic" + ReferencedContainer = "container:NLAutomatic.xcodeproj"> @@ -35,7 +35,7 @@ BlueprintIdentifier = "B52A0D32188DED6C00C21D6C" BuildableName = "Specs.xctest" BlueprintName = "Specs" - ReferencedContainer = "container:BDKAutomatic.xcodeproj"> + ReferencedContainer = "container:NLAutomatic.xcodeproj"> @@ -43,9 +43,9 @@ + BuildableName = "NLAutomatic.app" + BlueprintName = "NLAutomatic" + ReferencedContainer = "container:NLAutomatic.xcodeproj"> @@ -58,13 +58,14 @@ ignoresPersistentStateOnLaunch = "NO" debugDocumentVersioning = "YES" allowLocationSimulation = "YES"> - + + BuildableName = "NLAutomatic.app" + BlueprintName = "NLAutomatic" + ReferencedContainer = "container:NLAutomatic.xcodeproj"> @@ -76,13 +77,14 @@ useCustomWorkingDirectory = "NO" buildConfiguration = "Release" debugDocumentVersioning = "YES"> - + + BuildableName = "NLAutomatic.app" + BlueprintName = "NLAutomatic" + ReferencedContainer = "container:NLAutomatic.xcodeproj"> diff --git a/Project/Podfile b/Project/Podfile index 17212ba..f563d52 100644 --- a/Project/Podfile +++ b/Project/Podfile @@ -1,7 +1,7 @@ -pod "BDKAutomatic", :path => "../BDKAutomatic.podspec" +pod "NLAutomatic", :path => "../NLAutomatic.podspec" pod 'Reveal-iOS-SDK' -# target "BDKAutomatic" do +# target "NLAutomatic" do # end diff --git a/Project/Podfile.lock b/Project/Podfile.lock index d11eb32..405ba00 100644 --- a/Project/Podfile.lock +++ b/Project/Podfile.lock @@ -6,31 +6,36 @@ PODS: - AFNetworking/Reachability (2.5.2) - AFNetworking/Security (2.5.2) - AFNetworking/Serialization (2.5.2) - - BDKAutomatic (0.1.0): - - BDKAutomatic/Adapter (= 0.1.0) - - BDKAutomatic/MKPolyline (= 0.1.0) - - BDKAutomatic/Adapter (0.1.0): - - AFNetworking/NSURLConnection (~> 2.0) - - BDKAutomatic/MKPolyline (0.1.0) - Expecta (HEAD based on 0.3.2) + - NLAutomatic (0.1.0): + - NLAutomatic/Adapter (= 0.1.0) + - NLAutomatic/MKPolyline (= 0.1.0) + - NLAutomatic/Promise (= 0.1.0) + - NLAutomatic/Adapter (0.1.0): + - AFNetworking/NSURLConnection (~> 2.0) + - NLAutomatic/MKPolyline (0.1.0) + - NLAutomatic/Promise (0.1.0): + - PromiseKit/Promise + - PromiseKit/Promise (1.4.2) - Reveal-iOS-SDK (1.5.1) - - Specta (HEAD based on 0.4.0) + - Specta (HEAD based on 0.5.0) DEPENDENCIES: - - BDKAutomatic (from `../BDKAutomatic.podspec`) - Expecta (HEAD) + - NLAutomatic (from `../NLAutomatic.podspec`) - Reveal-iOS-SDK - Specta (HEAD) EXTERNAL SOURCES: - BDKAutomatic: - :path: ../BDKAutomatic.podspec + NLAutomatic: + :path: ../NLAutomatic.podspec SPEC CHECKSUMS: AFNetworking: fefbce9660acb17f48ae0011292d4da0f457bf36 - BDKAutomatic: 773b5a584d4fcbe399e06cc0cc7cf9f2e0508244 Expecta: 8c507baf13211207b1e9d0a741480600e6b4ed15 + NLAutomatic: f5056a62c4a554f652e1575c3a0527321d8d054e + PromiseKit: ea36001b558f42aa104a1422f305b46f8c343f2e Reveal-iOS-SDK: c9c55cad2729c85f6ced415f1b21857c9a2d8ef9 - Specta: a353759f073ffcc0a365b782fe4aaeac064c03c6 + Specta: eb90708ed77569bbda089f8ead10bb99b8e9489e COCOAPODS: 0.36.0 diff --git a/Project/Specs/BDKAutomaticTests.m b/Project/Specs/NLAutomaticTests.m similarity index 81% rename from Project/Specs/BDKAutomaticTests.m rename to Project/Specs/NLAutomaticTests.m index d44921f..55c0751 100644 --- a/Project/Specs/BDKAutomaticTests.m +++ b/Project/Specs/NLAutomaticTests.m @@ -1,6 +1,6 @@ // -// BDKAutomaticTests.m -// BDKAutomaticTests +// NLAutomaticTests.m +// NLAutomaticTests // // Created by Ben Kreeger on 1/20/14. // Copyright (c) 2014 Ben Kreeger. All rights reserved. @@ -8,11 +8,11 @@ #import -@interface BDKAutomaticTests : XCTestCase +@interface NLAutomaticTests : XCTestCase @end -@implementation BDKAutomaticTests +@implementation NLAutomaticTests - (void)setUp { From f215366ae1230a226bf5152aa791f129f59c86d2 Mon Sep 17 00:00:00 2001 From: Nelson LeDuc Date: Sat, 4 Apr 2015 05:05:30 -0500 Subject: [PATCH 13/17] Fix podspec --- NLAutomatic.podspec | 1 + 1 file changed, 1 insertion(+) diff --git a/NLAutomatic.podspec b/NLAutomatic.podspec index 20c0c8d..0769c0b 100644 --- a/NLAutomatic.podspec +++ b/NLAutomatic.podspec @@ -23,6 +23,7 @@ Pod::Spec.new do |s| s.subspec 'Promise' do |sub| sub.source_files = 'Classes/Promise/*.{h,m}' + sub.dependency 'NLAutomatic/Adapter' sub.dependency 'PromiseKit/Promise' end end From f921e41e80661ac266c0591044c238401a0660f4 Mon Sep 17 00:00:00 2001 From: Nelson LeDuc Date: Sat, 4 Apr 2015 05:11:51 -0500 Subject: [PATCH 14/17] Update readme --- readme.markdown | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/readme.markdown b/readme.markdown index d8358ba..1282051 100644 --- a/readme.markdown +++ b/readme.markdown @@ -1,8 +1,7 @@ -# BDKAutomatic +# NLAutomatic -[![Version](http://cocoapod-badges.herokuapp.com/v/BDKAutomatic/badge.png)](http://cocoadocs.org/docsets/BDKAutomatic) -[![Platform](http://cocoapod-badges.herokuapp.com/p/BDKAutomatic/badge.png)](http://cocoadocs.org/docsets/BDKAutomatic) -[![Build Status](https://travis-ci.org/kreeger/BDKAutomatic.png?branch=master)](https://travis-ci.org/kreeger/BDKAutomatic) +[![Version](http://cocoapod-badges.herokuapp.com/v/NLAutomatic/badge.png)](http://cocoadocs.org/docsets/NLAutomatic) +[![Platform](http://cocoapod-badges.herokuapp.com/p/NLAutomatic/badge.png)](http://cocoadocs.org/docsets/NLAutomatic) ## Overview @@ -14,56 +13,56 @@ A library, along with a sample project, that demonstrates some basic usage of th Sweet GIF action: -![In action](https://raw.github.com/kreeger/BDKAutomatic/master/Project/BDKAutomaticDemo.gif) +![In action](https://raw.github.com/nelsonleduc/NLAutomatic/master/Project/NLAutomaticDemo.gif) ## Usage -Just include `#import ` at the top of whatever Objective-C thing you're doing, and fire away. +Just include `#import ` at the top of whatever Objective-C thing you're doing, and fire away. ``` objective-c -BDKAutomatic *adapter = [[BDKAutomatic alloc] initWithClientId:clientId +NLAutomatic *adapter = [[NLAutomatic alloc] initWithClientId:clientId clientSecret:clientSecret redirectUrl:redirectUrl]; ``` -You'll need to authenticate it against a user account using the OAuth2 dance. See `-[BDKAuthViewController handleAutomaticAuthenticationQueryString:]` for usage examples. Once you trade your authorization code for a legitimate `BDKAutomaticToken` (which conforms to `NSCopying`, by the way, so you can marshal that bad boy to Keychain or something), you can make calls on behalf of an Automatic user. +You'll need to authenticate it against a user account using the OAuth2 dance. See `-[NLAuthViewController handleAutomaticAuthenticationQueryString:]` for usage examples. Once you trade your authorization code for a legitimate `NLAutomaticToken` (which conforms to `NSCopying`, by the way, so you can marshal that bad boy to Keychain or something), you can make calls on behalf of an Automatic user. ``` objective-c [self.automatic getTrips:^(NSError *error, NSArray *trips) { - BDKAutomaticTrip *trip = [trips firstObject]; + NLAutomaticTrip *trip = [trips firstObject]; NSLog(@"Trip started %@.", trip.startTime); }]; ``` -If you want an `MKPolyline` out of `-[BDKAutomaticTrip path]`, you'll want to include the separate `BDKAutomatic/MKPolylineSupport` subspec in your `Podfile`, and use it like so. +If you want an `MKPolyline` out of `-[NLAutomaticTrip path]`, you'll want to include the separate `NLAutomatic/MKPolylineSupport` subspec in your `Podfile`, and use it like so. ``` objective-c -#import +#import ... MKPolyline *mapPath = [MKPolyline polylineWithEncodedString:trip.path]; [self.mapView addOverlay:mapPath level:MKOverlayLevelAboveRoads]; ``` -You get the idea. See `BDKMapViewController.m` for more goodies. +You get the idea. See `NLMapViewController.m` for more goodies. ## Example project setup -To run the example project; clone the repo, and run `pod install` from the Project directory first. Then, open `BDKAutomatic.xcworkspace` in the Project directory. +To run the example project; clone the repo, and run `pod install` from the Project directory first. Then, open `NLAutomatic.xcworkspace` in the Project directory. -You'll want to copy the secret PLIST file from `Project/Classes/BDKAutomaticSecrets.plist.example` to `Project/Classes/BDKAutomaticSecrets.plist` and fill it out with your Automatic API client ID and client secret. +You'll want to copy the secret PLIST file from `Project/Classes/NLAutomaticSecrets.plist.example` to `Project/Classes/NLAutomaticSecrets.plist` and fill it out with your Automatic API client ID and client secret. ## Installation -BDKAutomatic is available through [CocoaPods](http://cocoapods.org), which is righteously awesome. To install it, simply add the following line to your Podfile. +NLAutomatic is available through [CocoaPods](http://cocoapods.org), which is righteously awesome. To install it, simply add the following line to your Podfile. ``` ruby -pod 'BDKAutomatic' +pod 'NLAutomatic' ``` -If you don't want to use the "path-to-`MKPolyline`" functionality, just use [the subspec for the adapter](https://github.com/kreeger/BDKAutomatic/blob/master/BDKAutomatic.podspec#L14). +If you don't want to use the "path-to-`MKPolyline`" functionality, just use [the subspec for the adapter](https://github.com/nelsonleduc/NLAutomatic/blob/master/NLAutomatic.podspec#L14). ``` ruby -pod 'BDKAutomatic/Adapter' +pod 'NLAutomatic/Adapter' ``` ## Author @@ -72,6 +71,6 @@ Ben Kreeger, ben@kree.gr ## License -BDKAutomatic is available under the MIT license. See the LICENSE file for more info. +NLAutomatic is available under the MIT license. See the LICENSE file for more info. [rest]: https://www.automatic.com/developer/ From 03a358e38e8a89ffe651e5adea309c09d464e358 Mon Sep 17 00:00:00 2001 From: Nelson LeDuc Date: Sat, 4 Apr 2015 05:15:06 -0500 Subject: [PATCH 15/17] Update gif name --- .../contents.xcworkspacedata | 10 ----- .../xcshareddata/BDKAutomatic.xccheckout | 41 ------------------ ...KAutomaticDemo.gif => NLAutomaticDemo.gif} | Bin Project/Podfile.lock | 3 +- 4 files changed, 2 insertions(+), 52 deletions(-) delete mode 100644 Project/BDKAutomatic.xcworkspace/contents.xcworkspacedata delete mode 100644 Project/BDKAutomatic.xcworkspace/xcshareddata/BDKAutomatic.xccheckout rename Project/{BDKAutomaticDemo.gif => NLAutomaticDemo.gif} (100%) diff --git a/Project/BDKAutomatic.xcworkspace/contents.xcworkspacedata b/Project/BDKAutomatic.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 5d1d7cb..0000000 --- a/Project/BDKAutomatic.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - diff --git a/Project/BDKAutomatic.xcworkspace/xcshareddata/BDKAutomatic.xccheckout b/Project/BDKAutomatic.xcworkspace/xcshareddata/BDKAutomatic.xccheckout deleted file mode 100644 index 1092305..0000000 --- a/Project/BDKAutomatic.xcworkspace/xcshareddata/BDKAutomatic.xccheckout +++ /dev/null @@ -1,41 +0,0 @@ - - - - - IDESourceControlProjectFavoriteDictionaryKey - - IDESourceControlProjectIdentifier - 1D47559F-68FE-4535-A615-5DDC995BFEEF - IDESourceControlProjectName - BDKAutomatic - IDESourceControlProjectOriginsDictionary - - 3CC2F2072B5DF56FA0EB852FD2A76AA6EC0162CF - github.com:NelsonLeDuc/BDKAutomatic.git - - IDESourceControlProjectPath - Project/BDKAutomatic.xcworkspace - IDESourceControlProjectRelativeInstallPathDictionary - - 3CC2F2072B5DF56FA0EB852FD2A76AA6EC0162CF - ../.. - - IDESourceControlProjectURL - github.com:NelsonLeDuc/BDKAutomatic.git - IDESourceControlProjectVersion - 111 - IDESourceControlProjectWCCIdentifier - 3CC2F2072B5DF56FA0EB852FD2A76AA6EC0162CF - IDESourceControlProjectWCConfigurations - - - IDESourceControlRepositoryExtensionIdentifierKey - public.vcs.git - IDESourceControlWCCIdentifierKey - 3CC2F2072B5DF56FA0EB852FD2A76AA6EC0162CF - IDESourceControlWCCName - BDKAutomatic - - - - diff --git a/Project/BDKAutomaticDemo.gif b/Project/NLAutomaticDemo.gif similarity index 100% rename from Project/BDKAutomaticDemo.gif rename to Project/NLAutomaticDemo.gif diff --git a/Project/Podfile.lock b/Project/Podfile.lock index 405ba00..6c0f57f 100644 --- a/Project/Podfile.lock +++ b/Project/Podfile.lock @@ -15,6 +15,7 @@ PODS: - AFNetworking/NSURLConnection (~> 2.0) - NLAutomatic/MKPolyline (0.1.0) - NLAutomatic/Promise (0.1.0): + - NLAutomatic/Adapter - PromiseKit/Promise - PromiseKit/Promise (1.4.2) - Reveal-iOS-SDK (1.5.1) @@ -33,7 +34,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: AFNetworking: fefbce9660acb17f48ae0011292d4da0f457bf36 Expecta: 8c507baf13211207b1e9d0a741480600e6b4ed15 - NLAutomatic: f5056a62c4a554f652e1575c3a0527321d8d054e + NLAutomatic: 4480f3297183d1e75f383403d56abe82866174c6 PromiseKit: ea36001b558f42aa104a1422f305b46f8c343f2e Reveal-iOS-SDK: c9c55cad2729c85f6ced415f1b21857c9a2d8ef9 Specta: eb90708ed77569bbda089f8ead10bb99b8e9489e From 5ab89b0f6fbfcaa1c43634e130e12d5d21abc51f Mon Sep 17 00:00:00 2001 From: Nelson LeDuc Date: Sat, 4 Apr 2015 19:53:35 -0500 Subject: [PATCH 16/17] Update readme --- readme.markdown | 4 ---- 1 file changed, 4 deletions(-) diff --git a/readme.markdown b/readme.markdown index 1282051..9e6372a 100644 --- a/readme.markdown +++ b/readme.markdown @@ -65,10 +65,6 @@ If you don't want to use the "path-to-`MKPolyline`" functionality, just use [the pod 'NLAutomatic/Adapter' ``` -## Author - -Ben Kreeger, ben@kree.gr - ## License NLAutomatic is available under the MIT license. See the LICENSE file for more info. From 1016bc5e117f7a3220a3b7dec50bf540eb11dabc Mon Sep 17 00:00:00 2001 From: Nelson LeDuc Date: Mon, 6 Apr 2015 19:20:05 -0500 Subject: [PATCH 17/17] Start returning an operation to allow canceling, pausing, and resuming --- ...TTPRequestOperation+NLAutomaticOperation.h | 14 ++++++++ ...TTPRequestOperation+NLAutomaticOperation.m | 28 ++++++++++++++++ Classes/NLAutomatic.h | 15 +++++---- Classes/NLAutomatic.m | 33 +++++++++++++------ Classes/NLAutomaticOperation.h | 17 ++++++++++ 5 files changed, 90 insertions(+), 17 deletions(-) create mode 100644 Classes/AFHTTPRequestOperation+NLAutomaticOperation.h create mode 100644 Classes/AFHTTPRequestOperation+NLAutomaticOperation.m create mode 100644 Classes/NLAutomaticOperation.h diff --git a/Classes/AFHTTPRequestOperation+NLAutomaticOperation.h b/Classes/AFHTTPRequestOperation+NLAutomaticOperation.h new file mode 100644 index 0000000..824166a --- /dev/null +++ b/Classes/AFHTTPRequestOperation+NLAutomaticOperation.h @@ -0,0 +1,14 @@ +// +// AFHTTPRequestOperation+NLAutomaticOperation.h +// Pods +// +// Created by Nelson LeDuc on 4/6/15. +// +// + +#import +#import "NLAutomaticOperation.h" + +@interface AFHTTPRequestOperation (NLAutomaticOperation) + +@end diff --git a/Classes/AFHTTPRequestOperation+NLAutomaticOperation.m b/Classes/AFHTTPRequestOperation+NLAutomaticOperation.m new file mode 100644 index 0000000..13c7394 --- /dev/null +++ b/Classes/AFHTTPRequestOperation+NLAutomaticOperation.m @@ -0,0 +1,28 @@ +// +// AFHTTPRequestOperation+NLAutomaticOperation.m +// Pods +// +// Created by Nelson LeDuc on 4/6/15. +// +// + +#import "AFHTTPRequestOperation+NLAutomaticOperation.h" + +@implementation AFHTTPRequestOperation (NLAutomaticOperation) + +- (void)cancelAutomaticOperation +{ + [self cancel]; +} + +- (void)pauseAutomaticOperation +{ + [self pause]; +} + +- (void)resumeAutomaticOperation +{ + [self resume]; +} + +@end diff --git a/Classes/NLAutomatic.h b/Classes/NLAutomatic.h index 3c77bec..ba22da7 100644 --- a/Classes/NLAutomatic.h +++ b/Classes/NLAutomatic.h @@ -7,9 +7,10 @@ // @import Foundation; - #import "NLAutomaticScopes.h" -#import "NLAutomaticToken.h" + +@class NLAutomaticToken; +@protocol NLAutomaticOperation; typedef void(^NLAutomaticCompletionBlock)(NSError *error, id responseObject); typedef void(^NLAutomaticTokenCompletionBlock)(NSError *error, NLAutomaticToken *token); @@ -40,17 +41,17 @@ typedef void(^NLAutomaticTokenCompletionBlock)(NSError *error, NLAutomaticToken #pragma mark - Trip data -- (void)getTrips:(NLAutomaticCompletionBlock)completion; -- (void)getTripForId:(NSString *)identifier completion:(NLAutomaticCompletionBlock)completion; +- (id)getTrips:(NLAutomaticCompletionBlock)completion; +- (id)getTripForId:(NSString *)identifier completion:(NLAutomaticCompletionBlock)completion; #pragma mark - User data -- (void)getUser:(NLAutomaticCompletionBlock)completion; +- (id)getUser:(NLAutomaticCompletionBlock)completion; #pragma mark - Vehicle data -- (void)getVehicles:(NLAutomaticCompletionBlock)completion; -- (void)getVehicleForId:(NSString *)identifier completion:(NLAutomaticCompletionBlock)completion; +- (id)getVehicles:(NLAutomaticCompletionBlock)completion; +- (id)getVehicleForId:(NSString *)identifier completion:(NLAutomaticCompletionBlock)completion; @end diff --git a/Classes/NLAutomatic.m b/Classes/NLAutomatic.m index 80ff363..de6a0f0 100644 --- a/Classes/NLAutomatic.m +++ b/Classes/NLAutomatic.m @@ -11,6 +11,9 @@ #import "NLAutomaticTrip.h" #import "NLAutomaticUser.h" #import "NLAutomaticVehicle.h" +#import "NLAutomaticToken.h" +#import "NLAutomaticOperation.h" +#import "AFHTTPRequestOperation+NLAutomaticOperation.h" #import static NSString * const kAutomaticAPIBaseURLString = @"https://api.automatic.com/v1"; @@ -133,10 +136,10 @@ - (void)getAccessTokenForCode:(NSString *)code completion:(NLAutomaticTokenCompl #pragma mark - Trip data -- (void)getTrips:(NLAutomaticCompletionBlock)completion { +- (id)getTrips:(NLAutomaticCompletionBlock)completion { NSString *url = @"trips"; NSDictionary *params = @{}; - [self.operationManager GET:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { + id automaticOp = [self.operationManager GET:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { NSMutableArray *mResults = [NSMutableArray array]; [responseObject enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { [mResults addObject:[[NLAutomaticTrip alloc] initWithAPIObject:obj]]; @@ -149,13 +152,15 @@ - (void)getTrips:(NLAutomaticCompletionBlock)completion { completion(error, operation.responseObject); } }]; + + return automaticOp; } -- (void)getTripForId:(NSString *)identifier completion:(NLAutomaticCompletionBlock)completion +- (id)getTripForId:(NSString *)identifier completion:(NLAutomaticCompletionBlock)completion { NSString *url = [NSString stringWithFormat:@"%@/%@", @"trips", identifier]; NSDictionary *params = @{}; - [self.operationManager GET:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { + id automaticOp = [self.operationManager GET:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { NLAutomaticTrip *trip = [[NLAutomaticTrip alloc] initWithAPIObject:responseObject]; if (completion) { completion(nil, trip); @@ -165,15 +170,17 @@ - (void)getTripForId:(NSString *)identifier completion:(NLAutomaticCompletionBlo completion(error, operation.responseObject); } }]; + + return automaticOp; } #pragma mark - User data -- (void)getUser:(NLAutomaticCompletionBlock)completion +- (id)getUser:(NLAutomaticCompletionBlock)completion { NSString *url = @"user"; NSDictionary *params = @{}; - [self.operationManager GET:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { + id automaticOp = [self.operationManager GET:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { NLAutomaticUser *user = [[NLAutomaticUser alloc] initWithAPIObject:responseObject]; if (completion) { completion(nil, user); @@ -183,15 +190,17 @@ - (void)getUser:(NLAutomaticCompletionBlock)completion completion(error, operation.responseObject); } }]; + + return automaticOp; } #pragma mark - Vehicle data -- (void)getVehicles:(NLAutomaticCompletionBlock)completion +- (id)getVehicles:(NLAutomaticCompletionBlock)completion { NSString *url = @"vehicles"; NSDictionary *params = @{}; - [self.operationManager GET:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { + id automaticOp = [self.operationManager GET:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { NSMutableArray *mResults = [NSMutableArray array]; [responseObject enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { [mResults addObject:[[NLAutomaticVehicle alloc] initWithAPIObject:obj]]; @@ -204,13 +213,15 @@ - (void)getVehicles:(NLAutomaticCompletionBlock)completion completion(error, operation.responseObject); } }]; + + return automaticOp; } -- (void)getVehicleForId:(NSString *)identifier completion:(NLAutomaticCompletionBlock)completion +- (id)getVehicleForId:(NSString *)identifier completion:(NLAutomaticCompletionBlock)completion { NSString *url = [NSString stringWithFormat:@"%@/%@", @"vehicles", identifier]; NSDictionary *params = @{}; - [self.operationManager GET:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { + id automaticOp = [self.operationManager GET:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { NLAutomaticVehicle *vehicle = [[NLAutomaticVehicle alloc] initWithAPIObject:responseObject]; if (completion) { completion(nil, vehicle); @@ -220,6 +231,8 @@ - (void)getVehicleForId:(NSString *)identifier completion:(NLAutomaticCompletion completion(error, operation.responseObject); } }]; + + return automaticOp; } @end diff --git a/Classes/NLAutomaticOperation.h b/Classes/NLAutomaticOperation.h new file mode 100644 index 0000000..7f13a80 --- /dev/null +++ b/Classes/NLAutomaticOperation.h @@ -0,0 +1,17 @@ +// +// NLAutomaticOperation.h +// Pods +// +// Created by Nelson LeDuc on 4/6/15. +// +// + +#import + +@protocol NLAutomaticOperation + +- (void)cancelAutomaticOperation; +- (void)pauseAutomaticOperation; +- (void)resumeAutomaticOperation; + +@end