mercadolibre 0.3.4 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1cdd0a8806a54f7bf13f3af7438d96c87ebcf22f
4
- data.tar.gz: b3625580caf2b132d1b36f95dac2d9c85fc9ef52
3
+ metadata.gz: ca5981ecdfaffc11a6dd83fbb8dcc46dcca69cbc
4
+ data.tar.gz: 541ea2124e4d1d45e77049e16b4facc87231d822
5
5
  SHA512:
6
- metadata.gz: 213b9d5bf71d5a841cfcc72962a38be15caadab1cb95554249d746e09320354e372728a774d2d28bbfdcce6e97d57c9a98bcd55e0f15fc4c2cfb4f76d796382e
7
- data.tar.gz: 1f79ed50a6babb2158ee0f6198aa7ccc9b6619adc9ed18d71a50c45f6b48f18a71d972de253a15d09176f99a104d2f9b5ba168237088beb8ba8d91af33f9feea
6
+ metadata.gz: 8f0e3817ff0d254f9c180092c37def9860dcc187a6e05cc40de023bf472d99bc43abcaab8c7dcb6342c460ae3a1473e5ac35351fd5c9ef9feb8097200beea53c
7
+ data.tar.gz: 36d3ee88b4deeca17c1917079f781f3eefd2b8e80003f0ec8e301c692d278dc6f96b5b57fd0ac664c98825b569dfd08a511ea39ddd7215b83efccda4c85c905d
data/CHANGELOG.md CHANGED
@@ -89,3 +89,7 @@
89
89
  ## v0.3.4
90
90
 
91
91
  * Added methods to create, update and destroy order notes
92
+
93
+ ## v0.4.0
94
+
95
+ * New feedbacks interface
@@ -100,71 +100,67 @@ module Mercadolibre
100
100
  end
101
101
 
102
102
  def get_order_feedbacks(order_id)
103
- filters = { access_token: @access_token }
103
+ filters = { version: '3.0', access_token: @access_token }
104
104
 
105
- result = get_request("/orders/#{order_id}/feedback", filters)[:body]
105
+ result = get_request("/orders/#{order_id}/feedback", filters)
106
106
 
107
- if result['sale']
108
- sale_feedback = Mercadolibre::Entity::Feedback.new(result['sale'])
109
- else
110
- sale_feedback = nil
111
- end
107
+ Mercadolibre::Entity::OrderFeedback.new(result[:body])
108
+ end
112
109
 
113
- if result['purchase']
114
- purchase_feedback = Mercadolibre::Entity::Feedback.new(result['purchase'])
115
- else
116
- purchase_feedback = nil
117
- end
110
+ def get_order_buyer_feedback(order_id)
111
+ filters = { version: '3.0', access_token: @access_token }
118
112
 
119
- { seller: sale_feedback, buyer: purchase_feedback }
113
+ result = get_request("/orders/#{order_id}/feedback/purchase", filters)
114
+
115
+ Mercadolibre::Entity::Feedback.new(result[:body])
120
116
  end
121
117
 
122
- def get_buyer_feedback(order_id)
123
- result = get_request("/orders/#{order_id}/feedback/purchase?access_token=#{@access_token}")
118
+ def get_order_seller_feedback(order_id)
119
+ filters = { version: '3.0', access_token: @access_token }
120
+
121
+ result = get_request("/orders/#{order_id}/feedback/sale", filters)
124
122
 
125
123
  Mercadolibre::Entity::Feedback.new(result[:body])
126
124
  end
127
125
 
128
- def get_seller_feedback(order_id)
129
- result = get_request("/orders/#{order_id}/feedback/sale?access_token=#{@access_token}")
126
+ def create_order_feedback(order_id, feedback_data)
127
+ payload = feedback_data.to_json
130
128
 
131
- Mercadolibre::Entity::Feedback.new(result[:body])
129
+ headers = { content_type: :json }
130
+
131
+ post_request("/orders/#{order_id}/feedback?version=3.0&access_token=#{@access_token}", payload, headers)[:body]
132
132
  end
133
133
 
134
- def give_feedback_to_order(order_id, feedback_data)
134
+ def change_order_seller_feedback(order_id, kind, feedback_data)
135
135
  payload = feedback_data.to_json
136
136
 
137
137
  headers = { content_type: :json }
138
138
 
139
- post_request("/orders/#{order_id}/feedback?access_token=#{@access_token}", payload, headers)[:body]
139
+ put_request("/orders/#{order_id}/feedback/sale?version=3.0&access_token=#{@access_token}", payload, headers)[:body]
140
140
  end
141
141
 
142
- def change_feedback_from_order(order_id, kind, feedback_data)
142
+ def change_order_buyer_feedback(order_id, kind, feedback_data)
143
143
  payload = feedback_data.to_json
144
144
 
145
145
  headers = { content_type: :json }
146
146
 
147
- if kind.to_s == 'buyer'
148
- put_request("/orders/#{order_id}/feedback/purchase?access_token=#{@access_token}", payload, headers)[:body]
149
- elsif kind.to_s == 'seller'
150
- put_request("/orders/#{order_id}/feedback/sale?access_token=#{@access_token}", payload, headers)[:body]
151
- else
152
- raise 'invalid kind'
153
- end
147
+ put_request("/orders/#{order_id}/feedback/purchase?version=3.0&access_token=#{@access_token}", payload, headers)[:body]
154
148
  end
155
149
 
156
- def reply_feedback(order_id, kind, text)
150
+ def change_order_feedback(feedback_id, feedback_data)
151
+ payload = feedback_data.to_json
152
+
153
+ headers = { content_type: :json }
154
+
155
+ put_request("/feedback/#{feedback_id}?version=3.0&access_token=#{@access_token}", payload, headers)[:body]
156
+ end
157
+
158
+ def reply_order_feedback(feedback_id, text)
157
159
  payload = { reply: text }.to_json
158
160
 
159
161
  headers = { content_type: :json }
160
162
 
161
- if kind.to_s == 'buyer'
162
- post_request("/orders/#{order_id}/feedback/purchase?access_token=#{@access_token}", payload, headers)[:body]
163
- elsif kind.to_s == 'seller'
164
- post_request("/orders/#{order_id}/feedback/sale?access_token=#{@access_token}", payload, headers)[:body]
165
- else
166
- raise 'invalid kind'
167
- end
163
+ post_request("/feedback/{feedback_id}/reply?version=3.0&access_token=#{@access_token}", payload, headers)[:body]
168
164
  end
169
165
 
170
166
  def get_site_payment_methods(site_id)
@@ -2,15 +2,23 @@ module Mercadolibre
2
2
  module Entity
3
3
  class Feedback
4
4
  def self.attr_list
5
- [:rating, :date_created, :fulfilled, :reason, :message, :reply, :status]
5
+ [:to, :has_seller_refunded_money, :status, :reason, :site_id, :date_created, :from,
6
+ :order_id, :modified, :id, :message, :fulfilled, :item, :visibility_date, :reply,
7
+ :role, :app_id, :rating, :restock_item]
6
8
  end
7
9
 
8
10
  attr_reader *attr_list
9
11
 
10
12
  def initialize(attributes={})
11
13
  attributes.each do |k, v|
12
- if k.to_s == 'date_created'
14
+ if ['date_created', 'visibility_date'].include?(k.to_s)
13
15
  self.date_created = Time.parse(v) unless v.nil?
16
+ elsif k.to_s == 'to'
17
+ self.to = User.new(v)
18
+ elsif k.to_s == 'from'
19
+ self.from = User.new(v)
20
+ elsif k.to_s == 'item'
21
+ self.item = Item.new(v)
14
22
  else
15
23
  self.send("#{k}=", v) if self.respond_to?(k)
16
24
  end
@@ -2,14 +2,19 @@ module Mercadolibre
2
2
  module Entity
3
3
  class OrderFeedback
4
4
  def self.attr_list
5
- [:buyer, :seller]
5
+ [:sale, :purchase]
6
6
  end
7
7
 
8
8
  attr_reader *attr_list
9
9
 
10
10
  def initialize(attributes={})
11
- self.buyer = Feedback.new(attributes['buyer']) unless attributes['buyer'].nil?
12
- self.seller = Feedback.new(attributes['seller']) unless attributes['seller'].nil?
11
+ if attributes['sale'].present?
12
+ self.sale = Feedback.new(attributes['sale'])
13
+ end
14
+
15
+ if attributes['purchase'].present?
16
+ self.purchase = Feedback.new(attributes['purchase'])
17
+ end
13
18
  end
14
19
 
15
20
  private
@@ -4,7 +4,7 @@ module Mercadolibre
4
4
  def self.attr_list
5
5
  [:id, :nickname, :registration_date, :first_name, :last_name, :blocked,
6
6
  :country_id, :email, :user_type, :points, :site_id, :permalink, :phone,
7
- :alternative_phone, :billing_info]
7
+ :alternative_phone, :billing_info, :status]
8
8
  end
9
9
 
10
10
  attr_reader *attr_list
@@ -1,3 +1,3 @@
1
1
  module Mercadolibre
2
- VERSION = "0.3.4"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mercadolibre
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matias Hick
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-19 00:00:00.000000000 Z
11
+ date: 2014-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler