Skip to content

Commit

Permalink
Address plugin review items and update changelog.
Browse files Browse the repository at this point in the history
  • Loading branch information
allen-mckenzie committed Mar 17, 2022
1 parent d7ac5d8 commit e227f24
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 29 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ Getting a Yelp API Key:

Here is the Changelog

### 0.1.1 ###

Fixed declared default constanst to have unique prefixes. Instead of API_KEY this plugin uses the prefix BM_ to make this BM_API_KEY
Added assets for the plugin icon and banner images
Added documentation for plugin configuration and integration with Yelp and StrawPoll

### 0.1.0 ###

Code cleanup and prep for the first release and review
Expand Down
2 changes: 1 addition & 1 deletion business-matchup.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Business Matchup
* Plugin URI: https://github.com/allen-mckenzie/business-matchup
* Description: Create custom polls using Yelp and Straw Polls to let your followers vote for which business they think is the best.
* Version: 0.1.0
* Version: 0.1.1
* Requires at least: 5.5
* Requires PHP: 7.0
* Author: Allen McKenzie
Expand Down
52 changes: 26 additions & 26 deletions includes/classes/class-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,35 @@
/**
* Configuration Details and Defining Our Global Constants
*
* @since 0.1.0
* @since 0.1.1
*
* @param string $businessMatchupYelpAPI contains the Yelp API Key.
* @param string $strawAPI contains the StrawPoll API Key.
* @param string API_KEY contains the Yelp API Key.
* @param string STRAWPOLL_API_KEY contains the StrawPoll API Key.
* @param string API_HOST contains the URL base for the Yelp API.
* @param string SEARCH_PATH specifies the Yelp API Endpoint for searches.
* @param string BUSINESS_PATH specifies the Yelp API Endoint for business data.
* @param string DEFAULT_TERM specifies the term to use when one isn't provided.
* @param string DEFAULT_LOCATION specifies the location to use when one isn't provided.
* @param string SEARCH_LIMIT limits the number of business to search for to only the first 3.
* @param string BM_API_KEY contains the Yelp API Key.
* @param string BM_STRAWPOLL_API_KEY contains the StrawPoll API Key.
* @param string BM_API_HOST contains the URL base for the Yelp API.
* @param string BM_SEARCH_PATH specifies the Yelp API Endpoint for searches.
* @param string BM_BUSINESS_PATH specifies the Yelp API Endoint for business data.
* @param string BM_DEFAULT_TERM specifies the term to use when one isn't provided.
* @param string BM_DEFAULT_LOCATION specifies the location to use when one isn't provided.
* @param string BM_SEARCH_LIMIT limits the number of business to search for to only the first 3.
*/
$businessMatchupYelpAPI = get_option( 'business_matchup_yelp_api' );
$strawAPI = get_option( 'business_matchup_straw_poll_api' );
define( 'API_KEY', $businessMatchupYelpAPI );
define( 'STRAWPOLL_API_KEY', $strawAPI );
define( 'API_HOST', 'https://api.yelp.com' );
define( 'SEARCH_PATH','/v3/businesses/search' );
define( 'BUSINESS_PATH', '/v3/businesses/' );
define( 'DEFAULT_TERM', 'dinner' );
define( 'DEFAULT_LOCATION','San Francisco, CA' );
define( 'SEARCH_LIMIT', 3 );
define( 'BM_API_KEY', $businessMatchupYelpAPI );
define( 'BM_STRAWPOLL_API_KEY', $strawAPI );
define( 'BM_API_HOST', 'https://api.yelp.com' );
define( 'BM_SEARCH_PATH','/v3/businesses/search' );
define( 'BM_BUSINESS_PATH', '/v3/businesses/' );
define( 'BM_DEFAULT_TERM', 'dinner' );
define( 'BM_DEFAULT_LOCATION','San Francisco, CA' );
define( 'BM_SEARCH_LIMIT', 3 );

/**
* Business_Matchup_API class
* This class defines the actions taken to access the API's
*
* @since 0.1.0
* @since 0.1.1
*/
class Business_Matchup_API {

Expand All @@ -49,7 +49,7 @@ class Business_Matchup_API {
function doAPI( $api_url, $path, $url_params = array() ) {
$query = http_build_query( $url_params );
$api_url = $api_url."".$path."?".$query;
$api_key = API_KEY;
$api_key = BM_API_KEY;
if( $api_key === '' ) {
return;
}
Expand All @@ -69,7 +69,7 @@ function doAPI( $api_url, $path, $url_params = array() ) {
* search function
* This function creates the paramaters needed to submit a search to the Yelp API.
*
* @since 0.1.0
* @since 0.1.1
*
* @param string $term contains the type of business we want to look for.
* @param string $businessLocation contains the City and State-Abbreviation where we want to look for those businesses.
Expand All @@ -79,8 +79,8 @@ function search( $term, $businessLocation ) {
$url_params = array();
$url_params['term'] = $term;
$url_params['location'] = $businessLocation;
$url_params['limit'] = SEARCH_LIMIT;
$result = $this->doAPI(API_HOST, SEARCH_PATH, $url_params);
$url_params['limit'] = BM_SEARCH_LIMIT;
$result = $this->doAPI(BM_API_HOST, BM_SEARCH_PATH, $url_params);
return $result;
}

Expand All @@ -94,8 +94,8 @@ function search( $term, $businessLocation ) {
* @return array response output from the Business_Matchup_API for the given call.
*/
function get_business( $business_id ) {
$business_path = BUSINESS_PATH . urlencode($business_id);
return $this->doAPI(API_HOST, $business_path);
$business_path = BM_BUSINESS_PATH . urlencode($business_id);
return $this->doAPI(BM_API_HOST, $business_path);
}

/**
Expand All @@ -118,7 +118,7 @@ function query_api( $term, $businessLocation ) {
* createPoll function
* This function creates a new Poll on StrawPoll using the StrawPoll API using the information provided in $poll_json.
*
* @since 0.1.0
* @since 0.1.1
*
* @param string $poll_json JSON object containing the details of the businesses we are creating a poll for.
* @return string $html contains the formatted iFrame that will be used in the content of our custom post type.
Expand All @@ -129,7 +129,7 @@ public function createPoll( $poll_json ) {
$headers = array(
'user-agent' => '',
'Content-Type' => 'application/json',
'X-API-KEY' => STRAWPOLL_API_KEY
'X-API-KEY' => BM_STRAWPOLL_API_KEY
);
$args = array(
'method' => 'POST',
Expand Down
38 changes: 36 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,39 @@ Here are some frequently asked questions

=== Where do I enter my Yelp API Key ===

The Yelp API integration has not been added yet. This is a development release.
Getting a Yelp API Key:

1. If you don't already have a Yelp account go to: https://yelp.com/ and signup.
2. After you login go to https://www.yelp.com/developers/v3/manage_app and create a new app.
![create-app-page](https://user-images.githubusercontent.com/43300142/158496476-2c1d5522-986d-41cb-9150-021cd0a491e8.png)
![enter-new-app-details](https://user-images.githubusercontent.com/43300142/158496510-46346d71-2222-4986-b670-a70f9bcd4ebd.png)
3. If you see an error message when you create your new app because you didn't verify your email. Go do that and try again.
![create-app-error](https://user-images.githubusercontent.com/43300142/158496522-bbac1b97-f03b-4af2-917c-303af76bde6d.png)
4. You should see a success messages that says, "Great your app has been created!"
![create-app-sucess](https://user-images.githubusercontent.com/43300142/158496541-f45bfa74-1ce9-4ae1-aff9-846da6612413.png)
5. Copy your new API details and save them in a safe location

=== What about my StrawPoll API Key ===

The StrawPoll integration has not been added yet. This is a development release.
1. If you don't already have a Straw Poll account go to: https://strawpoll.com/en/signup/ and signup.
2. Once you are logged in go to: https://strawpoll.com/account/settings/
3. Then click the Generate new key if you don't see a key there otherwise click the Show link and copy your API key.

=== How do I create a Business Matchup Poll ===

1. Click on Business Matchups
2. Next, click on Add New
![add-new-business-matchup-poll](https://user-images.githubusercontent.com/43300142/158496712-29ef2661-0658-4412-a2c9-63634905b8d1.png)
3. Give your page a title just like you would for any other page or post. This will create the permalink for your new poll.
![enter-business-matchup-poll-details](https://user-images.githubusercontent.com/43300142/158496755-db941097-a63b-429b-9970-890e89f9aa8a.png)
4. Next, Enter the business location that your would like to base your matchup on. For example: San Francisco, CA.
5. Then, Enter the type of businesses you want to matchup. For example: Pizza.
6. Next, add a featured image that the social networks will use to create a thumbnail of your post when you share it.
7. Finally, you can schedule this to post at a later date or publish now. This will gather the data we need and create the poll for you.
![business-matchup-poll-example](https://user-images.githubusercontent.com/43300142/158496794-a6216dd6-dde4-4ba6-9469-cbc4c4749b84.png)
8. If you have Jetpack installed and use Publicize these posts are supported so that they automatically post to your connected accounts. For more information on how to do this please check out: https://jetpack.com/support/publicize/
9. Check out your new Business Matchup poll and share it on social media!
![publish-business-matchup-poll-and-view](https://user-images.githubusercontent.com/43300142/158496822-3919ceaa-5260-435f-a6f0-e849304e0cc9.png)

== Screenshots ==

Expand All @@ -45,6 +73,12 @@ This is an upgrade notice

Here is the Changelog

=== 0.1.1 ===

Fixed declared default constanst to have unique prefixes. Instead of API_KEY this plugin uses the prefix BM_ to make this BM_API_KEY
Added assets for the plugin icon and banner images
Added documentation for plugin configuration and integration with Yelp and StrawPoll

=== 0.1.0 ===

Code cleanup and prep for the first release and review
Expand Down

0 comments on commit e227f24

Please sign in to comment.