Skip to content

Commit

Permalink
use original pulkitjalan/google-apiclient 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kawax committed Aug 14, 2016
1 parent 98dbdd0 commit a9f2332
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -7,7 +7,7 @@ php:

before_script:
- travis_retry composer self-update
- travis_retry composer install --no-interaction --prefer-source --dev
- travis_retry composer install --no-interaction --prefer-source -q

script:
- vendor/bin/phpunit
66 changes: 49 additions & 17 deletions README.md
Expand Up @@ -10,29 +10,17 @@ composer require revolution/laravel-google-sheets
```

### Laravel
```json
"repositories": [
{
"type": "vcs",
"url": "https://github.com/kawax/google-apiclient"
}
],
```

```
composer require pulkitjalan/google-apiclient:^3.0
```

config/google.php
https://github.com/kawax/google-apiclient
https://github.com/pulkitjalan/google-apiclient

config/app.php

```php
PulkitJalan\Google\GoogleServiceProvider::class,
GoogleSheets\Providers\SheetsServiceProvider::class,
```

```php
'Google' => PulkitJalan\Google\Facades\Google::class,
'Sheets' => GoogleSheets\Facades\Sheets::class,
```

Expand All @@ -43,6 +31,8 @@ GoogleSheets\Providers\SheetsServiceProvider::class,
|1|name1|mail1|
|2|name2|mail2|

https://docs.google.com/spreadsheets/d/{spreadsheetID}/...

### Laravel example1
```php
use Sheets;
Expand Down Expand Up @@ -85,11 +75,12 @@ view
```php
use GoogleSheets\Sheets;

$client = Google_Client();
$client = \Google_Client();
$client->setScopes([Google_Service_Sheets::DRIVE, Google_Service_Sheets::SPREADSHEETS]);
// setup Google Client
// ...

$service = new Google_Service_Sheets($client);
$service = new \Google_Service_Sheets($client);

$sheets = new Sheets();
$sheets->setService($service);
Expand Down Expand Up @@ -129,7 +120,48 @@ Sheets::getService()->spreadsheets->...
```
see https://github.com/google/google-api-php-client-services/blob/master/Sheets.php

## Upgrade

### to 2.0 from 1.0.x
- Remove "repositories" from composer.json
```json
"repositories": [
{
"type": "vcs",
"url": "https://github.com/kawax/google-apiclient"
}
],
```
- Change composer.json
Bump version
```json
"require": {
"revolution/laravel-google-sheets": "^2.0"
}
```
Remove
```
"pulkitjalan/google-apiclient": "^3.0",
```
- Remove "vendor" dir.
- Remove composer.lock
- Clear composer cache. `composer clear-cache`
- `composer install`
- Change config/google.php
```
'service' => [
/*
| Enable service account auth or not.
*/
'enabled' => false,
/*
| Path to service account json file
*/
'file' => '',
],
```
https://github.com/pulkitjalan/google-apiclient#usage

## LICENSE
MIT
Expand Down
9 changes: 1 addition & 8 deletions composer.json
Expand Up @@ -3,18 +3,11 @@
"description": "Google Sheets API v4",
"keywords": ["google", "sheets", "laravel"],
"license": "MIT",
"repositories": [
{
"type": "vcs",
"url": "https://github.com/kawax/google-apiclient"
}
],
"require": {
"php": ">=5.5.9",
"google/apiclient": "^2.0"
"pulkitjalan/google-apiclient": "3.*"
},
"require-dev": {
"pulkitjalan/google-apiclient": "^3.0",
"phpunit/phpunit": "5.*",
"mockery/mockery": "0.9.*"
},
Expand Down
2 changes: 1 addition & 1 deletion src/GoogleSheets/Facades/Sheets.php
Expand Up @@ -13,6 +13,6 @@ class Sheets extends Facade
*/
protected static function getFacadeAccessor()
{
return 'google.sheets';
return \GoogleSheets\Sheets::class;
}
}
8 changes: 4 additions & 4 deletions src/GoogleSheets/Providers/SheetsServiceProvider.php
Expand Up @@ -3,7 +3,7 @@

use Illuminate\Support\ServiceProvider;

use GoogleSheets\SheetsLaravel;
use GoogleSheets\Sheets;

class SheetsServiceProvider extends ServiceProvider
{
Expand All @@ -28,8 +28,8 @@ public function boot()
*/
public function register()
{
$this->app->singleton('google.sheets', function ($app) {
return new SheetsLaravel();
$this->app->singleton(Sheets::class, function ($app) {
return new Sheets();
});
}

Expand All @@ -40,6 +40,6 @@ public function register()
*/
public function provides()
{
return ['google.sheets'];
return [Sheets::class];
}
}
2 changes: 1 addition & 1 deletion src/GoogleSheets/Sheets.php
Expand Up @@ -5,7 +5,7 @@

class Sheets
{
use SheetsValues, SheetsDrive, SheetsProperties;
use SheetsValues, SheetsDrive, SheetsProperties, SheetsCollection;

/**
* @var \Google_Service_Sheets
Expand Down
Expand Up @@ -3,7 +3,7 @@

use Illuminate\Support\Collection;

class SheetsLaravel extends Sheets
trait SheetsCollection
{
/**
* @return \Illuminate\Support\Collection
Expand Down
16 changes: 8 additions & 8 deletions tests/SheetsLaravelTest.php → tests/SheetsCollectionTest.php
@@ -1,20 +1,20 @@
<?php
namespace GoogleSheet\tests;

use Mockery as m;
//use Mockery as m;
use PHPUnit_Framework_TestCase;

use GoogleSheets\SheetsLaravel;
use GoogleSheets\Sheets;

class SheetsLaravelTest extends PHPUnit_Framework_TestCase
class SheetsCollectionTest extends PHPUnit_Framework_TestCase
{
protected $laravel;
protected $sheet;

public function setUp()
{
parent::setUp();

$this->laravel = new SheetsLaravel();
$this->sheet = new Sheets();
}

// public function tearDown()
Expand All @@ -30,7 +30,7 @@ public function testCollection()
['2', 'name2', 'mail2']
];

$collection = $this->laravel->collection($header, $rows);
$collection = $this->sheet->collection($header, $rows);

// dd($collection);
$this->assertEquals('name1', $collection->first()['name']);
Expand All @@ -44,7 +44,7 @@ public function testCollection2()
['2', 'name2']
];

$collection = $this->laravel->collection($header, $rows);
$collection = $this->sheet->collection($header, $rows);

// dd($collection);
$this->assertNotNull($collection->last()['mail']);
Expand All @@ -60,7 +60,7 @@ public function testCollection3()

$header = $rows->pull(0);

$collection = $this->laravel->collection($header, $rows);
$collection = $this->sheet->collection($header, $rows);

// dd($collection);
$this->assertEquals('mail3', $collection->last()['mail']);
Expand Down
23 changes: 11 additions & 12 deletions tests/SheetsTest.php
Expand Up @@ -55,12 +55,12 @@ public function setUp()
}

$this->client = new Client([
'service' => [
'enable' => true,
'scopes' => [Google_Service_Sheets::DRIVE, Google_Service_Sheets::SPREADSHEETS],
'credentials' => $config,
]
]);
'scopes' => [Google_Service_Sheets::DRIVE, Google_Service_Sheets::SPREADSHEETS],
'service' => [
'enable' => true,
'file' => $config,
],
]);

$this->sheet = new Sheets();

Expand Down Expand Up @@ -100,7 +100,7 @@ public function testSpreadsheetProperties()

$properties = $this->sheet->spreadsheet($this->spreadsheetId)->spreadsheetProperties();

// dd($properties);
// dd($properties);

$this->assertNotEmpty($properties->title);
}
Expand All @@ -113,12 +113,11 @@ public function testSheetProperties()

$properties = $this->sheet->spreadsheet($this->spreadsheetId)->sheet($this->sheetTitle)->sheetProperties();

// dd($properties);
// dd($properties);

$this->assertEquals($this->sheetTitle, $properties->title);
}


public function testSheetList()
{
if (!$this->checkDevConfig()) {
Expand Down Expand Up @@ -206,7 +205,7 @@ public function testSheetValuesRange()
->range('A1:E3')
->all();

// dd($sheets);
// dd($sheets);
$this->assertEquals(3, count($sheets));
}

Expand All @@ -223,7 +222,7 @@ public function testSheetValuesMajorDimension()
->majorDimension('COLUMNS')
->all();

// dd($sheets);
// dd($sheets);
$this->assertEquals(5, count($sheets));
}

Expand All @@ -239,7 +238,7 @@ public function testSheetUpdate()
->range('A1:B3')
->update([['test', 'test2'], ['test3']]);

// dd($response);
// dd($response);
$this->assertEquals($this->spreadsheetId, $response->getSpreadsheetId());
}
}

0 comments on commit a9f2332

Please sign in to comment.