threetaps-client 1.0.10 → 1.0.11
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.
- data/VERSION +1 -1
- data/lib/client/client.rb +6 -1
- data/lib/client/geocoder_client.rb +2 -0
- data/lib/dto/geocoder/geocoder_request.rb +8 -8
- data/lib/models/posting.rb +1 -0
- data/threetaps-client.gemspec +1 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.11
|
data/lib/client/client.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
class Client
|
3
3
|
DEFAULT_URL = 'http://3taps.net'
|
4
4
|
DEFAULT_API_PORT = 80
|
5
|
+
TIMEOUT = 15
|
5
6
|
# Initializes Client class with +baseUrl+ and +port+ parameters. By default
|
6
7
|
# DEFAULT_URL and DEFAULT_API_PORT are used. Examples:
|
7
8
|
# Client.new
|
@@ -31,7 +32,11 @@ class Client
|
|
31
32
|
#
|
32
33
|
# execute_post("search", "data=data")
|
33
34
|
def execute_post( path, params = nil )
|
34
|
-
c = Curl::Easy.
|
35
|
+
c = Curl::Easy.new("#{@baseURL}:#{@port}/#{path}")
|
36
|
+
param, data = params.split("=",2)
|
37
|
+
c.http_post(param.to_s + '=' + c.escape(data.to_s))
|
38
|
+
c.timeout = TIMEOUT
|
39
|
+
c.perform
|
35
40
|
c.body_str
|
36
41
|
end
|
37
42
|
|
@@ -36,7 +36,9 @@ class GeocoderClient < Client
|
|
36
36
|
params = "data=["
|
37
37
|
params << geocoder_requests.collect{|request| "#{request.to_params}"}.join(',')
|
38
38
|
params << "]"
|
39
|
+
p params
|
39
40
|
response = execute_post('geocoder/geocode', params)
|
41
|
+
p response
|
40
42
|
p decode(response)
|
41
43
|
GeocoderResponse.from_array(decode(response))
|
42
44
|
end
|
@@ -2,14 +2,14 @@ class GeocoderRequest < Struct.new(:latitude, :longitude, :country, :state, :cit
|
|
2
2
|
|
3
3
|
def to_params
|
4
4
|
result = []
|
5
|
-
result << "\"latitude\":#{
|
6
|
-
result << "\"longitude\":#{
|
7
|
-
result << "\"country\":\"#{
|
8
|
-
result << "\"state\":\"#{
|
9
|
-
result << "\"city\":\"#{
|
10
|
-
result << "\"locality\":\"#{
|
11
|
-
result << "\"postal\":\"#{
|
12
|
-
result << "\"text\":\"#{
|
5
|
+
result << "\"latitude\":#{latitude}" unless latitude.nil?
|
6
|
+
result << "\"longitude\":#{longitude}" unless longitude.nil?
|
7
|
+
result << "\"country\":\"#{country}\"" unless country.nil?
|
8
|
+
result << "\"state\":\"#{state}\"" unless state.nil?
|
9
|
+
result << "\"city\":\"#{city}\"" unless city.nil?
|
10
|
+
result << "\"locality\":\"#{locality}\"" unless locality.nil?
|
11
|
+
result << "\"postal\":\"#{postal}\"" unless postal.nil?
|
12
|
+
result << "\"text\":\"#{text}\"" unless text.nil?
|
13
13
|
'{' + result.join(", ") + '}'
|
14
14
|
end
|
15
15
|
|
data/lib/models/posting.rb
CHANGED
@@ -54,6 +54,7 @@ class Posting < SuperModel::Base
|
|
54
54
|
posting << ',images:' + "[#{images.collect{ |image| "'#{image}'"}.join(',')}]"
|
55
55
|
unless self.body.blank?
|
56
56
|
self.body.gsub!(/[&']/,"")
|
57
|
+
#self.body.gsub!(/\s*<[^>]*>/,"")
|
57
58
|
posting << ',body:' + "'#{ActiveSupport::JSON.encode(self.body)}'"
|
58
59
|
end
|
59
60
|
posting << ',price:' + "#{self.price.to_f}"
|
data/threetaps-client.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: threetaps-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 11
|
10
|
+
version: 1.0.11
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- 3taps.com
|