Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add beginning of everhour, main setup menu and tests
- Loading branch information
Showing
9 changed files
with
196 additions
and
11 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
namespace Godbout\Alfred\Time\Menus\Everhour; | ||
|
||
use Godbout\Alfred\Time\Workflow; | ||
use Godbout\Alfred\Workflow\Icon; | ||
use Godbout\Alfred\Workflow\Item; | ||
use Godbout\Alfred\Time\Menus\Menu; | ||
use Godbout\Alfred\Workflow\ScriptFilter; | ||
|
||
class Setup extends Menu | ||
{ | ||
public static function scriptFilter() | ||
{ | ||
ScriptFilter::add( | ||
self::apikey(), | ||
self::state(), | ||
self::back() | ||
); | ||
} | ||
|
||
private static function apikey() | ||
{ | ||
return Item::create() | ||
->title(self::apikeyTitle()) | ||
->subtitle(self::apikeySubtitle()) | ||
->arg('everhour_setup_apikey') | ||
->icon(Icon::create('resources/icons/everhour.png')); | ||
} | ||
|
||
private static function apikeyTitle() | ||
{ | ||
return empty(Workflow::getConfig()->read('everhour.api_token')) ? 'Set API KEY' : 'Update API KEY'; | ||
} | ||
|
||
private static function apikeySubtitle() | ||
{ | ||
$apikey = Workflow::getConfig()->read('everhour.api_token'); | ||
|
||
return empty($apikey) ? 'No API KEY found' : 'Current API KEY: ' . substr($apikey, 0, 11) . '...'; | ||
} | ||
|
||
private static function state() | ||
{ | ||
return Item::create() | ||
->title(self::stateTitle()) | ||
->subtitle(self::stateSubtitle()) | ||
->arg('everhour_setup_state') | ||
->variable('everhour_enabled', Workflow::getConfig()->read('everhour.is_active') ? 'false' : 'true') | ||
->icon(Icon::create('resources/icons/everhour.png')); | ||
} | ||
|
||
private static function stateTitle() | ||
{ | ||
return (Workflow::getConfig()->read('everhour.is_active') === true) ? 'Disable' : 'Enable'; | ||
} | ||
|
||
private static function stateSubtitle() | ||
{ | ||
return (Workflow::getConfig()->read('everhour.is_active') === true) ? 'Currently enabled' : 'Currently disabled'; | ||
} | ||
|
||
private static function back() | ||
{ | ||
return Item::create() | ||
->title('Back') | ||
->arg('setup') | ||
->icon(Icon::create('resources/icons/icon.png')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace Godbout\Alfred\Time\Services; | ||
|
||
use Exception; | ||
use Carbon\Carbon; | ||
use Carbon\CarbonInterval; | ||
use MorningTrain\TogglApi\TogglApi; | ||
|
||
class Everhour extends TimerService | ||
{ | ||
private $client; | ||
|
||
private $data = null; | ||
|
||
|
||
public function __construct($apiToken) | ||
{ | ||
} | ||
|
||
public function projects() | ||
{ | ||
} | ||
|
||
public function tags() | ||
{ | ||
} | ||
|
||
public function pastTimers() | ||
{ | ||
} | ||
|
||
public function startTimer() | ||
{ | ||
} | ||
|
||
public function stopCurrentTimer() | ||
{ | ||
} | ||
|
||
public function runningTimer() | ||
{ | ||
} | ||
|
||
public function continueTimer($timerId) | ||
{ | ||
} | ||
|
||
public function deleteTimer($timerId) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Tests\Feature; | ||
|
||
use Tests\TestCase; | ||
use Godbout\Alfred\Time\Workflow; | ||
|
||
class EverhourSetupMenusTest extends TestCase | ||
{ | ||
/** @test */ | ||
public function it_shows_setting_an_api_key_if_none_is_saved_in_the_config_yet() | ||
{ | ||
$this->everhourApikey(''); | ||
|
||
$output = $this->reachEverhourSetupMenu(); | ||
|
||
$this->assertStringContainsString('"subtitle":"No API KEY found"', $output); | ||
} | ||
|
||
/** @test */ | ||
public function some_more_test() | ||
{ | ||
$this->markTestIncomplete('lots of test to add for everhour'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters