Skip to content

Commit 7ad18fd

Browse files
author
Mario Basic
committed
Added new resource for heartbeats. Optimized code and upgraded guzzle.
1 parent 1cdc0ba commit 7ad18fd

11 files changed

+4787
-445
lines changed

.env.example

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
WAKATIME_API_KEY=YourWakatimeApiKey
2+
WAKATIME_PROJECT=ProjectName

.gitignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
.idea/
2-
1+
.env
32
vendor/

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
language: php
2-
sudo: false
32

43
php:
54
- 5.4
65
- 5.5
76
- 5.6
7+
- 7.0
88
- hhvm
99

1010
install:
11-
- composer install --prefer-source --no-interaction --no-dev
11+
- composer install --prefer-source --no-interaction

LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2014 Mario Basic
3+
Copyright (c) 2014-2016 Mario Basic
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+30-41
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,18 @@
44

55
**WakaTime API for PHP**
66

7-
This is a PHP package for WakaTime API. It offers all the methods from [WakaTime API](https://wakatime.com/developers) with additional methods for total hours logged.
7+
This is a PHP package for WakaTime API. It supports resource endpoints from [WakaTime API](https://wakatime.com/developers) with additional helper methods for hours logged.
88

9-
If you are using [Laravel](http://laravel.com/) check out [WakaTime Reports and Laravel](http://mariobasic.com/wakatime-reports-and-laravel/) on my blog.
9+
If you are using [Laravel](http://laravel.com/) check out [WakaTime Reports and Laravel](http://laravelista.com/wakatime-reports-and-laravel/).
1010

11-
## Planned Features
12-
13-
- [ ] OAuth 2.0 authentication
11+
If you find that some resource endpoints are missing feel free to send me a PR. *(Be sure to include tests for your code)*
1412

1513
## Installation
1614

17-
Add to your `composer.json`:
18-
19-
```php
20-
"mabasic/wakatime-php-api": "~1.0"
21-
```
22-
23-
and run `composer update` or type this from command line:
15+
Type this from command line:
2416

2517
```php
26-
composer require "mabasic/wakatime-php-api=~1.0"
18+
composer require mabasic/wakatime-php-api
2719
```
2820

2921
## Usage
@@ -34,43 +26,52 @@ composer require "mabasic/wakatime-php-api=~1.0"
3426
use GuzzleHttp\Client as Guzzle;
3527
use Mabasic\WakaTime\WakaTime;
3628

37-
$wakatime = new WakaTime(new Guzzle);
38-
$wakaTime->setApiKey($your_api_key_for_wakatime);
29+
$wakatime = new WakaTime(new Guzzle, $your_api_key_for_wakatime);
3930
```
4031

4132
You can get your Api Key from your [settings page](https://wakatime.com/settings).
4233

43-
> Be sure to set your Api Key before using any of the methods because you will get an Exception.
44-
45-
## Methods
34+
## Resource Endpoints
4635

47-
### Official methods
48-
49-
#### currentUser
36+
#### Users
5037

5138
```php
5239
$wakatime->currentUser()
40+
41+
// or
42+
43+
$wakatime->users('username');
5344
```
5445

5546
See: https://wakatime.com/developers/#users for details.
5647

57-
#### dailySummary
48+
#### Summaries
5849

5950
```php
60-
$wakatime->dailySummary($startDate, $endDate, $project = null)
51+
$wakatime->summaries($startDate, $endDate, $project = null)
6152
```
6253

6354
See: https://wakatime.com/developers/#summaries for details.
6455

65-
#### stats
56+
#### Stats
6657

6758
```php
6859
$wakatime->stats($range, $project = null)
6960
```
7061

7162
See: https://wakatime.com/developers/#stats for details.
7263

73-
### Additional methods
64+
#### Heartbeats
65+
66+
```php
67+
$date = '01/22/2016';
68+
69+
$wakatime->heartbeats($date);
70+
```
71+
72+
See: https://wakatime.com/developers#heartbeats for details.
73+
74+
## Helper methods aka Reports aka Shortcuts
7475

7576
#### getHoursLoggedFor
7677

@@ -163,22 +164,10 @@ _You can optionally specify a project._
163164

164165
---
165166

166-
## Testing instructions
167-
168-
For testing purposes set these environment variables before running tests:
167+
## For developers only
169168

170-
On windows use:
169+
Copy `.env.example` file to `.env` and set your api key and project name before running tests with:
171170

172171
```
173-
setx WAKATIME_API_KEY xyz
174-
setx WAKATIME_PROJECT xyz
175-
```
176-
177-
On Linux use:
178-
179-
```
180-
export WAKATIME_API_KEY=xyz
181-
export WAKATIME_PROJECT=xyz
182-
```
183-
184-
_Of course replace `xyz` with correct values._
172+
vendor/bin/phpunit
173+
```

composer.json

+5-7
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"keywords": ["wakatime", "time tracking", "api"],
55
"require": {
66
"php": ">=5.4",
7-
"guzzlehttp/guzzle": "4.*"
7+
"guzzlehttp/guzzle": "~6.0"
88
},
99
"require-dev": {
10-
"phpunit/phpunit": "4.4.*",
11-
"mockery/mockery": "dev-master"
10+
"phpunit/phpunit": "^5.1",
11+
"vlucas/phpdotenv": "^2.2"
1212
},
1313
"license": "MIT",
1414
"authors": [
@@ -21,7 +21,5 @@
2121
"psr-4": {
2222
"Mabasic\\WakaTime\\": "src/"
2323
}
24-
},
25-
"minimum-stability": "dev",
26-
"prefer-stable": true
27-
}
24+
}
25+
}

0 commit comments

Comments
 (0)