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

Feat/api/filter activities #58

Open
wants to merge 2 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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ The library implements a few basic API functions that you can use to retrieve us
| Method | Parameters | Returns |
| ----------------------- | -------------------- | --------------------------- |
| getActivityTypes() | - | Array |
| getActivityList() | integer $intStart, integer $intLimit, string $strActivityType | stdClass |
| getActivityList() | integer $intStart, integer $intLimit, string $strActivityType, array $filters | stdClass |
| getActivitySummary() | integer $intActivityID | stdClass |
| getActivityDetails() | integer $intActivityID | stdClass |
| getDataFile | string $strType, integer $intActivityID | string |
Expand Down Expand Up @@ -105,7 +105,7 @@ try {
)


### getActivityList(integer $intStart, integer $intLimit, string $strActivityType)
### getActivityList(integer $intStart, integer $intLimit, string $strActivityType, array $filters)

Returns a stdClass object, which contains an array called results, that contains stdClass objects that represents an activity. It accepts three parameters - start, limit and activity type; start is the record that you wish to start from, limit is the number of records that you would like returned, and activity type is the (optional) string representation of the activity type returned from `getActivityTypes()`

Expand Down
7 changes: 6 additions & 1 deletion src/dawguk/GarminConnect.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,11 @@ public function getActivityTypes()
* @param integer $intStart
* @param integer $intLimit
* @param null $strActivityType
* @param array $filters
* @return mixed
* @throws UnexpectedResponseCodeException
*/
public function getActivityList($intStart = 0, $intLimit = 10, $strActivityType = null)
public function getActivityList($intStart = 0, $intLimit = 10, $strActivityType = null, $filters = array())
{
$arrParams = array(
'start' => $intStart,
Expand All @@ -219,6 +220,10 @@ public function getActivityList($intStart = 0, $intLimit = 10, $strActivityType
$arrParams['activityType'] = $strActivityType;
}

if (!empty($filters)) {
$arrParams = array_merge($arrParams, $filters);
}

$strResponse = $this->objConnector->get(
'https://connect.garmin.com/modern/proxy/activitylist-service/activities/search/activities',
$arrParams,
Expand Down