threetaps-client 1.0.9 → 1.0.10

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 CHANGED
@@ -1 +1 @@
1
- 1.0.9
1
+ 1.0.10
@@ -36,7 +36,10 @@ class PostingClient < Client
36
36
  data << postings.collect{|posting| posting.to_json}.join(',')
37
37
  data << "]"
38
38
  params = "postings=#{data}"
39
+ p params
39
40
  response = execute_post("/posting/create", params)
41
+ p response.inspect
42
+ p decode(response)
40
43
  CreateResponse.from_array(decode(response))
41
44
  end
42
45
 
@@ -52,7 +55,7 @@ class PostingClient < Client
52
55
  def update_posting(postings)
53
56
  postings = [postings] unless postings.is_a? Array
54
57
  data = "["
55
- data << postings.collect{|posting| posting.to_json_for_update.gsub("%22","")}.join(',')
58
+ data << postings.collect{|posting| posting.to_json_for_update}.join(',')
56
59
  data << "]"
57
60
  params = "data=#{data}"
58
61
  response = execute_post("posting/update", params)
@@ -37,7 +37,6 @@ class Posting < SuperModel::Base
37
37
  :externalURL, :externalID, :accountName, :accountID, :clickCount,
38
38
  :timestamp, :expiration, :indexed, :trustedAnnotations,
39
39
  :annotations, :errors, :status, :history
40
-
41
40
  def initialize(*params)
42
41
  super(*params)
43
42
  @attributes[:images] ||= []
@@ -46,14 +45,17 @@ class Posting < SuperModel::Base
46
45
  end
47
46
 
48
47
  def to_json
49
- posting = "{"+'source:'+"'#{self.source}'" + ',category:' + "'#{self.category}'" + ',location:' + "'#{self.location}'" + ',heading:' + "'#{CGI.escape self.heading.to_s[0,254]}'"
48
+ posting = "{"+'source:'+"'#{self.source}'" + ',category:' + "'#{self.category}'" + ',location:' + "'#{self.location}'" + ',heading:' + "'#{self.heading.to_s[0,254]}'"
50
49
  if self.timestamp
51
- posting << ",timestamp: '#{(self.timestamp.utc.to_s(:db)).gsub(/\s/,"+").gsub("-","/")}'"
50
+ posting << ",timestamp: '#{(Time.at(self.timestamp).utc.to_s(:db)).gsub("-","/")}'"
52
51
  else
53
- posting << ",timestamp: '#{(Time.now.utc.to_s(:db)).gsub(/\s/,"+").gsub("-","/")}'"
52
+ posting << ",timestamp: '#{(Time.now.utc.to_s(:db)).gsub("-","/")}'"
54
53
  end
55
54
  posting << ',images:' + "[#{images.collect{ |image| "'#{image}'"}.join(',')}]"
56
- posting << ',body:' + "'#{CGI.escape self.body}'" unless self.body.blank?
55
+ unless self.body.blank?
56
+ self.body.gsub!(/[&']/,"")
57
+ posting << ',body:' + "'#{ActiveSupport::JSON.encode(self.body)}'"
58
+ end
57
59
  posting << ',price:' + "#{self.price.to_f}"
58
60
  posting << ',currency:' + "'#{self.currency}'"
59
61
  posting << ',accountName:' + "'#{self.accountName}'"
@@ -70,12 +72,12 @@ class Posting < SuperModel::Base
70
72
 
71
73
  def to_json_for_update
72
74
  data = "['#{self.postKey}',"
73
- data << "{heading:"+ "'#{CGI.escape self.heading}'" unless self.heading.blank?
75
+ data << "{heading:"+ "'#{self.heading}'" unless self.heading.blank?
74
76
  data << ",images:" + "[#{images.collect{ |image| "'#{image}'"}.join(',')}]"
75
77
  data << ",source:'#{self.source}'" unless self.source.blank?
76
78
  data << ",category:'#{self.category}'" unless self.category.blank?
77
79
  data << ",location:'#{self.location}'" unless self.location.blank?
78
- data << ",body:" + "'#{CGI.escape self.body}'" unless self.body.blank?
80
+ data << ",body:" + "'#{self.body}'" unless self.body.blank?
79
81
  data << ',price:' + "'#{self.price}'"
80
82
  data << ',currency:' + "'#{self.currency}'"
81
83
  data << ',accountName:' + "'#{self.accountName}'"
@@ -89,21 +91,18 @@ class Posting < SuperModel::Base
89
91
  end
90
92
  data << "}"
91
93
  data << "]"
92
- data.gsub()
93
94
  end
94
95
 
95
96
  def to_json_for_status
96
97
  # {source: 'CRAIG', externalID: 3434399120}
97
- data = "{source: '"
98
- data << self.source || " "
99
- data << "', externalID: "
100
- data << self.externalID || " "
101
- data << "}"
98
+ data = "source:'#{self.source}', " unless self.source.blank?
99
+ data << "externalID: '#{self.externalID}'" unless self.externalID.blank?
100
+ data
102
101
  end
103
102
  def to_json_for_status_client
104
103
  # source: 'CRAIG', externalID: 3434399120
105
- data = "source:'#{CGI.escape self.source}', " unless self.source.blank?
106
- data << "externalID:#{CGI.escape self.externalID}" unless self.externalID.blank?
104
+ data = "source:'#{self.source}', " unless self.source.blank?
105
+ data << "externalID: '#{self.externalID}'" unless self.externalID.blank?
107
106
  data
108
107
  end
109
108
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{threetaps-client}
8
- s.version = "1.0.9"
8
+ s.version = "1.0.10"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["3taps.com"]
12
- s.date = %q{2011-04-20}
12
+ s.date = %q{2011-04-21}
13
13
  s.description = %q{A Ruby gem for accessing the 3taps API. See more at http://developers.3taps.net}
14
14
  s.email = %q{developers@3taps.com}
15
15
  s.extra_rdoc_files = [
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: 5
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 9
10
- version: 1.0.9
9
+ - 10
10
+ version: 1.0.10
11
11
  platform: ruby
12
12
  authors:
13
13
  - 3taps.com
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-20 00:00:00 Z
18
+ date: 2011-04-21 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  requirement: &id001 !ruby/object:Gem::Requirement