Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel 5.3 Package Shift #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
15 changes: 10 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
{
"name": "nikapps/bazaar-api-laravel",
"description": "An API wrapper for cafebazaar based on popular Laravel Framework",
"keywords": ["CafeBazaar", "API", "Laravel", "Wrapper", "Cafebazaar Api", "In App Purchase", "iap"],
"keywords": [
"CafeBazaar",
"API",
"Laravel",
"Wrapper",
"Cafebazaar Api",
"In App Purchase",
"iap"
],
"license": "MIT",
"type": "project",
"authors": [
Expand All @@ -20,16 +28,13 @@
"nikapps/bazaar-api-php": "1.*"
},
"autoload": {

"classmap": [
"src/Console",
"src/TokenManager"
],

"psr-0": {
"Nikapps\\BazaarApiLaravel\\": "src/"
}

},
"minimum-stability": "stable"
}
}
24 changes: 11 additions & 13 deletions src/Console/BazaarApiClearCacheCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;

class BazaarApiClearCacheCommand extends Command {
class BazaarApiClearCacheCommand extends Command
{

/**
* The console command name.
Expand All @@ -31,7 +32,8 @@ class BazaarApiClearCacheCommand extends Command {
* @param ConfigRepository $config
* @return \Nikapps\BazaarApiLaravel\Console\BazaarApiClearCacheCommand
*/
public function __construct(ConfigRepository $config) {
public function __construct(ConfigRepository $config)
{

$this->config = $config;

Expand All @@ -44,32 +46,30 @@ public function __construct(ConfigRepository $config) {
*
* @return mixed
*/
public function fire() {
public function fire()
{
$cacheDriver = $this->option('driver');
$cacheName = $this->option('name');

if(\Cache::driver($cacheDriver)->has($cacheName)){

if (\Cache::driver($cacheDriver)->has($cacheName)) {
$this->comment('Value: ' . \Cache::driver($cacheDriver)->get($cacheName));
\Cache::driver($cacheDriver)->forget($cacheName);

$this->info("$cacheName has been successfully removed from cache $cacheDriver");

}else{

} else {
$this->error("$cacheName is already cleared from cache $cacheDriver");
}

$this->info('Done!');

}

/**
* command options
*
* @return array
*/
protected function getOptions() {
protected function getOptions()
{
return [
[
"driver",
Expand All @@ -89,6 +89,4 @@ protected function getOptions() {

];
}


}
}
37 changes: 19 additions & 18 deletions src/Console/BazaarApiRefreshTokenCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
use Illuminate\Console\Command;
use Illuminate\Config\Repository as ConfigRepository;


class BazaarApiRefreshTokenCommand extends Command {
class BazaarApiRefreshTokenCommand extends Command
{

/**
* The console command name.
Expand Down Expand Up @@ -39,7 +39,8 @@ class BazaarApiRefreshTokenCommand extends Command {
* @param ConfigRepository $config
* @return \Nikapps\BazaarApiLaravel\Console\BazaarApiRefreshTokenCommand
*/
public function __construct(ConfigRepository $config) {
public function __construct(ConfigRepository $config)
{

$this->config = $config;

Expand All @@ -53,7 +54,8 @@ public function __construct(ConfigRepository $config) {
*
* @return mixed
*/
public function fire() {
public function fire()
{


$code = $this->option('code');
Expand All @@ -66,7 +68,8 @@ public function fire() {
$bazaarApi->setApiConfig($apiConfig);
$bazaarApi->setAccountConfig($accountConfig);

$this->line(sprintf($this->generateCodeUri,
$this->line(sprintf(
$this->generateCodeUri,
$accountConfig->getRedirectUri(),
$accountConfig->getClientId()
));
Expand All @@ -84,34 +87,31 @@ public function fire() {
$this->comment('Save refresh token in your config file');

$this->table($headers, $rows);

} catch (NetworkErrorException $e) {

$this->error('Error: ' . $e->getClientException()->getRequest()->getUrl());
$this->error('Response Status: ' . $e->getClientException()->getResponse()->getStatusCode());

if($e->getClientException()->getResponse()->getStatusCode() == 401) {
if ($e->getClientException()->getResponse()->getStatusCode() == 401) {
$this->comment('Your credentials is invalid or you should generate new code from this url: ');

$this->line(sprintf($this->generateCodeUri,
$this->line(sprintf(
$this->generateCodeUri,
$accountConfig->getRedirectUri(),
$accountConfig->getClientId()
));
}

} catch (\Exception $e){
} catch (\Exception $e) {
$this->error("Unknown Error: " . $e->getMessage());
}


}

/**
* command options
*
* @return array
*/
protected function getOptions() {
protected function getOptions()
{
return [
["code", "c", InputOption::VALUE_REQUIRED, "returned code from cafebazaar", null],
[
Expand All @@ -130,7 +130,8 @@ protected function getOptions() {
*
* @return ApiConfig
*/
protected function getApiConfig(){
protected function getApiConfig()
{

$apiConfig = new ApiConfig();
$apiConfig->setAuthorizationGrantType($this->config->get('bazaar-api-laravel::api.authorization.grant_type'));
Expand All @@ -148,7 +149,8 @@ protected function getApiConfig(){
* @param $redirectUrl
* @return \Nikapps\BazaarApiPhp\Configs\AccountConfig
*/
protected function getAccountConfig($code, $redirectUrl){
protected function getAccountConfig($code, $redirectUrl)
{

$accountConfig = new AccountConfig();
$accountConfig->setClientId($this->config->get('bazaar-api-laravel::credentials.client_id'));
Expand All @@ -158,5 +160,4 @@ protected function getAccountConfig($code, $redirectUrl){

return $accountConfig;
}

}
}
2 changes: 1 addition & 1 deletion src/Nikapps/BazaarApiLaravel/BazaarApiFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ protected static function getFacadeAccessor()
{
return 'BazaarApi';
}
}
}
Loading