Skip to content

Commit

Permalink
Merge pull request #30 from iFery/master
Browse files Browse the repository at this point in the history
added garmin weight support
  • Loading branch information
DaveWilcock authored Apr 16, 2019
2 parents 9c1023d + d7e40ca commit 53a89b8
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/dawguk/GarminConnect.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,4 +304,37 @@ public function getUsername()
$objResponse = json_decode($strResponse);
return $objResponse->username;
}

/**
* Retrieves weight data
*
* @param date "Y-m-d" $from
* @param date "Y-m-d" $until
* @throws GarminConnect\exceptions\UnexpectedResponseCodeException
* @throws \Exception
* @return mixed
*/
public function getWeightData($strFrom = '2019-01-01', $strUntil = '2099-12-31')
{
$intDateFrom = (strtotime($strFrom) + 86400) * 1000;
$intDateUntil = strtotime($strUntil) * 1000;

$arrParams = array(
'from' => $strDateFrom,
'until' => $strDateUntil
);

$strResponse = $this->objConnector->get(
'https://connect.garmin.com/modern/proxy/userprofile-service/userprofile/personal-information/weightWithOutbound/',
$arrParams,
true
);

if ($this->objConnector->getLastResponseCode() != 200) {
throw new UnexpectedResponseCodeException($this->objConnector->getLastResponseCode());
}
$objResponse = json_decode($strResponse, true);
return $objResponse;
}

}

0 comments on commit 53a89b8

Please sign in to comment.