ohmage 0.0.10 → 0.0.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 37dc20d0591f071bbf12a953fc0814cab13c8923
4
- data.tar.gz: 9b09debd1c7c1430b66fd3a2645bcd3854cb6bd0
3
+ metadata.gz: 5346e0bbef95966904e71f121444a7953aef1f25
4
+ data.tar.gz: 15c14cf7eb79247f05519225fe4beeb46627a203
5
5
  SHA512:
6
- metadata.gz: 2da59701975de44f0a0a00e244eda1a9746baa98d1c2dc166d436c0c0180db9191569b54f8dad3f06301ec42751b259bd5789f843055d85af2ab7681d4b14607
7
- data.tar.gz: 794e46d0799cbbe5c443bf41c8d14cd763a1558986809c67bfdac97143c4eee778c99543c18a8308559aba516ff4695d91b746f28a90ab0f87aad35d12843a7b
6
+ metadata.gz: ca7ad1732dd2e189ead2d9ff1360a01c4cd6a0f9be05cfca98fb40e58bfa2176122bda3cf1c522cde49313b630f79fe997c5fe86e3c3550dd58b9a28dc74c07b
7
+ data.tar.gz: 0b90a0cff36432d5b9f87dd6958125af287b7d5b46a619b164874615c4c7977c7a56c51e136c4cd19df061349fcdf68281d4f475ef8d3be0608328ef8c42d3b4
@@ -15,6 +15,31 @@ module Ohmage
15
15
  t
16
16
  end
17
17
 
18
+ #
19
+ # ohmage campaign/create call
20
+ # @see https://github.com/ohmage/server/wiki/Campaign-Manipulation#campaignCreate
21
+ # @returns [Ohmage::Campaign object] or nil if urn is not passed as param
22
+ #
23
+ def campaign_create(params = {})
24
+ params[:xml] = HTTP::FormData::File.new(params[:xml])
25
+ request = Ohmage::Request.new(self, :post, 'campaign/create', params)
26
+ request.perform
27
+ # we cannot create a campaign object if campaign_urn is not passed as a param. returns nil otherwise
28
+ campaign_read(campaign_urn_list: params[:campaign_urn], output_format: 'long') if params[:campaign_urn]
29
+ end
30
+
31
+ #
32
+ # ohmage campaign/update call
33
+ # @see https://github.com/ohmage/server/wiki/Campaign-Manipulation#campaignUpdate
34
+ # @returns [Ohmage::Campaign object]
35
+ #
36
+ def campaign_update(params = {})
37
+ params[:xml] = HTTP::FormData::File.new(params[:xml]) if params[:xml]
38
+ request = Ohmage::Request.new(self, :post, 'campaign/update', params)
39
+ request.perform
40
+ campaign_read(campaign_urn_list: params[:campaign_urn])
41
+ end
42
+
18
43
  def campaign_delete(params = {})
19
44
  request = Ohmage::Request.new(self, :post, 'campaign/delete', params)
20
45
  request.perform
@@ -89,13 +89,13 @@ module Ohmage
89
89
  if options[:campaign_role].nil? && options[:class_role].nil?
90
90
  puts 'must supply one of [--class_role, --campaign_role]'
91
91
  elsif options[:name].nil?
92
- new_document = Ohmage.document_create(file,
92
+ new_document = Ohmage.document_create(document: file,
93
93
  document_class_role_list: options[:class_role],
94
94
  document_campaign_role_list: options[:campaign_role],
95
95
  privacy_state: privacy_state,
96
96
  description: options[:description])
97
97
  else
98
- new_document = Ohmage.document_create(file,
98
+ new_document = Ohmage.document_create(document: file,
99
99
  document_class_role_list: options[:class_role],
100
100
  document_campaign_role_list: options[:campaign_role],
101
101
  privacy_state: privacy_state,
@@ -15,15 +15,30 @@ module Ohmage
15
15
  t
16
16
  end
17
17
 
18
- def document_create(file, params = {})
19
- params[:document] = HTTP::FormData::File.new(file)
18
+ #
19
+ # ohmage document/create call
20
+ # @see https://github.com/ohmage/server/wiki/Document-Manipulation#documentCreate
21
+ # @returns [Ohmage::Document object]
22
+ #
23
+ def document_create(params = {})
24
+ params[:document] = HTTP::FormData::File.new(params[:document])
20
25
  # catch lack of document_name param, since we can just append the filename we have!
21
- params[:document_name] = File.basename(file) unless params.key?(:document_name)
22
26
  request = Ohmage::Request.new(self, :post, 'document/create', params)
23
27
  request.perform
24
28
  document_read(document_name_search: params[:document_name])
25
29
  end
26
30
 
31
+ #
32
+ # ohmage document/update call
33
+ # @see https://github.com/ohmage/server/wiki/Document-Manipulation#documentUpdate
34
+ # @returns nil, can't be sure we can search for the updated file.
35
+ #
36
+ def document_update(params = {})
37
+ params[:document] = HTTP::FormData::File.new(params[:document]) if params[:document]
38
+ request = Ohmage::Request.new(self, :post, 'document/update', params)
39
+ request.perform
40
+ end
41
+
27
42
  def document_delete(params = {})
28
43
  request = Ohmage::Request.new(self, :post, 'document/delete', params)
29
44
  request.perform
@@ -16,7 +16,7 @@ module Ohmage
16
16
  @request_method = request_method
17
17
  # some create/upload apis require content to be sent as multipart form. catch that here
18
18
  case api
19
- when 'document/create', 'survey/upload'
19
+ when 'document/create', 'survey/upload', 'document/update', 'campaign/create', 'campaign/update'
20
20
  @params = {form: @options}
21
21
  else
22
22
  @params = {params: @options}
@@ -14,7 +14,7 @@ module Ohmage
14
14
 
15
15
  # @return [Integer]
16
16
  def patch
17
- 10
17
+ 11
18
18
  end
19
19
 
20
20
  # @return [Integer, NilClass]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ohmage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Nolen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-04 00:00:00.000000000 Z
11
+ date: 2015-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -115,9 +115,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  version: 1.3.5
116
116
  requirements: []
117
117
  rubyforge_project:
118
- rubygems_version: 2.4.1
118
+ rubygems_version: 2.4.6
119
119
  signing_key:
120
120
  specification_version: 4
121
121
  summary: A Ruby interface for the ohmage 2.x API.
122
122
  test_files: []
123
- has_rdoc: