ohmage 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5346e0bbef95966904e71f121444a7953aef1f25
4
- data.tar.gz: 15c14cf7eb79247f05519225fe4beeb46627a203
3
+ metadata.gz: c80568e11cf17291690bbb7490013e0d53e367a0
4
+ data.tar.gz: d2392cf5c7a592adac6c2ff9733f019616222f26
5
5
  SHA512:
6
- metadata.gz: ca7ad1732dd2e189ead2d9ff1360a01c4cd6a0f9be05cfca98fb40e58bfa2176122bda3cf1c522cde49313b630f79fe997c5fe86e3c3550dd58b9a28dc74c07b
7
- data.tar.gz: 0b90a0cff36432d5b9f87dd6958125af287b7d5b46a619b164874615c4c7977c7a56c51e136c4cd19df061349fcdf68281d4f475ef8d3be0608328ef8c42d3b4
6
+ metadata.gz: dce10c7dc367820a2452624d126b25f3a0b16b3160248093c5c432499764ec62c1ffc727588e2ebd4ead23e2555417979ef4616a0931a387ad7ab26e7697a6c2
7
+ data.tar.gz: 2fa36965395ef97cea82dd2650c16f14f306d1ba90150861a891afc77ce049e8c6eb2a3d9597e47664385e1fce2424c9a49395240d66590add2246284f2ca290
data/lib/ohmage.rb CHANGED
@@ -8,6 +8,7 @@ require 'ohmage/entity/user'
8
8
  require 'ohmage/entity/clazz'
9
9
  require 'ohmage/entity/campaign'
10
10
  require 'ohmage/entity/document'
11
+ require 'ohmage/entity/survey'
11
12
  require 'ohmage/version'
12
13
 
13
14
  module Ohmage
data/lib/ohmage/api.rb CHANGED
@@ -3,6 +3,7 @@ require 'ohmage/campaign'
3
3
  require 'ohmage/clazz'
4
4
  require 'ohmage/document'
5
5
  require 'ohmage/media'
6
+ require 'ohmage/survey'
6
7
 
7
8
  module Ohmage
8
9
  module API
@@ -11,5 +12,6 @@ module Ohmage
11
12
  include Ohmage::API::Campaign
12
13
  include Ohmage::API::Document
13
14
  include Ohmage::API::Media
15
+ include Ohmage::API::Survey
14
16
  end
15
17
  end
@@ -0,0 +1,22 @@
1
+ module Ohmage
2
+ class SurveyResponse
3
+ # @return [String]
4
+ attr_reader :client, :privacy_state, :repeatable_set_id, :repeatable_set_iteration, :survey_description, :survey_id, :survey_title, :user, :timezone
5
+ # @return [String] location stuffz
6
+ attr_reader :location_accuracy, :location_provider, :location_status, :location_timestamp
7
+ # @return [Long]
8
+ attr_reader :latitude, :longitude
9
+ # @return [Hash]
10
+ attr_reader :launch_context_long, :launch_context_short, :responses
11
+ # @return [Something Else]
12
+ attr_reader :time, :utc_timestamp
13
+
14
+
15
+ def initialize(attrs = {})
16
+ @urn = attrs.keys[0].to_s
17
+ attrs.values[0].each do |k, v|
18
+ instance_variable_set("@#{k}", v)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,48 @@
1
+ module Ohmage
2
+ module API
3
+ module Survey
4
+ #
5
+ # ohmage survey_response/read call
6
+ # @see https://github.com/ohmage/server/wiki/Survey-Manipulation#surveyResponseRead
7
+ # @returns [Array Ohmage::Survey objects] pertaining to request params.
8
+ #
9
+ def survey_response_read(params = {})
10
+ params[:column_list] = params[:column_list] || 'urn:ohmage:special:all'
11
+ params[:output_format] = params[:output_format] || 'json-rows'
12
+ params[:user_list] = params[:user_list] || 'urn:ohmage:special:all'
13
+ params[:prompt_id_list] = 'urn:ohmage:special:all' unless params[:prompt_id_list] || params[:survey_id_list]
14
+ request = Ohmage::Request.new(self, :post, 'survey_response/read', params)
15
+ t = []
16
+ # We can't possibly make Ohmage::SurveyReponse objects unless we use json-rows. json-columns and csv output is so odd for this.
17
+ if params[:output_format] == 'json-rows'
18
+ request.perform[:data].each do |v|
19
+ t << Ohmage::SurveyResponse.new(v[:survey_key] => v)
20
+ end
21
+ t
22
+ else
23
+ request.perform
24
+ end
25
+ end
26
+
27
+ #
28
+ # ohmage survey_response/update call
29
+ # @see https://github.com/ohmage/server/wiki/Survey-Manipulation#surveyResponseUpdatePrivacyState
30
+ # @returns success/fail as string.
31
+ #
32
+ def survey_response_update(params = {})
33
+ request = Ohmage::Request.new(self, :post, 'survey_response/update', params)
34
+ request.perform
35
+ end
36
+
37
+ #
38
+ # ohmage survey_response/delete call
39
+ # @see https://github.com/ohmage/server/wiki/Survey-Manipulation#surveyResponseDelete
40
+ # @returns success/fail as string.
41
+ #
42
+ def survey_response_delete(params = {})
43
+ request = Ohmage::Request.new(self, :post, 'survey_response/delete', params)
44
+ request.perform
45
+ end
46
+ end
47
+ end
48
+ end
@@ -14,7 +14,7 @@ module Ohmage
14
14
 
15
15
  # @return [Integer]
16
16
  def patch
17
- 11
17
+ 12
18
18
  end
19
19
 
20
20
  # @return [Integer, NilClass]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ohmage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Nolen
@@ -87,10 +87,12 @@ files:
87
87
  - lib/ohmage/entity/campaign.rb
88
88
  - lib/ohmage/entity/clazz.rb
89
89
  - lib/ohmage/entity/document.rb
90
+ - lib/ohmage/entity/survey.rb
90
91
  - lib/ohmage/entity/user.rb
91
92
  - lib/ohmage/error.rb
92
93
  - lib/ohmage/media.rb
93
94
  - lib/ohmage/request.rb
95
+ - lib/ohmage/survey.rb
94
96
  - lib/ohmage/user.rb
95
97
  - lib/ohmage/version.rb
96
98
  - ohmage.gemspec