text: (window.webpackJsonp=window.webpackJsonp||[]).push([[17],{367:function(t,a,e){"use strict";e.r(a);var s=e(42),r=Object(s.a)({},(function(){var t=this,a=t.$createElement,e=t._self._c||a;return e("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[e("h2",{attrs:{id:"get-heart-data"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#get-heart-data"}},[t._v("#")]),t._v(" Get Heart Data")]),t._v(" "),e("div",{staticClass:"custom-block tip"},[e("p",{staticClass:"custom-block-title"},[t._v("TIP")]),t._v(" "),e("p",[t._v("This guide assumes that your app has already been authorized and the snippet of code that I will show you can access to the Fitbit user id, here called "),e("code",[t._v("userID")]),t._v(", the Fitbit OAuth 2.0 client ID, here called "),e("code",[t._v("clientID")]),t._v(", and the Fitbit client secret, here called "),e("code",[t._v("clientSecret")]),t._v(".")])]),t._v(" "),e("p",[t._v("Information about the user's Heart data can be obtained in three steps")]),t._v(" "),e("h3",{attrs:{id:"step-1-instanciate-a-manager"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#step-1-instanciate-a-manager"}},[t._v("#")]),t._v(" Step 1: Instanciate a manager")]),t._v(" "),e("p",[t._v("First, you need to instanciate a "),e("code",[t._v("FitbitHeartDataManager")])]),t._v(" "),e("div",{staticClass:"language-dart extra-class"},[e("pre",{pre:!0,attrs:{class:"language-dart"}},[e("code",[t._v("    FitbitHeartDataManager fitbitHeartDataManager "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("FitbitHeartDataManager")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("\n        clientID"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token string"}},[t._v("'<OAuth 2.0 Client ID>'")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n        clientSecret"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token string"}},[t._v("'<Client Secret>'")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n    "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n")])])]),e("h3",{attrs:{id:"step-2-create-the-request-url"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#step-2-create-the-request-url"}},[t._v("#")]),t._v(" Step 2: Create the request url")]),t._v(" "),e("p",[t._v("Then, you have to create a url object, "),e("code",[t._v("FitbitHeartAPIURL")]),t._v(", that fetches the Heart data, during the desidered time range. For example:")]),t._v(" "),e("div",{staticClass:"language-dart extra-class"},[e("pre",{pre:!0,attrs:{class:"language-dart"}},[e("code",[t._v("    FitbitHeartAPIURL fitbitHeartApiUrl "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" FitbitHeartAPIURL"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("dayWithUserID")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("\n                                    date"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" DateTime"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("now")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n                                    userID"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(":")]),t._v(" userID"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v("\n                                  "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n")])])]),e("p",[t._v("For the complete list of possible "),e("code",[t._v("FitbitHeartAPIURL")]),t._v(", defined for different time ranges, please refer to the "),e("a",{attrs:{href:"https://pub.dev/documentation/fitbitter/latest/fitbitter/FitbitHeartAPIURL-class.html",target:"_blank",rel:"noopener noreferrer"}},[t._v("API Doc"),e("OutboundLink")],1),t._v(".")]),t._v(" "),e("h3",{attrs:{id:"step-3-get-the-data"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#step-3-get-the-data"}},[t._v("#")]),t._v(" Step 3: Get the data")]),t._v(" "),e("p",[t._v("Finally you can obtain the Heart data using")]),t._v(" "),e("div",{staticClass:"language-dart extra-class"},[e("pre",{pre:!0,attrs:{class:"language-dart"}},[e("code",[t._v("    List"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),t._v("FitbitHeartData"),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v(" fitbitHeartData "),e("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),e("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("await")]),t._v(" fitbitHeartDataManager"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),e("span",{pre:!0,attrs:{class:"token function"}},[t._v("fetch")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("fitbitHeartApiUrl"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n")])])])])}),[],!1,null,null,null);a.default=r.exports}}]);