nestoria 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/nestoria/api.rb +28 -28
  3. data/nestoria.gemspec +1 -1
  4. metadata +98 -108
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
@@ -10,45 +10,45 @@ class Hash
10
10
  end
11
11
 
12
12
  module Nestoria
13
-
13
+
14
14
  class BadLocation < StandardError; end
15
15
  class InvalidRequest < StandardError; end
16
16
  class InternalError < StandardError; end
17
17
  class InvalidVersion < StandardError; end
18
-
18
+
19
19
  class Api
20
-
21
- API_VERSION = 1.19
22
-
20
+
21
+ API_VERSION = 1.21
22
+
23
23
  # Valid search parameters - See http://www.nestoria.co.uk/help/api-search-listings for key/value details
24
24
  LOCATION_KEYS = [ :place_name, :south_west, :north_east, :centre_point, :radius ]
25
- SEARCH_KEYS = [ :guid, :listing_type, :property_type, :min_price, :max_price,
26
- :bedroom_min, :bedroom_max, :room_min, :room_max, :bathroom_min, :bathroom_max,
27
- :size_min, :size_max, :keywords, :keywords_exclude, :has_photo, :updated_min,
25
+ SEARCH_KEYS = [ :guid, :listing_type, :property_type, :price_min, :price_max,
26
+ :bedroom_min, :bedroom_max, :room_min, :room_max, :bathroom_min, :bathroom_max,
27
+ :size_min, :size_max, :keywords, :keywords_exclude, :has_photo, :updated_min,
28
28
  :number_of_results, :page, :sort ] + LOCATION_KEYS
29
-
29
+
30
30
  def initialize(country)
31
31
  @country = country
32
32
  end
33
-
33
+
34
34
  # Search nestoria property listings - See http://www.nestoria.co.uk/help/api-search-listings
35
- def search(params)
35
+ def search(params)
36
36
  invalid_keys = params.keys - SEARCH_KEYS
37
37
  raise InvalidRequest.new "Invalid keys: #{invalid_keys.join(", ")}" unless invalid_keys.empty?
38
-
38
+
39
39
  # Convert arrays into CSVs
40
40
  [:keywords, :keywords_exclude].each do |key|
41
41
  params[key] = params[key].join(",") unless params[key].nil?
42
42
  end
43
-
43
+
44
44
  # Convert any Time/DateTime objects to UNIX time integers
45
45
  params[:updated_min] = params[:updated_min].to_i unless params[:updated_min].nil?
46
-
46
+
47
47
  process_location! params
48
-
48
+
49
49
  request :search_listings, params
50
50
  end
51
-
51
+
52
52
  # List of keywords that can be used in search - See http://www.nestoria.co.uk/help/api-keywords
53
53
  def keywords
54
54
  response = request :keywords
@@ -58,24 +58,24 @@ module Nestoria
58
58
  end
59
59
  keywords
60
60
  end
61
-
61
+
62
62
  # Average house price for an area - See http://www.nestoria.co.uk/help/api-metadata
63
63
  def metadata(params)
64
64
  invalid_keys = params.keys - LOCATION_KEYS
65
65
  raise InvalidRequest.new "Invalid keys: #{invalid_keys.join(", ")}" unless invalid_keys.empty?
66
-
66
+
67
67
  process_location! params
68
-
68
+
69
69
  request :metadata, params
70
70
  end
71
-
71
+
72
72
  # Test URL request, returns whatever params you put in
73
73
  def echo(params = {:foo => "bar"})
74
74
  request :echo, params
75
75
  end
76
-
76
+
77
77
  private
78
-
78
+
79
79
  def base_url
80
80
  domains = {:au => "api.nestoria.com.au",
81
81
  :br => "api.nestoria.com.br",
@@ -87,19 +87,19 @@ module Nestoria
87
87
  :uk => "api.nestoria.co.uk"}
88
88
  "http://#{domains[@country]}/api"
89
89
  end
90
-
90
+
91
91
  def process_location!(params)
92
92
  [:south_west, :north_east, :centre_point].each do |key|
93
93
  params[key] = params[key].join(",") unless params[key].nil?
94
94
  end
95
95
  end
96
-
96
+
97
97
  def request(action, params = {})
98
98
  url = "#{base_url}?version=#{API_VERSION}&action=#{action}&encoding=json&#{params.to_query}"
99
99
  puts url
100
100
  res = Net::HTTP.get_response(URI.parse(url))
101
101
  data = JSON.parse(res.body)
102
-
102
+
103
103
  # Catch any errors returned from the API and raise an appropriate exception
104
104
  if action.to_s == "search"
105
105
  application_response_code = data["response"]["application_response_code"]
@@ -115,9 +115,9 @@ module Nestoria
115
115
  raise InvalidRequest.new "#{application_response_code}, #{application_response_text}"
116
116
  end
117
117
  end
118
-
118
+
119
119
  data["response"]
120
120
  end
121
-
121
+
122
122
  end
123
- end
123
+ end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{nestoria}
8
- s.version = "1.0.0"
8
+ s.version = "1.0.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Dan Wentworth"]
metadata CHANGED
@@ -1,121 +1,121 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: nestoria
3
- version: !ruby/object:Gem::Version
4
- hash: 23
5
- prerelease: false
6
- segments:
7
- - 1
8
- - 0
9
- - 0
10
- version: 1.0.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Dan Wentworth
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-01-09 00:00:00 +00:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- requirement: &id001 !ruby/object:Gem::Requirement
12
+ date: 2011-01-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: json
16
+ requirement: !ruby/object:Gem::Requirement
23
17
  none: false
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- hash: 3
28
- segments:
29
- - 0
30
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
31
22
  type: :runtime
32
- name: json
33
23
  prerelease: false
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
37
25
  none: false
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- hash: 3
42
- segments:
43
- - 0
44
- version: "0"
45
- type: :development
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
46
31
  name: shoulda
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
47
39
  prerelease: false
48
- version_requirements: *id002
49
- - !ruby/object:Gem::Dependency
50
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
51
41
  none: false
52
- requirements:
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: bundler
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
53
51
  - - ~>
54
- - !ruby/object:Gem::Version
55
- hash: 23
56
- segments:
57
- - 1
58
- - 0
59
- - 0
52
+ - !ruby/object:Gem::Version
60
53
  version: 1.0.0
61
54
  type: :development
62
- name: bundler
63
55
  prerelease: false
64
- version_requirements: *id003
65
- - !ruby/object:Gem::Dependency
66
- requirement: &id004 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
67
57
  none: false
68
- requirements:
58
+ requirements:
69
59
  - - ~>
70
- - !ruby/object:Gem::Version
71
- hash: 7
72
- segments:
73
- - 1
74
- - 5
75
- - 2
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.0
62
+ - !ruby/object:Gem::Dependency
63
+ name: jeweler
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
76
69
  version: 1.5.2
77
70
  type: :development
78
- name: jeweler
79
71
  prerelease: false
80
- version_requirements: *id004
81
- - !ruby/object:Gem::Dependency
82
- requirement: &id005 !ruby/object:Gem::Requirement
72
+ version_requirements: !ruby/object:Gem::Requirement
83
73
  none: false
84
- requirements:
85
- - - ">="
86
- - !ruby/object:Gem::Version
87
- hash: 3
88
- segments:
89
- - 0
90
- version: "0"
91
- type: :development
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.5.2
78
+ - !ruby/object:Gem::Dependency
92
79
  name: rcov
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
93
87
  prerelease: false
94
- version_requirements: *id005
95
- - !ruby/object:Gem::Dependency
96
- requirement: &id006 !ruby/object:Gem::Requirement
88
+ version_requirements: !ruby/object:Gem::Requirement
97
89
  none: false
98
- requirements:
99
- - - ">="
100
- - !ruby/object:Gem::Version
101
- hash: 3
102
- segments:
103
- - 0
104
- version: "0"
105
- type: :runtime
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
106
95
  name: json
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :runtime
107
103
  prerelease: false
108
- version_requirements: *id006
109
- description: A simple library to interface with Nestoria's API, currently compatible with v1.19
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ description: A simple library to interface with Nestoria's API, currently compatible
111
+ with v1.19
110
112
  email: dan.wentworth@gmail.com
111
113
  executables: []
112
-
113
114
  extensions: []
114
-
115
- extra_rdoc_files:
115
+ extra_rdoc_files:
116
116
  - LICENSE.txt
117
117
  - README.md
118
- files:
118
+ files:
119
119
  - .document
120
120
  - Gemfile
121
121
  - Gemfile.lock
@@ -125,39 +125,29 @@ files:
125
125
  - VERSION
126
126
  - lib/nestoria/api.rb
127
127
  - nestoria.gemspec
128
- has_rdoc: true
129
128
  homepage: http://github.com/darkphnx/nestoria
130
- licenses:
129
+ licenses:
131
130
  - MIT
132
131
  post_install_message:
133
132
  rdoc_options: []
134
-
135
- require_paths:
133
+ require_paths:
136
134
  - lib
137
- required_ruby_version: !ruby/object:Gem::Requirement
135
+ required_ruby_version: !ruby/object:Gem::Requirement
138
136
  none: false
139
- requirements:
140
- - - ">="
141
- - !ruby/object:Gem::Version
142
- hash: 3
143
- segments:
144
- - 0
145
- version: "0"
146
- required_rubygems_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ! '>='
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
142
  none: false
148
- requirements:
149
- - - ">="
150
- - !ruby/object:Gem::Version
151
- hash: 3
152
- segments:
153
- - 0
154
- version: "0"
143
+ requirements:
144
+ - - ! '>='
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
155
147
  requirements: []
156
-
157
148
  rubyforge_project:
158
- rubygems_version: 1.3.7
149
+ rubygems_version: 1.8.21
159
150
  signing_key:
160
151
  specification_version: 3
161
152
  summary: A simple library to interface with Nestoria's API
162
153
  test_files: []
163
-