From faa00f7ae3f23529f0242311d425e7bb923689ea Mon Sep 17 00:00:00 2001 From: Srini Vasudevan Date: Fri, 13 Sep 2019 20:07:37 +1000 Subject: [PATCH 1/9] added snk --- Fitbit.NetCore/Fitbit.NetCore.csproj | 4 +++- Fitbit.NetCore/FitbitNetCore.snk | Bin 0 -> 596 bytes 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 Fitbit.NetCore/FitbitNetCore.snk diff --git a/Fitbit.NetCore/Fitbit.NetCore.csproj b/Fitbit.NetCore/Fitbit.NetCore.csproj index 125143c4..6b8ef6cd 100644 --- a/Fitbit.NetCore/Fitbit.NetCore.csproj +++ b/Fitbit.NetCore/Fitbit.NetCore.csproj @@ -1,4 +1,4 @@ - + netstandard1.3;net45 @@ -17,6 +17,8 @@ http://static3.fitbit.com/simple.b-dis-png.h76d53d8e6a0653b38326a825b2b9cf57.pack?items=%2Fimages%2Fcommon%2Fbg_branding_b.png Fitbit OAuth2 API .NET IoT Wearables ..\NuGet + true + FitbitNetCore.snk diff --git a/Fitbit.NetCore/FitbitNetCore.snk b/Fitbit.NetCore/FitbitNetCore.snk new file mode 100644 index 0000000000000000000000000000000000000000..48358b5272b5bd639a80f6d77c735c01fc3f30f6 GIT binary patch literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa50098Sd04f?B)#QJ5iu&pnIj{t{e9)wVM3Bw z!NZ`6TFgO~Q*sWCXR)!y^FbRR6zFGoeBK&1}e;0B!V;v^S1)xWAU@a~7{*HiYF~0f=8K{)ln8kl5 z0k>w6Mn~qva`?*M!cFj1Yo!b>R^xjvEOTQ>i~F%dJqvJi+hV#aG(1bfw!4k>{}wKf zC{2}ht@hwSEYZ>=XIL+EOEgNJfCSzf*V(9Y>d+650zF2tT9kXduE#^IDj{k}yiSHk z!pnNsg&w8o!$XdFFlDZ^N;&1*^U~@y8>`~Lj}!6V6WB6I23z&}NNT$z0&TIp(4ON8 zlUpw$*Ac|WNS|6gyug(h5PzRZt}%bm5npw-SeJmxCh75o`S!sgDqVK4PSLm*tsL!y zCz=(>5iN^Y&%2RvEbPWV^jAk|0+-h;W)Nj4I=;<`s6jzRHjhtrt1--mEiNVNb4)l5 z2iHlZ5-Pe?7DI2406Sn0xr9L2H6Uk(wSE1pf^nlhwKY?nJ^2=Hm6swZtcw!W#*c}y z_ewOXQ@#cfG-9a@ss-x0)4`_5O)=cY^1c|qPvn-98j3mcY^!>k35cSd<57vl8?M|h i9}$ez_E-il5fiV?Zxwy4roq+x95aT)>Ga*3d(D9o^%+M1 literal 0 HcmV?d00001 From 9743730662de010764e474e33f08e8455d950175 Mon Sep 17 00:00:00 2001 From: Srini Vasudevan Date: Mon, 16 Sep 2019 19:35:45 +1000 Subject: [PATCH 2/9] added fitbit snk --- FitbitNetCore.snk | Bin 0 -> 596 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 FitbitNetCore.snk diff --git a/FitbitNetCore.snk b/FitbitNetCore.snk new file mode 100644 index 0000000000000000000000000000000000000000..f2c4275bf18b9173a4917678af36d8eceb70b617 GIT binary patch literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa50097Hv%7b)r7CCTvX?C9;6ayHfzZ*qu?R`B zua|L5fK(Ah4?e3gF=iY$7>3%FR?BrrVR%^Ub1LH=)ly`%E9rn}6?fH#ZY4-?kYU`Z zqji0?1lgH{d6P{!vicT>GdWyUu*K$bIa+qm8gH#=&`K0vX5#f-B%=>kXrfJ(zE--I zES~7a7L~!2ZW}kTpKTHF%_~3TE3|oP<%0gaC@or-$r%pU>Gj`16_DCdqJRSoJ=p5-Hp@b$<>1f99w+1r?OrTyjV%Z2 zL+v2NaUp^aWB%wE(#@lt-TbRwzJ&BD3~_Z<{IeJn79maD2!r4oyAT9Kw@DFS9FzEE zIipK^p8UG>^LBx|kaL+&!rTM$g4@)t)3!AmDhV#vWl| zH*u*&c}9>1O7M?(TIP6~I iTtbbQQN)7zUwr^nA-zE56-gwdj;51m6T Date: Mon, 16 Sep 2019 19:45:51 +1000 Subject: [PATCH 3/9] added signature to test project --- .../Fitbit.NetCore.Tests.csproj | 249 +++++++++--------- Fitbit.NetCore.Tests/FitbitNetCore.snk | Bin 0 -> 596 bytes 2 files changed, 126 insertions(+), 123 deletions(-) create mode 100644 Fitbit.NetCore.Tests/FitbitNetCore.snk diff --git a/Fitbit.NetCore.Tests/Fitbit.NetCore.Tests.csproj b/Fitbit.NetCore.Tests/Fitbit.NetCore.Tests.csproj index 526904a2..0bc422f7 100644 --- a/Fitbit.NetCore.Tests/Fitbit.NetCore.Tests.csproj +++ b/Fitbit.NetCore.Tests/Fitbit.NetCore.Tests.csproj @@ -1,124 +1,127 @@ - - - - - Debug - AnyCPU - {DE9D7F3C-6F6C-43E2-AEE6-32E7DF894F3E} - Library - Properties - Fitbit.NetCore.Tests - Fitbit.NetCore.Tests - v4.6 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 15.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest - - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\Fitbit\packages\Castle.Core.4.1.1\lib\net45\Castle.Core.dll - - - ..\Fitbit\packages\FluentAssertions.4.19.3\lib\net45\FluentAssertions.dll - - - ..\Fitbit\packages\FluentAssertions.4.19.3\lib\net45\FluentAssertions.Core.dll - - - ..\Fitbit\packages\Moq.4.7.99\lib\net45\Moq.dll - - - ..\Fitbit\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll - - - ..\Fitbit\packages\NUnit.3.7.1\lib\net45\nunit.framework.dll - - - ..\Fitbit\packages\AutoFixture.3.50.3\lib\net40\Ploeh.AutoFixture.dll - - - - - ..\Fitbit\packages\System.Net.Http.4.3.2\lib\net46\System.Net.Http.dll - - - ..\Fitbit\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net46\System.Security.Cryptography.Algorithms.dll - - - ..\Fitbit\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll - - - ..\Fitbit\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll - - - ..\Fitbit\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net46\System.Security.Cryptography.X509Certificates.dll - - - - - - - - %(RecursiveDir)%(Filename)%(Extension) - - - - - %(RecursiveDir)%(Filename)%(Extension) - PreserveNewest - - - - %(RecursiveDir)%(Filename)%(Extension) - PreserveNewest - - - - - - netstandard1.3 - - - - - - - - - {81f4f528-0e81-49e0-a2b2-ed77495a9c15} - Fitbit.NetCore - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - + + + + + Debug + AnyCPU + {DE9D7F3C-6F6C-43E2-AEE6-32E7DF894F3E} + Library + Properties + Fitbit.NetCore.Tests + Fitbit.NetCore.Tests + v4.6 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 15.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\Fitbit\packages\Castle.Core.4.1.1\lib\net45\Castle.Core.dll + + + ..\Fitbit\packages\FluentAssertions.4.19.3\lib\net45\FluentAssertions.dll + + + ..\Fitbit\packages\FluentAssertions.4.19.3\lib\net45\FluentAssertions.Core.dll + + + ..\Fitbit\packages\Moq.4.7.99\lib\net45\Moq.dll + + + ..\Fitbit\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll + + + ..\Fitbit\packages\NUnit.3.7.1\lib\net45\nunit.framework.dll + + + ..\Fitbit\packages\AutoFixture.3.50.3\lib\net40\Ploeh.AutoFixture.dll + + + + + ..\Fitbit\packages\System.Net.Http.4.3.2\lib\net46\System.Net.Http.dll + + + ..\Fitbit\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net46\System.Security.Cryptography.Algorithms.dll + + + ..\Fitbit\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + + + ..\Fitbit\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + + + ..\Fitbit\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net46\System.Security.Cryptography.X509Certificates.dll + + + + + + + + %(RecursiveDir)%(Filename)%(Extension) + + + + %(RecursiveDir)%(Filename)%(Extension) + PreserveNewest + + + %(RecursiveDir)%(Filename)%(Extension) + PreserveNewest + + + + + netstandard1.3 + + + true + + + FitbitNetCore.snk + + + + + + + + + {81f4f528-0e81-49e0-a2b2-ed77495a9c15} + Fitbit.NetCore + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + \ No newline at end of file diff --git a/Fitbit.NetCore.Tests/FitbitNetCore.snk b/Fitbit.NetCore.Tests/FitbitNetCore.snk new file mode 100644 index 0000000000000000000000000000000000000000..48358b5272b5bd639a80f6d77c735c01fc3f30f6 GIT binary patch literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa50098Sd04f?B)#QJ5iu&pnIj{t{e9)wVM3Bw z!NZ`6TFgO~Q*sWCXR)!y^FbRR6zFGoeBK&1}e;0B!V;v^S1)xWAU@a~7{*HiYF~0f=8K{)ln8kl5 z0k>w6Mn~qva`?*M!cFj1Yo!b>R^xjvEOTQ>i~F%dJqvJi+hV#aG(1bfw!4k>{}wKf zC{2}ht@hwSEYZ>=XIL+EOEgNJfCSzf*V(9Y>d+650zF2tT9kXduE#^IDj{k}yiSHk z!pnNsg&w8o!$XdFFlDZ^N;&1*^U~@y8>`~Lj}!6V6WB6I23z&}NNT$z0&TIp(4ON8 zlUpw$*Ac|WNS|6gyug(h5PzRZt}%bm5npw-SeJmxCh75o`S!sgDqVK4PSLm*tsL!y zCz=(>5iN^Y&%2RvEbPWV^jAk|0+-h;W)Nj4I=;<`s6jzRHjhtrt1--mEiNVNb4)l5 z2iHlZ5-Pe?7DI2406Sn0xr9L2H6Uk(wSE1pf^nlhwKY?nJ^2=Hm6swZtcw!W#*c}y z_ewOXQ@#cfG-9a@ss-x0)4`_5O)=cY^1c|qPvn-98j3mcY^!>k35cSd<57vl8?M|h i9}$ez_E-il5fiV?Zxwy4roq+x95aT)>Ga*3d(D9o^%+M1 literal 0 HcmV?d00001 From a01f1c9e7e8bbc92994a855d4500dbc5ce71c7d4 Mon Sep 17 00:00:00 2001 From: Srini Vasudevan Date: Mon, 16 Sep 2019 20:25:35 +1000 Subject: [PATCH 4/9] migrate the package references --- .../Fitbit.NetCore.Tests.csproj | 76 +++++++------------ Fitbit.NetCore.Tests/packages.config | 22 ------ Fitbit.NetCore/AssemblyInfo.cs | 3 +- Fitbit.Portable.Tests/FatTests.cs | 2 +- Fitbit.Portable.Tests/WeightTests.cs | 2 +- 5 files changed, 33 insertions(+), 72 deletions(-) delete mode 100644 Fitbit.NetCore.Tests/packages.config diff --git a/Fitbit.NetCore.Tests/Fitbit.NetCore.Tests.csproj b/Fitbit.NetCore.Tests/Fitbit.NetCore.Tests.csproj index 0bc422f7..b4954985 100644 --- a/Fitbit.NetCore.Tests/Fitbit.NetCore.Tests.csproj +++ b/Fitbit.NetCore.Tests/Fitbit.NetCore.Tests.csproj @@ -1,6 +1,5 @@  - Debug AnyCPU @@ -39,46 +38,7 @@ 4 - - ..\Fitbit\packages\Castle.Core.4.1.1\lib\net45\Castle.Core.dll - - - ..\Fitbit\packages\FluentAssertions.4.19.3\lib\net45\FluentAssertions.dll - - - ..\Fitbit\packages\FluentAssertions.4.19.3\lib\net45\FluentAssertions.Core.dll - - - ..\Fitbit\packages\Moq.4.7.99\lib\net45\Moq.dll - - - ..\Fitbit\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll - - - ..\Fitbit\packages\NUnit.3.7.1\lib\net45\nunit.framework.dll - - - ..\Fitbit\packages\AutoFixture.3.50.3\lib\net40\Ploeh.AutoFixture.dll - - - - ..\Fitbit\packages\System.Net.Http.4.3.2\lib\net46\System.Net.Http.dll - - - ..\Fitbit\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net46\System.Security.Cryptography.Algorithms.dll - - - ..\Fitbit\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll - - - ..\Fitbit\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll - - - ..\Fitbit\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net46\System.Security.Cryptography.X509Certificates.dll - - - @@ -108,7 +68,6 @@ - @@ -116,12 +75,35 @@ Fitbit.NetCore + + + 3.50.3 + + + 4.19.3 + + + 14.0.0 + + + 4.7.99 + + + 10.0.3 + + + 3.12.0 + + + 3.7.0 + + + 3.8.0 + + + 4.3.2 + + - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - \ No newline at end of file diff --git a/Fitbit.NetCore.Tests/packages.config b/Fitbit.NetCore.Tests/packages.config deleted file mode 100644 index 02550478..00000000 --- a/Fitbit.NetCore.Tests/packages.config +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Fitbit.NetCore/AssemblyInfo.cs b/Fitbit.NetCore/AssemblyInfo.cs index b3701f58..ab2ab4bd 100644 --- a/Fitbit.NetCore/AssemblyInfo.cs +++ b/Fitbit.NetCore/AssemblyInfo.cs @@ -1,6 +1,7 @@ using System.Resources; using System.Reflection; using System.Runtime.CompilerServices; +using System.Security.Cryptography.X509Certificates; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information @@ -28,4 +29,4 @@ [assembly: AssemblyVersion("2.0.1.0")] [assembly: AssemblyFileVersion("1.0.0.0")] -[assembly: InternalsVisibleTo("Fitbit.NetCore.Tests")] \ No newline at end of file +[assembly: InternalsVisibleTo("Fitbit.NetCore.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c57958b5c424bde54b11312ac6992323acfd7de5d861429259c1c3a08a5acc419653720e8d67b1b1c6f3411b2014e867787cde1a36e3bf0cccc85492020e4a12fe95a049eb426b75d8e64f2d82b593587d08cd9ae0fc0653b40b427fc0bee6a7824509838aa98f8b7260c52c3ba4f8d53f675d84c554eb1670f85344620507b0")] \ No newline at end of file diff --git a/Fitbit.Portable.Tests/FatTests.cs b/Fitbit.Portable.Tests/FatTests.cs index 1aead3b9..6a85dd9a 100644 --- a/Fitbit.Portable.Tests/FatTests.cs +++ b/Fitbit.Portable.Tests/FatTests.cs @@ -16,7 +16,7 @@ public class FatTests { public Fixture fixture { get; set; } - [TestFixtureSetUp] + [SetUp] public void Init() { fixture = new Fixture(); diff --git a/Fitbit.Portable.Tests/WeightTests.cs b/Fitbit.Portable.Tests/WeightTests.cs index 4692e212..c7cf820a 100644 --- a/Fitbit.Portable.Tests/WeightTests.cs +++ b/Fitbit.Portable.Tests/WeightTests.cs @@ -16,7 +16,7 @@ public class WeightTests { public Fixture fixture { get; set; } - [TestFixtureSetUp] + [SetUp] public void Init() { fixture = new Fixture(); From 532d56ecd2bab22b64d75a2aa80559c669d451c7 Mon Sep 17 00:00:00 2001 From: Srini Vasudevan Date: Thu, 19 Sep 2019 15:02:47 +1000 Subject: [PATCH 5/9] added get activities list endpoint --- Fitbit.Portable/Fitbit.Portable.csproj | 393 +++++++++--------- Fitbit.Portable/FitbitClient.cs | 43 +- Fitbit.Portable/IFitbitClient.cs | 3 +- Fitbit.Portable/Models/ActivitiesList.cs | 9 + Fitbit.Portable/Models/ActivitiesStats.cs | 6 +- Fitbit.Portable/Models/ActivityDetail.cs | 46 ++ Fitbit.Portable/Models/ActivityLevel.cs | 9 + Fitbit.Portable/Models/DateTypeEnum.cs | 8 + Fitbit.Portable/Models/HeartRateZone.cs | 18 +- .../Models/ManualValuesSpecified.cs | 11 + Fitbit.Portable/Models/Pagination.cs | 27 +- Fitbit.Portable/Models/SortEnum.cs | 1 - 12 files changed, 339 insertions(+), 235 deletions(-) create mode 100644 Fitbit.Portable/Models/ActivitiesList.cs create mode 100644 Fitbit.Portable/Models/ActivityDetail.cs create mode 100644 Fitbit.Portable/Models/ActivityLevel.cs create mode 100644 Fitbit.Portable/Models/DateTypeEnum.cs create mode 100644 Fitbit.Portable/Models/ManualValuesSpecified.cs diff --git a/Fitbit.Portable/Fitbit.Portable.csproj b/Fitbit.Portable/Fitbit.Portable.csproj index f1688c90..f8d5649e 100644 --- a/Fitbit.Portable/Fitbit.Portable.csproj +++ b/Fitbit.Portable/Fitbit.Portable.csproj @@ -1,201 +1,206 @@ - - - - - 10.0 - Debug - AnyCPU - {1358D3B4-0698-4003-97EB-B6D489E04138} - Library - Properties - Fitbit.Api.Portable - Fitbit.Portable - en-US - 512 - {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Profile344 - v4.0 - ..\Fitbit\ - - - - - true - full - false - bin\Debug\ - TRACE;DEBUG;REQUIRES_JSONNET - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE;REQUIRES_JSONNET - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ..\Fitbit\packages\Microsoft.Bcl.Async.1.0.168\lib\portable-net40+sl4+win8+wp71+wpa81\Microsoft.Threading.Tasks.dll - - - ..\Fitbit\packages\Microsoft.Bcl.Async.1.0.168\lib\portable-net40+sl4+win8+wp71+wpa81\Microsoft.Threading.Tasks.Extensions.dll - - - ..\Fitbit\packages\Newtonsoft.Json.8.0.2\lib\portable-net40+sl5+wp80+win8+wpa81\Newtonsoft.Json.dll - True - - - ..\Fitbit\packages\Microsoft.Bcl.1.1.10\lib\portable-net40+sl5+win8+wp8+wpa81\System.IO.dll - - - ..\Fitbit\packages\Microsoft.Net.Http.2.2.29\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.dll - - - ..\Fitbit\packages\Microsoft.Net.Http.2.2.29\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.Extensions.dll - - - ..\Fitbit\packages\Microsoft.Net.Http.2.2.29\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.Primitives.dll - - - ..\Fitbit\packages\Microsoft.Bcl.1.1.10\lib\portable-net40+sl5+win8+wp8+wpa81\System.Runtime.dll - - - ..\Fitbit\packages\Microsoft.Bcl.1.1.10\lib\portable-net40+sl5+win8+wp8+wpa81\System.Threading.Tasks.dll - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - + + + + + 10.0 + Debug + AnyCPU + {1358D3B4-0698-4003-97EB-B6D489E04138} + Library + Properties + Fitbit.Api.Portable + Fitbit.Portable + en-US + 512 + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Profile344 + v4.0 + ..\Fitbit\ + + + + + true + full + false + bin\Debug\ + TRACE;DEBUG;REQUIRES_JSONNET + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE;REQUIRES_JSONNET + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ..\Fitbit\packages\Microsoft.Bcl.Async.1.0.168\lib\portable-net40+sl4+win8+wp71+wpa81\Microsoft.Threading.Tasks.dll + + + ..\Fitbit\packages\Microsoft.Bcl.Async.1.0.168\lib\portable-net40+sl4+win8+wp71+wpa81\Microsoft.Threading.Tasks.Extensions.dll + + + ..\Fitbit\packages\Newtonsoft.Json.8.0.2\lib\portable-net40+sl5+wp80+win8+wpa81\Newtonsoft.Json.dll + True + + + ..\Fitbit\packages\Microsoft.Bcl.1.1.10\lib\portable-net40+sl5+win8+wp8+wpa81\System.IO.dll + + + ..\Fitbit\packages\Microsoft.Net.Http.2.2.29\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.dll + + + ..\Fitbit\packages\Microsoft.Net.Http.2.2.29\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.Extensions.dll + + + ..\Fitbit\packages\Microsoft.Net.Http.2.2.29\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.Primitives.dll + + + ..\Fitbit\packages\Microsoft.Bcl.1.1.10\lib\portable-net40+sl5+win8+wp8+wpa81\System.Runtime.dll + + + ..\Fitbit\packages\Microsoft.Bcl.1.1.10\lib\portable-net40+sl5+win8+wp8+wpa81\System.Threading.Tasks.dll + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + --> \ No newline at end of file diff --git a/Fitbit.Portable/FitbitClient.cs b/Fitbit.Portable/FitbitClient.cs index 2ca91a5f..ce708a1f 100644 --- a/Fitbit.Portable/FitbitClient.cs +++ b/Fitbit.Portable/FitbitClient.cs @@ -161,14 +161,41 @@ public async Task RefreshOAuth2TokenAsync() AccessToken = await TokenManager.RefreshTokenAsync(this); return AccessToken; } - - /// - /// Requests the activity details of the encoded user id or if none supplied the current logged in user for the specified date - /// - /// - /// encoded user id, can be null for current logged in user - /// FitbitResponse of - public async Task GetDayActivityAsync(DateTime activityDate, string encodedUserId = null) + + /// + /// Requests the activity list of the encoded user id or if none supplied the current logged in user from before or after a certain date with pagination + /// + /// The boundary date for the request + /// Select whether the boundary is before the selected date or after the selected date + /// + /// + /// + /// encoded user id, can be null for current logged in user + /// FitbitResponse of + public async Task GetActivityListAsync(DateTime dateTime, DateTypeEnum dateType, SortEnum sort, int limit = 20, int offset = 0, string encodedUserId = default(string)) + { + string apiCall = FitbitClientHelperExtensions.ToFullUrl("/1/user/{0}/activities/list.json?sort={1}&offset={2}&limit={3}&{4}={5}", + encodedUserId, + sort, + offset, + limit, + dateType == DateTypeEnum.AfterDate ? "afterDate" : "beforeDate", + dateTime.ToFitbitFormat()); + + HttpResponseMessage response = await HttpClient.GetAsync(apiCall); + await HandleResponse(response); + string responseBody = await response.Content.ReadAsStringAsync(); + var serializer = new JsonDotNetSerializer(); + return serializer.Deserialize(responseBody); + } + + /// + /// Requests the activity details of the encoded user id or if none supplied the current logged in user for the specified date + /// + /// + /// encoded user id, can be null for current logged in user + /// FitbitResponse of + public async Task GetDayActivityAsync(DateTime activityDate, string encodedUserId = null) { string apiCall = FitbitClientHelperExtensions.ToFullUrl("/1/user/{0}/activities/date/{1}.json", encodedUserId, activityDate.ToFitbitFormat()); diff --git a/Fitbit.Portable/IFitbitClient.cs b/Fitbit.Portable/IFitbitClient.cs index 80d89719..0d4aa5e9 100644 --- a/Fitbit.Portable/IFitbitClient.cs +++ b/Fitbit.Portable/IFitbitClient.cs @@ -8,7 +8,8 @@ namespace Fitbit.Api.Portable { public interface IFitbitClient { - Task GetDayActivityAsync(DateTime activityDate, string encodedUserId = default(string)); + Task GetActivityListAsync(DateTime dateTime, DateTypeEnum dateType, SortEnum sort, int limit = 20, int offset = 0, string encodedUserId = default(string)); + Task GetDayActivityAsync(DateTime activityDate, string encodedUserId = default(string)); Task GetDayActivitySummaryAsync(DateTime activityDate, string encodedUserId = default(string)); Task GetActivitiesStatsAsync(string encodedUserId = default(string)); Task GetSleepAsync(DateTime sleepDate); diff --git a/Fitbit.Portable/Models/ActivitiesList.cs b/Fitbit.Portable/Models/ActivitiesList.cs new file mode 100644 index 00000000..e8019b35 --- /dev/null +++ b/Fitbit.Portable/Models/ActivitiesList.cs @@ -0,0 +1,9 @@ +namespace Fitbit.Api.Portable.Models +{ + public class ActivitiesList + { + public ActivityDetail[] Activities { get; set; } + + public Pagination Pagination { get; set; } + } +} diff --git a/Fitbit.Portable/Models/ActivitiesStats.cs b/Fitbit.Portable/Models/ActivitiesStats.cs index 27c9a070..38990bd2 100644 --- a/Fitbit.Portable/Models/ActivitiesStats.cs +++ b/Fitbit.Portable/Models/ActivitiesStats.cs @@ -1,13 +1,9 @@ -using Newtonsoft.Json; - -namespace Fitbit.Models +namespace Fitbit.Models { public class ActivitiesStats { - [JsonProperty("best")] public BestStats Best { get; set; } - [JsonProperty("lifetime")] public LifetimeStats Lifetime { get; set; } } } \ No newline at end of file diff --git a/Fitbit.Portable/Models/ActivityDetail.cs b/Fitbit.Portable/Models/ActivityDetail.cs new file mode 100644 index 00000000..1f215b34 --- /dev/null +++ b/Fitbit.Portable/Models/ActivityDetail.cs @@ -0,0 +1,46 @@ +using System; +using Fitbit.Models; + +namespace Fitbit.Api.Portable.Models +{ + public class ActivityDetail + { + public long ActiveDuration { get; set; } + + public ActivityLevel[] ActivityLevel { get; set; } + + public string ActivityName { get; set; } + + public long ActivityTypeId { get; set; } + + public long? AverageHeartRate { get; set; } + + public long Calories { get; set; } + + public long Duration { get; set; } + + public Uri HeartRateLink { get; set; } + + public HeartRateZone[] HeartRateZones { get; set; } + + public DateTimeOffset LastModified { get; set; } + + public long LogId { get; set; } + + public string LogType { get; set; } + + public ManualValuesSpecified ManualValuesSpecified { get; set; } + + public long OriginalDuration { get; set; } + + public DateTimeOffset OriginalStartTime { get; set; } + + public DateTimeOffset StartTime { get; set; } + + public long? Steps { get; set; } + + public Uri TcxLink { get; set; } + + public double? ElevationGain { get; set; } + } +} \ No newline at end of file diff --git a/Fitbit.Portable/Models/ActivityLevel.cs b/Fitbit.Portable/Models/ActivityLevel.cs new file mode 100644 index 00000000..c040c568 --- /dev/null +++ b/Fitbit.Portable/Models/ActivityLevel.cs @@ -0,0 +1,9 @@ +namespace Fitbit.Api.Portable.Models +{ + public partial class ActivityLevel + { + public long Minutes { get; set; } + + public string Name { get; set; } + } +} \ No newline at end of file diff --git a/Fitbit.Portable/Models/DateTypeEnum.cs b/Fitbit.Portable/Models/DateTypeEnum.cs new file mode 100644 index 00000000..8554d02e --- /dev/null +++ b/Fitbit.Portable/Models/DateTypeEnum.cs @@ -0,0 +1,8 @@ +namespace Fitbit.Api.Portable.Models +{ + public enum DateTypeEnum + { + BeforeDate, + AfterDate + } +} \ No newline at end of file diff --git a/Fitbit.Portable/Models/HeartRateZone.cs b/Fitbit.Portable/Models/HeartRateZone.cs index ebf306dc..e2f96da8 100644 --- a/Fitbit.Portable/Models/HeartRateZone.cs +++ b/Fitbit.Portable/Models/HeartRateZone.cs @@ -1,11 +1,11 @@ namespace Fitbit.Models { - public class HeartRateZone - { - public float CaloriesOut { get; set; } - public int Max { get; set; } - public int Min { get; set; } - public int Minutes { get; set; } - public string Name { get; set; } - } -} + public class HeartRateZone + { + public float CaloriesOut { get; set; } + public int Max { get; set; } + public int Min { get; set; } + public int Minutes { get; set; } + public string Name { get; set; } + } +} \ No newline at end of file diff --git a/Fitbit.Portable/Models/ManualValuesSpecified.cs b/Fitbit.Portable/Models/ManualValuesSpecified.cs new file mode 100644 index 00000000..861012a0 --- /dev/null +++ b/Fitbit.Portable/Models/ManualValuesSpecified.cs @@ -0,0 +1,11 @@ +namespace Fitbit.Api.Portable.Models +{ + public class ManualValuesSpecified + { + public bool Calories { get; set; } + + public bool Distance { get; set; } + + public bool Steps { get; set; } + } +} \ No newline at end of file diff --git a/Fitbit.Portable/Models/Pagination.cs b/Fitbit.Portable/Models/Pagination.cs index 3150ea21..a121bc68 100644 --- a/Fitbit.Portable/Models/Pagination.cs +++ b/Fitbit.Portable/Models/Pagination.cs @@ -1,19 +1,12 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Fitbit.Api.Portable.Models +namespace Fitbit.Api.Portable.Models { - public class Pagination - { - public string BeforeDate { get; set; } - public int Limit { get; set; } - public string Next { get; set; } - public int Offset { get; set; } - public string Previous { get; set; } - public string Sort { get; set; } - } - - + public class Pagination + { + public string BeforeDate { get; set; } + public int Limit { get; set; } + public string Next { get; set; } + public int Offset { get; set; } + public string Previous { get; set; } + public string Sort { get; set; } + } } diff --git a/Fitbit.Portable/Models/SortEnum.cs b/Fitbit.Portable/Models/SortEnum.cs index b12998f0..39d354de 100644 --- a/Fitbit.Portable/Models/SortEnum.cs +++ b/Fitbit.Portable/Models/SortEnum.cs @@ -9,6 +9,5 @@ public enum SortEnum { Asc, Dsc - } } From 45dd186b41f30206f2b3557dda5deba9b9c12ca2 Mon Sep 17 00:00:00 2001 From: Srini Vasudevan Date: Thu, 19 Sep 2019 15:12:23 +1000 Subject: [PATCH 6/9] addded activities list json data --- .../Fitbit.Portable.Tests.csproj | 697 ++++----- .../SampleData/ActivitiesList.json | 1257 +++++++++++++++++ 2 files changed, 1607 insertions(+), 347 deletions(-) create mode 100644 Fitbit.Portable.Tests/SampleData/ActivitiesList.json diff --git a/Fitbit.Portable.Tests/Fitbit.Portable.Tests.csproj b/Fitbit.Portable.Tests/Fitbit.Portable.Tests.csproj index 54fb4182..6f6990d1 100644 --- a/Fitbit.Portable.Tests/Fitbit.Portable.Tests.csproj +++ b/Fitbit.Portable.Tests/Fitbit.Portable.Tests.csproj @@ -1,354 +1,357 @@ - - - - - Debug - AnyCPU - {F811594D-3323-4147-9780-D3A1F930B99F} - Library - Properties - Fitbit.Portable.Tests - Fitbit.Portable.Tests - v4.5 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest - ..\Fitbit\ - - - - - true - full - false - bin\Debug\ - TRACE;DEBUG;REQUIRES_JSONNET - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\Fitbit\packages\Castle.Core.4.1.1\lib\net45\Castle.Core.dll - - - ..\Fitbit\packages\FluentAssertions.4.19.3\lib\net45\FluentAssertions.dll - - - ..\Fitbit\packages\FluentAssertions.4.19.3\lib\net45\FluentAssertions.Core.dll - - - ..\Fitbit\packages\Moq.4.7.99\lib\net45\Moq.dll - - - ..\Fitbit\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll - True - - - ..\Fitbit\packages\NUnit.3.7.1\lib\net45\nunit.framework.dll - - - ..\Fitbit\packages\AutoFixture.3.50.3\lib\net40\Ploeh.AutoFixture.dll - - - - - - ..\Fitbit\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll - - - ..\Fitbit\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Primitives.dll - - - ..\Fitbit\packages\Microsoft.Bcl.1.1.10\lib\portable-net40+sl5+win8+wp8+wpa81\System.Threading.Tasks.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - - - - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - - - PreserveNewest - - - - - {1358d3b4-0698-4003-97eb-b6d489e04138} - Fitbit.Portable - - - - - - - False - - - False - - - False - - - False - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - + + + + + Debug + AnyCPU + {F811594D-3323-4147-9780-D3A1F930B99F} + Library + Properties + Fitbit.Portable.Tests + Fitbit.Portable.Tests + v4.5 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + ..\Fitbit\ + + + + + true + full + false + bin\Debug\ + TRACE;DEBUG;REQUIRES_JSONNET + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\Fitbit\packages\Castle.Core.4.1.1\lib\net45\Castle.Core.dll + + + ..\Fitbit\packages\FluentAssertions.4.19.3\lib\net45\FluentAssertions.dll + + + ..\Fitbit\packages\FluentAssertions.4.19.3\lib\net45\FluentAssertions.Core.dll + + + ..\Fitbit\packages\Moq.4.7.99\lib\net45\Moq.dll + + + ..\Fitbit\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll + True + + + ..\Fitbit\packages\NUnit.3.7.1\lib\net45\nunit.framework.dll + + + ..\Fitbit\packages\AutoFixture.3.50.3\lib\net40\Ploeh.AutoFixture.dll + + + + + + ..\Fitbit\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll + + + ..\Fitbit\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Primitives.dll + + + ..\Fitbit\packages\Microsoft.Bcl.1.1.10\lib\portable-net40+sl5+win8+wp8+wpa81\System.Threading.Tasks.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + + + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + + + PreserveNewest + + + + + {1358d3b4-0698-4003-97eb-b6d489e04138} + Fitbit.Portable + + + + + + + False + + + False + + + False + + + False + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + --> \ No newline at end of file diff --git a/Fitbit.Portable.Tests/SampleData/ActivitiesList.json b/Fitbit.Portable.Tests/SampleData/ActivitiesList.json new file mode 100644 index 00000000..142004ad --- /dev/null +++ b/Fitbit.Portable.Tests/SampleData/ActivitiesList.json @@ -0,0 +1,1257 @@ +{ + "activities": [ + { + "activeDuration": 1791000, + "activityLevel": [ + { + "minutes": 0, + "name": "sedentary" + }, + { + "minutes": 2, + "name": "lightly" + }, + { + "minutes": 24, + "name": "fairly" + }, + { + "minutes": 3, + "name": "very" + } + ], + "activityName": "Sport", + "activityTypeId": 15000, + "averageHeartRate": 110, + "calories": 179, + "duration": 1791000, + "heartRateLink": "https://api.fitbit.com/1/user/-/activities/heart/date/2017-04-08/2017-04-08/1sec/time/07:28:00/07:57:51.json", + "heartRateZones": [ + { + "max": 94, + "min": 30, + "minutes": 0, + "name": "Out of Range" + }, + { + "max": 132, + "min": 94, + "minutes": 30, + "name": "Fat Burn" + }, + { + "max": 160, + "min": 132, + "minutes": 0, + "name": "Cardio" + }, + { + "max": 220, + "min": 160, + "minutes": 0, + "name": "Peak" + } + ], + "lastModified": "2017-04-07T22:25:15.000Z", + "logId": 7009488499, + "logType": "auto_detected", + "manualValuesSpecified": { + "calories": false, + "distance": false, + "steps": false + }, + "originalDuration": 1791000, + "originalStartTime": "2017-04-08T07:28:00.000+10:00", + "startTime": "2017-04-08T07:28:00.000+10:00", + "steps": 1688, + "tcxLink": "https://api.fitbit.com/1/user/-/activities/7009488499.tcx" + }, + { + "activeDuration": 1127000, + "activityLevel": [ + { + "minutes": 0, + "name": "sedentary" + }, + { + "minutes": 0, + "name": "lightly" + }, + { + "minutes": 12, + "name": "fairly" + }, + { + "minutes": 7, + "name": "very" + } + ], + "activityName": "Outdoor Bike", + "activityTypeId": 1071, + "averageHeartRate": 112, + "calories": 125, + "duration": 1127000, + "elevationGain": 0, + "heartRateLink": "https://api.fitbit.com/1/user/-/activities/heart/date/2017-04-08/2017-04-08/1sec/time/09:43:38/10:02:25.json", + "heartRateZones": [ + { + "max": 94, + "min": 30, + "minutes": 0, + "name": "Out of Range" + }, + { + "max": 132, + "min": 94, + "minutes": 19, + "name": "Fat Burn" + }, + { + "max": 160, + "min": 132, + "minutes": 0, + "name": "Cardio" + }, + { + "max": 220, + "min": 160, + "minutes": 0, + "name": "Peak" + } + ], + "lastModified": "2017-04-08T00:30:46.000Z", + "logId": 7010871715, + "logType": "auto_detected", + "manualValuesSpecified": { + "calories": false, + "distance": false, + "steps": false + }, + "originalDuration": 1127000, + "originalStartTime": "2017-04-08T09:43:38.000+10:00", + "startTime": "2017-04-08T09:43:38.000+10:00", + "tcxLink": "https://api.fitbit.com/1/user/-/activities/7010871715.tcx" + }, + { + "activeDuration": 2253000, + "activityLevel": [ + { + "minutes": 0, + "name": "sedentary" + }, + { + "minutes": 0, + "name": "lightly" + }, + { + "minutes": 19, + "name": "fairly" + }, + { + "minutes": 19, + "name": "very" + } + ], + "activityName": "Outdoor Bike", + "activityTypeId": 1071, + "averageHeartRate": 117, + "calories": 264, + "duration": 2253000, + "elevationGain": 0, + "heartRateLink": "https://api.fitbit.com/1/user/-/activities/heart/date/2017-04-08/2017-04-08/1sec/time/10:52:44/11:30:17.json", + "heartRateZones": [ + { + "max": 94, + "min": 30, + "minutes": 0, + "name": "Out of Range" + }, + { + "max": 132, + "min": 94, + "minutes": 36, + "name": "Fat Burn" + }, + { + "max": 160, + "min": 132, + "minutes": 2, + "name": "Cardio" + }, + { + "max": 220, + "min": 160, + "minutes": 0, + "name": "Peak" + } + ], + "lastModified": "2017-04-08T02:11:38.000Z", + "logId": 7012031336, + "logType": "auto_detected", + "manualValuesSpecified": { + "calories": false, + "distance": false, + "steps": false + }, + "originalDuration": 2253000, + "originalStartTime": "2017-04-08T10:52:44.000+10:00", + "startTime": "2017-04-08T10:52:44.000+10:00", + "tcxLink": "https://api.fitbit.com/1/user/-/activities/7012031336.tcx" + }, + { + "activeDuration": 1177000, + "activityLevel": [ + { + "minutes": 0, + "name": "sedentary" + }, + { + "minutes": 12, + "name": "lightly" + }, + { + "minutes": 7, + "name": "fairly" + }, + { + "minutes": 0, + "name": "very" + } + ], + "activityName": "Sport", + "activityTypeId": 15000, + "averageHeartRate": 107, + "calories": 99, + "duration": 1177000, + "heartRateLink": "https://api.fitbit.com/1/user/-/activities/heart/date/2017-04-08/2017-04-08/1sec/time/14:46:38/15:06:15.json", + "heartRateZones": [ + { + "max": 94, + "min": 30, + "minutes": 0, + "name": "Out of Range" + }, + { + "max": 132, + "min": 94, + "minutes": 20, + "name": "Fat Burn" + }, + { + "max": 160, + "min": 132, + "minutes": 0, + "name": "Cardio" + }, + { + "max": 220, + "min": 160, + "minutes": 0, + "name": "Peak" + } + ], + "lastModified": "2017-04-08T05:25:21.000Z", + "logId": 7013436876, + "logType": "auto_detected", + "manualValuesSpecified": { + "calories": false, + "distance": false, + "steps": false + }, + "originalDuration": 1177000, + "originalStartTime": "2017-04-08T14:46:38.000+10:00", + "startTime": "2017-04-08T14:46:38.000+10:00", + "steps": 540, + "tcxLink": "https://api.fitbit.com/1/user/-/activities/7013436876.tcx" + }, + { + "activeDuration": 1178000, + "activityLevel": [ + { + "minutes": 0, + "name": "sedentary" + }, + { + "minutes": 7, + "name": "lightly" + }, + { + "minutes": 12, + "name": "fairly" + }, + { + "minutes": 0, + "name": "very" + } + ], + "activityName": "Walk", + "activityTypeId": 90013, + "averageHeartRate": 104, + "calories": 101, + "duration": 1178000, + "elevationGain": 0, + "heartRateLink": "https://api.fitbit.com/1/user/-/activities/heart/date/2017-04-08/2017-04-08/1sec/time/16:16:13/16:35:51.json", + "heartRateZones": [ + { + "max": 94, + "min": 30, + "minutes": 0, + "name": "Out of Range" + }, + { + "max": 132, + "min": 94, + "minutes": 19, + "name": "Fat Burn" + }, + { + "max": 160, + "min": 132, + "minutes": 0, + "name": "Cardio" + }, + { + "max": 220, + "min": 160, + "minutes": 0, + "name": "Peak" + } + ], + "lastModified": "2017-04-08T06:47:57.000Z", + "logId": 7013940568, + "logType": "auto_detected", + "manualValuesSpecified": { + "calories": false, + "distance": false, + "steps": false + }, + "originalDuration": 1178000, + "originalStartTime": "2017-04-08T16:16:13.000+10:00", + "startTime": "2017-04-08T16:16:13.000+10:00", + "steps": 996, + "tcxLink": "https://api.fitbit.com/1/user/-/activities/7013940568.tcx" + }, + { + "activeDuration": 1332000, + "activityLevel": [ + { + "minutes": 0, + "name": "sedentary" + }, + { + "minutes": 5, + "name": "lightly" + }, + { + "minutes": 12, + "name": "fairly" + }, + { + "minutes": 5, + "name": "very" + } + ], + "activityName": "Walk", + "activityTypeId": 90013, + "averageHeartRate": 106, + "calories": 131, + "duration": 1332000, + "elevationGain": 9.144, + "heartRateLink": "https://api.fitbit.com/1/user/-/activities/heart/date/2017-04-09/2017-04-09/1sec/time/09:12:21/09:34:33.json", + "heartRateZones": [ + { + "max": 94, + "min": 30, + "minutes": 0, + "name": "Out of Range" + }, + { + "max": 132, + "min": 94, + "minutes": 22, + "name": "Fat Burn" + }, + { + "max": 160, + "min": 132, + "minutes": 0, + "name": "Cardio" + }, + { + "max": 220, + "min": 160, + "minutes": 0, + "name": "Peak" + } + ], + "lastModified": "2017-04-09T00:17:32.000Z", + "logId": 7027599224, + "logType": "auto_detected", + "manualValuesSpecified": { + "calories": false, + "distance": false, + "steps": false + }, + "originalDuration": 1332000, + "originalStartTime": "2017-04-09T09:12:21.000+10:00", + "startTime": "2017-04-09T09:12:21.000+10:00", + "steps": 1277, + "tcxLink": "https://api.fitbit.com/1/user/-/activities/7027599224.tcx" + }, + { + "activeDuration": 973000, + "activityLevel": [ + { + "minutes": 1, + "name": "sedentary" + }, + { + "minutes": 3, + "name": "lightly" + }, + { + "minutes": 10, + "name": "fairly" + }, + { + "minutes": 2, + "name": "very" + } + ], + "activityName": "Sport", + "activityTypeId": 15000, + "averageHeartRate": 110, + "calories": 92, + "duration": 973000, + "heartRateLink": "https://api.fitbit.com/1/user/-/activities/heart/date/2017-04-09/2017-04-09/1sec/time/10:02:41/10:18:54.json", + "heartRateZones": [ + { + "max": 94, + "min": 30, + "minutes": 1, + "name": "Out of Range" + }, + { + "max": 132, + "min": 94, + "minutes": 15, + "name": "Fat Burn" + }, + { + "max": 160, + "min": 132, + "minutes": 0, + "name": "Cardio" + }, + { + "max": 220, + "min": 160, + "minutes": 0, + "name": "Peak" + } + ], + "lastModified": "2017-04-09T01:49:14.000Z", + "logId": 7028422974, + "logType": "auto_detected", + "manualValuesSpecified": { + "calories": false, + "distance": false, + "steps": false + }, + "originalDuration": 973000, + "originalStartTime": "2017-04-09T10:02:41.000+10:00", + "startTime": "2017-04-09T10:02:41.000+10:00", + "steps": 642, + "tcxLink": "https://api.fitbit.com/1/user/-/activities/7028422974.tcx" + }, + { + "activeDuration": 915000, + "activityLevel": [ + { + "minutes": 1, + "name": "sedentary" + }, + { + "minutes": 2, + "name": "lightly" + }, + { + "minutes": 0, + "name": "fairly" + }, + { + "minutes": 12, + "name": "very" + } + ], + "activityName": "Walk", + "activityTypeId": 90013, + "averageHeartRate": 111, + "calories": 110, + "duration": 915000, + "elevationGain": 21.336, + "heartRateLink": "https://api.fitbit.com/1/user/-/activities/heart/date/2017-04-10/2017-04-10/1sec/time/16:33:27/16:48:42.json", + "heartRateZones": [ + { + "max": 94, + "min": 30, + "minutes": 1, + "name": "Out of Range" + }, + { + "max": 132, + "min": 94, + "minutes": 14, + "name": "Fat Burn" + }, + { + "max": 160, + "min": 132, + "minutes": 0, + "name": "Cardio" + }, + { + "max": 220, + "min": 160, + "minutes": 0, + "name": "Peak" + } + ], + "lastModified": "2017-04-10T07:33:07.000Z", + "logId": 7047269799, + "logType": "auto_detected", + "manualValuesSpecified": { + "calories": false, + "distance": false, + "steps": false + }, + "originalDuration": 915000, + "originalStartTime": "2017-04-10T16:33:27.000+10:00", + "startTime": "2017-04-10T16:33:27.000+10:00", + "steps": 1384, + "tcxLink": "https://api.fitbit.com/1/user/-/activities/7047269799.tcx" + }, + { + "activeDuration": 973000, + "activityLevel": [ + { + "minutes": 0, + "name": "sedentary" + }, + { + "minutes": 1, + "name": "lightly" + }, + { + "minutes": 4, + "name": "fairly" + }, + { + "minutes": 11, + "name": "very" + } + ], + "activityName": "Walk", + "activityTypeId": 90013, + "averageHeartRate": 112, + "calories": 116, + "duration": 973000, + "elevationGain": 3.048, + "heartRateLink": "https://api.fitbit.com/1/user/-/activities/heart/date/2017-04-13/2017-04-13/1sec/time/08:19:21/08:35:34.json", + "heartRateZones": [ + { + "max": 94, + "min": 30, + "minutes": 2, + "name": "Out of Range" + }, + { + "max": 132, + "min": 94, + "minutes": 14, + "name": "Fat Burn" + }, + { + "max": 160, + "min": 132, + "minutes": 0, + "name": "Cardio" + }, + { + "max": 220, + "min": 160, + "minutes": 0, + "name": "Peak" + } + ], + "lastModified": "2017-04-12T23:31:58.000Z", + "logId": 7103688373, + "logType": "auto_detected", + "manualValuesSpecified": { + "calories": false, + "distance": false, + "steps": false + }, + "originalDuration": 973000, + "originalStartTime": "2017-04-13T08:19:21.000+10:00", + "startTime": "2017-04-13T08:19:21.000+10:00", + "steps": 1522, + "tcxLink": "https://api.fitbit.com/1/user/-/activities/7103688373.tcx" + }, + { + "activeDuration": 1433000, + "activityLevel": [ + { + "minutes": 0, + "name": "sedentary" + }, + { + "minutes": 8, + "name": "lightly" + }, + { + "minutes": 13, + "name": "fairly" + }, + { + "minutes": 3, + "name": "very" + } + ], + "activityName": "Sport", + "activityTypeId": 15000, + "averageHeartRate": 111, + "calories": 132, + "duration": 1433000, + "heartRateLink": "https://api.fitbit.com/1/user/-/activities/heart/date/2017-04-14/2017-04-14/1sec/time/10:44:27/11:08:20.json", + "heartRateZones": [ + { + "max": 94, + "min": 30, + "minutes": 0, + "name": "Out of Range" + }, + { + "max": 132, + "min": 94, + "minutes": 24, + "name": "Fat Burn" + }, + { + "max": 160, + "min": 132, + "minutes": 0, + "name": "Cardio" + }, + { + "max": 220, + "min": 160, + "minutes": 0, + "name": "Peak" + } + ], + "lastModified": "2017-04-14T03:31:57.000Z", + "logId": 7126150327, + "logType": "auto_detected", + "manualValuesSpecified": { + "calories": false, + "distance": false, + "steps": false + }, + "originalDuration": 1433000, + "originalStartTime": "2017-04-14T10:44:27.000+10:00", + "startTime": "2017-04-14T10:44:27.000+10:00", + "steps": 1013, + "tcxLink": "https://api.fitbit.com/1/user/-/activities/7126150327.tcx" + }, + { + "activeDuration": 1843000, + "activityLevel": [ + { + "minutes": 0, + "name": "sedentary" + }, + { + "minutes": 7, + "name": "lightly" + }, + { + "minutes": 19, + "name": "fairly" + }, + { + "minutes": 4, + "name": "very" + } + ], + "activityName": "Walk", + "activityTypeId": 90013, + "averageHeartRate": 112, + "calories": 172, + "duration": 1843000, + "elevationGain": 0, + "heartRateLink": "https://api.fitbit.com/1/user/-/activities/heart/date/2017-04-14/2017-04-14/1sec/time/17:33:06/18:03:49.json", + "heartRateZones": [ + { + "max": 94, + "min": 30, + "minutes": 0, + "name": "Out of Range" + }, + { + "max": 132, + "min": 94, + "minutes": 30, + "name": "Fat Burn" + }, + { + "max": 160, + "min": 132, + "minutes": 0, + "name": "Cardio" + }, + { + "max": 220, + "min": 160, + "minutes": 0, + "name": "Peak" + } + ], + "lastModified": "2017-04-14T08:26:31.000Z", + "logId": 7128444847, + "logType": "auto_detected", + "manualValuesSpecified": { + "calories": false, + "distance": false, + "steps": false + }, + "originalDuration": 1843000, + "originalStartTime": "2017-04-14T17:33:06.000+10:00", + "startTime": "2017-04-14T17:33:06.000+10:00", + "steps": 1516, + "tcxLink": "https://api.fitbit.com/1/user/-/activities/7128444847.tcx" + }, + { + "activeDuration": 1127000, + "activityLevel": [ + { + "minutes": 0, + "name": "sedentary" + }, + { + "minutes": 4, + "name": "lightly" + }, + { + "minutes": 6, + "name": "fairly" + }, + { + "minutes": 8, + "name": "very" + } + ], + "activityName": "Sport", + "activityTypeId": 15000, + "averageHeartRate": 106, + "calories": 110, + "duration": 1127000, + "heartRateLink": "https://api.fitbit.com/1/user/-/activities/heart/date/2017-04-15/2017-04-15/1sec/time/17:03:12/17:21:59.json", + "heartRateZones": [ + { + "max": 94, + "min": 30, + "minutes": 0, + "name": "Out of Range" + }, + { + "max": 132, + "min": 94, + "minutes": 18, + "name": "Fat Burn" + }, + { + "max": 160, + "min": 132, + "minutes": 0, + "name": "Cardio" + }, + { + "max": 220, + "min": 160, + "minutes": 0, + "name": "Peak" + } + ], + "lastModified": "2017-04-15T13:07:12.000Z", + "logId": 7146774413, + "logType": "auto_detected", + "manualValuesSpecified": { + "calories": false, + "distance": false, + "steps": false + }, + "originalDuration": 1127000, + "originalStartTime": "2017-04-15T17:03:12.000+10:00", + "startTime": "2017-04-15T17:03:12.000+10:00", + "steps": 1258, + "tcxLink": "https://api.fitbit.com/1/user/-/activities/7146774413.tcx" + }, + { + "activeDuration": 922000, + "activityLevel": [ + { + "minutes": 0, + "name": "sedentary" + }, + { + "minutes": 2, + "name": "lightly" + }, + { + "minutes": 3, + "name": "fairly" + }, + { + "minutes": 10, + "name": "very" + } + ], + "activityName": "Walk", + "activityTypeId": 90013, + "averageHeartRate": 118, + "calories": 107, + "duration": 922000, + "elevationGain": 6.096, + "heartRateLink": "https://api.fitbit.com/1/user/-/activities/heart/date/2017-04-20/2017-04-20/1sec/time/08:06:07/08:21:29.json", + "heartRateZones": [ + { + "max": 94, + "min": 30, + "minutes": 0, + "name": "Out of Range" + }, + { + "max": 132, + "min": 94, + "minutes": 15, + "name": "Fat Burn" + }, + { + "max": 160, + "min": 132, + "minutes": 0, + "name": "Cardio" + }, + { + "max": 220, + "min": 160, + "minutes": 0, + "name": "Peak" + } + ], + "lastModified": "2017-04-19T22:27:55.000Z", + "logId": 7224073808, + "logType": "auto_detected", + "manualValuesSpecified": { + "calories": false, + "distance": false, + "steps": false + }, + "originalDuration": 922000, + "originalStartTime": "2017-04-20T08:06:07.000+10:00", + "startTime": "2017-04-20T08:06:07.000+10:00", + "steps": 1334, + "tcxLink": "https://api.fitbit.com/1/user/-/activities/7224073808.tcx" + }, + { + "activeDuration": 921000, + "activityLevel": [ + { + "minutes": 0, + "name": "sedentary" + }, + { + "minutes": 1, + "name": "lightly" + }, + { + "minutes": 4, + "name": "fairly" + }, + { + "minutes": 10, + "name": "very" + } + ], + "activityName": "Walk", + "activityTypeId": 90013, + "averageHeartRate": 119, + "calories": 124, + "duration": 921000, + "elevationGain": 18.288, + "heartRateLink": "https://api.fitbit.com/1/user/-/activities/heart/date/2017-04-21/2017-04-21/1sec/time/08:17:43/08:33:04.json", + "heartRateZones": [ + { + "max": 94, + "min": 30, + "minutes": 2, + "name": "Out of Range" + }, + { + "max": 132, + "min": 94, + "minutes": 9, + "name": "Fat Burn" + }, + { + "max": 160, + "min": 132, + "minutes": 5, + "name": "Cardio" + }, + { + "max": 220, + "min": 160, + "minutes": 0, + "name": "Peak" + } + ], + "lastModified": "2017-04-20T22:53:51.000Z", + "logId": 7244039018, + "logType": "auto_detected", + "manualValuesSpecified": { + "calories": false, + "distance": false, + "steps": false + }, + "originalDuration": 921000, + "originalStartTime": "2017-04-21T08:17:43.000+10:00", + "startTime": "2017-04-21T08:17:43.000+10:00", + "steps": 1386, + "tcxLink": "https://api.fitbit.com/1/user/-/activities/7244039018.tcx" + }, + { + "activeDuration": 1126000, + "activityLevel": [ + { + "minutes": 0, + "name": "sedentary" + }, + { + "minutes": 2, + "name": "lightly" + }, + { + "minutes": 3, + "name": "fairly" + }, + { + "minutes": 14, + "name": "very" + } + ], + "activityName": "Walk", + "activityTypeId": 90013, + "averageHeartRate": 117, + "calories": 140, + "duration": 1126000, + "elevationGain": 0, + "heartRateLink": "https://api.fitbit.com/1/user/-/activities/heart/date/2017-04-21/2017-04-21/1sec/time/20:24:37/20:43:23.json", + "heartRateZones": [ + { + "max": 94, + "min": 30, + "minutes": 0, + "name": "Out of Range" + }, + { + "max": 132, + "min": 94, + "minutes": 16, + "name": "Fat Burn" + }, + { + "max": 160, + "min": 132, + "minutes": 3, + "name": "Cardio" + }, + { + "max": 220, + "min": 160, + "minutes": 0, + "name": "Peak" + } + ], + "lastModified": "2017-04-21T10:48:48.000Z", + "logId": 7250867070, + "logType": "auto_detected", + "manualValuesSpecified": { + "calories": false, + "distance": false, + "steps": false + }, + "originalDuration": 1126000, + "originalStartTime": "2017-04-21T20:24:37.000+10:00", + "startTime": "2017-04-21T20:24:37.000+10:00", + "steps": 1730, + "tcxLink": "https://api.fitbit.com/1/user/-/activities/7250867070.tcx" + }, + { + "activeDuration": 1075000, + "activityLevel": [ + { + "minutes": 17, + "name": "sedentary" + }, + { + "minutes": 0, + "name": "lightly" + }, + { + "minutes": 0, + "name": "fairly" + }, + { + "minutes": 0, + "name": "very" + } + ], + "activityName": "Walk", + "activityTypeId": 90013, + "calories": 21, + "duration": 1075000, + "elevationGain": 0, + "lastModified": "2017-04-30T01:18:44.000Z", + "logId": 7406354656, + "logType": "auto_detected", + "manualValuesSpecified": { + "calories": false, + "distance": false, + "steps": false + }, + "originalDuration": 1075000, + "originalStartTime": "2017-04-24T08:17:46.000+10:00", + "startTime": "2017-04-24T08:17:46.000+10:00", + "steps": 0 + }, + { + "activeDuration": 1484000, + "activityLevel": [ + { + "minutes": 24, + "name": "sedentary" + }, + { + "minutes": 0, + "name": "lightly" + }, + { + "minutes": 0, + "name": "fairly" + }, + { + "minutes": 0, + "name": "very" + } + ], + "activityName": "Walk", + "activityTypeId": 90013, + "calories": 28, + "duration": 1484000, + "elevationGain": 0, + "lastModified": "2017-04-30T01:18:44.000Z", + "logId": 7406354660, + "logType": "auto_detected", + "manualValuesSpecified": { + "calories": false, + "distance": false, + "steps": false + }, + "originalDuration": 1484000, + "originalStartTime": "2017-04-25T17:46:16.000+10:00", + "startTime": "2017-04-25T17:46:16.000+10:00", + "steps": 0 + }, + { + "activeDuration": 973000, + "activityLevel": [ + { + "minutes": 16, + "name": "sedentary" + }, + { + "minutes": 0, + "name": "lightly" + }, + { + "minutes": 0, + "name": "fairly" + }, + { + "minutes": 0, + "name": "very" + } + ], + "activityName": "Walk", + "activityTypeId": 90013, + "calories": 18, + "duration": 973000, + "elevationGain": 0, + "lastModified": "2017-04-30T01:18:44.000Z", + "logId": 7406354663, + "logType": "auto_detected", + "manualValuesSpecified": { + "calories": false, + "distance": false, + "steps": false + }, + "originalDuration": 973000, + "originalStartTime": "2017-04-27T08:09:07.000+10:00", + "startTime": "2017-04-27T08:09:07.000+10:00", + "steps": 0 + }, + { + "activeDuration": 1024000, + "activityLevel": [ + { + "minutes": 6, + "name": "sedentary" + }, + { + "minutes": 11, + "name": "lightly" + }, + { + "minutes": 0, + "name": "fairly" + }, + { + "minutes": 0, + "name": "very" + } + ], + "activityName": "Outdoor Bike", + "activityTypeId": 1071, + "averageHeartRate": 102, + "calories": 64, + "duration": 1024000, + "elevationGain": 0, + "heartRateLink": "https://api.fitbit.com/1/user/-/activities/heart/date/2017-05-05/2017-05-05/1sec/time/14:21:26/14:38:30.json", + "heartRateZones": [ + { + "max": 94, + "min": 30, + "minutes": 2, + "name": "Out of Range" + }, + { + "max": 132, + "min": 94, + "minutes": 15, + "name": "Fat Burn" + }, + { + "max": 160, + "min": 132, + "minutes": 0, + "name": "Cardio" + }, + { + "max": 220, + "min": 160, + "minutes": 0, + "name": "Peak" + } + ], + "lastModified": "2017-05-05T04:55:43.000Z", + "logId": 7501810689, + "logType": "auto_detected", + "manualValuesSpecified": { + "calories": false, + "distance": false, + "steps": false + }, + "originalDuration": 1024000, + "originalStartTime": "2017-05-05T14:21:26.000+10:00", + "startTime": "2017-05-05T14:21:26.000+10:00", + "tcxLink": "https://api.fitbit.com/1/user/-/activities/7501810689.tcx" + }, + { + "activeDuration": 2405000, + "activityLevel": [ + { + "minutes": 0, + "name": "sedentary" + }, + { + "minutes": 0, + "name": "lightly" + }, + { + "minutes": 18, + "name": "fairly" + }, + { + "minutes": 22, + "name": "very" + } + ], + "activityName": "Walk", + "activityTypeId": 90013, + "averageHeartRate": 118, + "calories": 276, + "duration": 2405000, + "elevationGain": 0, + "heartRateLink": "https://api.fitbit.com/1/user/-/activities/heart/date/2017-05-06/2017-05-06/1sec/time/08:28:43/09:08:48.json", + "heartRateZones": [ + { + "max": 94, + "min": 30, + "minutes": 0, + "name": "Out of Range" + }, + { + "max": 132, + "min": 94, + "minutes": 40, + "name": "Fat Burn" + }, + { + "max": 160, + "min": 132, + "minutes": 0, + "name": "Cardio" + }, + { + "max": 220, + "min": 160, + "minutes": 0, + "name": "Peak" + } + ], + "lastModified": "2017-05-06T00:56:50.000Z", + "logId": 7515277484, + "logType": "auto_detected", + "manualValuesSpecified": { + "calories": false, + "distance": false, + "steps": false + }, + "originalDuration": 2405000, + "originalStartTime": "2017-05-06T08:28:43.000+10:00", + "startTime": "2017-05-06T08:28:43.000+10:00", + "steps": 2850, + "tcxLink": "https://api.fitbit.com/1/user/-/activities/7515277484.tcx" + } + ], + "pagination": { + "beforeDate": "2018-10-18", + "limit": 20, + "next": "https://api.fitbit.com/1/user/-/activities/list.json?offset=20&limit=20&sort=asc&beforeDate=2018-10-18", + "offset": 0, + "previous": "", + "sort": "asc" + } +} \ No newline at end of file From ba29f0cc703aa4fc9db340075f1f188c49e472b2 Mon Sep 17 00:00:00 2001 From: Srini Vasudevan Date: Thu, 19 Sep 2019 15:26:00 +1000 Subject: [PATCH 7/9] added activities test --- Fitbit.Portable.Tests/ActivitiesListTests.cs | 63 +++++++++++++++++++ .../Fitbit.Portable.Tests.csproj | 1 + 2 files changed, 64 insertions(+) create mode 100644 Fitbit.Portable.Tests/ActivitiesListTests.cs diff --git a/Fitbit.Portable.Tests/ActivitiesListTests.cs b/Fitbit.Portable.Tests/ActivitiesListTests.cs new file mode 100644 index 00000000..84ad6d53 --- /dev/null +++ b/Fitbit.Portable.Tests/ActivitiesListTests.cs @@ -0,0 +1,63 @@ +using System; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Threading; +using Fitbit.Api.Portable; +using FluentAssertions; +using NUnit.Framework; +using System.Threading.Tasks; +using Fitbit.Api.Portable.Models; +// ReSharper disable PossibleNullReferenceException + +namespace Fitbit.Portable.Tests +{ + public class ActivitiesListTests + { + [Test] + [Category("Portable")] + public async Task ActivitiesListTests_Success() + { + string content = SampleDataHelper.GetContent("ActivitiesList.json"); + + var responseMessage = new Func(() => + { + return new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(content) }; + }); + + var verification = new Action((message, token) => + { + message.Method.Should().Be(HttpMethod.Get); + message.RequestUri.AbsoluteUri.Should().StartWith("https://api.fitbit.com/1/user/-/activities/list.json"); + }); + + var fitbitClient = Helper.CreateFitbitClient(responseMessage, verification); + + var response = await fitbitClient.GetActivityListAsync(DateTime.Now.AddYears(-1), DateTypeEnum.BeforeDate, SortEnum.Asc); + + ValidateActivitiesList(response); + } + + [Test] + [Category("Portable")] + public void Can_Deserialize_Activities() + { + string content = SampleDataHelper.GetContent("ActivitiesList.json"); + var deserializer = new JsonDotNetSerializer(); + + ActivitiesList stats = deserializer.Deserialize(content); + + ValidateActivitiesList(stats); + } + + private void ValidateActivitiesList(ActivitiesList results) + { + results.Activities.Length.Should().Be(20); + results.Activities.FirstOrDefault().ActiveDuration.Should().Be(1791000); + results.Activities.FirstOrDefault().ActivityName.Should().Be("Sport"); + results.Activities.FirstOrDefault().HeartRateZones.Length.Should().Be(4); + results.Activities.FirstOrDefault().ManualValuesSpecified.Calories.Should().Be(false); + results.Activities.FirstOrDefault().TcxLink.Should().NotBeNull(); + } + } +} diff --git a/Fitbit.Portable.Tests/Fitbit.Portable.Tests.csproj b/Fitbit.Portable.Tests/Fitbit.Portable.Tests.csproj index 6f6990d1..d3e9e83c 100644 --- a/Fitbit.Portable.Tests/Fitbit.Portable.Tests.csproj +++ b/Fitbit.Portable.Tests/Fitbit.Portable.Tests.csproj @@ -87,6 +87,7 @@ + From d7ab00df57eb1e845d4cfc7e2e17e205b8b6788a Mon Sep 17 00:00:00 2001 From: Srini Vasudevan Date: Thu, 19 Sep 2019 18:32:20 +1000 Subject: [PATCH 8/9] fix up sort param --- Fitbit.Portable/FitbitClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Fitbit.Portable/FitbitClient.cs b/Fitbit.Portable/FitbitClient.cs index ce708a1f..c385f873 100644 --- a/Fitbit.Portable/FitbitClient.cs +++ b/Fitbit.Portable/FitbitClient.cs @@ -176,7 +176,7 @@ public async Task RefreshOAuth2TokenAsync() { string apiCall = FitbitClientHelperExtensions.ToFullUrl("/1/user/{0}/activities/list.json?sort={1}&offset={2}&limit={3}&{4}={5}", encodedUserId, - sort, + sort == SortEnum.Asc ? "asc" : "desc", offset, limit, dateType == DateTypeEnum.AfterDate ? "afterDate" : "beforeDate", From 94ead1af7c5735654b498bd391be4f23f5d2df29 Mon Sep 17 00:00:00 2001 From: Srini Vasudevan Date: Thu, 19 Sep 2019 18:50:36 +1000 Subject: [PATCH 9/9] renamed Activity to Activities to better represent the API --- Fitbit.Portable.Tests/ActivitiesListTests.cs | 2 +- Fitbit.Portable/FitbitClient.cs | 4 ++-- Fitbit.Portable/IFitbitClient.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Fitbit.Portable.Tests/ActivitiesListTests.cs b/Fitbit.Portable.Tests/ActivitiesListTests.cs index 84ad6d53..a59116ff 100644 --- a/Fitbit.Portable.Tests/ActivitiesListTests.cs +++ b/Fitbit.Portable.Tests/ActivitiesListTests.cs @@ -33,7 +33,7 @@ public async Task ActivitiesListTests_Success() var fitbitClient = Helper.CreateFitbitClient(responseMessage, verification); - var response = await fitbitClient.GetActivityListAsync(DateTime.Now.AddYears(-1), DateTypeEnum.BeforeDate, SortEnum.Asc); + var response = await fitbitClient.GetActivitiesListAsync(DateTime.Now.AddYears(-1), DateTypeEnum.BeforeDate, SortEnum.Asc); ValidateActivitiesList(response); } diff --git a/Fitbit.Portable/FitbitClient.cs b/Fitbit.Portable/FitbitClient.cs index c385f873..07bb6669 100644 --- a/Fitbit.Portable/FitbitClient.cs +++ b/Fitbit.Portable/FitbitClient.cs @@ -163,7 +163,7 @@ public async Task RefreshOAuth2TokenAsync() } /// - /// Requests the activity list of the encoded user id or if none supplied the current logged in user from before or after a certain date with pagination + /// Requests the activities list of the encoded user id or if none supplied the current logged in user from before or after a certain date with pagination /// /// The boundary date for the request /// Select whether the boundary is before the selected date or after the selected date @@ -172,7 +172,7 @@ public async Task RefreshOAuth2TokenAsync() /// /// encoded user id, can be null for current logged in user /// FitbitResponse of - public async Task GetActivityListAsync(DateTime dateTime, DateTypeEnum dateType, SortEnum sort, int limit = 20, int offset = 0, string encodedUserId = default(string)) + public async Task GetActivitiesListAsync(DateTime dateTime, DateTypeEnum dateType, SortEnum sort, int limit = 20, int offset = 0, string encodedUserId = default(string)) { string apiCall = FitbitClientHelperExtensions.ToFullUrl("/1/user/{0}/activities/list.json?sort={1}&offset={2}&limit={3}&{4}={5}", encodedUserId, diff --git a/Fitbit.Portable/IFitbitClient.cs b/Fitbit.Portable/IFitbitClient.cs index 0d4aa5e9..b85570ec 100644 --- a/Fitbit.Portable/IFitbitClient.cs +++ b/Fitbit.Portable/IFitbitClient.cs @@ -8,7 +8,7 @@ namespace Fitbit.Api.Portable { public interface IFitbitClient { - Task GetActivityListAsync(DateTime dateTime, DateTypeEnum dateType, SortEnum sort, int limit = 20, int offset = 0, string encodedUserId = default(string)); + Task GetActivitiesListAsync(DateTime dateTime, DateTypeEnum dateType, SortEnum sort, int limit = 20, int offset = 0, string encodedUserId = default(string)); Task GetDayActivityAsync(DateTime activityDate, string encodedUserId = default(string)); Task GetDayActivitySummaryAsync(DateTime activityDate, string encodedUserId = default(string)); Task GetActivitiesStatsAsync(string encodedUserId = default(string));