homeflow_api 0.14.4 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -23,7 +23,7 @@ GEM
23
23
  metaclass (~> 0.0.1)
24
24
  multi_json (1.4.0)
25
25
  multi_xml (0.5.1)
26
- rake (10.0.2)
26
+ rake (10.0.4)
27
27
  rspec (2.12.0)
28
28
  rspec-core (~> 2.12.0)
29
29
  rspec-expectations (~> 2.12.0)
data/README.rdoc CHANGED
@@ -9,8 +9,8 @@ The homeflow_api gem provides homeflow api v2 functions from ruby. This is alpha
9
9
  * Fork the project
10
10
  * Start a feature/bugfix branch
11
11
  * Commit and push until you are happy with your contribution
12
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
12
+ * Make sure to add tests for it. This is important so we don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or it is otherwise necessary, that is fine, but please isolate to its own commit so we can cherry-pick around it.
14
14
 
15
15
  == Copyright
16
16
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.14.4
1
+ 0.16.0
data/homeflow_api.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "homeflow_api"
8
- s.version = "0.14.4"
8
+ s.version = "0.16.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Daniel Cooper"]
12
- s.date = "2013-03-14"
12
+ s.date = "2013-07-04"
13
13
  s.description = "A gem for dealing the homeflow api"
14
14
  s.email = "daniel@homeflow.co.uk"
15
15
  s.extra_rdoc_files = [
data/lib/homeflow/api.rb CHANGED
@@ -61,13 +61,14 @@ module Homeflow
61
61
 
62
62
  # A configuration instance
63
63
  class Configuration
64
- attr_accessor :api_key, :source
64
+ attr_accessor :api_key, :source, :show_debug
65
65
 
66
66
  def initialize
67
67
  @api_key = 'API_KEY_REQUIRED'
68
68
  @source = 'http://localhost:3000'
69
+ @show_debug = false
69
70
  end
70
71
  end
71
72
 
72
73
  end
73
- end
74
+ end
@@ -3,6 +3,22 @@ module Homeflow
3
3
  module API
4
4
  class Put < Post
5
5
 
6
+ attr_accessor :resource_uri
7
+
8
+ def initialize(resource_uri, params = {}, put_params = {})
9
+ @resource_uri = resource_uri
10
+ @params = params
11
+ @put_params = put_params
12
+ end
13
+
14
+ def post_params
15
+ @put_params
16
+ end
17
+
18
+ def to_params
19
+ @params
20
+ end
21
+
6
22
  end
7
23
  end
8
24
  end
@@ -20,15 +20,34 @@ module Homeflow
20
20
 
21
21
  def perform_request
22
22
  if request_specification.is_a? Query
23
- return (HTTParty.get("#{Homeflow::API.config.source}/#{request_specification.resource_class.resource_uri}", :query => @request_specification.to_params.merge(constant_params))).body
23
+ url = "#{Homeflow::API.config.source}/#{request_specification.resource_class.resource_uri}"
24
+ else
25
+ url = "#{Homeflow::API.config.source}/#{request_specification.resource_uri}"
26
+ end
27
+ query_params = @request_specification.to_params.merge(constant_params)
28
+ post_params = @request_specification.post_params
29
+ if Homeflow::API.config.show_debug
30
+ puts "****************************************************************************************"
31
+ puts "HESTIA CALL"
32
+ puts "==========="
33
+ puts "Destination" - url
34
+ puts "Request params:\n#{query_params.to_json}\n"
35
+ puts "Post params:\n#{post_params.to_json}\n"
36
+ puts "request_specification:\n#{request_specification.to_json}\n"
37
+ puts "@request_specification:\n#{@request_specification.to_json}\n"
38
+ puts "****************************************************************************************"
39
+ end
40
+
41
+ if request_specification.is_a? Query
42
+ return (HTTParty.get (url, :query => query)).body
24
43
  elsif request_specification.is_a? ResourceIdentifier
25
- return (HTTParty.get("#{Homeflow::API.config.source}/#{request_specification.resource_uri}", :query => @request_specification.to_params.merge(constant_params))).body
44
+ return (HTTParty.get (url, :query => query)).body
26
45
  elsif request_specification.is_a? Delete
27
- return (HTTParty.delete("#{Homeflow::API.config.source}/#{request_specification.resource_uri}", :query => @request_specification.to_params.merge(constant_params))).body
46
+ return (HTTParty.delete(url, :query => query)).body
28
47
  elsif request_specification.is_a? Put
29
- return (HTTParty.put("#{Homeflow::API.config.source}/#{request_specification.resource_uri}", :query => @request_specification.to_params.merge(constant_params), :body => @request_specification.post_params)).body
48
+ return (HTTParty.put (url, :query => query, :body => post_params)).body
30
49
  elsif request_specification.is_a? Post
31
- return (HTTParty.post("#{Homeflow::API.config.source}/#{request_specification.resource_uri}", :query => @request_specification.to_params.merge(constant_params), :body => @request_specification.post_params)).body
50
+ return (HTTParty.post (url, :query => query, :body => post_params)).body
32
51
  end
33
52
  end
34
53
 
@@ -8,6 +8,9 @@ module Homeflow
8
8
  Request.run_for(Homeflow::API::Post.new("/#{resource_uri}/", {}, params))
9
9
  end
10
10
 
11
+ def self.update(id, params)
12
+ Request.run_for(Homeflow::API::Put.new("/#{resource_uri}/#{id}", {}, params))
13
+ end
11
14
 
12
15
  end
13
16
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: homeflow_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.4
4
+ version: 0.16.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-14 00:00:00.000000000 Z
12
+ date: 2013-07-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: hashie
@@ -177,7 +177,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
177
177
  version: '0'
178
178
  segments:
179
179
  - 0
180
- hash: -2190708412302486509
180
+ hash: 3908852289382539102
181
181
  required_rubygems_version: !ruby/object:Gem::Requirement
182
182
  none: false
183
183
  requirements: