Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sachin Agarwal committed Dec 31, 2017
2 parents 68c55a4 + 1223380 commit 844e35f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ With just 2 lines of code you can request to any google places api feature. No n
* [Place Autocomplete](#place-autocomplete) This service is Used to automatically fill in the name and/or address of a place as you type.
* [Query Autocomplete](#query-autocomplete) This service is Used to provide a query prediction service for text-based geographic searches, by returning suggested queries as you type.
* [Place Add](#place-add) This service Used to Add/Delete a place to Google's Place database
* [Additional Methods](#additional-methods) Additional Methods Available.

# Installation
Install it with composer
Expand Down Expand Up @@ -66,6 +67,10 @@ function () {

<a name=laravel-usage></a>
# Use with Laravel
## For Laravel 5.5
Auto Discovery added.

## For Laravel 5.4 and below
## Step 1
Set up the service provider and facade in the **config\app.php**
```php
Expand Down Expand Up @@ -167,6 +172,7 @@ _**(This method is depricated, and will be removed when google removes it from t
_**(This method is depricated, and will be removed when google removes it from the api)**_
* `placeId` - The Place Id you want to delete.

<a name=additional-methods></a>
# Additional Methods
### getStatus()
This will return the status of the response send by google api. Use it after making any request.
Expand All @@ -177,6 +183,11 @@ This will return the `API KEY` been used with the requests.
### setKey($key)
This will set the `API KEY`.

### verifySSL($verifySSL = true)
You can pass `false` to disable Verification of SSL Certification.

Or You can Pass the path to the certificate.

# Contribution
Feel free to report issues or make Pull Requests.
If you find this document can be improved in any way, please feel free to open an issue for it.
Expand Down
10 changes: 10 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,15 @@
"psr-4": {
"SKAgarwal\\GoogleApi\\": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"SKAgarwal\\GoogleApi\\ServiceProvider"
],
"aliases": {
"GooglePlaces": "SKAgarwal\\GoogleApi\\Facade"
}
}
}
}
26 changes: 24 additions & 2 deletions src/PlacesApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,18 @@ class PlacesApi
*/
private $client;

/**
* @var bool
*/
private $verifySSL = true;

/**
* PlacesApi constructor.
*
* @param null $key
* @param bool $verifySSL
*/
public function __construct($key = null)
public function __construct($key = null, $verifySSL = true)
{
$this->key = $key;

Expand Down Expand Up @@ -142,6 +148,7 @@ public function placeDetails($placeId, $params = [])
* @param array $params
*
* @return \Illuminate\Support\Collection
* @throws \SKAgarwal\GoogleApi\Exceptions\GooglePlacesApiException
*/
public function placeAutocomplete($input, $params = [])
{
Expand Down Expand Up @@ -236,6 +243,8 @@ private function makeRequest($uri, $params, $method = 'get')
$options['query'] = array_merge($options['query'], $params);
}

$options['verify'] = $this->verifySSL;

$response = json_decode(
$this->client->$method($uri, $options)->getBody()->getContents(),
true
Expand All @@ -247,7 +256,8 @@ private function makeRequest($uri, $params, $method = 'get')
AND $response['status'] !== 'ZERO_RESULTS') {
throw new GooglePlacesApiException(
"Response returned with status: " . $response['status'] . "\n" .
array_key_exists('error_message', $response) ?: "Error Message: {$response['error_message']}"
array_key_exists('error_message', $response)
?: "Error Message: {$response['error_message']}"
);
}

Expand Down Expand Up @@ -368,4 +378,16 @@ private function prepareRadarSearchParams($location, $radius, $params)

return $params;
}

/**
* @param bool $verifySSL
*
* @return PlacesApi
*/
public function verifySSL($verifySSL = true)
{
$this->verifySSL = $verifySSL;

return $this;
}
}

0 comments on commit 844e35f

Please sign in to comment.