homeflow_api 0.14.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +19 -0
- data/Gemfile.lock +55 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +46 -0
- data/VERSION +1 -0
- data/homeflow_api.gemspec +100 -0
- data/lib/homeflow/api.rb +72 -0
- data/lib/homeflow/api/agency.rb +9 -0
- data/lib/homeflow/api/branch.rb +9 -0
- data/lib/homeflow/api/collection.rb +22 -0
- data/lib/homeflow/api/county.rb +10 -0
- data/lib/homeflow/api/delete.rb +19 -0
- data/lib/homeflow/api/exceptions.rb +17 -0
- data/lib/homeflow/api/favourite_property.rb +13 -0
- data/lib/homeflow/api/lead.rb +13 -0
- data/lib/homeflow/api/location.rb +19 -0
- data/lib/homeflow/api/message.rb +13 -0
- data/lib/homeflow/api/password_reset.rb +13 -0
- data/lib/homeflow/api/place.rb +13 -0
- data/lib/homeflow/api/portal.rb +13 -0
- data/lib/homeflow/api/post.rb +24 -0
- data/lib/homeflow/api/postcode.rb +9 -0
- data/lib/homeflow/api/property.rb +10 -0
- data/lib/homeflow/api/put.rb +8 -0
- data/lib/homeflow/api/query.rb +85 -0
- data/lib/homeflow/api/queryable.rb +27 -0
- data/lib/homeflow/api/request.rb +48 -0
- data/lib/homeflow/api/request_specification.rb +11 -0
- data/lib/homeflow/api/resource.rb +27 -0
- data/lib/homeflow/api/resource_identifier.rb +19 -0
- data/lib/homeflow/api/response.rb +108 -0
- data/lib/homeflow/api/search.rb +14 -0
- data/lib/homeflow/api/session.rb +13 -0
- data/lib/homeflow/api/site.rb +9 -0
- data/lib/homeflow/api/site_page.rb +17 -0
- data/lib/homeflow/api/user.rb +21 -0
- data/spec/data/example_search_response.json +1 -0
- data/spec/data/invalid_api_key.json +1 -0
- data/spec/data/property_details.json +1 -0
- data/spec/data/with_alt_places.json +2 -0
- data/spec/homeflow_api_spec.rb +22 -0
- data/spec/query_spec.rb +38 -0
- data/spec/response_spec.rb +46 -0
- data/spec/spec_helper.rb +3 -0
- metadata +192 -0
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
# Add dependencies to develop your gem here.
|
4
|
+
# Include everything needed to run rake, tests, features, etc.
|
5
|
+
group :development do
|
6
|
+
gem "shoulda", ">= 0"
|
7
|
+
gem "bundler"
|
8
|
+
gem "jeweler", "~> 1.6.4"
|
9
|
+
end
|
10
|
+
|
11
|
+
gem "hashie", "~> 1.1"
|
12
|
+
gem "json"
|
13
|
+
gem "httparty"
|
14
|
+
|
15
|
+
group :test do
|
16
|
+
gem 'test-unit'
|
17
|
+
gem 'shoulda'
|
18
|
+
gem "rspec"
|
19
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (3.2.9)
|
5
|
+
i18n (~> 0.6)
|
6
|
+
multi_json (~> 1.0)
|
7
|
+
bourne (1.1.2)
|
8
|
+
mocha (= 0.10.5)
|
9
|
+
diff-lcs (1.1.3)
|
10
|
+
git (1.2.5)
|
11
|
+
hashie (1.2.0)
|
12
|
+
httparty (0.9.0)
|
13
|
+
multi_json (~> 1.0)
|
14
|
+
multi_xml
|
15
|
+
i18n (0.6.1)
|
16
|
+
jeweler (1.6.4)
|
17
|
+
bundler (~> 1.0)
|
18
|
+
git (>= 1.2.5)
|
19
|
+
rake
|
20
|
+
json (1.7.5)
|
21
|
+
metaclass (0.0.1)
|
22
|
+
mocha (0.10.5)
|
23
|
+
metaclass (~> 0.0.1)
|
24
|
+
multi_json (1.4.0)
|
25
|
+
multi_xml (0.5.1)
|
26
|
+
rake (10.0.2)
|
27
|
+
rspec (2.12.0)
|
28
|
+
rspec-core (~> 2.12.0)
|
29
|
+
rspec-expectations (~> 2.12.0)
|
30
|
+
rspec-mocks (~> 2.12.0)
|
31
|
+
rspec-core (2.12.1)
|
32
|
+
rspec-expectations (2.12.0)
|
33
|
+
diff-lcs (~> 1.1.3)
|
34
|
+
rspec-mocks (2.12.0)
|
35
|
+
shoulda (3.3.2)
|
36
|
+
shoulda-context (~> 1.0.1)
|
37
|
+
shoulda-matchers (~> 1.4.1)
|
38
|
+
shoulda-context (1.0.1)
|
39
|
+
shoulda-matchers (1.4.2)
|
40
|
+
activesupport (>= 3.0.0)
|
41
|
+
bourne (~> 1.1.2)
|
42
|
+
test-unit (2.5.3)
|
43
|
+
|
44
|
+
PLATFORMS
|
45
|
+
ruby
|
46
|
+
|
47
|
+
DEPENDENCIES
|
48
|
+
bundler
|
49
|
+
hashie (~> 1.1)
|
50
|
+
httparty
|
51
|
+
jeweler (~> 1.6.4)
|
52
|
+
json
|
53
|
+
rspec
|
54
|
+
shoulda
|
55
|
+
test-unit
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Homeflow
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= homeflow_api
|
2
|
+
|
3
|
+
The homeflow_api gem provides homeflow api v2 functions from ruby. This is alpha quality software and is in active development.
|
4
|
+
|
5
|
+
== Contributing to homeflow_api
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
+
* Fork the project
|
10
|
+
* Start a feature/bugfix branch
|
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.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2011 Homeflow. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "homeflow_api"
|
18
|
+
gem.homepage = "http://github.com/homeflow/Homeflow_Api"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Homeflow API Gem}
|
21
|
+
gem.description = %Q{A gem for dealing the homeflow api}
|
22
|
+
gem.email = "daniel@homeflow.co.uk"
|
23
|
+
gem.authors = ["Daniel Cooper"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
task :default => :test
|
37
|
+
|
38
|
+
require 'rdoc/task'
|
39
|
+
Rake::RDocTask.new do |rdoc|
|
40
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
41
|
+
|
42
|
+
rdoc.rdoc_dir = 'rdoc'
|
43
|
+
rdoc.title = "homeflow_api #{version}"
|
44
|
+
rdoc.rdoc_files.include('README*')
|
45
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
46
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.14.3
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "homeflow_api"
|
8
|
+
s.version = "0.14.3"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Daniel Cooper"]
|
12
|
+
s.date = "2013-03-06"
|
13
|
+
s.description = "A gem for dealing the homeflow api"
|
14
|
+
s.email = "daniel@homeflow.co.uk"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
"Gemfile",
|
22
|
+
"Gemfile.lock",
|
23
|
+
"LICENSE.txt",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"homeflow_api.gemspec",
|
28
|
+
"lib/homeflow/api.rb",
|
29
|
+
"lib/homeflow/api/agency.rb",
|
30
|
+
"lib/homeflow/api/branch.rb",
|
31
|
+
"lib/homeflow/api/collection.rb",
|
32
|
+
"lib/homeflow/api/county.rb",
|
33
|
+
"lib/homeflow/api/delete.rb",
|
34
|
+
"lib/homeflow/api/exceptions.rb",
|
35
|
+
"lib/homeflow/api/favourite_property.rb",
|
36
|
+
"lib/homeflow/api/lead.rb",
|
37
|
+
"lib/homeflow/api/location.rb",
|
38
|
+
"lib/homeflow/api/message.rb",
|
39
|
+
"lib/homeflow/api/password_reset.rb",
|
40
|
+
"lib/homeflow/api/place.rb",
|
41
|
+
"lib/homeflow/api/portal.rb",
|
42
|
+
"lib/homeflow/api/post.rb",
|
43
|
+
"lib/homeflow/api/postcode.rb",
|
44
|
+
"lib/homeflow/api/property.rb",
|
45
|
+
"lib/homeflow/api/put.rb",
|
46
|
+
"lib/homeflow/api/query.rb",
|
47
|
+
"lib/homeflow/api/queryable.rb",
|
48
|
+
"lib/homeflow/api/request.rb",
|
49
|
+
"lib/homeflow/api/request_specification.rb",
|
50
|
+
"lib/homeflow/api/resource.rb",
|
51
|
+
"lib/homeflow/api/resource_identifier.rb",
|
52
|
+
"lib/homeflow/api/response.rb",
|
53
|
+
"lib/homeflow/api/search.rb",
|
54
|
+
"lib/homeflow/api/session.rb",
|
55
|
+
"lib/homeflow/api/site.rb",
|
56
|
+
"lib/homeflow/api/site_page.rb",
|
57
|
+
"lib/homeflow/api/user.rb",
|
58
|
+
"spec/data/example_search_response.json",
|
59
|
+
"spec/data/invalid_api_key.json",
|
60
|
+
"spec/data/property_details.json",
|
61
|
+
"spec/data/with_alt_places.json",
|
62
|
+
"spec/homeflow_api_spec.rb",
|
63
|
+
"spec/query_spec.rb",
|
64
|
+
"spec/response_spec.rb",
|
65
|
+
"spec/spec_helper.rb"
|
66
|
+
]
|
67
|
+
s.homepage = "http://github.com/homeflow/Homeflow_Api"
|
68
|
+
s.licenses = ["MIT"]
|
69
|
+
s.require_paths = ["lib"]
|
70
|
+
s.rubygems_version = "1.8.24"
|
71
|
+
s.summary = "Homeflow API Gem"
|
72
|
+
|
73
|
+
if s.respond_to? :specification_version then
|
74
|
+
s.specification_version = 3
|
75
|
+
|
76
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
77
|
+
s.add_runtime_dependency(%q<hashie>, ["~> 1.1"])
|
78
|
+
s.add_runtime_dependency(%q<json>, [">= 0"])
|
79
|
+
s.add_runtime_dependency(%q<httparty>, [">= 0"])
|
80
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
81
|
+
s.add_development_dependency(%q<bundler>, [">= 0"])
|
82
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
83
|
+
else
|
84
|
+
s.add_dependency(%q<hashie>, ["~> 1.1"])
|
85
|
+
s.add_dependency(%q<json>, [">= 0"])
|
86
|
+
s.add_dependency(%q<httparty>, [">= 0"])
|
87
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
88
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
89
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
90
|
+
end
|
91
|
+
else
|
92
|
+
s.add_dependency(%q<hashie>, ["~> 1.1"])
|
93
|
+
s.add_dependency(%q<json>, [">= 0"])
|
94
|
+
s.add_dependency(%q<httparty>, [">= 0"])
|
95
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
96
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
97
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
data/lib/homeflow/api.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'hashie/mash'
|
2
|
+
require 'json'
|
3
|
+
require 'httparty'
|
4
|
+
|
5
|
+
current_dir = File.expand_path(File.dirname(__FILE__))
|
6
|
+
|
7
|
+
require current_dir + "/api/request"
|
8
|
+
require current_dir + "/api/queryable"
|
9
|
+
require current_dir + "/api/resource"
|
10
|
+
require current_dir + "/api/collection"
|
11
|
+
require current_dir + "/api/request_specification"
|
12
|
+
require current_dir + "/api/resource_identifier"
|
13
|
+
require current_dir + "/api/post"
|
14
|
+
require current_dir + "/api/put"
|
15
|
+
require current_dir + "/api/delete"
|
16
|
+
require current_dir + "/api/query"
|
17
|
+
require current_dir + "/api/exceptions"
|
18
|
+
|
19
|
+
require current_dir + "/api/search"
|
20
|
+
require current_dir + "/api/property"
|
21
|
+
require current_dir + "/api/county"
|
22
|
+
require current_dir + "/api/location"
|
23
|
+
require current_dir + "/api/place"
|
24
|
+
require current_dir + "/api/agency"
|
25
|
+
require current_dir + "/api/password_reset"
|
26
|
+
require current_dir + "/api/branch"
|
27
|
+
require current_dir + "/api/user"
|
28
|
+
require current_dir + "/api/session"
|
29
|
+
require current_dir + "/api/lead"
|
30
|
+
require current_dir + "/api/portal"
|
31
|
+
require current_dir + "/api/postcode"
|
32
|
+
require current_dir + "/api/site"
|
33
|
+
require current_dir + '/api/site_page'
|
34
|
+
require current_dir + '/api/message'
|
35
|
+
require current_dir + "/api/favourite_property"
|
36
|
+
require current_dir + "/api/response"
|
37
|
+
|
38
|
+
|
39
|
+
module Homeflow
|
40
|
+
module API
|
41
|
+
|
42
|
+
class << self
|
43
|
+
attr_accessor :configuration
|
44
|
+
end
|
45
|
+
|
46
|
+
# Gets or create a new configuration instance
|
47
|
+
def self.config
|
48
|
+
self.configuration ||= Configuration.new
|
49
|
+
end
|
50
|
+
|
51
|
+
# Provides a block allowing for eacy configuration
|
52
|
+
# ==== Examples
|
53
|
+
# Homeflow::API.configure do |config|
|
54
|
+
# config.api_key = "Your api key here"
|
55
|
+
# end
|
56
|
+
#
|
57
|
+
def self.configure
|
58
|
+
yield(config)
|
59
|
+
end
|
60
|
+
|
61
|
+
# A configuration instance
|
62
|
+
class Configuration
|
63
|
+
attr_accessor :api_key, :source
|
64
|
+
|
65
|
+
def initialize
|
66
|
+
@api_key = 'API_KEY_REQUIRED'
|
67
|
+
@source = 'http://localhost:3000'
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#This module contains class methods used when building up querys on resources. Think index?
|
2
|
+
module Homeflow
|
3
|
+
module API
|
4
|
+
class Collection < Array
|
5
|
+
|
6
|
+
def initialize(collection_response, klass)
|
7
|
+
@has_next_page = collection_response["has_next"]
|
8
|
+
@total = collection_response["total"]
|
9
|
+
collection_response["elements"].each{|element| self << klass.new(element)}
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
def has_next_page?
|
14
|
+
@has_next_page
|
15
|
+
end
|
16
|
+
|
17
|
+
def total
|
18
|
+
@total
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#This module contains class methods used when building up querys on resources. Think index?
|
2
|
+
module Homeflow
|
3
|
+
module API
|
4
|
+
class Delete < RequestSpecification
|
5
|
+
|
6
|
+
attr_accessor :resource_uri
|
7
|
+
|
8
|
+
def initialize(resource_uri, params = {})
|
9
|
+
@resource_uri = resource_uri
|
10
|
+
@params = params
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_params
|
14
|
+
@params
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Homeflow
|
2
|
+
module API
|
3
|
+
module Exceptions
|
4
|
+
class InvalidResponse < StandardError; end
|
5
|
+
class UnknownAPIError < StandardError; end
|
6
|
+
class APIArgumentError < StandardError; end
|
7
|
+
class APIConnectionError < StandardError; end
|
8
|
+
|
9
|
+
class ExceptionsList
|
10
|
+
def self.list
|
11
|
+
[InvalidResponse,APIArgumentError,UnknownAPIError]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|