Skip to content

Commit

Permalink
docs: improve docs
Browse files Browse the repository at this point in the history
add example to very method, fix types, convert example output to JSON
  • Loading branch information
macelai committed Mar 23, 2021
1 parent 45d0266 commit e52f2d0
Show file tree
Hide file tree
Showing 58 changed files with 956 additions and 368 deletions.
25 changes: 21 additions & 4 deletions docs/getActiveEnergyBurned.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,38 @@
# getActiveEnergyBurned

A quantity sample type that measures the amount of active energy the user has burned.

Example input options:

```javascript
let d = new Date(2016, 1, 1)
let options = {
startDate: new Date(2016, 10, 1).toISOString(), // required
startDate: new Date(2021, 0, 0).toISOString(), // required
endDate: new Date().toISOString(), // optional; default now
}
```

Call the method:

```javascript
AppleHealthKit.getActiveEnergyBurned(
(options: Object),
(err: Object, results: Object) => {
(options: HealthInputOptions),
(err: Object, results: HealthValue) => {
if (err) {
return
}
console.log(results)
},
)
```

Example output:

```json
[
{
"endDate": "2021-03-22T16:00:00.000-0300",
"startDate": "2021-03-22T15:00:00.000-0300",
"value": 123
}
]
```
25 changes: 21 additions & 4 deletions docs/getAppleStandTime.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,38 @@
# getAppleStandTime

A quantity sample type that measures the amount of time the user has spent standing.

Example input options:

```javascript
let d = new Date(2016, 1, 1)
let options = {
startDate: new Date(2016, 10, 1).toISOString(), // required
startDate: new Date(2021, 0, 0).toISOString(), // required
endDate: new Date().toISOString(), // optional; default now
}
```

Call the method:

```javascript
AppleHealthKit.getAppleStandTime(
(options: Object),
(err: Object, results: Object) => {
(options: HealthInputOptions),
(err: Object, results: HealthValue) => {
if (err) {
return
}
console.log(results)
},
)
```

Example output:

```json
[
{
"endDate": "2021-03-22T16:00:00.000-0300",
"startDate": "2021-03-22T15:00:00.000-0300",
"value": 123
}
]
```
2 changes: 2 additions & 0 deletions docs/getAuthStatus.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# getAuthStatus

Check the authorization status for sharing (writing) the specified data type.

Status will be a HealthStatusResult[]. From index.d.ts:
Expand Down
25 changes: 22 additions & 3 deletions docs/getBasalEnergyBurned.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,38 @@
# getBasalEnergyBurned

A quantity sample type that measures the amount of energy burned.

Example input options:

```javascript
let d = new Date(2016, 1, 1)
let options = {
startDate: new Date(2018, 10, 1).toISOString(), // required
endDate: new Date().toISOString(), // optional; default now
}
```

Call the method:

```javascript
AppleHealthKit.getBasalEnergyBurned(
(options: Object),
(err: Object, results: Object) => {
(options: HealthInputOptions),
(err: Object, results: HealthValue) => {
if (err) {
return
}
console.log(results)
},
)
```

Example output:

```json
[
{
"endDate": "2021-03-22T17:00:00.000-0300",
"startDate": "2021-03-22T16:00:00.000-0300",
"value": 42
}
]
```
10 changes: 7 additions & 3 deletions docs/getBiologicalSex.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# getBiologicalSex

Get the biological sex (gender). If the `BiologicalSex` read permission is missing or the user has denied it then the value will be `unknown`. The possible values are:

| Value | HKBiologicalSex |
Expand All @@ -9,15 +11,17 @@ Get the biological sex (gender). If the `BiologicalSex` read permission is missi

```javascript
AppleHealthKit.getBiologicalSex(null, (err: Object, results: Object) => {
if (this._handleHealthkitError(err, 'getBiologicalSex')) {
if (err) {
return
}
console.log(results)
})
```

```javascript
Example output:

```json
{
value: 'female',
"value": "female"
}
```
48 changes: 28 additions & 20 deletions docs/getBloodAlcoholContentSamples.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
Query for blood alcohol content samples. the options object is used to setup a query to retrieve relevant samples.
# getBloodAlcoholContentSamples

Query for blood alcohol content samples. The options object is used to setup a query to retrieve relevant samples.

Example input options:

```javascript
let options = {
startDate: new Date(2016, 4, 27).toISOString(), // required
startDate: new Date(2021, 0, 0).toISOString(), // required
endDate: new Date().toISOString(), // optional; default now
ascending: false, // optional; default false
limit: 10, // optional; default no limit
}
```

Call the method:

```javascript
AppleHealthKit.getBloodAlcoholContentSamples(
options,
Expand All @@ -21,28 +27,30 @@ AppleHealthKit.getBloodAlcoholContentSamples(
)
```

```javascript
;[
Example output:

```json
[
{
endDate: '2020-09-29T22:09:35.527+0200',
sourceId: 'com.example.app',
sourceName: 'app',
startDate: '2020-09-29T22:09:35.527+0200',
value: 0.003,
"endDate": "2020-09-29T22:09:35.527+0200",
"sourceId": "com.example.app",
"sourceName": "app",
"startDate": "2020-09-29T22:09:35.527+0200",
"value": 0.003
},
{
endDate: '2020-09-29T21:52:00.000+0200',
sourceId: 'com.apple.Health',
sourceName: 'Helse',
startDate: '2020-09-29T21:52:00.000+0200',
value: 0.001,
"endDate": "2020-09-29T21:52:00.000+0200",
"sourceId": "com.apple.Health",
"sourceName": "Helse",
"startDate": "2020-09-29T21:52:00.000+0200",
"value": 0.001
},
{
endDate: '2020-09-28T22:46:00.000+0200',
sourceId: 'com.apple.Health',
sourceName: 'Helse',
startDate: '2020-09-28T22:46:00.000+0200',
value: 0.00015,
},
"endDate": "2020-09-28T22:46:00.000+0200",
"sourceId": "com.apple.Health",
"sourceName": "Helse",
"startDate": "2020-09-28T22:46:00.000+0200",
"value": 0.00015
}
]
```
24 changes: 20 additions & 4 deletions docs/getBloodGlucoseSamples.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
Query for blood glucose samples. the options object is used to setup a query to retrieve relevant samples.
# getBloodGlucoseSamples

Query for blood glucose samples. The options object is used to setup a query to retrieve relevant samples.

Example input options:

```javascript
let options = {
unit: 'mmolPerL', // optional; default 'mmolPerL'
startDate: new Date(2016, 4, 27).toISOString(), // required
startDate: new Date(2021, 0, 0).toISOString(), // required
endDate: new Date().toISOString(), // optional; default now
ascending: false, // optional; default false
limit: 10, // optional; default no limit
Expand All @@ -12,8 +16,6 @@ let options = {

Available units are: `'mmolPerL'`, `'mgPerdL'`.

The callback function will be called with a `samples` array containing objects with _value_, _sourceId_, _sourceName_, _startDate_, and _endDate_ fields

```javascript
AppleHealthKit.getBloodGlucoseSamples(
options,
Expand All @@ -25,3 +27,17 @@ AppleHealthKit.getBloodGlucoseSamples(
},
)
```

Example output:

```json
[
{
"endDate": "2021-03-22T16:19:00.000-0300",
"sourceId": "com.apple.Health",
"sourceName": "Health",
"startDate": "2021-03-22T16:19:00.000-0300",
"value": 90.07794000002704
}
]
```
34 changes: 19 additions & 15 deletions docs/getBloodPressureSamples.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
Query for blood pressure samples. the options object is used to setup a query to retrieve relevant samples.
# getBloodPressureSamples

Query for blood pressure samples. The options object is used to setup a query to retrieve relevant samples.

Example input options:

```javascript
let options = {
unit: 'mmhg', // optional; default 'mmhg'
startDate: new Date(2016, 4, 27).toISOString(), // required
startDate: new Date(2021, 0, 0).toISOString(), // required
endDate: new Date().toISOString(), // optional; default now
ascending: false, // optional; default false
limit: 10, // optional; default no limit
}
```

The callback function will be called with a `samples` array containing objects with _bloodPressureSystolicValue_, _bloodPressureDiastolicValue_, _startDate_, and _endDate_ fields

```javascript
AppleHealthKit.getBloodPressureSamples(
options,
Expand All @@ -24,19 +26,21 @@ AppleHealthKit.getBloodPressureSamples(
)
```

```javascript
;[
Example output:

```json
[
{
bloodPressureSystolicValue: 120,
bloodPressureDiastolicValue: 81,
startDate: '2016-06-29T17:55:00.000-0400',
endDate: '2016-06-29T17:55:00.000-0400',
"bloodPressureSystolicValue": 120,
"bloodPressureDiastolicValue": 81,
"startDate": "2016-06-29T17:55:00.000-0400",
"endDate": "2016-06-29T17:55:00.000-0400"
},
{
bloodPressureSystolicValue: 119,
bloodPressureDiastolicValue: 77,
startDate: '2016-03-12T13:22:00.000-0400',
endDate: '2016-03-12T13:22:00.000-0400',
},
"bloodPressureSystolicValue": 119,
"bloodPressureDiastolicValue": 77,
"startDate": "2016-03-12T13:22:00.000-0400",
"endDate": "2016-03-12T13:22:00.000-0400"
}
]
```
38 changes: 23 additions & 15 deletions docs/getBodyFatPercentageSamples.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
Query for body fat percentage samples. the options object is used to setup a query to retrieve relevant samples.
# getBodyFatPercentageSamples

Query for body fat percentage samples. The options object is used to setup a query to retrieve relevant samples.

Example input options:

```javascript
let options = {
startDate: new Date(2016, 4, 27).toISOString(), // required
startDate: new Date(2021, 0, 0).toISOString(), // required
endDate: new Date().toISOString(), // optional; default now
ascending: false, // optional; default false
limit: 10, // optional; default no limit
}
```

Call the method:

```javascript
AppleHealthKit.getBodyFatPercentageSamples(
options,
(err: Object, results: Array<Object>) => {
(err: Object, results: Array<HealthValue>) => {
if (err) {
return
}
Expand All @@ -21,22 +27,24 @@ AppleHealthKit.getBodyFatPercentageSamples(
)
```

```javascript
;[
Example output:

```json
[
{
value: 16.5,
startDate: '2016-07-09T00:00:00.000-0400',
endDate: '2016-07-10T00:00:00.000-0400',
"value": 16.5,
"startDate": "2016-07-09T00:00:00.000-0400",
"endDate": "2016-07-10T00:00:00.000-0400"
},
{
value: 16.1,
startDate: '2016-07-08T00:00:00.000-0400',
endDate: '2016-07-09T00:00:00.000-0400',
"value": 16.1,
"startDate": "2016-07-08T00:00:00.000-0400",
"endDate": "2016-07-09T00:00:00.000-0400"
},
{
value: 15.9,
startDate: '2016-07-07T00:00:00.000-0400',
endDate: '2016-07-08T00:00:00.000-0400',
},
"value": 15.9,
"startDate": "2016-07-07T00:00:00.000-0400",
"endDate": "2016-07-08T00:00:00.000-0400"
}
]
```
Loading

0 comments on commit e52f2d0

Please sign in to comment.