Skip to content

Commit

Permalink
Changed name of account (and tests) for more general use.
Browse files Browse the repository at this point in the history
Added all missing API calls to server class and converted received JSON objects.
Added global header for JSON objects classes.
Fixed imports of headers in JSON objects classes.
  • Loading branch information
Davide De Franceschi authored and Davide De Franceschi committed Aug 23, 2014
1 parent 1b70bda commit 76d845c
Show file tree
Hide file tree
Showing 21 changed files with 407 additions and 67 deletions.
32 changes: 22 additions & 10 deletions BopplExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
033AFC1219A818B300212011 /* BopplProduct.m in Sources */ = {isa = PBXBuildFile; fileRef = 033AFC1119A818B300212011 /* BopplProduct.m */; };
033AFC1519A818C400212011 /* BopplProductCategory.m in Sources */ = {isa = PBXBuildFile; fileRef = 033AFC1419A818C400212011 /* BopplProductCategory.m */; };
033AFC1819A818D100212011 /* BopplProductGroup.m in Sources */ = {isa = PBXBuildFile; fileRef = 033AFC1719A818D100212011 /* BopplProductGroup.m */; };
033AFC1C19A8AB0300212011 /* WebImageDownloader.m in Sources */ = {isa = PBXBuildFile; fileRef = 033AFC1B19A8AB0300212011 /* WebImageDownloader.m */; };
033AFC1E19A8AB1F00212011 /* WebImageDownloaderTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 033AFC1D19A8AB1F00212011 /* WebImageDownloaderTest.m */; };
03FBA2DE19A4F8100014DE22 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 03FBA2DD19A4F8100014DE22 /* Foundation.framework */; };
03FBA2E019A4F8100014DE22 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 03FBA2DF19A4F8100014DE22 /* CoreGraphics.framework */; };
03FBA2E219A4F8100014DE22 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 03FBA2E119A4F8100014DE22 /* UIKit.framework */; };
Expand All @@ -28,8 +30,8 @@
03FBA2FF19A4F8160014DE22 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 03FBA2E119A4F8100014DE22 /* UIKit.framework */; };
03FBA30719A4F8160014DE22 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 03FBA30519A4F8160014DE22 /* InfoPlist.strings */; };
03FBA31519A4FDC70014DE22 /* BopplServer.m in Sources */ = {isa = PBXBuildFile; fileRef = 03FBA31419A4FDC70014DE22 /* BopplServer.m */; };
03FBA31919A513A00014DE22 /* BopplAccount.m in Sources */ = {isa = PBXBuildFile; fileRef = 03FBA31819A513A00014DE22 /* BopplAccount.m */; };
03FBA31B19A521040014DE22 /* BopplAccountTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 03FBA31A19A521040014DE22 /* BopplAccountTest.m */; };
03FBA31919A513A00014DE22 /* BasicHTTPAuthAccount.m in Sources */ = {isa = PBXBuildFile; fileRef = 03FBA31819A513A00014DE22 /* BasicHTTPAuthAccount.m */; };
03FBA31B19A521040014DE22 /* BasicHTTPAuthAccountTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 03FBA31A19A521040014DE22 /* BasicHTTPAuthAccountTest.m */; };
03FBA31D19A561260014DE22 /* BopplServerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 03FBA31C19A561260014DE22 /* BopplServerTest.m */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -59,6 +61,10 @@
033AFC1619A818D100212011 /* BopplProductGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BopplProductGroup.h; sourceTree = "<group>"; };
033AFC1719A818D100212011 /* BopplProductGroup.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BopplProductGroup.m; sourceTree = "<group>"; };
033AFC1919A81A2900212011 /* init_macros.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = init_macros.h; sourceTree = "<group>"; };
033AFC1A19A8AB0300212011 /* WebImageDownloader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebImageDownloader.h; sourceTree = "<group>"; };
033AFC1B19A8AB0300212011 /* WebImageDownloader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebImageDownloader.m; sourceTree = "<group>"; };
033AFC1D19A8AB1F00212011 /* WebImageDownloaderTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebImageDownloaderTest.m; sourceTree = "<group>"; };
033AFC1F19A8C6C700212011 /* BopplJSONObjects.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BopplJSONObjects.h; sourceTree = "<group>"; };
03FBA2DA19A4F80F0014DE22 /* BopplExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BopplExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
03FBA2DD19A4F8100014DE22 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
03FBA2DF19A4F8100014DE22 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
Expand All @@ -79,9 +85,9 @@
03FBA30619A4F8160014DE22 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
03FBA31319A4FDC70014DE22 /* BopplServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BopplServer.h; sourceTree = "<group>"; };
03FBA31419A4FDC70014DE22 /* BopplServer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BopplServer.m; sourceTree = "<group>"; };
03FBA31719A5139F0014DE22 /* BopplAccount.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BopplAccount.h; sourceTree = "<group>"; };
03FBA31819A513A00014DE22 /* BopplAccount.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BopplAccount.m; sourceTree = "<group>"; };
03FBA31A19A521040014DE22 /* BopplAccountTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BopplAccountTest.m; sourceTree = "<group>"; };
03FBA31719A5139F0014DE22 /* BasicHTTPAuthAccount.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BasicHTTPAuthAccount.h; sourceTree = "<group>"; };
03FBA31819A513A00014DE22 /* BasicHTTPAuthAccount.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BasicHTTPAuthAccount.m; sourceTree = "<group>"; };
03FBA31A19A521040014DE22 /* BasicHTTPAuthAccountTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BasicHTTPAuthAccountTest.m; sourceTree = "<group>"; };
03FBA31C19A561260014DE22 /* BopplServerTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BopplServerTest.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -168,8 +174,9 @@
03FBA30219A4F8160014DE22 /* BopplExampleTests */ = {
isa = PBXGroup;
children = (
03FBA31A19A521040014DE22 /* BopplAccountTest.m */,
03FBA31A19A521040014DE22 /* BasicHTTPAuthAccountTest.m */,
03FBA31C19A561260014DE22 /* BopplServerTest.m */,
033AFC1D19A8AB1F00212011 /* WebImageDownloaderTest.m */,
03FBA30319A4F8160014DE22 /* Supporting Files */,
);
path = BopplExampleTests;
Expand Down Expand Up @@ -200,10 +207,11 @@
03FBA31619A4FDD00014DE22 /* Model */ = {
isa = PBXGroup;
children = (
03FBA31719A5139F0014DE22 /* BopplAccount.h */,
03FBA31819A513A00014DE22 /* BopplAccount.m */,
03FBA31719A5139F0014DE22 /* BasicHTTPAuthAccount.h */,
03FBA31819A513A00014DE22 /* BasicHTTPAuthAccount.m */,
03FBA31319A4FDC70014DE22 /* BopplServer.h */,
03FBA31419A4FDC70014DE22 /* BopplServer.m */,
033AFC1F19A8C6C700212011 /* BopplJSONObjects.h */,
033AFC1619A818D100212011 /* BopplProductGroup.h */,
033AFC1719A818D100212011 /* BopplProductGroup.m */,
033AFC1319A818C400212011 /* BopplProductCategory.h */,
Expand All @@ -214,6 +222,8 @@
033AFC0E19A8187800212011 /* BopplProductModifierCategory.m */,
033AFC1019A818B300212011 /* BopplProduct.h */,
033AFC1119A818B300212011 /* BopplProduct.m */,
033AFC1A19A8AB0300212011 /* WebImageDownloader.h */,
033AFC1B19A8AB0300212011 /* WebImageDownloader.m */,
);
name = Model;
sourceTree = "<group>";
Expand Down Expand Up @@ -317,6 +327,7 @@
files = (
033AFC1519A818C400212011 /* BopplProductCategory.m in Sources */,
03FBA31519A4FDC70014DE22 /* BopplServer.m in Sources */,
033AFC1C19A8AB0300212011 /* WebImageDownloader.m in Sources */,
033AFC0919A675DC00212011 /* ResultViewController.m in Sources */,
03FBA2F419A4F8110014DE22 /* MainViewController.m in Sources */,
033AFC0F19A8187800212011 /* BopplProductModifierCategory.m in Sources */,
Expand All @@ -326,7 +337,7 @@
03FBA2EA19A4F8110014DE22 /* main.m in Sources */,
033AFC1819A818D100212011 /* BopplProductGroup.m in Sources */,
033AFC0C19A8185800212011 /* BopplProductModifier.m in Sources */,
03FBA31919A513A00014DE22 /* BopplAccount.m in Sources */,
03FBA31919A513A00014DE22 /* BasicHTTPAuthAccount.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -335,7 +346,8 @@
buildActionMask = 2147483647;
files = (
03FBA31D19A561260014DE22 /* BopplServerTest.m in Sources */,
03FBA31B19A521040014DE22 /* BopplAccountTest.m in Sources */,
03FBA31B19A521040014DE22 /* BasicHTTPAuthAccountTest.m in Sources */,
033AFC1E19A8AB1F00212011 /* WebImageDownloaderTest.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#import <Foundation/Foundation.h>

@interface BopplAccount : NSObject
@interface BasicHTTPAuthAccount : NSObject

@property (strong, nonatomic) NSString *username;
@property (strong, nonatomic) NSString *password;
Expand All @@ -20,7 +20,7 @@

- (NSString *)encodedAuthorizationString;

- (BOOL)isEqualToAccount:(BopplAccount *)account;
- (BOOL)isEqualToAccount:(BasicHTTPAuthAccount *)account;

#warning TODO: add KeyChain support

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
// Copyright (c) 2014 Davide De Franceschi. All rights reserved.
//

#import "BopplAccount.h"
#import "BasicHTTPAuthAccount.h"
#import "init_macros.h"

@implementation BopplAccount
@implementation BasicHTTPAuthAccount

#pragma mark Initialization

Expand Down Expand Up @@ -133,7 +133,7 @@ + (NSString *)authorizationStringWithUsername:(NSString *)username andPassword:(

#pragma mark Equality

- (BOOL)isEqualToAccount:(BopplAccount *)anAccount
- (BOOL)isEqualToAccount:(BasicHTTPAuthAccount *)anAccount
{
if (anAccount == nil) {
return NO;
Expand All @@ -150,11 +150,11 @@ - (BOOL)isEqual:(id)object
return YES;
}

if (![object isKindOfClass:[BopplAccount class]]) {
if (![object isKindOfClass:[BasicHTTPAuthAccount class]]) {
return NO;
}

return [self isEqualToAccount:(BopplAccount *)object];
return [self isEqualToAccount:(BasicHTTPAuthAccount *)object];
}

- (NSUInteger)hash
Expand Down
18 changes: 18 additions & 0 deletions BopplExample/BopplJSONObjects.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// BopplJSONObjects.h
// BopplExample
//
// Created by Davide De Franceschi on 23/08/14.
// Copyright (c) 2014 Davide De Franceschi. All rights reserved.
//

#ifndef BopplExample_BopplJSONObjects_h
#define BopplExample_BopplJSONObjects_h

#import "BopplProduct.h"
#import "BopplProductGroup.h"
#import "BopplProductCategory.h"
#import "BopplProductModifier.h"
#import "BopplProductModifierCategory.h"

#endif
6 changes: 4 additions & 2 deletions BopplExample/BopplProduct.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
//

#import <Foundation/Foundation.h>
#import "BopplProductCategory.h"
#import "BopplProductModifierCategory.h"
#import "WebImageDownloader.h"
@class BopplProductCategory;

@interface BopplProduct : NSObject

Expand Down Expand Up @@ -37,4 +37,6 @@
- (instancetype)initWithJSONData:(NSData *)data;
- (instancetype)initWithDictionary:(NSDictionary *)dictionary;

- (void)downloadThumbnailImageWithDownloader:(WebImageDownloader *)downloader completion:(void (^)())completion;

@end
17 changes: 17 additions & 0 deletions BopplExample/BopplProduct.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
//

#import "BopplProduct.h"
#import "BopplProductCategory.h"
#import "BopplProductModifierCategory.h"
#import "init_macros.h"

@implementation BopplProduct
Expand Down Expand Up @@ -70,4 +72,19 @@ + (instancetype)productWithDictionary:(NSDictionary *)dictionary
return [[self alloc] initWithDictionary:dictionary];
}

#pragma mark BopplProduct

- (void)downloadThumbnailImageWithDownloader:(WebImageDownloader *)downloader completion:(void (^)())completion
{
if (downloader == nil) {
NSLog(@"Trying to download thumbnail image with nil downloader.");
return;
}

[downloader downloadImageFromURL:self.thumbnailImageURL completion:^(UIImage *downloadedImage) {
self.thumbnailImage = downloadedImage;
completion(self.thumbnailImage);
}];
}

@end
2 changes: 1 addition & 1 deletion BopplExample/BopplProductCategory.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

#import <Foundation/Foundation.h>
#import "BopplProductGroup.h"
@class BopplProductGroup;

@interface BopplProductCategory : NSObject

Expand Down
1 change: 1 addition & 0 deletions BopplExample/BopplProductCategory.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

#import "BopplProductCategory.h"
#import "BopplProductGroup.h"
#import "init_macros.h"

@implementation BopplProductCategory
Expand Down
2 changes: 1 addition & 1 deletion BopplExample/BopplProductModifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

#import <Foundation/Foundation.h>
#import "BopplProduct.h"
@class BopplProduct;

@interface BopplProductModifier : NSObject

Expand Down
1 change: 1 addition & 0 deletions BopplExample/BopplProductModifier.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

#import "BopplProductModifier.h"
#import "BopplProduct.h"
#import "init_macros.h"

@implementation BopplProductModifier
Expand Down
1 change: 0 additions & 1 deletion BopplExample/BopplProductModifierCategory.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//

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

@interface BopplProductModifierCategory : NSObject

Expand Down
1 change: 1 addition & 0 deletions BopplExample/BopplProductModifierCategory.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

#import "BopplProductModifierCategory.h"
#import "BopplProductModifier.h"
#import "init_macros.h"

@implementation BopplProductModifierCategory
Expand Down
14 changes: 11 additions & 3 deletions BopplExample/BopplServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,22 @@
//

#import <Foundation/Foundation.h>
#import "BopplAccount.h"
#import "BasicHTTPAuthAccount.h"
#import "BopplJSONObjects.h"

@interface BopplServer : NSObject

@property (strong, nonatomic) BopplAccount *account;
@property (strong, nonatomic) BasicHTTPAuthAccount *account;

- (void)authenticateAccountWithCompletion:(void (^)(BOOL authenticated, NSHTTPURLResponse *response, NSError *error))completion;
- (void)getModifierCategoriesForVenue:(NSInteger)venueID completion:(void (^)(NSArray *modifierCategories, NSHTTPURLResponse *response, NSError *error))completion;
- (void)getModifierCategoriesForVenueID:(NSInteger)venueID completion:(void (^)(NSArray *modifierCategories, NSHTTPURLResponse *response, NSError *error))completion;
- (void)getModifiersForVenueID:(NSInteger)venueID completion:(void (^)(NSArray *modifiers, NSHTTPURLResponse *response, NSError *error))completion;
- (void)getProductForVenueID:(NSInteger)venueID withProductID:(NSInteger)productID completion:(void (^)(BopplProduct *product, NSHTTPURLResponse *response, NSError *error))completion;
- (void)getProductCategoriesForVenueID:(NSInteger)venueID completion:(void (^)(NSArray *productCategories, NSHTTPURLResponse *response, NSError *error))completion;
- (void)getProductGroupsForVenueID:(NSInteger)venueID completion:(void (^)(NSArray *productGroups, NSHTTPURLResponse *response, NSError *error))completion;
- (void)getProductsForVenueID:(NSInteger)venueID completion:(void (^)(NSArray *products, NSHTTPURLResponse *response, NSError *error))completion;
- (void)getProductsForVenueID:(NSInteger)venueID withCategoryID:(NSInteger)categoryID completion:(void (^)(NSArray *products, NSHTTPURLResponse *response, NSError *error))completion;
- (void)getProductsForVenueID:(NSInteger)venueID withGroupID:(NSInteger)groupID completion:(void (^)(NSArray *products, NSHTTPURLResponse *response, NSError *error))completion;

@end

Expand Down
Loading

0 comments on commit 76d845c

Please sign in to comment.