two_net 0.0.1
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/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +32 -0
- data/lib/tasks/two_net_tasks.rake +4 -0
- data/lib/two_net/version.rb +3 -0
- data/lib/two_net.rb +435 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +29 -0
- data/test/dummy/config/environments/production.rb +80 -0
- data/test/dummy/config/environments/test.rb +36 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +12 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +56 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/public/404.html +58 -0
- data/test/dummy/public/422.html +58 -0
- data/test/dummy/public/500.html +57 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/test_helper.rb +15 -0
- data/test/two_net_test.rb +7 -0
- metadata +158 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 0bbf714ae37d8f6c39b9b11a0e5cd4b0fede0e67
|
|
4
|
+
data.tar.gz: cd3038f5156c30c9894121a3ca47838da8d97f2a
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 94696ce978f6a5f6477bcb70346ca1a77c077e55b0e338326f92462368f628c99fbd34bfe906d5d4541f9c839b5892b3c55c4b1f7b01d6a3219f93444b30372c
|
|
7
|
+
data.tar.gz: 99175b4d8493fff9ec075c78ae181efd5c0c115494c8ddaa37f67e6f479d3fc8e6ff889e6afdc50c2cc165c9f0d8c11439e8a8fa129600f0cd4476ee56751bbe
|
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright 2014 YOURNAME
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
begin
|
|
2
|
+
require 'bundler/setup'
|
|
3
|
+
rescue LoadError
|
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
require 'rdoc/task'
|
|
8
|
+
|
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
11
|
+
rdoc.title = 'TwoNet'
|
|
12
|
+
rdoc.options << '--line-numbers'
|
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
Bundler::GemHelper.install_tasks
|
|
21
|
+
|
|
22
|
+
require 'rake/testtask'
|
|
23
|
+
|
|
24
|
+
Rake::TestTask.new(:test) do |t|
|
|
25
|
+
t.libs << 'lib'
|
|
26
|
+
t.libs << 'test'
|
|
27
|
+
t.pattern = 'test/**/*_test.rb'
|
|
28
|
+
t.verbose = false
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
task default: :test
|
data/lib/two_net.rb
ADDED
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
require 'builder'
|
|
2
|
+
require 'httparty'
|
|
3
|
+
|
|
4
|
+
module TwoNet
|
|
5
|
+
|
|
6
|
+
class Client
|
|
7
|
+
|
|
8
|
+
include HTTParty
|
|
9
|
+
headers 'Content-Type' => 'application/xml' ,'Accept' => 'application/xml'
|
|
10
|
+
debug_output if ENV['TWONET_DEBUG']
|
|
11
|
+
base_uri( ENV['TWONET_URL'])
|
|
12
|
+
@key = ENV['TWONET_KEY']
|
|
13
|
+
@secret = ENV['TWONET_SECRET']
|
|
14
|
+
basic_auth(@key, @secret)
|
|
15
|
+
@error = nil;
|
|
16
|
+
#timezone = 'Canada/Atlantic' Or "Atlantic Time (Canada)"
|
|
17
|
+
|
|
18
|
+
def self.get_error()
|
|
19
|
+
return @error;
|
|
20
|
+
end
|
|
21
|
+
def self.clear_error()
|
|
22
|
+
@error = nil
|
|
23
|
+
end
|
|
24
|
+
def self.register_user(guid)
|
|
25
|
+
response = Client.post('/partner/register', :body=>{:guid=>guid }.to_xml(:root=>:registerRequest))
|
|
26
|
+
return false if @error = response["errorStatus"].blank? == false
|
|
27
|
+
return response["trackGuidsResponse"]["status"]["code"] == "1"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def self.delete_user(guid)
|
|
31
|
+
response = Client.delete("/partner/user/delete/#{guid}")
|
|
32
|
+
return false if @error = response["errorStatus"].blank? == false
|
|
33
|
+
return check_status_response response
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.user_exists?(guid)
|
|
37
|
+
response = Client.get("/partner/user/exists/#{guid}")
|
|
38
|
+
return check_status_response response
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
#return array
|
|
42
|
+
def self.get_guids()
|
|
43
|
+
audit_response = Client.get('/partner/audit/guids')
|
|
44
|
+
return nil if audit_response["auditResponse"]["status"]["code"] != "1"
|
|
45
|
+
return audit_response["auditResponse"]["guids"]["guid"]
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def self.user_track_details(guid)
|
|
49
|
+
response = Client.get("/partner/user/tracks/details/#{guid}")
|
|
50
|
+
return check_user_track_details_response response
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
## TODO clean up the hash that arrives back
|
|
54
|
+
def self.list_all_sensors(guid)
|
|
55
|
+
response = TwoNet.get("/partner/user/tracks/registerable/#{guid}")
|
|
56
|
+
response["trackRegistrationTemplateResponse"]
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
#Properties
|
|
61
|
+
# [ {:name=>:make, :value=> make },
|
|
62
|
+
# {:name=>:model, :value=>model},
|
|
63
|
+
# {:name=>:serialNumber, :value=>identification},
|
|
64
|
+
# {:name=>:qualifier, :value=>1}
|
|
65
|
+
# ]
|
|
66
|
+
#
|
|
67
|
+
|
|
68
|
+
def self.add_sensor(guid,properties)
|
|
69
|
+
# https://twonetcom.qualcomm.com/kernel/api/objects/trackRegistrationRequest.jsp
|
|
70
|
+
body = {:guid=>guid ,
|
|
71
|
+
:type =>"2net",
|
|
72
|
+
:properties => properties,
|
|
73
|
+
"registerType" => "properties" }
|
|
74
|
+
response = Client.post('/partner/user/track/register',:body=>Client.trackRegistrationRequest_xml(body))
|
|
75
|
+
return false if @error = response["errorStatus"].blank? == false
|
|
76
|
+
return nil if response["trackRegistrationResponse"]["status"]["code"].to_s != "1"
|
|
77
|
+
return response["trackRegistrationResponse"]["trackDetail"]["guid"]
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def self.add_oauth(opts={})
|
|
81
|
+
guid = opts[:type]
|
|
82
|
+
type = opts[:type]
|
|
83
|
+
body = {:guid=>guid,
|
|
84
|
+
:type =>type,
|
|
85
|
+
"registerType" => "oauth" }
|
|
86
|
+
response = Client.post('/partner/user/track/register',:body=>body.to_xml(:root=>'trackRegistrationRequest'))
|
|
87
|
+
return false if @error = response["errorStatus"].blank? == false
|
|
88
|
+
return nil if response["trackRegistrationResponse"]["status"]["code"].to_s != "1"
|
|
89
|
+
return response["trackRegistrationResponse"]["oauthAuthorizationUrl"]
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def self.remove_sensor(guid,track_id)
|
|
93
|
+
response = Client.delete("/partner/user/track/unregister/#{guid}/#{track_id}")
|
|
94
|
+
return Client.check_status_response response
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def self.generate_guid()
|
|
98
|
+
SecureRandom.uuid
|
|
99
|
+
end
|
|
100
|
+
def self.latest_reading(opts={})
|
|
101
|
+
guid = opts[:guid]
|
|
102
|
+
track_guid = opts[:track_guid]
|
|
103
|
+
#timezone = 'Canada/Atlantic'
|
|
104
|
+
body = Client.trackRequest_xml(guid: guid, track_guid: track_guid)
|
|
105
|
+
response = Client.post('/partner/user/track/latest',:body=>body)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def self.latest_activity(opts={})
|
|
109
|
+
guid = opts[:guid]
|
|
110
|
+
track_guid = opts[:track_guid]
|
|
111
|
+
timezone = opts[:timezone]
|
|
112
|
+
#timezone = 'Canada/Atlantic'
|
|
113
|
+
body = activityRequest_xml(guid: guid, track_guid: track_guid, timezone: timezone)
|
|
114
|
+
response = Client.post('/partner/activity/day/latest',:body=>body)
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def self.filtered_activity(opts={})
|
|
118
|
+
guid = opts[:guid]
|
|
119
|
+
track_guid = opts[:track_guid]
|
|
120
|
+
timezone = opts[:timezone]
|
|
121
|
+
start_date = opts[:start_date]
|
|
122
|
+
end_date = opts[:end_date]
|
|
123
|
+
|
|
124
|
+
body = Client.activityRequestFilter_xml(guid: guid, track_guid: track_guid,
|
|
125
|
+
start_date: start_date.to_i, end_date: end_date.to_i,
|
|
126
|
+
timezone: timezone )
|
|
127
|
+
response = Client.post('/partner/activity/filtered',:body=>body)
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def self.latest_blood(opts={})
|
|
131
|
+
guid = opts[:guid]
|
|
132
|
+
track_guid = opts[:track_guid]
|
|
133
|
+
|
|
134
|
+
body = measureRequest_xml(guid: guid, track_guid: track_guid)
|
|
135
|
+
response = Client.post('/partner/measure/blood/latest',:body=>body)
|
|
136
|
+
return nil if @error = response["measureResponse"]["status"]["code"].to_s != "1"
|
|
137
|
+
return response["measureResponse"]
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def self.latest_breath(opts={})
|
|
141
|
+
guid = opts[:guid]
|
|
142
|
+
track_guid = opts[:track_guid]
|
|
143
|
+
|
|
144
|
+
body = measureRequest_xml(guid: guid, track_guid: track_guid)
|
|
145
|
+
response = Client.post('/partner/measure/breath/latest',:body=>body)
|
|
146
|
+
return nil if response["measureResponse"]["status"]["code"].to_s != "1"
|
|
147
|
+
return response["measureResponse"]
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def self.latest_body(opts={})
|
|
151
|
+
guid = opts[:guid]
|
|
152
|
+
track_guid = opts[:track_guid]
|
|
153
|
+
timezone = opts[:timezone]
|
|
154
|
+
|
|
155
|
+
body = Client.measureRequest_xml(guid: guid, track_guid: track_guid, timezone: timezone)
|
|
156
|
+
response = Client.post('/partner/measure/body/latest',:body=>body)
|
|
157
|
+
return nil if @error = response["measureResponse"]["status"]["code"] != "1"
|
|
158
|
+
return response["measureResponse"]
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
# measurement in blood, breath, blood
|
|
162
|
+
def self.user_latest(opts={})
|
|
163
|
+
measurement = opts[:measurement]
|
|
164
|
+
patient_guid = opts[:patient_guid]
|
|
165
|
+
sensor_guid = opts[:sensor_guid]
|
|
166
|
+
timezone = opts[:timezone]
|
|
167
|
+
|
|
168
|
+
if measurement == :blood
|
|
169
|
+
results = Client.latest_blood(guid: patient_guid,track_guid: sensor_guid)
|
|
170
|
+
elsif measurement == :body
|
|
171
|
+
results = Client.latest_body(guid: patient_guid,track_guid: sensor_guid, timezone: timezone)
|
|
172
|
+
elsif measurement == :breath
|
|
173
|
+
results = Client.latest_breath(guid: patient_guid,track_guid: sensor_guid)
|
|
174
|
+
end
|
|
175
|
+
return results
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
def self.user_latest_debug(opts={})
|
|
179
|
+
measurement = opts[:measurement]
|
|
180
|
+
patient_guid = opts[:patient_guid]
|
|
181
|
+
sensor_guid = opts[:sensor_guid]
|
|
182
|
+
timezone = opts[:timezone]
|
|
183
|
+
results = Hash.new
|
|
184
|
+
|
|
185
|
+
results["blood"] = Client.latest_blood(guid: patient_guid,track_guid: sensor_guid)
|
|
186
|
+
|
|
187
|
+
results["body"] = Client.latest_body(guid: patient_guid,track_guid: sensor_guid, timezone: timezone)
|
|
188
|
+
|
|
189
|
+
results["breath"] = Client.latest_breath(guid: patient_guid,track_guid: sensor_guid)
|
|
190
|
+
|
|
191
|
+
return results
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
def self.user_filtered(opts={})
|
|
195
|
+
measurement = opts[:measurement]
|
|
196
|
+
guid = opts[:guid]
|
|
197
|
+
track_guid = opts[:track_guid]
|
|
198
|
+
start_date = opts[:start_date]
|
|
199
|
+
end_date = opts[:end_date]
|
|
200
|
+
timezone = opts[:timezone]
|
|
201
|
+
|
|
202
|
+
body = Client.measureRequest_xml(guid: guid, track_guid: track_guid, timezone: timezone, start_date: start_date, end_date: end_date)
|
|
203
|
+
if measurement == "blood"
|
|
204
|
+
response = Client.post('/partner/measure/blood/filtered', :body=>body)
|
|
205
|
+
elsif measurement == "body"
|
|
206
|
+
response = Client.post('/partner/measure/body/filtered', :body=>body)
|
|
207
|
+
elsif measurement == "breath"
|
|
208
|
+
response = Client.post('/partner/measure/breath/filtered',:body=>body)
|
|
209
|
+
elsif measurement == "activity"
|
|
210
|
+
response = Client.post('/partner/measure/activity/filtered',:body=>body)
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
return nil if response["measureResponse"]["status"]["code"] != "1"
|
|
214
|
+
return response["measureResponse"]
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
def self.debug_user_filtered(opts={})
|
|
218
|
+
measurement = opts[:measurement]
|
|
219
|
+
guid = opts[:guid]
|
|
220
|
+
track_guid = opts[:track_guid]
|
|
221
|
+
start_date = opts[:start_date]
|
|
222
|
+
end_date = opts[:end_date]
|
|
223
|
+
timezone = opts[:timezone]
|
|
224
|
+
responses = Hash.new
|
|
225
|
+
|
|
226
|
+
body = Client.measureRequest_xml(guid: guid, track_guid: track_guid, timezone: timezone, start_date: start_date, end_date: end_date)
|
|
227
|
+
|
|
228
|
+
responses["blood"] = Client.post('/partner/measure/blood/filtered', :body=>body)
|
|
229
|
+
|
|
230
|
+
responses["body"] = Client.post('/partner/measure/body/filtered', :body=>body)
|
|
231
|
+
|
|
232
|
+
responses["breath"] = Client.post('/partner/measure/breath/filtered',:body=>body)
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
return responses
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
def self.check_status_response(response)
|
|
242
|
+
return false if @error = response["errorStatus"].blank? == false
|
|
243
|
+
return response["statusResponse"]["status"]["code"].to_s == "1"
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
def self.check_response(object, response, data)
|
|
247
|
+
return false if @error = response["errorStatus"].blank? == false || response[object].nil?
|
|
248
|
+
return nil if response[object]["status"]["code"].to_s != "1"
|
|
249
|
+
return response[object][data]
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
def self.check_user_track_details_response(response)
|
|
253
|
+
return false if @error = response["errorStatus"].blank? == false
|
|
254
|
+
return nil if response["trackDetailsResponse"]["status"]["code"].to_s != "1"
|
|
255
|
+
return response["trackDetailsResponse"]["trackDetails"]
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
def self.trackRegistrationRequest_xml(body)
|
|
259
|
+
builder = Builder::XmlMarkup.new
|
|
260
|
+
xml = builder.trackRegistrationRequest do |xml|
|
|
261
|
+
xml.guid body[:guid]
|
|
262
|
+
xml.type body[:type]
|
|
263
|
+
xml.registerType body[:registerType]
|
|
264
|
+
xml.properties do
|
|
265
|
+
body[:properties].each do |property|
|
|
266
|
+
xml.property do
|
|
267
|
+
xml.name property[:name].to_s
|
|
268
|
+
xml.value property[:value]
|
|
269
|
+
end
|
|
270
|
+
end
|
|
271
|
+
end
|
|
272
|
+
end
|
|
273
|
+
xml
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
def self.activityRequest_xml(opts={})
|
|
277
|
+
guid = opts[:guid]
|
|
278
|
+
track_guid = opts[:track_guid]
|
|
279
|
+
timezone = opts[:timezone]
|
|
280
|
+
builder = Builder::XmlMarkup.new
|
|
281
|
+
xml = builder.activityRequest do |xml|
|
|
282
|
+
xml.guid guid
|
|
283
|
+
xml.trackGuid track_guid
|
|
284
|
+
xml.timezone timezone
|
|
285
|
+
end
|
|
286
|
+
xml
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
def self.measureRequest_xml(opts={})
|
|
290
|
+
guid = opts[:guid]
|
|
291
|
+
track_guid = opts[:track_guid]
|
|
292
|
+
timezone = opts[:timezone]
|
|
293
|
+
start_date = opts[:start_date]
|
|
294
|
+
end_date = opts[:end_date]
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
builder = Builder::XmlMarkup.new
|
|
298
|
+
xml = builder.measureRequest do |xml|
|
|
299
|
+
xml.guid guid
|
|
300
|
+
xml.trackGuid track_guid
|
|
301
|
+
xml.filter do |xml2|
|
|
302
|
+
xml2.startDate start_date.to_i
|
|
303
|
+
xml2.endDate end_date.to_i
|
|
304
|
+
xml2.aggregateLevel 'EPOCH'
|
|
305
|
+
end
|
|
306
|
+
xml.timezone timezone
|
|
307
|
+
end
|
|
308
|
+
xml
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
def self.trackRequest_xml(opts={})
|
|
312
|
+
guid = opts[:guid]
|
|
313
|
+
track_guid = opts[:track_guid]
|
|
314
|
+
start_date = opts[:start_date]
|
|
315
|
+
end_date = opts[:end_date]
|
|
316
|
+
|
|
317
|
+
builder = Builder::XmlMarkup.new
|
|
318
|
+
xml = builder.trackRequest do |xml|
|
|
319
|
+
xml.guid guid
|
|
320
|
+
xml.trackGuid track_guid
|
|
321
|
+
xml.filter do |xml2|
|
|
322
|
+
xml2.startDate start_date.to_i
|
|
323
|
+
xml2.endDate end_date.to_i
|
|
324
|
+
xml2.aggregateLevel 'EPOCH'
|
|
325
|
+
end
|
|
326
|
+
end
|
|
327
|
+
xml
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
def self.activityRequestFilter_xml(opts={})
|
|
331
|
+
guid = opts[:guid]
|
|
332
|
+
track_guid = opts[:track_guid]
|
|
333
|
+
start_date = opts[:start_date]
|
|
334
|
+
end_date = opts[:end_date]
|
|
335
|
+
timezone = opts[:timezone]
|
|
336
|
+
|
|
337
|
+
builder = Builder::XmlMarkup.new
|
|
338
|
+
xml = builder.activityRequest do |xml|
|
|
339
|
+
xml.guid guid
|
|
340
|
+
xml.trackGuid track_guid
|
|
341
|
+
xml.filter do |xml2|
|
|
342
|
+
xml2.startDate start_date.to_i
|
|
343
|
+
xml2.endDate end_date.to_i
|
|
344
|
+
xml2.aggregateLevel 'EPOCH'
|
|
345
|
+
end
|
|
346
|
+
xml.timezone timezone
|
|
347
|
+
end
|
|
348
|
+
xml
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
def self.arrayify(object)
|
|
352
|
+
object.is_a?(Array) ? object : [object]
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
def fake_glucometer
|
|
357
|
+
properties = [ {:name=>:make, :value=>'Entra'},
|
|
358
|
+
{:name=>:model, :value=>'MGH-BT1'},
|
|
359
|
+
{:name=>:serialNumber, :value=>'2NET00001'},
|
|
360
|
+
{:name=>:qualifier, :value=>1}
|
|
361
|
+
]
|
|
362
|
+
return properties
|
|
363
|
+
end
|
|
364
|
+
|
|
365
|
+
def fake_pulse_oximeter
|
|
366
|
+
properties = [ {:name=>:make, :value=>'Nonin'},
|
|
367
|
+
{:name=>:model, :value=>'9560 Onyx II'},
|
|
368
|
+
{:name=>:serialNumber, :value=>'2NET00002'},
|
|
369
|
+
{:name=>:qualifier, :value=>1}
|
|
370
|
+
]
|
|
371
|
+
return properties
|
|
372
|
+
end
|
|
373
|
+
|
|
374
|
+
def fake_weigh_scale
|
|
375
|
+
properties = [ {:name=>:make, :value=>'A&D'},
|
|
376
|
+
{:name=>:model, :value=>'UC-321PBT'},
|
|
377
|
+
{:name=>:serialNumber, :value=>'2NET00003'},
|
|
378
|
+
{:name=>:qualifier, :value=>1}
|
|
379
|
+
]
|
|
380
|
+
return properties
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
def fake_blood_pressure
|
|
384
|
+
properties = [ {:name=>:make, :value=>'A&D'},
|
|
385
|
+
{:name=>:model, :value=>'UA-767PBT'},
|
|
386
|
+
{:name=>:serialNumber, :value=>'2NET00004'},
|
|
387
|
+
{:name=>:qualifier, :value=>1}
|
|
388
|
+
]
|
|
389
|
+
return properties
|
|
390
|
+
end
|
|
391
|
+
def fake_inhaler
|
|
392
|
+
properties = [ {:name=>:make, :value=>'Asthmapolis'},
|
|
393
|
+
{:name=>:model, :value=>'Rev B'},
|
|
394
|
+
{:name=>:serialNumber, :value=>'2NET00005'},
|
|
395
|
+
{:name=>:qualifier, :value=>1}
|
|
396
|
+
]
|
|
397
|
+
return properties
|
|
398
|
+
end
|
|
399
|
+
def add_fake_sensors(guid, properties)
|
|
400
|
+
# https://twonetcom.qualcomm.com/kernel/api/objects/trackRegistrationRequest.jsp
|
|
401
|
+
body = {:guid=>guid ,
|
|
402
|
+
:type =>"2net",
|
|
403
|
+
:properties => properties,
|
|
404
|
+
"registerType" => "properties" }
|
|
405
|
+
response = Client.post('/partner/user/track/register',:body=>TwoNet.trackRegistrationRequest_xml(body))
|
|
406
|
+
return false if response["errorStatus"].blank? == false
|
|
407
|
+
return nil if response["trackRegistrationResponse"]["status"]["code"].to_s != "1"
|
|
408
|
+
return response["trackRegistrationResponse"]["trackDetail"]["guid"]
|
|
409
|
+
end
|
|
410
|
+
|
|
411
|
+
def compress_track(track_details)
|
|
412
|
+
h = Hash.new
|
|
413
|
+
# return nil if track_details.nil? == true
|
|
414
|
+
|
|
415
|
+
track_detail = track_details["trackDetail"]
|
|
416
|
+
return [] if track_detail.blank?
|
|
417
|
+
track_detail = Client.arrayify(track_detail)
|
|
418
|
+
track_detail.each do |track_detail|
|
|
419
|
+
h[ track_detail["guid"] ] = track_detail["properties"]
|
|
420
|
+
end
|
|
421
|
+
return h
|
|
422
|
+
end
|
|
423
|
+
|
|
424
|
+
def print_uid_sensors(guids = nil)
|
|
425
|
+
guids = Client.get_guids() if guids == nil
|
|
426
|
+
guids= Client.arrayify(guids)
|
|
427
|
+
h = Hash.new
|
|
428
|
+
guids.each do |guid|
|
|
429
|
+
results = Client.user_track_details(guid)
|
|
430
|
+
h[guid] = compress_track(results)
|
|
431
|
+
end
|
|
432
|
+
return h
|
|
433
|
+
end
|
|
434
|
+
end
|
|
435
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
== README
|
|
2
|
+
|
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
|
4
|
+
application up and running.
|
|
5
|
+
|
|
6
|
+
Things you may want to cover:
|
|
7
|
+
|
|
8
|
+
* Ruby version
|
|
9
|
+
|
|
10
|
+
* System dependencies
|
|
11
|
+
|
|
12
|
+
* Configuration
|
|
13
|
+
|
|
14
|
+
* Database creation
|
|
15
|
+
|
|
16
|
+
* Database initialization
|
|
17
|
+
|
|
18
|
+
* How to run the test suite
|
|
19
|
+
|
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
|
21
|
+
|
|
22
|
+
* Deployment instructions
|
|
23
|
+
|
|
24
|
+
* ...
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
|
28
|
+
<tt>rake doc:app</tt>.
|
data/test/dummy/Rakefile
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
|
2
|
+
// listed below.
|
|
3
|
+
//
|
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
|
6
|
+
//
|
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
|
8
|
+
// compiled file.
|
|
9
|
+
//
|
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
|
11
|
+
// about supported directives.
|
|
12
|
+
//
|
|
13
|
+
//= require_tree .
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
|
3
|
+
* listed below.
|
|
4
|
+
*
|
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
|
7
|
+
*
|
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
|
10
|
+
*
|
|
11
|
+
*= require_self
|
|
12
|
+
*= require_tree .
|
|
13
|
+
*/
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Dummy</title>
|
|
5
|
+
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
|
|
6
|
+
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
|
|
7
|
+
<%= csrf_meta_tags %>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
|
|
11
|
+
<%= yield %>
|
|
12
|
+
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
data/test/dummy/bin/rake
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
|
2
|
+
|
|
3
|
+
require 'rails/all'
|
|
4
|
+
|
|
5
|
+
Bundler.require(*Rails.groups)
|
|
6
|
+
require "two_net"
|
|
7
|
+
|
|
8
|
+
module Dummy
|
|
9
|
+
class Application < Rails::Application
|
|
10
|
+
# Settings in config/environments/* take precedence over those specified here.
|
|
11
|
+
# Application configuration should go into files in config/initializers
|
|
12
|
+
# -- all .rb files in that directory are automatically loaded.
|
|
13
|
+
|
|
14
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
|
15
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
|
16
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
|
17
|
+
|
|
18
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
|
19
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
|
20
|
+
# config.i18n.default_locale = :de
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# SQLite version 3.x
|
|
2
|
+
# gem install sqlite3
|
|
3
|
+
#
|
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
|
5
|
+
# gem 'sqlite3'
|
|
6
|
+
development:
|
|
7
|
+
adapter: sqlite3
|
|
8
|
+
database: db/development.sqlite3
|
|
9
|
+
pool: 5
|
|
10
|
+
timeout: 5000
|
|
11
|
+
|
|
12
|
+
# Warning: The database defined as "test" will be erased and
|
|
13
|
+
# re-generated from your development database when you run "rake".
|
|
14
|
+
# Do not set this db to the same as development or production.
|
|
15
|
+
test:
|
|
16
|
+
adapter: sqlite3
|
|
17
|
+
database: db/test.sqlite3
|
|
18
|
+
pool: 5
|
|
19
|
+
timeout: 5000
|
|
20
|
+
|
|
21
|
+
production:
|
|
22
|
+
adapter: sqlite3
|
|
23
|
+
database: db/production.sqlite3
|
|
24
|
+
pool: 5
|
|
25
|
+
timeout: 5000
|