nikeplusgem 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +44 -0
- data/LICENSE +21 -0
- data/Rakefile +47 -0
- data/lib/nikeplusgem.rb +21 -0
- data/lib/nikeplusgem/activity_data.rb +14 -0
- data/lib/nikeplusgem/aggregate_sport.rb +13 -0
- data/lib/nikeplusgem/client.rb +56 -0
- data/lib/nikeplusgem/errors.rb +6 -0
- data/lib/nikeplusgem/experience_type.rb +32 -0
- data/lib/nikeplusgem/extensions.rb +12 -0
- data/lib/nikeplusgem/helpers.rb +74 -0
- data/lib/nikeplusgem/list_activities.rb +27 -0
- data/lib/nikeplusgem/version.rb +3 -0
- data/nikeplusgem-0.0.1.gem +0 -0
- data/nikeplusgem-0.1.0.gem +0 -0
- data/nikeplusgem.gemspec +28 -0
- data/readme.markdown +32 -0
- data/spec/client_spec.rb +50 -0
- data/spec/endpoints_spec.rb +99 -0
- data/spec/fixtures/vcr_cassettes/activity_data.yml +36 -0
- data/spec/fixtures/vcr_cassettes/aggregate_sport.yml +36 -0
- data/spec/fixtures/vcr_cassettes/experience_type.yml +36 -0
- data/spec/fixtures/vcr_cassettes/list_activities.yml +36 -0
- data/spec/hash_extension_spec.rb +36 -0
- data/spec/helpers_spec.rb +71 -0
- data/spec/spec_helper.rb +11 -0
- metadata +172 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 760d346b4935c6ee4a85ba97cb25aa07033a0088
|
4
|
+
data.tar.gz: a844e23ea7d883eadce81d2d0b239929faa4f12b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8c065121b3e68185e3179f54719d6d3c0202bae870e0e74e29e1f9f372313cfaf2ade16f77883bc9eeeb01e0ce15987fc2ccdc278391943373648ca68baa2f00
|
7
|
+
data.tar.gz: b9c98f8193a0188f28bd527c25afd1a378713a18d786637bc9353729b0e90ce65c80677715cc141fdebacc89a2a107b93c6d3c50d46bb138d611077eb0141097
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
nikeplusgem (0.0.1)
|
5
|
+
httparty
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.3.5)
|
11
|
+
crack (0.4.2)
|
12
|
+
safe_yaml (~> 1.0.0)
|
13
|
+
diff-lcs (1.2.5)
|
14
|
+
httparty (0.13.0)
|
15
|
+
json (~> 1.8)
|
16
|
+
multi_xml (>= 0.5.2)
|
17
|
+
json (1.8.1)
|
18
|
+
multi_xml (0.5.5)
|
19
|
+
rake (10.1.1)
|
20
|
+
rspec (2.14.1)
|
21
|
+
rspec-core (~> 2.14.0)
|
22
|
+
rspec-expectations (~> 2.14.0)
|
23
|
+
rspec-mocks (~> 2.14.0)
|
24
|
+
rspec-core (2.14.8)
|
25
|
+
rspec-expectations (2.14.5)
|
26
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
27
|
+
rspec-mocks (2.14.6)
|
28
|
+
safe_yaml (1.0.1)
|
29
|
+
vcr (2.8.0)
|
30
|
+
webmock (1.15.2)
|
31
|
+
addressable (>= 2.2.7)
|
32
|
+
crack (>= 0.3.2)
|
33
|
+
yard (0.8.7.3)
|
34
|
+
|
35
|
+
PLATFORMS
|
36
|
+
ruby
|
37
|
+
|
38
|
+
DEPENDENCIES
|
39
|
+
nikeplusgem!
|
40
|
+
rake
|
41
|
+
rspec
|
42
|
+
vcr
|
43
|
+
webmock (>= 1.8.0, < 1.16.0)
|
44
|
+
yard
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2013 - Rob Shaw, http://borwahs.com/
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/clean'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
require 'yard'
|
5
|
+
|
6
|
+
# values to reuse
|
7
|
+
NAME = 'nikeplusgem'
|
8
|
+
VERSION = lambda do
|
9
|
+
require File.expand_path("../lib/nikeplusgem", __FILE__)
|
10
|
+
NikePlusGem::VERSION
|
11
|
+
end
|
12
|
+
|
13
|
+
# set default task to install and build the gem
|
14
|
+
task :default => :install
|
15
|
+
|
16
|
+
# tasks to manage gem
|
17
|
+
desc "Build gem"
|
18
|
+
task :build do
|
19
|
+
sh %{gem build #{NAME}.gemspec}
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "Install gem"
|
23
|
+
task :install => [:build] do
|
24
|
+
sh %{gem install ./#{NAME}-#{VERSION.call}.gem --local}
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "Uninstall gem"
|
28
|
+
task :uninstall do
|
29
|
+
sh %{gem uninstall #{NAME}}
|
30
|
+
end
|
31
|
+
|
32
|
+
# get version
|
33
|
+
desc "Print current version"
|
34
|
+
task :version do
|
35
|
+
puts VERSION.call
|
36
|
+
end
|
37
|
+
|
38
|
+
# testing
|
39
|
+
desc "run rspec tests"
|
40
|
+
RSpec::Core::RakeTask.new(:spec)
|
41
|
+
|
42
|
+
task :test => :spec
|
43
|
+
|
44
|
+
desc "Create documentation"
|
45
|
+
YARD::Rake::YardocTask.new do |t|
|
46
|
+
t.files = ['lib/**/*.rb']
|
47
|
+
end
|
data/lib/nikeplusgem.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'date'
|
3
|
+
require 'time'
|
4
|
+
require 'uri'
|
5
|
+
require 'httparty'
|
6
|
+
|
7
|
+
require_relative 'nikeplusgem/client'
|
8
|
+
require_relative 'nikeplusgem/version'
|
9
|
+
require_relative 'nikeplusgem/list_activities'
|
10
|
+
require_relative 'nikeplusgem/aggregate_sport'
|
11
|
+
require_relative 'nikeplusgem/experience_type'
|
12
|
+
require_relative 'nikeplusgem/activity_data'
|
13
|
+
require_relative 'nikeplusgem/extensions'
|
14
|
+
require_relative 'nikeplusgem/helpers'
|
15
|
+
require_relative 'nikeplusgem/errors'
|
16
|
+
|
17
|
+
# Read data from Nike+ Developer API
|
18
|
+
#
|
19
|
+
# @author Rob Shaw
|
20
|
+
module NikePlusGem
|
21
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module NikePlusGem
|
2
|
+
class Client
|
3
|
+
|
4
|
+
# Get details of one of the user's activities, by Activity ID
|
5
|
+
#
|
6
|
+
# @param activity_id [String, Integer] The Activity ID to request
|
7
|
+
#
|
8
|
+
# @return [Hash] A hash with the requested Activity
|
9
|
+
def activity_data(activity_id)
|
10
|
+
get("/me/sport/activities/#{activity_id}")
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module NikePlusGem
|
2
|
+
class Client
|
3
|
+
|
4
|
+
# Get list of Nike+ experiences in which the user participates and
|
5
|
+
# a summary of the user's statistics for each sport category
|
6
|
+
#
|
7
|
+
# @return [Hash] A hash of the user's Nike+ Experiences
|
8
|
+
def aggregate_sport()
|
9
|
+
get("/me/sport")
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module NikePlusGem
|
2
|
+
class Client
|
3
|
+
include HTTParty
|
4
|
+
|
5
|
+
BASE_URL = "https://api.nike.com"
|
6
|
+
|
7
|
+
# Gets the Access Token to be used in calls to API. Set via
|
8
|
+
# the constructor.
|
9
|
+
#
|
10
|
+
# @return [String]
|
11
|
+
attr_reader :access_token
|
12
|
+
|
13
|
+
# Gets the Application ID to be sent in Header for calls to
|
14
|
+
# API. Set via the constructor.
|
15
|
+
#
|
16
|
+
# @return [String]
|
17
|
+
attr_reader :app_id
|
18
|
+
|
19
|
+
# Creates a client object to communicate with API
|
20
|
+
#
|
21
|
+
# @param access_token [String] The Access Token needed to authorize
|
22
|
+
# @param app_id [String] The Application ID to send in Header
|
23
|
+
#
|
24
|
+
# @example Create new client with Access Token and App ID
|
25
|
+
# client = NikePlusGem::Client.new("abcdef12345", "My Nike+ Data")
|
26
|
+
#
|
27
|
+
# @return [Client] A NikePlusGem::Client object
|
28
|
+
def initialize(access_token, app_id)
|
29
|
+
|
30
|
+
if access_token.nil? or access_token.empty?
|
31
|
+
raise InvalidArgumentError, "The Access Token must be set"
|
32
|
+
end
|
33
|
+
|
34
|
+
if app_id.nil? or app_id.empty?
|
35
|
+
raise InvalidArgumentError, "The App ID must be set"
|
36
|
+
end
|
37
|
+
|
38
|
+
@access_token = access_token
|
39
|
+
@app_id = app_id
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def get(endpoint, qs_options={}, headers={})
|
45
|
+
options = {}
|
46
|
+
options[:headers] = Helpers.merge_required_headers(@app_id, headers)
|
47
|
+
options[:query] = Helpers.merge_required_qs_params(@access_token, qs_options)
|
48
|
+
|
49
|
+
url = Helpers.combine_url_endpoint(BASE_URL, endpoint)
|
50
|
+
|
51
|
+
res = self.class.get(url.to_s, options)
|
52
|
+
res.parsed_response
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module NikePlusGem
|
2
|
+
class Client
|
3
|
+
|
4
|
+
EXPERIENCE_TYPE_PARAM = ["experienceType", "offset", "count", "startDate", "endDate"]
|
5
|
+
EXPERIENCE_TYPES = ["RUNNING", "FUELBAND"]
|
6
|
+
|
7
|
+
# Get the User's sport activity for the specified experience type as a paginated list
|
8
|
+
#
|
9
|
+
# @param params [Hash] Query Parameters to include in call
|
10
|
+
#
|
11
|
+
# @option params [String] experienceType The Experience Type by which to
|
12
|
+
# filter the list (FUELBAND or RUNNING). REQUIRED
|
13
|
+
#
|
14
|
+
# @return [Hash] A hash with the requested sport activity.
|
15
|
+
def experience_type(params={})
|
16
|
+
params = params.only(EXPERIENCE_TYPE_PARAM)
|
17
|
+
|
18
|
+
unless params.include?("experienceType") and !params["experienceType"].empty?
|
19
|
+
raise InvalidArgumentError, "Must specify the Experience Type to fetch results for."
|
20
|
+
end
|
21
|
+
|
22
|
+
unless EXPERIENCE_TYPES.include?params["experienceType"]
|
23
|
+
raise InvalidArgumentError, "Must specify a valid Experience Type"
|
24
|
+
end
|
25
|
+
|
26
|
+
exp_type = params["experienceType"]
|
27
|
+
|
28
|
+
get("/me/sport/activities/" << exp_type, params)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class Hash
|
2
|
+
|
3
|
+
# Removes keys from Hash that aren't provided in params
|
4
|
+
#
|
5
|
+
# @param params [Hash] The keys to keep in the returned hash
|
6
|
+
#
|
7
|
+
# @return [Hash] A hash with only the keys provided
|
8
|
+
def only(params)
|
9
|
+
self.select {|param| params.include?(param)}
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module NikePlusGem
|
2
|
+
class Helpers
|
3
|
+
|
4
|
+
# Format any of a variety of date types into the formatted string
|
5
|
+
# required when using the API.
|
6
|
+
#
|
7
|
+
# The date parameter can take several different kind of objects: a
|
8
|
+
# DateTime object, a Date object, a Time object or a String object.
|
9
|
+
#
|
10
|
+
# @param [DateTime, Date, Time, String] date The object to format into a
|
11
|
+
# date string
|
12
|
+
#
|
13
|
+
# @return [String] Date in "yyyy/MM/dd" string format; or ERROR if unable
|
14
|
+
# parse
|
15
|
+
def self.format_date(date)
|
16
|
+
if date.nil?
|
17
|
+
return "ERROR"
|
18
|
+
end
|
19
|
+
|
20
|
+
if date.instance_of? Date or date.instance_of? Time or date.instance_of? DateTime
|
21
|
+
return date.strftime("%Y/%m/%d")
|
22
|
+
elsif date.is_a? String and not date.empty?
|
23
|
+
match = date.match(/(\d{4}\/\d{2}\/\d{2}).*/)
|
24
|
+
|
25
|
+
if match.nil?
|
26
|
+
return "ERROR"
|
27
|
+
end
|
28
|
+
|
29
|
+
capture_groups = match.captures
|
30
|
+
|
31
|
+
return Date.strptime(capture_groups[0], "%Y/%m/%d").strftime("%Y/%m/%d")
|
32
|
+
end
|
33
|
+
|
34
|
+
"ERROR"
|
35
|
+
end
|
36
|
+
|
37
|
+
# Merges user defined headers with the required headers needed by API
|
38
|
+
#
|
39
|
+
# @param app_id [String] The Application ID
|
40
|
+
# @param headers [Hash] Additional headers defined by user
|
41
|
+
#
|
42
|
+
# @return [Hash] Merge of user Headers and required headers by API
|
43
|
+
def self.merge_required_headers(app_id, headers={})
|
44
|
+
req_headers = {"appid" => app_id, "Accept" => "application/json"}
|
45
|
+
|
46
|
+
if not headers.empty?
|
47
|
+
req_headers.merge!(headers)
|
48
|
+
end
|
49
|
+
|
50
|
+
req_headers
|
51
|
+
end
|
52
|
+
|
53
|
+
# Merges query parameter key/value with the required Access Token parameter
|
54
|
+
#
|
55
|
+
# @param access_token [String] The Access Token to communicate with the API
|
56
|
+
# @param params [Hash] Additional Query String Parameters
|
57
|
+
#
|
58
|
+
# @return [Hash] Passed in query string parameter hash with Access Token key/value
|
59
|
+
def self.merge_required_qs_params(access_token, params={})
|
60
|
+
params.merge!({"access_token" => access_token})
|
61
|
+
end
|
62
|
+
|
63
|
+
# Joins two strings into a URI object
|
64
|
+
#
|
65
|
+
# @param base [String] The base portion of the URL
|
66
|
+
# @param endpoint [String] The endpoint to append to the base URL
|
67
|
+
#
|
68
|
+
# @return [URI] Joined URL of base and endpoint
|
69
|
+
def self.combine_url_endpoint(base, endpoint)
|
70
|
+
URI.join(base, endpoint)
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module NikePlusGem
|
2
|
+
class Client
|
3
|
+
|
4
|
+
LIST_ACTIVITY_PARAMS = ["offset", "count", "startDate", "endDate"]
|
5
|
+
|
6
|
+
# Get details of the user's activities, beginning with the most recent, as a paginated list
|
7
|
+
#
|
8
|
+
# @param params [Hash] Query Parameters to include in call
|
9
|
+
#
|
10
|
+
# @option params [String] offset Pagination - first record to
|
11
|
+
# retrieve (starts at 1)
|
12
|
+
# @option params [String] count Pagination - number of records to
|
13
|
+
# retrieve (default 5)
|
14
|
+
# @option params [String] startDate The Activity list's start date
|
15
|
+
# in ISO8601 standard format, 'yyyy-mm-dd'
|
16
|
+
# @option params [String] endDate The Activity list's end date in
|
17
|
+
# ISO8601 standard format, 'yyyy-mm-dd'
|
18
|
+
#
|
19
|
+
# @return [Hash] A hash with the requested Activities
|
20
|
+
def list_activities(params={})
|
21
|
+
params = params.only(LIST_ACTIVITY_PARAMS)
|
22
|
+
|
23
|
+
get("/me/sport/activities", params)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
Binary file
|
Binary file
|
data/nikeplusgem.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
2
|
+
require 'nikeplusgem/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |g|
|
5
|
+
g.name = "nikeplusgem"
|
6
|
+
g.version = NikePlusGem::VERSION
|
7
|
+
g.platform = Gem::Platform::RUBY
|
8
|
+
g.license = "MIT"
|
9
|
+
g.summary = "Nike+ Gem"
|
10
|
+
g.description = "A client library to retrieve data from the Nike+ Developer Resources API."
|
11
|
+
g.authors = ["Rob Shaw"]
|
12
|
+
g.email = ["rob@borwahs.com"]
|
13
|
+
g.homepage = "https://github.com/borwahs/nikeplusgem/"
|
14
|
+
|
15
|
+
g.files = Dir["./**/*"].reject{|file| file =~ /\.\/(doc|pkg|spec|test)/}
|
16
|
+
g.require_paths = ["lib"]
|
17
|
+
|
18
|
+
g.test_files = Dir["./spec/**/*"]
|
19
|
+
|
20
|
+
# Dependencies
|
21
|
+
g.add_development_dependency "rspec"
|
22
|
+
g.add_development_dependency "rake"
|
23
|
+
g.add_development_dependency "vcr"
|
24
|
+
g.add_development_dependency "yard"
|
25
|
+
g.add_development_dependency "webmock", ">= 1.8.0", "< 1.16.0"
|
26
|
+
|
27
|
+
g.add_runtime_dependency "httparty"
|
28
|
+
end
|
data/readme.markdown
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Nike Plus Gem
|
2
|
+
|
3
|
+
This gem provides access to the [Nike+ Developer Resources](http://developer.nike.com) data through their REST API.
|
4
|
+
|
5
|
+
## Documentation
|
6
|
+
|
7
|
+
Good method documentation is available at [rubydoc.info](http://www.rubydoc.info/github/borwahs/nikeplusgem/frames).
|
8
|
+
|
9
|
+
The API methods are exposed in the Client class:
|
10
|
+
|
11
|
+
* Aggregate Sports Data
|
12
|
+
* List Activities
|
13
|
+
* Activities By Experience Type
|
14
|
+
* Activity Details
|
15
|
+
|
16
|
+
At the moment, the only way to connect is to get a specific Access Token for an account from [Nike+ Developer API Portal](https://developer.nike.com).
|
17
|
+
|
18
|
+
##Usage
|
19
|
+
|
20
|
+
Require the gem:
|
21
|
+
|
22
|
+
require 'nikeplusgem'
|
23
|
+
|
24
|
+
Setup a new Client object with an Access Token and Application ID:
|
25
|
+
|
26
|
+
client = NikePlusGem::Client.new("access_token", "app_id")
|
27
|
+
|
28
|
+
# Disclaimer
|
29
|
+
|
30
|
+
This is MIT licensed with no added caveats. See LICENSE file for more details.
|
31
|
+
|
32
|
+
**I am not employed by or have any association with Nike or the development of the Nike+ API.**
|
data/spec/client_spec.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NikePlusGem::Client do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@access_token = "12345"
|
7
|
+
@app_id = "abcde"
|
8
|
+
|
9
|
+
@client = NikePlusGem::Client.new(@access_token, @app_id)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#new" do
|
13
|
+
it "takes two parameters and returns a Client object" do
|
14
|
+
@client.should be_an_instance_of NikePlusGem::Client
|
15
|
+
end
|
16
|
+
|
17
|
+
it "requires the access_token to be non-empty and not nil" do
|
18
|
+
expect {
|
19
|
+
client = NikePlusGem::Client.new("", @app_id)
|
20
|
+
}.to raise_error(NikePlusGem::InvalidArgumentError)
|
21
|
+
|
22
|
+
expect {
|
23
|
+
client = NikePlusGem::Client.new(nil, @app_id)
|
24
|
+
}.to raise_error(NikePlusGem::InvalidArgumentError)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "requires the app_id to be non-empty and not nil" do
|
28
|
+
expect {
|
29
|
+
client = NikePlusGem::Client.new(@access_token, "")
|
30
|
+
}.to raise_error(NikePlusGem::InvalidArgumentError)
|
31
|
+
|
32
|
+
expect {
|
33
|
+
client = NikePlusGem::Client.new(@access_token, nil)
|
34
|
+
}.to raise_error(NikePlusGem::InvalidArgumentError)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "#access_token" do
|
39
|
+
it "returns the correct access token" do
|
40
|
+
@client.access_token.should eql @access_token
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#app_id" do
|
45
|
+
it "returns the correct app id" do
|
46
|
+
@client.app_id.should eql @app_id
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NikePlusGem::Client do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@access_token = "12345"
|
7
|
+
@app_id = "abcde"
|
8
|
+
|
9
|
+
@client = NikePlusGem::Client.new(@access_token, @app_id)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "list_activities" do
|
13
|
+
|
14
|
+
before do
|
15
|
+
VCR.insert_cassette 'list_activities'
|
16
|
+
end
|
17
|
+
|
18
|
+
it "return json request for list activities" do
|
19
|
+
@client.list_activities.should be_instance_of Hash
|
20
|
+
end
|
21
|
+
|
22
|
+
after do
|
23
|
+
VCR.eject_cassette
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "aggregate_sport" do
|
29
|
+
|
30
|
+
before do
|
31
|
+
VCR.insert_cassette 'aggregate_sport'
|
32
|
+
end
|
33
|
+
|
34
|
+
it "return json request for aggregate sport" do
|
35
|
+
@client.aggregate_sport.should be_instance_of Hash
|
36
|
+
end
|
37
|
+
|
38
|
+
after do
|
39
|
+
VCR.eject_cassette
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "experience_type" do
|
45
|
+
|
46
|
+
before do
|
47
|
+
VCR.insert_cassette 'experience_type'
|
48
|
+
end
|
49
|
+
|
50
|
+
before(:each) do
|
51
|
+
@params = {}
|
52
|
+
@params["experienceType"] = "FUELBAND"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "return json request for experience type" do
|
56
|
+
@client.experience_type(@params).should be_instance_of Hash
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'raises an exception if the experience type key is missing' do
|
60
|
+
@params.delete("experienceType")
|
61
|
+
|
62
|
+
expect {
|
63
|
+
@client.experience_type(@params)
|
64
|
+
}.to raise_error(NikePlusGem::InvalidArgumentError)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'raises an exception if the experience type value is not valid' do
|
68
|
+
@params["experienceType"] = "NOT_SOMETHING"
|
69
|
+
|
70
|
+
expect {
|
71
|
+
@client.experience_type(@params)
|
72
|
+
}.to raise_error(NikePlusGem::InvalidArgumentError)
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
after do
|
77
|
+
VCR.eject_cassette
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
describe "activity_data" do
|
83
|
+
|
84
|
+
before do
|
85
|
+
VCR.insert_cassette 'activity_data'
|
86
|
+
@activity_id = "2bd0fec0-3955-450b-92dd-29426a19d2f5"
|
87
|
+
end
|
88
|
+
|
89
|
+
it "return json request for activity data with string parameter" do
|
90
|
+
@client.activity_data(@activity_id).should be_instance_of Hash
|
91
|
+
end
|
92
|
+
|
93
|
+
after do
|
94
|
+
VCR.eject_cassette
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.nike.com/me/sport/activities/2bd0fec0-3955-450b-92dd-29426a19d2f5?access_token=<ACCESS_TOKEN>
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Appid:
|
11
|
+
- <APP_ID>
|
12
|
+
Accept:
|
13
|
+
- application/json
|
14
|
+
response:
|
15
|
+
status:
|
16
|
+
code: 200
|
17
|
+
message: OK
|
18
|
+
headers:
|
19
|
+
Content-Type:
|
20
|
+
- application/json;charset=UTF-8
|
21
|
+
Date:
|
22
|
+
- Tue, 04 Mar 2014 04:15:29 GMT
|
23
|
+
Server:
|
24
|
+
- Apache
|
25
|
+
X-Swooshlet:
|
26
|
+
- app-msp-api-0 prd sin-85-app-msp-api-0
|
27
|
+
Content-Length:
|
28
|
+
- '23937'
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
body:
|
32
|
+
encoding: UTF-8
|
33
|
+
string: '{"activityId":"2bd0fec0-3955-450b-92dd-29426a19d2f5","activityType":"ALL_DAY","startTime":"2014-02-09T05:00:00Z","activityTimeZone":"America/Indiana/Indianapolis","status":"IN_PROGRESS","deviceType":"FUELBAND","metricSummary":{"calories":678,"fuel":2369,"distance":6.01494836807251,"steps":7639,"duration":"5:40:00.000"},"tags":[],"metrics":[{"intervalMetric":1,"intervalUnit":"MIN","metricType":"FUEL","values":["1","1","0","0","0","0","0","0","2","0","0","0","0","1","0","0","1","1","1","5","10","8","12","7","1","2","4","1","4","5","9","11","0","3","6","3","4","2","5","5","10","1","2","1","1","18","18","11","9","9","9","5","10","7","2","2","2","2","1","2","1","1","12","6","3","0","0","0","2","1","6","19","3","9","2","8","3","1","5","3","4","2","7","4","8","4","5","9","13","8","7","10","16","16","10","1","5","6","6","1","5","1","3","1","5","8","0","2","2","3","12","14","7","6","8","5","3","4","4","18","4","7","5","4","6","2","9","8","5","3","5","2","4","3","1","2","1","0","1","4","0","3","3","4","0","9","5","7","13","0","0","1","1","2","12","7","8","1","2","7","0","1","4","0","2","3","1","3","0","0","0","0","0","0","1","0","1","6","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","15","17","5","11","18","16","17","18","16","10","14","20","20","20","19","12","20","18","20","17","19","21","18","19","22","46","40","20","30","49","44","43","16","17","28","48","23","16","14","3","5","17","24","24","21","9","13","22","3","4","16","4","8","4","3","7","10","9","5","2","0","0","0","0","0","0","2","3","0","0","0","0","0","0","0","0","0","0","0","0","2","1","3","2","8","2","0","1","6","5","15","14","3","4","2","8","8","9","7","17","6","0","0","11","6","7","5","6","13","6","5","4","1","7","1","4","1","1","4","0","0","0","0","0","1","0","0","0","2","2","3","1","4","9","3","1","3","0","1","2","4","1","3","4","4","3","2","3","1","4","5","3","6","16","6","4","15","4","4","4","5","1","11","4","1","6","2","1","3","2","0","0","0","1","0","0","0","2","1","3","6","1","0","0","0","0","0","2","6","1","1","6","4","0","0","1","9","9","1","3","6","1","8","2","2","0","1","2","2","0","2","5","10","2","3","2","1","1","3","1","2","1","0","0","0","1","3","2","3","4","0","0","0","0","0","1","1","7","2","2","5","2","5","6","0","0","0","0","9","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]},{"intervalMetric":1,"intervalUnit":"MIN","metricType":"CALORIES","values":["0","0","0","0","0","0","0","0","1","0","0","0","0","0","0","0","0","1","0","1","3","3","3","2","0","1","1","0","1","2","3","2","0","2","1","1","1","1","1","2","2","1","0","1","0","5","5","3","3","3","2","1","3","2","1","0","1","1","0","0","1","0","4","1","1","0","0","0","1","0","2","5","1","3","0","3","0","1","1","1","1","1","2","1","2","1","2","2","4","2","2","3","5","4","3","1","1","2","1","1","1","0","1","1","1","2","0","1","0","1","4","4","2","2","2","1","1","1","1","5","2","2","1","1","2","0","3","2","2","1","1","1","1","1","0","0","1","0","0","1","0","1","1","1","0","3","1","2","4","0","0","0","1","0","3","3","2","0","1","2","0","0","1","0","1","1","0","1","0","0","0","0","0","0","0","0","0","2","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","4","5","1","3","5","5","5","5","5","3","4","5","6","5","6","3","6","5","6","5","5","6","5","6","6","13","12","5","9","14","13","12","5","5","8","13","7","5","3","1","2","5","7","6","6","3","4","6","1","1","5","1","2","1","1","2","3","3","1","1","0","0","0","0","0","0","0","1","0","0","0","0","0","0","0","0","0","0","0","0","1","0","1","0","3","0","0","1","1","2","4","4","1","1","0","3","2","3","2","5","1","0","0","4","1","2","2","1","4","2","1","1","1","2","0","1","0","1","1","0","0","0","0","0","0","0","0","0","1","0","1","0","2","2","1","0","1","0","0","1","1","1","0","2","1","0","1","1","0","1","2","1","1","5","2","1","4","1","1","1","2","0","3","1","1","2","0","0","1","1","0","0","0","0","0","0","0","1","0","1","2","0","0","0","0","0","0","0","2","0","1","1","2","0","0","0","2","3","0","1","2","0","2","1","0","0","1","1","0","0","1","1","3","0","1","1","0","1","0","1","0","1","0","0","0","0","1","0","1","1","0","0","0","0","0","0","1","2","0","1","1","1","1","2","0","0","0","0","3","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]},{"intervalMetric":1,"intervalUnit":"MIN","metricType":"STEPS","values":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","7","16","37","24","0","0","0","0","0","16","27","34","0","0","0","0","17","0","25","0","54","0","0","0","0","64","32","63","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","18","35","13","0","0","9","0","0","0","11","15","15","0","24","11","0","0","42","24","44","36","47","61","56","30","0","0","0","0","13","0","0","0","10","0","0","0","0","0","7","83","70","31","11","0","8","0","0","0","14","34","33","48","23","44","13","122","91","0","18","0","0","0","9","0","0","0","0","9","9","0","29","14","9","0","7","24","0","20","0","0","0","0","0","43","36","41","0","0","34","0","0","0","0","0","0","0","0","0","0","0","0","0","0","6","0","10","10","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","27","59","16","70","107","99","97","80","81","45","72","108","108","108","108","27","108","99","108","101","104","115","106","107","102","156","139","81","109","152","141","131","68","54","103","152","95","72","81","9","7","54","50","27","18","0","0","17","7","0","0","0","0","0","0","64","31","62","14","0","0","0","0","0","0","0","6","0","0","0","0","0","0","0","0","0","0","0","0","0","10","6","14","0","18","9","0","6","19","28","70","92","0","0","0","34","79","51","27","63","37","0","0","67","36","9","20","0","91","27","18","41","0","0","0","0","11","0","20","0","0","0","0","0","9","0","0","0","0","9","17","11","13","49","0","0","0","0","0","0","0","0","0","10","12","7","0","25","0","7","29","0","52","54","0","10","14","9","7","27","14","7","39","0","0","0","0","0","0","0","0","0","0","9","0","0","0","0","0","24","37","7","0","0","0","0","0","10","21","10","6","7","0","0","0","0","7","0","0","0","0","0","0","0","0","0","0","11","0","0","0","20","19","15","18","23","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","7","0","7","33","0","30","6","0","0","0","0","26","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]},{"intervalMetric":1,"intervalUnit":"MIN","metricType":"STARS","values":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]}]}'
|
34
|
+
http_version:
|
35
|
+
recorded_at: Tue, 04 Mar 2014 04:15:30 GMT
|
36
|
+
recorded_with: VCR 2.8.0
|
@@ -0,0 +1,36 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.nike.com/me/sport?access_token=<ACCESS_TOKEN>
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Appid:
|
11
|
+
- <APP_ID>
|
12
|
+
Accept:
|
13
|
+
- application/json
|
14
|
+
response:
|
15
|
+
status:
|
16
|
+
code: 200
|
17
|
+
message: OK
|
18
|
+
headers:
|
19
|
+
Content-Type:
|
20
|
+
- application/json;charset=UTF-8
|
21
|
+
Date:
|
22
|
+
- Sun, 02 Mar 2014 07:45:20 GMT
|
23
|
+
Server:
|
24
|
+
- Apache
|
25
|
+
X-Swooshlet:
|
26
|
+
- app-msp-api-0 prd sin-87-app-msp-api-0
|
27
|
+
Content-Length:
|
28
|
+
- '643'
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
body:
|
32
|
+
encoding: UTF-8
|
33
|
+
string: '{"experienceTypes":["FUELBAND"],"summaries":[{"experienceType":"ALL","records":[{"recordType":"LIFETIMEFUEL","recordValue":"424189"}]},{"experienceType":"FUELBAND","records":[{"recordType":"LIFETIMEFUEL","recordValue":"424189"},{"recordType":"DAILYGOALTARGETVALUE","recordValue":"2250.0"},{"recordType":"CURRENTSTREAK","recordValue":"1"},{"recordType":"TOTALDAILYGOALSACHIEVED","recordValue":"127"},{"recordType":"LIFETIMEAVERAGEFUELDAY","recordValue":"2790"},{"recordType":"LIFETIMEAVERAGEFUELWEEK","recordValue":"19281"},{"recordType":"LIFETIMEAVERAGEFUELMONTH","recordValue":"70698"},{"recordType":"NUMOFACTIVITIES","recordValue":"152"}]}]}'
|
34
|
+
http_version:
|
35
|
+
recorded_at: Sun, 02 Mar 2014 07:45:37 GMT
|
36
|
+
recorded_with: VCR 2.8.0
|
@@ -0,0 +1,36 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.nike.com/me/sport/activities/FUELBAND?access_token=<ACCESS_TOKEN>&experienceType=FUELBAND
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Appid:
|
11
|
+
- <APP_ID>
|
12
|
+
Accept:
|
13
|
+
- application/json
|
14
|
+
response:
|
15
|
+
status:
|
16
|
+
code: 200
|
17
|
+
message: OK
|
18
|
+
headers:
|
19
|
+
Content-Type:
|
20
|
+
- application/json;charset=UTF-8
|
21
|
+
Date:
|
22
|
+
- Sun, 02 Mar 2014 07:45:23 GMT
|
23
|
+
Server:
|
24
|
+
- Apache
|
25
|
+
X-Swooshlet:
|
26
|
+
- app-msp-api-0 prd sin-84-app-msp-api-0
|
27
|
+
Content-Length:
|
28
|
+
- '1871'
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
body:
|
32
|
+
encoding: UTF-8
|
33
|
+
string: '{"data":[{"activityId":"2bd0fec0-3955-450b-92dd-29426a19d2f5","activityType":"ALL_DAY","startTime":"2014-02-09T05:00:00Z","activityTimeZone":"America/Indiana/Indianapolis","status":"IN_PROGRESS","deviceType":"FUELBAND","metricSummary":{"calories":678,"fuel":2369,"distance":6.01494836807251,"steps":7639,"duration":"5:40:00.000"},"tags":[],"metrics":[]},{"activityId":"eb68365c-819e-4638-ad7b-57ff23f034ad","activityType":"ALL_DAY","startTime":"2014-02-08T05:00:00Z","activityTimeZone":"America/Indiana/Indianapolis","status":"IN_PROGRESS","deviceType":"FUELBAND","metricSummary":{"calories":527,"fuel":1839,"distance":2.8440887928009033,"steps":3612,"duration":"7:51:00.000"},"tags":[],"metrics":[]},{"activityId":"047eb85a-f60f-4c13-b6a9-392c3ef9ec98","activityType":"ALL_DAY","startTime":"2014-02-07T05:00:00Z","activityTimeZone":"America/Indiana/Indianapolis","status":"IN_PROGRESS","deviceType":"FUELBAND","metricSummary":{"calories":896,"fuel":3134,"distance":6.509435653686523,"steps":8267,"duration":"10:43:00.000"},"tags":[],"metrics":[]},{"activityId":"5bce184b-7ec4-4bd2-9681-79e40803093f","activityType":"ALL_DAY","startTime":"2014-02-06T05:00:00Z","activityTimeZone":"America/Indiana/Indianapolis","status":"IN_PROGRESS","deviceType":"FUELBAND","metricSummary":{"calories":358,"fuel":1249,"distance":1.348816156387329,"steps":1713,"duration":"7:12:00.000"},"tags":[],"metrics":[]},{"activityId":"f334bdf7-1e21-48e1-8c7c-ad38d122b294","activityType":"ALL_DAY","startTime":"2014-02-05T05:00:00Z","activityTimeZone":"America/Indiana/Indianapolis","status":"IN_PROGRESS","deviceType":"FUELBAND","metricSummary":{"calories":622,"fuel":2171,"distance":3.0338521003723145,"steps":3853,"duration":"9:50:00.000"},"tags":[],"metrics":[]}],"paging":{"next":"/me/sport/activities/FUELBAND?experienceType=FUELBAND&access_token=<ACCESS_TOKEN>&offset=6"}}'
|
34
|
+
http_version:
|
35
|
+
recorded_at: Sun, 02 Mar 2014 07:45:38 GMT
|
36
|
+
recorded_with: VCR 2.8.0
|
@@ -0,0 +1,36 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.nike.com/me/sport/activities?access_token=<ACCESS_TOKEN>
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Appid:
|
11
|
+
- <APP_ID>
|
12
|
+
Accept:
|
13
|
+
- application/json
|
14
|
+
response:
|
15
|
+
status:
|
16
|
+
code: 200
|
17
|
+
message: OK
|
18
|
+
headers:
|
19
|
+
Content-Type:
|
20
|
+
- application/json;charset=UTF-8
|
21
|
+
Date:
|
22
|
+
- Fri, 14 Feb 2014 03:20:22 GMT
|
23
|
+
Server:
|
24
|
+
- Apache
|
25
|
+
X-Swooshlet:
|
26
|
+
- app-msp-api-0 prd sin-163-app-msp-api-0
|
27
|
+
Content-Length:
|
28
|
+
- '1838'
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
body:
|
32
|
+
encoding: UTF-8
|
33
|
+
string: '{"data":[{"activityId":"2bd0fec0-3955-450b-92dd-29426a19d2f5","activityType":"ALL_DAY","startTime":"2014-02-09T05:00:00Z","activityTimeZone":"America/Indiana/Indianapolis","status":"IN_PROGRESS","deviceType":"FUELBAND","metricSummary":{"calories":678,"fuel":2369,"distance":6.01494836807251,"steps":7639,"duration":"5:40:00.000"},"tags":[],"metrics":[]},{"activityId":"eb68365c-819e-4638-ad7b-57ff23f034ad","activityType":"ALL_DAY","startTime":"2014-02-08T05:00:00Z","activityTimeZone":"America/Indiana/Indianapolis","status":"IN_PROGRESS","deviceType":"FUELBAND","metricSummary":{"calories":527,"fuel":1839,"distance":2.8440887928009033,"steps":3612,"duration":"7:51:00.000"},"tags":[],"metrics":[]},{"activityId":"047eb85a-f60f-4c13-b6a9-392c3ef9ec98","activityType":"ALL_DAY","startTime":"2014-02-07T05:00:00Z","activityTimeZone":"America/Indiana/Indianapolis","status":"IN_PROGRESS","deviceType":"FUELBAND","metricSummary":{"calories":896,"fuel":3134,"distance":6.509435653686523,"steps":8267,"duration":"10:43:00.000"},"tags":[],"metrics":[]},{"activityId":"5bce184b-7ec4-4bd2-9681-79e40803093f","activityType":"ALL_DAY","startTime":"2014-02-06T05:00:00Z","activityTimeZone":"America/Indiana/Indianapolis","status":"IN_PROGRESS","deviceType":"FUELBAND","metricSummary":{"calories":358,"fuel":1249,"distance":1.348816156387329,"steps":1713,"duration":"7:12:00.000"},"tags":[],"metrics":[]},{"activityId":"f334bdf7-1e21-48e1-8c7c-ad38d122b294","activityType":"ALL_DAY","startTime":"2014-02-05T05:00:00Z","activityTimeZone":"America/Indiana/Indianapolis","status":"IN_PROGRESS","deviceType":"FUELBAND","metricSummary":{"calories":622,"fuel":2171,"distance":3.0338521003723145,"steps":3853,"duration":"9:50:00.000"},"tags":[],"metrics":[]}],"paging":{"next":"/me/sport/activities?access_token=<ACCESS_TOKEN>&offset=6"}}'
|
34
|
+
http_version:
|
35
|
+
recorded_at: Fri, 14 Feb 2014 03:20:23 GMT
|
36
|
+
recorded_with: VCR 2.8.0
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Hash do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@include_params = ["param1", "param3", "Param5", "PaRam6"]
|
7
|
+
@test_params = { "param1" => 1, "param2" => 2, "param3" => 3, "param4" => 4, "param5" => 5, "PaRam6" => 6}
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should include a new method called only' do
|
11
|
+
@test_params.should respond_to(:only)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should accept an array as the parameter object' do
|
15
|
+
params = @test_params.only(@include_params)
|
16
|
+
|
17
|
+
params.should be_an_instance_of Hash
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should only include keys in argument passed in' do
|
21
|
+
params = @test_params.only(@include_params)
|
22
|
+
|
23
|
+
params.should have_key("param1")
|
24
|
+
params.should have_key("param3")
|
25
|
+
params.should have_key("PaRam6")
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should not include keys that argument is missing' do
|
29
|
+
params = @test_params.only(@include_params)
|
30
|
+
|
31
|
+
params.should_not have_key("param2")
|
32
|
+
params.should_not have_key("param4")
|
33
|
+
params.should_not have_key("PaRam5")
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NikePlusGem::Helpers do
|
4
|
+
|
5
|
+
it 'should return a string object' do
|
6
|
+
date_value = "2013/06/21"
|
7
|
+
date = NikePlusGem::Helpers.format_date(date_value)
|
8
|
+
|
9
|
+
date.should.instance_of? String
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should accept a string in the correct format' do
|
13
|
+
date_value = "2013/06/21"
|
14
|
+
date = NikePlusGem::Helpers.format_date(date_value)
|
15
|
+
|
16
|
+
date.should.eql? "2013/06/21"
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should error on a string in the incorrect format' do
|
20
|
+
date_value = "13/06/21"
|
21
|
+
date = NikePlusGem::Helpers.format_date(date_value)
|
22
|
+
|
23
|
+
date.should.eql? "ERROR"
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should accept a Date object' do
|
27
|
+
date_value = Date.new(2013,6,21)
|
28
|
+
date = NikePlusGem::Helpers.format_date(date_value)
|
29
|
+
|
30
|
+
date.should.eql? "2013/06/21"
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#merge_required_headers" do
|
34
|
+
it 'should include the App ID key in the header hash' do
|
35
|
+
headers = NikePlusGem::Helpers.merge_required_headers("appIdValue", {"test" => "value", "test2" => "value2"})
|
36
|
+
headers.should have_key("appid")
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should include the Accept key in the header hash' do
|
40
|
+
headers = NikePlusGem::Helpers.merge_required_headers("appIdValue", {"test" => "value", "test2" => "value2"})
|
41
|
+
headers.should have_key("Accept")
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should include the two keys passed in' do
|
45
|
+
headers = NikePlusGem::Helpers.merge_required_headers("appIdValue", {"test" => "value", "test2" => "value2"})
|
46
|
+
headers.should have_key("test")
|
47
|
+
headers.should have_key("test2")
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should set app_id to appIdValue' do
|
51
|
+
headers = NikePlusGem::Helpers.merge_required_headers("appIdValue", {"test" => "value", "test2" => "value2"})
|
52
|
+
headers.should have_key("appid")
|
53
|
+
headers["appid"].should.eql?("appIdValue")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "#merge_required_qs_params" do
|
58
|
+
it 'should include the Access Token key in the hash' do
|
59
|
+
query_string_params = NikePlusGem::Helpers.merge_required_qs_params("accessTokenValue", {"test" => "one"})
|
60
|
+
query_string_params.should have_key("access_token")
|
61
|
+
query_string_params.should have_key("test")
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should set access_token to accessTokenValue' do
|
65
|
+
query_string_params = NikePlusGem::Helpers.merge_required_qs_params("accessTokenValue", {"test" => "value"})
|
66
|
+
query_string_params.should have_key("access_token")
|
67
|
+
query_string_params["access_token"].should.eql?("accessTokenValue")
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require_relative '../lib/nikeplusgem'
|
2
|
+
|
3
|
+
require 'webmock/rspec'
|
4
|
+
require 'vcr'
|
5
|
+
|
6
|
+
VCR.configure do |c|
|
7
|
+
c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
|
8
|
+
c.hook_into :webmock
|
9
|
+
c.filter_sensitive_data('<ACCESS_TOKEN>') { '12345' }
|
10
|
+
c.filter_sensitive_data('<APP_ID>') { 'abcde' }
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,172 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nikeplusgem
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rob Shaw
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: vcr
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: yard
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.8.0
|
76
|
+
- - <
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 1.16.0
|
79
|
+
type: :development
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.8.0
|
86
|
+
- - <
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 1.16.0
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: httparty
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
type: :runtime
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
description: A client library to retrieve data from the Nike+ Developer Resources
|
104
|
+
API.
|
105
|
+
email:
|
106
|
+
- rob@borwahs.com
|
107
|
+
executables: []
|
108
|
+
extensions: []
|
109
|
+
extra_rdoc_files: []
|
110
|
+
files:
|
111
|
+
- ./Gemfile
|
112
|
+
- ./Gemfile.lock
|
113
|
+
- ./lib/nikeplusgem/activity_data.rb
|
114
|
+
- ./lib/nikeplusgem/aggregate_sport.rb
|
115
|
+
- ./lib/nikeplusgem/client.rb
|
116
|
+
- ./lib/nikeplusgem/errors.rb
|
117
|
+
- ./lib/nikeplusgem/experience_type.rb
|
118
|
+
- ./lib/nikeplusgem/extensions.rb
|
119
|
+
- ./lib/nikeplusgem/helpers.rb
|
120
|
+
- ./lib/nikeplusgem/list_activities.rb
|
121
|
+
- ./lib/nikeplusgem/version.rb
|
122
|
+
- ./lib/nikeplusgem.rb
|
123
|
+
- ./LICENSE
|
124
|
+
- ./nikeplusgem-0.0.1.gem
|
125
|
+
- ./nikeplusgem-0.1.0.gem
|
126
|
+
- ./nikeplusgem.gemspec
|
127
|
+
- ./Rakefile
|
128
|
+
- ./readme.markdown
|
129
|
+
- ./spec/client_spec.rb
|
130
|
+
- ./spec/endpoints_spec.rb
|
131
|
+
- ./spec/fixtures/vcr_cassettes/activity_data.yml
|
132
|
+
- ./spec/fixtures/vcr_cassettes/aggregate_sport.yml
|
133
|
+
- ./spec/fixtures/vcr_cassettes/experience_type.yml
|
134
|
+
- ./spec/fixtures/vcr_cassettes/list_activities.yml
|
135
|
+
- ./spec/hash_extension_spec.rb
|
136
|
+
- ./spec/helpers_spec.rb
|
137
|
+
- ./spec/spec_helper.rb
|
138
|
+
homepage: https://github.com/borwahs/nikeplusgem/
|
139
|
+
licenses:
|
140
|
+
- MIT
|
141
|
+
metadata: {}
|
142
|
+
post_install_message:
|
143
|
+
rdoc_options: []
|
144
|
+
require_paths:
|
145
|
+
- lib
|
146
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - '>='
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - '>='
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '0'
|
156
|
+
requirements: []
|
157
|
+
rubyforge_project:
|
158
|
+
rubygems_version: 2.1.11
|
159
|
+
signing_key:
|
160
|
+
specification_version: 4
|
161
|
+
summary: Nike+ Gem
|
162
|
+
test_files:
|
163
|
+
- ./spec/client_spec.rb
|
164
|
+
- ./spec/endpoints_spec.rb
|
165
|
+
- ./spec/fixtures/vcr_cassettes/activity_data.yml
|
166
|
+
- ./spec/fixtures/vcr_cassettes/aggregate_sport.yml
|
167
|
+
- ./spec/fixtures/vcr_cassettes/experience_type.yml
|
168
|
+
- ./spec/fixtures/vcr_cassettes/list_activities.yml
|
169
|
+
- ./spec/hash_extension_spec.rb
|
170
|
+
- ./spec/helpers_spec.rb
|
171
|
+
- ./spec/spec_helper.rb
|
172
|
+
has_rdoc:
|