hookercookerman-amee 0.0.9 → 0.1.0

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.
@@ -9,4 +9,5 @@ Feature: Create Amee Profile Item
9
9
  # representation=full&energyConsumption=10&energyConsumptionUnit=kWh&dataItemUid=66056991EE23&energyConsumptionPerUnit=month&name=representation
10
10
  When I create a profile item with uid: "48B97680BEGG" the path: "/profiles/48B97680BCCF/home/energy/quantity"
11
11
 
12
- Then the location of the new should be: "whatever"
12
+ # need to redo
13
+ Then the profile item should have: "uid" with: "D47C465B8157"
@@ -19,21 +19,17 @@ Then(/^the profile item's (\S+) should not (?:be|have) (?:an? )?(.*)/) do |metho
19
19
  end
20
20
 
21
21
  When(/^I create a profile item with uid: \"(\S+)\" the path: \"(.*)\"/) do |uid, path|
22
- FakeWeb.register_uri(:post, "http://stage.amee.com#{path}?type=dontmatter&dataItemUid=48B97680BEGG",
23
- :response => File.join(AMEE_FIXTURE_PATH, "#{path.gsub(/^\//, "")}/response.json")
22
+ FakeWeb.register_uri(:post, "http://stage.amee.com#{path}?type=dontmatter&dataItemUid=48B97680BEGG&representation=full",
23
+ :file => File.join(AMEE_FIXTURE_PATH, "/profiles/155DD3C63646/transport/motorcycle/generic/D47C465B8157.json")
24
24
  )
25
- @models["create_profile_item"] = @amee_session.create_profile_item(path, uid, :fields => {:type => "dontmatter"})
26
- end
27
-
28
- Then(/^the location of the new should be: "(\S+)"/) do |value|
29
- @models["create_profile_item"].should == value
25
+ @models["profile_item"] = @amee_session.create_profile_item(path, uid, :fields => {:type => "dontmatter"})
30
26
  end
31
27
 
32
28
  When(/^I update the profile item with: distance=400$/) do
33
29
  FakeWeb.register_uri(:put, "http://stage.amee.com#{@models["profile_item"].full_path}?distance=400&representation=true",
34
30
  :file => File.join(AMEE_FIXTURE_PATH, "#{@models["profile_item"].full_path.gsub(/^\//, "")}?distance=400&representation=true.json")
35
31
  )
36
- @models["profile_item"] = @models["profile_item"].update(:distance => 400)
32
+ @models["profile_item"].update(:distance => 400)
37
33
  end
38
34
 
39
35
  Then(/^the profile item item_value: with name: \"Distance\" should have value: \"400\"$/) do
data/lib/amee.rb CHANGED
@@ -33,5 +33,5 @@ require "amee/profile_api/profile_category"
33
33
  require "amee/profile_api/profile"
34
34
 
35
35
  module Amee
36
- VERSION = '0.0.9'
36
+ VERSION = '0.1.0'
37
37
  end
@@ -19,8 +19,12 @@ module Amee
19
19
  self.from_hash(hash, session)
20
20
  end
21
21
 
22
- def update(fields)
23
- session.update_profile_item(self.full_path, :fields => fields)
22
+ def update(fields = {})
23
+ session.api_call(:put, "profile_item", self.full_path,
24
+ :query => fields.merge({:representation => true})) do |response|
25
+ populate_from_hash!(response)
26
+ end
27
+ self
24
28
  end
25
29
 
26
30
  def destroy
data/lib/amee/session.rb CHANGED
@@ -153,7 +153,7 @@ module Amee
153
153
  # @return [String] locaion of the new resource
154
154
  def create_profile_item(path, uid, options = {})
155
155
  @cache.clear
156
- api_call(:post, "create.profile_item", path,
156
+ api_call(:post, "profile_item", path,
157
157
  :query => {:dataItemUid => uid, :representation => "full"}.merge(options[:fields])) do |response|
158
158
  Amee::ProfileApi::ProfileItem.from_hash(response, self)
159
159
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hookercookerman-amee
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Hooker