lib/amee/profile_item.rb in Floppy-amee-0.4.21 vs lib/amee/profile_item.rb in Floppy-amee-0.4.22
- old
+ new
@@ -76,36 +76,42 @@
Item.new(data)
rescue
raise AMEE::BadData.new("Couldn't load ProfileItem from XML data. Check that your URL is correct.")
end
- def self.get(connection, path, for_date = Date.today)
- # Load data from path
- response = connection.get(path, :profileDate => for_date.strftime("%Y%m"))
+ def self.parse(connection, response)
# Parse data from response
if response.is_json?
cat = Item.from_json(response)
else
cat = Item.from_xml(response)
end
# Store connection in object for future use
cat.connection = connection
# Done
return cat
+ end
+
+ def self.get(connection, path, for_date = Date.today)
+ # Load data from path
+ response = connection.get(path, :profileDate => for_date.strftime("%Y%m"))
+ return Item.parse(connection, response)
rescue
raise AMEE::BadData.new("Couldn't load ProfileItem. Check that your URL is correct.")
end
def self.create(profile, data_item_uid, options = {})
# Send data to path
options.merge! :dataItemUid => data_item_uid
- profile.connection.post(profile.full_path, options)
+ response = profile.connection.post(profile.full_path, options)
+ return Item.parse(profile.connection, response)
rescue
raise AMEE::BadData.new("Couldn't create ProfileItem. Check that your information is correct.")
end
def update(options = {})
connection.put(full_path, options)
+ return Item.parse(connection, response)
rescue
raise AMEE::BadData.new("Couldn't update ProfileItem. Check that your information is correct.")
end
def self.delete(connection, path)