Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 12 additions & 78 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,83 +1,17 @@
### Basic Yelp client
Overview: Build a Yelp search app.

This is a headless example of how to implement an OAuth 1.0a Yelp API client. The Yelp API provides an application token that allows applications to make unauthenticated requests to their search API.
Time taken: 15 hrs.

### Next steps
User stories done:

- Check out `MainViewController.m` to see how to use the `YelpClient`.
- Augment the search method in the `YelpClient` with whatever search parameters you want to support.
Search results page
- Custom cells should have the proper Auto Layout constraints
- Search bar should be in the navigation bar (doesn't have to expand to show location like the real Yelp app does).

### Sample request
Filter page. Unfortunately, not all the filters are supported in the Yelp API.
- The filters you should actually have are: category, sort (best match, distance, highest rated), radius (meters), deals (on/off).
- The filters table should be organized into sections as in the mock.
- Categories should show a subset of the full list with a "See All" row to expand. - I show all.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding a comment here.

- adding a line here for comment

```
self.client = [[YelpClient alloc] initWithConsumerKey:kYelpConsumerKey consumerSecret:kYelpConsumerSecret accessToken:kYelpToken accessSecret:kYelpTokenSecret];

[self.client searchWithTerm:@"Thai" success:^(AFHTTPRequestOperation *operation, id response) {
NSLog(@"response: %@", response);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"error: %@", [error description]);
}];
```

### Sample response

```
businesses = (
{
categories = (
(
Thai,
thai
)
);
"display_phone" = "+1-415-931-6917";
id = "lers-ros-thai-san-francisco";
"image_url" = "http://s3-media2.ak.yelpcdn.com/bphoto/IStxUNVdfuPR2ddDAIPk_A/ms.jpg";
"is_claimed" = 1;
"is_closed" = 0;
location = {
address = (
"730 Larkin St"
);
city = "San Francisco";
"country_code" = US;
"cross_streets" = "Olive St & Ellis St";
"display_address" = (
"730 Larkin St",
"(b/t Olive St & Ellis St)",
Tenderloin,
"San Francisco, CA 94109"
);
neighborhoods = (
Tenderloin
);
"postal_code" = 94109;
"state_code" = CA;
};
"menu_date_updated" = 1387658025;
"menu_provider" = "single_platform";
"mobile_url" = "http://m.yelp.com/biz/lers-ros-thai-san-francisco";
name = "Lers Ros Thai";
phone = 4159316917;
rating = 4;
"rating_img_url" = "http://s3-media4.ak.yelpcdn.com/assets/2/www/img/c2f3dd9799a5/ico/stars/v1/stars_4.png";
"rating_img_url_large" = "http://s3-media2.ak.yelpcdn.com/assets/2/www/img/ccf2b76faa2c/ico/stars/v1/stars_large_4.png";
"rating_img_url_small" = "http://s3-media4.ak.yelpcdn.com/assets/2/www/img/f62a5be2f902/ico/stars/v1/stars_small_4.png";
"review_count" = 1154;
"snippet_image_url" = "http://s3-media4.ak.yelpcdn.com/photo/D40HpcJt-O6Ll654S_--6w/ms.jpg";
"snippet_text" = "Fantastic pad-see-ew. Super rich, flavorful sauce and plenty of ginormous prawns, especially for a $12 price tag in San Francisco. I went through a pretty...";
url = "http://www.yelp.com/biz/lers-ros-thai-san-francisco";
}
);
region = {
center = {
latitude = "37.7703124";
longitude = "-122.43647245575";
};
span = {
"latitude_delta" = "0.06424638000000016";
"longitude_delta" = "0.07145348265001417";
};
};
total = 760;
```
![Yelp](yelp.gif)
24 changes: 22 additions & 2 deletions Yelp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
42FD6C6618DC286B000BF2B9 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 42FD6C4E18DC286B000BF2B9 /* UIKit.framework */; };
42FD6C6E18DC286B000BF2B9 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 42FD6C6C18DC286B000BF2B9 /* InfoPlist.strings */; };
42FD6C7018DC286B000BF2B9 /* YelpTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 42FD6C6F18DC286B000BF2B9 /* YelpTests.m */; };
48EF1B671956ACF800882BCD /* ReviewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 48EF1B651956ACF800882BCD /* ReviewCell.m */; };
48EF1B681956ACF800882BCD /* ReviewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 48EF1B661956ACF800882BCD /* ReviewCell.xib */; };
48EF1B6F195799BC00882BCD /* FilterViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 48EF1B6D195799BC00882BCD /* FilterViewController.m */; };
48EF1B70195799BC00882BCD /* FilterViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 48EF1B6E195799BC00882BCD /* FilterViewController.xib */; };
63E591F41F684901AF8C1C19 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9DEC6D18C14F46F8AF2EA320 /* libPods.a */; };
/* End PBXBuildFile section */

Expand All @@ -47,16 +51,22 @@
42FD6C4E18DC286B000BF2B9 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
42FD6C5218DC286B000BF2B9 /* Yelp-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Yelp-Info.plist"; sourceTree = "<group>"; };
42FD6C5418DC286B000BF2B9 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
42FD6C5618DC286B000BF2B9 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
42FD6C5618DC286B000BF2B9 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = main.m; path = Yelp/main.m; sourceTree = SOURCE_ROOT; };
42FD6C5818DC286B000BF2B9 /* Yelp-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Yelp-Prefix.pch"; sourceTree = "<group>"; };
42FD6C5918DC286B000BF2B9 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
42FD6C5A18DC286B000BF2B9 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
42FD6C5A18DC286B000BF2B9 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = Yelp/AppDelegate.m; sourceTree = SOURCE_ROOT; };
42FD6C5C18DC286B000BF2B9 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
42FD6C6218DC286B000BF2B9 /* YelpTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = YelpTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
42FD6C6318DC286B000BF2B9 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
42FD6C6B18DC286B000BF2B9 /* YelpTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "YelpTests-Info.plist"; sourceTree = "<group>"; };
42FD6C6D18DC286B000BF2B9 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
42FD6C6F18DC286B000BF2B9 /* YelpTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = YelpTests.m; sourceTree = "<group>"; };
48EF1B641956ACF800882BCD /* ReviewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReviewCell.h; sourceTree = "<group>"; };
48EF1B651956ACF800882BCD /* ReviewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ReviewCell.m; sourceTree = "<group>"; };
48EF1B661956ACF800882BCD /* ReviewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ReviewCell.xib; sourceTree = "<group>"; };
48EF1B6C195799BC00882BCD /* FilterViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FilterViewController.h; sourceTree = "<group>"; };
48EF1B6D195799BC00882BCD /* FilterViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FilterViewController.m; sourceTree = "<group>"; };
48EF1B6E195799BC00882BCD /* FilterViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = FilterViewController.xib; sourceTree = "<group>"; };
8436EC1AAEE1439D997D29F7 /* Pods.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.xcconfig; path = Pods/Pods.xcconfig; sourceTree = "<group>"; };
9DEC6D18C14F46F8AF2EA320 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -101,6 +111,12 @@
420474F818DC2B2100E88E07 /* MainViewController.h */,
420474F918DC2B2100E88E07 /* MainViewController.m */,
420474FA18DC2B2100E88E07 /* MainViewController.xib */,
48EF1B641956ACF800882BCD /* ReviewCell.h */,
48EF1B651956ACF800882BCD /* ReviewCell.m */,
48EF1B661956ACF800882BCD /* ReviewCell.xib */,
48EF1B6C195799BC00882BCD /* FilterViewController.h */,
48EF1B6D195799BC00882BCD /* FilterViewController.m */,
48EF1B6E195799BC00882BCD /* FilterViewController.xib */,
);
name = "View Controllers";
sourceTree = "<group>";
Expand Down Expand Up @@ -256,7 +272,9 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
48EF1B70195799BC00882BCD /* FilterViewController.xib in Resources */,
42FD6C5518DC286B000BF2B9 /* InfoPlist.strings in Resources */,
48EF1B681956ACF800882BCD /* ReviewCell.xib in Resources */,
420474FC18DC2B2100E88E07 /* MainViewController.xib in Resources */,
42FD6C5D18DC286B000BF2B9 /* Images.xcassets in Resources */,
);
Expand Down Expand Up @@ -310,9 +328,11 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
48EF1B671956ACF800882BCD /* ReviewCell.m in Sources */,
42FD6C5B18DC286B000BF2B9 /* AppDelegate.m in Sources */,
42FD6C5718DC286B000BF2B9 /* main.m in Sources */,
420474F618DC299500E88E07 /* YelpClient.m in Sources */,
48EF1B6F195799BC00882BCD /* FilterViewController.m in Sources */,
420474FB18DC2B2100E88E07 /* MainViewController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
9 changes: 8 additions & 1 deletion Yelp/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,16 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

self.window.rootViewController = [[MainViewController alloc] init];
//self.window.rootViewController = [[MainViewController alloc] init];

MainViewController *vc = [[MainViewController alloc] init];
UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];

self.window.rootViewController = nvc;

self.window.backgroundColor = [UIColor whiteColor];
[[UINavigationBar appearance] setBarTintColor:[UIColor redColor]];

[self.window makeKeyAndVisible];
return YES;
}
Expand Down
14 changes: 14 additions & 0 deletions Yelp/DetailView.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// DetailView.h
// Yelp
//
// Created by Bharti Agrawal on 6/21/14.
// Copyright (c) 2014 codepath. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface DetailView : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;

@end
25 changes: 25 additions & 0 deletions Yelp/DetailView.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// DetailView.m
// Yelp
//
// Created by Bharti Agrawal on 6/21/14.
// Copyright (c) 2014 codepath. All rights reserved.
//

#import "DetailView.h"

@implementation DetailView

- (void)awakeFromNib
{
// Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];

// Configure the view for the selected state
}

@end
30 changes: 30 additions & 0 deletions Yelp/DetailView.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="5056" systemVersion="13D65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="90" id="KGk-i7-Jjw" customClass="DetailView">
<rect key="frame" x="0.0" y="0.0" width="337" height="90"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="337" height="89"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="v47-pL-A43">
<rect key="frame" x="187" y="11" width="42" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
<connections>
<outlet property="nameLabel" destination="v47-pL-A43" id="flm-gh-SIo"/>
</connections>
</tableViewCell>
</objects>
</document>
14 changes: 14 additions & 0 deletions Yelp/FilterViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// FilterViewController.h
// Yelp
//
// Created by Bharti Agrawal on 6/22/14.
// Copyright (c) 2014 codepath. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface FilterViewController : UIViewController <UITableViewDataSource>


@end
Loading