Floppy-amee 2.0.18 → 2.0.19
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.
- data/lib/amee/data_category.rb +1 -1
- data/lib/amee/data_item.rb +2 -2
- data/lib/amee/item_definition.rb +6 -6
- data/lib/amee/profile.rb +2 -2
- data/lib/amee/profile_category.rb +9 -9
- data/lib/amee/profile_item.rb +24 -12
- data/lib/amee/profile_item_value.rb +3 -3
- data/lib/amee/version.rb +1 -1
- metadata +1 -1
data/lib/amee/data_category.rb
CHANGED
@@ -153,7 +153,7 @@ module AMEE
|
|
153
153
|
return location
|
154
154
|
end
|
155
155
|
rescue
|
156
|
-
raise AMEE::BadData.new("Couldn't create DataCategory. Check that your information is correct
|
156
|
+
raise AMEE::BadData.new("Couldn't create DataCategory. Check that your information is correct.\n#{response}")
|
157
157
|
end
|
158
158
|
|
159
159
|
def self.delete(connection, path)
|
data/lib/amee/data_item.rb
CHANGED
@@ -186,13 +186,13 @@ module AMEE
|
|
186
186
|
# return location
|
187
187
|
# end
|
188
188
|
rescue
|
189
|
-
raise AMEE::BadData.new("Couldn't create DataItem. Check that your information is correct
|
189
|
+
raise AMEE::BadData.new("Couldn't create DataItem. Check that your information is correct.\n#{response}")
|
190
190
|
end
|
191
191
|
|
192
192
|
def update(options = {})
|
193
193
|
response = connection.put(full_path, options).body
|
194
194
|
rescue
|
195
|
-
raise AMEE::BadData.new("Couldn't update DataItem. Check that your information is correct
|
195
|
+
raise AMEE::BadData.new("Couldn't update DataItem. Check that your information is correct.\n#{response}")
|
196
196
|
end
|
197
197
|
|
198
198
|
def value(name_or_path_or_uid)
|
data/lib/amee/item_definition.rb
CHANGED
@@ -37,7 +37,7 @@ module AMEE
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
rescue
|
40
|
-
raise AMEE::BadData.new("Couldn't load ItemDefinition list
|
40
|
+
raise AMEE::BadData.new("Couldn't load ItemDefinition list.\n#{response}")
|
41
41
|
end
|
42
42
|
|
43
43
|
attr_reader :pager
|
@@ -81,7 +81,7 @@ module AMEE
|
|
81
81
|
# Create object
|
82
82
|
ItemDefinition.new(data)
|
83
83
|
rescue
|
84
|
-
raise AMEE::BadData.new("Couldn't load ItemDefinition from JSON. Check that your URL is correct
|
84
|
+
raise AMEE::BadData.new("Couldn't load ItemDefinition from JSON. Check that your URL is correct.\n#{json}")
|
85
85
|
end
|
86
86
|
|
87
87
|
def self.from_xml(xml, is_list = true)
|
@@ -96,7 +96,7 @@ module AMEE
|
|
96
96
|
# Create object
|
97
97
|
ItemDefinition.new(data)
|
98
98
|
rescue
|
99
|
-
raise AMEE::BadData.new("Couldn't load ItemDefinition from XML. Check that your URL is correct
|
99
|
+
raise AMEE::BadData.new("Couldn't load ItemDefinition from XML. Check that your URL is correct.\n#{xml}")
|
100
100
|
end
|
101
101
|
|
102
102
|
def self.get(connection, path, options = {})
|
@@ -107,13 +107,13 @@ module AMEE
|
|
107
107
|
# Done
|
108
108
|
return item_definition
|
109
109
|
rescue
|
110
|
-
raise AMEE::BadData.new("Couldn't load ItemDefinition. Check that your URL is correct
|
110
|
+
raise AMEE::BadData.new("Couldn't load ItemDefinition. Check that your URL is correct.\n#{response}")
|
111
111
|
end
|
112
112
|
|
113
113
|
def update(options = {})
|
114
114
|
response = connection.put(full_path, options).body
|
115
115
|
rescue
|
116
|
-
raise AMEE::BadData.new("Couldn't update ItemDefinition. Check that your information is correct
|
116
|
+
raise AMEE::BadData.new("Couldn't update ItemDefinition. Check that your information is correct.\n#{response}")
|
117
117
|
end
|
118
118
|
|
119
119
|
def self.create(connection, options = {})
|
@@ -127,7 +127,7 @@ module AMEE
|
|
127
127
|
# Get the ItemDefinition again
|
128
128
|
return ItemDefinition.get(connection, "/definitions/itemDefinitions/" + item_definition.uid)
|
129
129
|
rescue
|
130
|
-
raise AMEE::BadData.new("Couldn't create ItemDefinition. Check that your information is correct
|
130
|
+
raise AMEE::BadData.new("Couldn't create ItemDefinition. Check that your information is correct.\n#{response}")
|
131
131
|
end
|
132
132
|
|
133
133
|
def self.delete(connection, item_definition)
|
data/lib/amee/profile.rb
CHANGED
@@ -42,7 +42,7 @@ module AMEE
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
rescue
|
45
|
-
raise AMEE::BadData.new("Couldn't load Profile list
|
45
|
+
raise AMEE::BadData.new("Couldn't load Profile list.\n#{response}")
|
46
46
|
end
|
47
47
|
|
48
48
|
attr_reader :pager
|
@@ -92,7 +92,7 @@ module AMEE
|
|
92
92
|
return profile
|
93
93
|
end
|
94
94
|
rescue
|
95
|
-
raise AMEE::BadData.new("Couldn't create Profile
|
95
|
+
raise AMEE::BadData.new("Couldn't create Profile.\n#{response}")
|
96
96
|
end
|
97
97
|
|
98
98
|
def self.delete(connection, uid)
|
@@ -115,7 +115,7 @@ module AMEE
|
|
115
115
|
# Create object
|
116
116
|
Category.new(data)
|
117
117
|
rescue
|
118
|
-
raise AMEE::BadData.new("Couldn't load ProfileCategory from JSON data. Check that your URL is correct
|
118
|
+
raise AMEE::BadData.new("Couldn't load ProfileCategory from JSON data. Check that your URL is correct.\n#{json}")
|
119
119
|
end
|
120
120
|
|
121
121
|
def self.from_v2_json(json, options)
|
@@ -144,7 +144,7 @@ module AMEE
|
|
144
144
|
# Create object
|
145
145
|
Category.new(data)
|
146
146
|
rescue
|
147
|
-
raise AMEE::BadData.new("Couldn't load ProfileCategory from V2 JSON data. Check that your URL is correct
|
147
|
+
raise AMEE::BadData.new("Couldn't load ProfileCategory from V2 JSON data. Check that your URL is correct.\n#{json}")
|
148
148
|
end
|
149
149
|
|
150
150
|
def self.parse_xml_profile_item(item)
|
@@ -188,7 +188,7 @@ module AMEE
|
|
188
188
|
end
|
189
189
|
return data
|
190
190
|
rescue
|
191
|
-
raise AMEE::BadData.new("Couldn't load ProfileCategory batch response from V2 JSON data. Check that your URL is correct
|
191
|
+
raise AMEE::BadData.new("Couldn't load ProfileCategory batch response from V2 JSON data. Check that your URL is correct.\n#{json}")
|
192
192
|
end
|
193
193
|
|
194
194
|
def self.parse_xml_profile_category(category)
|
@@ -251,7 +251,7 @@ module AMEE
|
|
251
251
|
# Create object
|
252
252
|
Category.new(data)
|
253
253
|
rescue
|
254
|
-
raise AMEE::BadData.new("Couldn't load ProfileCategory from XML data. Check that your URL is correct
|
254
|
+
raise AMEE::BadData.new("Couldn't load ProfileCategory from XML data. Check that your URL is correct.\n#{xml}")
|
255
255
|
end
|
256
256
|
|
257
257
|
def self.parse_v2_xml_profile_item(item)
|
@@ -327,7 +327,7 @@ module AMEE
|
|
327
327
|
# Create object
|
328
328
|
Category.new(data)
|
329
329
|
rescue
|
330
|
-
raise AMEE::BadData.new("Couldn't load ProfileCategory from V2 XML data. Check that your URL is correct
|
330
|
+
raise AMEE::BadData.new("Couldn't load ProfileCategory from V2 XML data. Check that your URL is correct.\n#{xml}")
|
331
331
|
end
|
332
332
|
|
333
333
|
def self.from_v2_batch_xml(xml)
|
@@ -343,7 +343,7 @@ module AMEE
|
|
343
343
|
end
|
344
344
|
return data
|
345
345
|
rescue
|
346
|
-
raise AMEE::BadData.new("Couldn't load ProfileCategory batch response from V2 XML data. Check that your URL is correct
|
346
|
+
raise AMEE::BadData.new("Couldn't load ProfileCategory batch response from V2 XML data. Check that your URL is correct.\n#{xml}")
|
347
347
|
end
|
348
348
|
|
349
349
|
def self.from_v2_atom(response, options)
|
@@ -398,7 +398,7 @@ module AMEE
|
|
398
398
|
# Create object
|
399
399
|
Category.new(data)
|
400
400
|
rescue
|
401
|
-
raise AMEE::BadData.new("Couldn't load ProfileCategory from V2 Atom data. Check that your URL is correct
|
401
|
+
raise AMEE::BadData.new("Couldn't load ProfileCategory from V2 Atom data. Check that your URL is correct.\n#{response}")
|
402
402
|
end
|
403
403
|
|
404
404
|
def self.get_history(connection, path, num_months, end_date = Date.today, items_per_page = 10)
|
@@ -451,7 +451,7 @@ module AMEE
|
|
451
451
|
elsif response.is_v2_xml?
|
452
452
|
return Category.from_v2_batch_xml(response)
|
453
453
|
else
|
454
|
-
return self.parse(connection, response)
|
454
|
+
return self.parse(connection, response, nil)
|
455
455
|
end
|
456
456
|
end
|
457
457
|
|
@@ -475,7 +475,7 @@ module AMEE
|
|
475
475
|
response = connection.get(path, options).body
|
476
476
|
return Category.parse(connection, response, options)
|
477
477
|
rescue
|
478
|
-
raise AMEE::BadData.new("Couldn't load ProfileCategory. Check that your URL is correct
|
478
|
+
raise AMEE::BadData.new("Couldn't load ProfileCategory. Check that your URL is correct.\n#{response}")
|
479
479
|
end
|
480
480
|
|
481
481
|
def child(child_path)
|
data/lib/amee/profile_item.rb
CHANGED
@@ -58,7 +58,7 @@ module AMEE
|
|
58
58
|
# Create object
|
59
59
|
Item.new(data)
|
60
60
|
rescue
|
61
|
-
raise AMEE::BadData.new("Couldn't load ProfileItem from JSON data. Check that your URL is correct
|
61
|
+
raise AMEE::BadData.new("Couldn't load ProfileItem from JSON data. Check that your URL is correct.\n#{json}")
|
62
62
|
end
|
63
63
|
|
64
64
|
def self.from_v2_json(json)
|
@@ -90,7 +90,7 @@ module AMEE
|
|
90
90
|
# Create object
|
91
91
|
Item.new(data)
|
92
92
|
rescue
|
93
|
-
raise AMEE::BadData.new("Couldn't load ProfileItem from V2 JSON data. Check that your URL is correct
|
93
|
+
raise AMEE::BadData.new("Couldn't load ProfileItem from V2 JSON data. Check that your URL is correct.\n#{json}")
|
94
94
|
end
|
95
95
|
|
96
96
|
def self.from_xml(xml)
|
@@ -123,7 +123,7 @@ module AMEE
|
|
123
123
|
# Create object
|
124
124
|
Item.new(data)
|
125
125
|
rescue
|
126
|
-
raise AMEE::BadData.new("Couldn't load ProfileItem from XML data. Check that your URL is correct
|
126
|
+
raise AMEE::BadData.new("Couldn't load ProfileItem from XML data. Check that your URL is correct.\n#{xml}")
|
127
127
|
end
|
128
128
|
|
129
129
|
def self.from_v2_xml(xml)
|
@@ -158,7 +158,7 @@ module AMEE
|
|
158
158
|
# Create object
|
159
159
|
Item.new(data)
|
160
160
|
rescue
|
161
|
-
raise AMEE::BadData.new("Couldn't load ProfileItem from V2 XML data. Check that your URL is correct
|
161
|
+
raise AMEE::BadData.new("Couldn't load ProfileItem from V2 XML data. Check that your URL is correct.\n#{xml}")
|
162
162
|
end
|
163
163
|
|
164
164
|
def self.from_v2_atom(response)
|
@@ -187,7 +187,7 @@ module AMEE
|
|
187
187
|
# Create object
|
188
188
|
Item.new(data)
|
189
189
|
rescue
|
190
|
-
raise AMEE::BadData.new("Couldn't load ProfileItem from V2 ATOM data. Check that your URL is correct
|
190
|
+
raise AMEE::BadData.new("Couldn't load ProfileItem from V2 ATOM data. Check that your URL is correct.\n#{response}")
|
191
191
|
end
|
192
192
|
|
193
193
|
def self.parse(connection, response)
|
@@ -231,7 +231,7 @@ module AMEE
|
|
231
231
|
response = connection.get(path, options).body
|
232
232
|
return Item.parse(connection, response)
|
233
233
|
rescue
|
234
|
-
raise AMEE::BadData.new("Couldn't load ProfileItem. Check that your URL is correct
|
234
|
+
raise AMEE::BadData.new("Couldn't load ProfileItem. Check that your URL is correct.\n#{response}")
|
235
235
|
end
|
236
236
|
|
237
237
|
def self.create(category, data_item_uid, options = {})
|
@@ -253,11 +253,9 @@ module AMEE
|
|
253
253
|
elsif options[:start_date] && connection.version >= 2
|
254
254
|
options[:startDate] = options[:start_date].xmlschema
|
255
255
|
end
|
256
|
-
options.delete(:start_date)
|
257
256
|
if options[:end_date] && connection.version >= 2
|
258
257
|
options[:endDate] = options[:end_date].xmlschema
|
259
258
|
end
|
260
|
-
options.delete(:end_date)
|
261
259
|
if options[:duration] && connection.version >= 2
|
262
260
|
options[:duration] = "PT#{options[:duration] * 86400}S"
|
263
261
|
end
|
@@ -267,7 +265,7 @@ module AMEE
|
|
267
265
|
if response['Location']
|
268
266
|
location = response['Location'].match("http://.*?(/.*)")[1]
|
269
267
|
else
|
270
|
-
category = Category.parse(connection, response.body)
|
268
|
+
category = Category.parse(connection, response.body, nil)
|
271
269
|
location = category.full_path + "/" + category.items[0][:path]
|
272
270
|
end
|
273
271
|
if get_item == true
|
@@ -280,7 +278,7 @@ module AMEE
|
|
280
278
|
return location
|
281
279
|
end
|
282
280
|
rescue
|
283
|
-
raise AMEE::BadData.new("Couldn't create ProfileItem. Check that your information is correct
|
281
|
+
raise AMEE::BadData.new("Couldn't create ProfileItem. Check that your information is correct.\n#{response}")
|
284
282
|
end
|
285
283
|
|
286
284
|
def self.create_batch(category, items, options = {})
|
@@ -309,6 +307,20 @@ module AMEE
|
|
309
307
|
# Do we want to automatically fetch the item afterwards?
|
310
308
|
get_item = options.delete(:get_item)
|
311
309
|
get_item = true if get_item.nil?
|
310
|
+
# Set dates
|
311
|
+
if options[:start_date] && connection.version < 2
|
312
|
+
options[:validFrom] = options[:start_date].amee1_date
|
313
|
+
elsif options[:start_date] && connection.version >= 2
|
314
|
+
options[:startDate] = options[:start_date].xmlschema
|
315
|
+
end
|
316
|
+
options.delete(:start_date)
|
317
|
+
if options[:end_date] && connection.version >= 2
|
318
|
+
options[:endDate] = options[:end_date].xmlschema
|
319
|
+
end
|
320
|
+
options.delete(:end_date)
|
321
|
+
if options[:duration] && connection.version >= 2
|
322
|
+
options[:duration] = "PT#{options[:duration] * 86400}S"
|
323
|
+
end
|
312
324
|
# Go
|
313
325
|
response = connection.put(path, options)
|
314
326
|
if get_item
|
@@ -319,7 +331,7 @@ module AMEE
|
|
319
331
|
end
|
320
332
|
end
|
321
333
|
rescue
|
322
|
-
raise AMEE::BadData.new("Couldn't update ProfileItem. Check that your information is correct
|
334
|
+
raise AMEE::BadData.new("Couldn't update ProfileItem. Check that your information is correct.\n#{response}")
|
323
335
|
end
|
324
336
|
|
325
337
|
def update(options = {})
|
@@ -340,7 +352,7 @@ module AMEE
|
|
340
352
|
response = connection.raw_put(category_path, put_data).body
|
341
353
|
# Send back a category object containing all the created items
|
342
354
|
unless response.empty?
|
343
|
-
return AMEE::Profile::Category.parse(connection, response)
|
355
|
+
return AMEE::Profile::Category.parse(connection, response, nil)
|
344
356
|
else
|
345
357
|
return true
|
346
358
|
end
|
@@ -53,7 +53,7 @@ module AMEE
|
|
53
53
|
# Create object
|
54
54
|
ItemValue.new(data)
|
55
55
|
rescue
|
56
|
-
raise AMEE::BadData.new("Couldn't load ProfileItemValue from JSON. Check that your URL is correct
|
56
|
+
raise AMEE::BadData.new("Couldn't load ProfileItemValue from JSON. Check that your URL is correct.\n#{json}")
|
57
57
|
end
|
58
58
|
|
59
59
|
def self.from_xml(xml, path)
|
@@ -74,7 +74,7 @@ module AMEE
|
|
74
74
|
# Create object
|
75
75
|
ItemValue.new(data)
|
76
76
|
rescue
|
77
|
-
raise AMEE::BadData.new("Couldn't load ProfileItemValue from XML. Check that your URL is correct
|
77
|
+
raise AMEE::BadData.new("Couldn't load ProfileItemValue from XML. Check that your URL is correct.\n#{xml}")
|
78
78
|
end
|
79
79
|
|
80
80
|
def self.get(connection, path)
|
@@ -91,7 +91,7 @@ module AMEE
|
|
91
91
|
# Done
|
92
92
|
return value
|
93
93
|
rescue
|
94
|
-
raise AMEE::BadData.new("Couldn't load ProfileItemValue. Check that your URL is correct
|
94
|
+
raise AMEE::BadData.new("Couldn't load ProfileItemValue. Check that your URL is correct.\n#{response}")
|
95
95
|
end
|
96
96
|
|
97
97
|
def save!
|
data/lib/amee/version.rb
CHANGED