|
1 | | -# YelpJavaClient |
2 | | -Provides a convenient Java Client Library for interfacing with Yelp |
| 1 | +YelpJavaClient |
| 2 | +=================== |
| 3 | + |
| 4 | +[<img src="http://brand.redroma.tech/Logos/RedRoma-Logo%402x.png" width="300">](http://RedRoma.tech) |
| 5 | + |
| 6 | +[](http://jenkins.redroma.tech/job/YelpAPI/) [](https://travis-ci.org/RedRoma/YelpJavaClient) |
| 7 | + |
| 8 | +--- |
| 9 | + |
| 10 | +The **YelpJavaClient** provides |
| 11 | + |
| 12 | +## Download |
| 13 | + |
| 14 | +### Maven |
| 15 | + |
| 16 | +```xml |
| 17 | +<dependency> |
| 18 | + <groupId>tech.redroma.yelp</groupId> |
| 19 | + <artifactId>yelp-api</artifactId> |
| 20 | + <version>1.0</version> |
| 21 | +</dependency> |
| 22 | +``` |
| 23 | + |
| 24 | +## Creating a Client |
| 25 | + |
| 26 | +Create a client using the App ID and App Secret that you obtained from the [Yelp Developer console](https://www.yelp.com/developers/v3/manage_app). |
| 27 | + |
| 28 | +```java |
| 29 | +String clientId = "..."; |
| 30 | +String clientSecret = "..."; |
| 31 | +YelpAPI yelp = YelpAPI.newInstance(clientId, clientSecret); |
| 32 | +``` |
| 33 | + |
| 34 | +## Searching Businesses |
| 35 | + |
| 36 | +#### [Yelp API Documentation](https://www.yelp.com/developers/documentation/v3/business_search) |
| 37 | + |
| 38 | + |
| 39 | +Searching businesses is as easy as making a request object and using the `searchForBusinesses()` method. |
| 40 | + |
| 41 | +```java |
| 42 | +//Create a request object |
| 43 | +YelpSearchRequest request = YelpSearchRequest.newBuilder() |
| 44 | + .withSearchTerm("Deli") |
| 45 | + .withCoordinate(Coordinate.of(34.018363, -118.492343)) |
| 46 | + .withLimit(10) |
| 47 | + .withSortBy(YelpSearchRequest.SortType.DISTANCE) |
| 48 | + .build(); |
| 49 | + |
| 50 | +//Make the request |
| 51 | +List<YelpBusiness> results = yelp.searchForBusinesses(request); |
| 52 | + |
| 53 | +LOG.info("Found {} results for request {}", results.size(), request); |
| 54 | +``` |
| 55 | + |
| 56 | + |
| 57 | +## Business Details |
| 58 | + |
| 59 | +#### [Yelp API Documentation](https://www.yelp.com/developers/documentation/v3/business) |
| 60 | + |
| 61 | + |
| 62 | +Sometimes you want more detailed information about a business, such as the business hours, additional photos, and price information. |
| 63 | + |
| 64 | +Simply call the `getBusinessDetails()` method. |
| 65 | + |
| 66 | +```java |
| 67 | +//Using any business |
| 68 | +YelpBusiness business = Lists.oneOf(results); |
| 69 | + |
| 70 | +//Make the request to get business details. |
| 71 | +YelpBusinessDetails businessDetails = yelp.getBusinessDetails(business); |
| 72 | + |
| 73 | +LOG.info("Received detailed info for business named {}: [{}]", business.name, businessDetails); |
| 74 | + |
| 75 | +if (businessDetails.isOpenNow()) |
| 76 | +{ |
| 77 | + LOG.info("{} is open now.", businessDetails.name) |
| 78 | +} |
| 79 | +``` |
| 80 | + |
| 81 | +## Reviews |
| 82 | + |
| 83 | +#### [Yelp API Documentation](https://www.yelp.com/developers/documentation/v3/business_reviews) |
| 84 | + |
| 85 | + |
| 86 | +```java |
| 87 | +YelpBusiness business = Lists.oneof(business); |
| 88 | +List<YelpReview> reviews = yelp.getReviewsForBusiness(business); |
| 89 | + |
| 90 | +LOG.info("Business named") |
| 91 | +``` |
| 92 | + |
| 93 | +## [Javadocs](http://www.javadoc.io/doc/tech.redroma.yelp/yelp-api/) |
| 94 | + |
| 95 | +## Currently Unsupported |
| 96 | + |
| 97 | +We do not yet support the following API calls: |
| 98 | + |
| 99 | ++ [Phone Search](https://www.yelp.com/developers/documentation/v3/business_search_phone) |
| 100 | ++ [Transaction Search](https://www.yelp.com/developers/documentation/v3/transactions_search) |
| 101 | ++ [Autocomplete](https://www.yelp.com/developers/documentation/v3/autocomplete) |
| 102 | + |
| 103 | +## Guiding Philosophy |
| 104 | + |
| 105 | +We used [**Alchemy Design Principles**](https://github.com/SirWellington/alchemy) when designing this library. |
| 106 | + |
| 107 | +[<img src="https://raw.githubusercontent.com/SirWellington/alchemy/develop/Graphics/Logo/Alchemy-Logo-v7-name.png" width="200">](https://github.com/SirWellington/alchemy) |
| 108 | + |
| 109 | +### Swift |
| 110 | +We wanted our code to feel like it was barely there. This meant keeping things minimal and light. |
| 111 | + |
| 112 | +### Intuitive |
| 113 | +Yelp already designed a great intuitive API. We didn't want to add a pool of unnecessary soda. |
| 114 | + |
| 115 | +### Solid |
| 116 | +Nearly everything is unit tested, and it is already being used in production by [BlackNectar](http://docs.blacknectarapi.apiary.io/), and others. |
| 117 | + |
| 118 | +### Invigorating |
| 119 | +We wanted you to have fun, and to feel powerful. |
| 120 | +We ditched the no-fun java `get() set()` pojo style in favor of open `public` |
| 121 | + variables. We trust you. |
| 122 | + |
| 123 | +# License |
| 124 | + |
| 125 | +This Software is licensed under the Apache 2.0 License |
| 126 | + |
| 127 | +http://www.apache.org/licenses/LICENSE-2.0 |
0 commit comments