Module: Mercadolibre::Core::Messaging
- Included in:
- Api
- Defined in:
- lib/mercadolibre/core/messaging.rb
Instance Method Summary collapse
- #create_attachment(file) ⇒ Object
- #create_order_message(message_data) ⇒ Object
- #create_pack_message(pack_id, user_id, message_data) ⇒ Object
- #get_attachment(attachment_id) ⇒ Object
- #get_order_message(message_id) ⇒ Object
- #get_order_messages(order_id, filters = {}) ⇒ Object
- #get_pack_messages(pack_id, user_id, filters = {}) ⇒ Object
- #get_unread_order_messages(filters = {}) ⇒ Object
- #mark_order_message_as_read(message_ids) ⇒ Object
Instance Method Details
#create_attachment(file) ⇒ Object
44 45 46 47 48 |
# File 'lib/mercadolibre/core/messaging.rb', line 44 def (file) payload = { file: file } headers = { content_type: 'multipart/form-data' } post_request("/messages/attachments?access_token=#{@access_token}", payload, headers).body end |
#create_order_message(message_data) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/mercadolibre/core/messaging.rb', line 22 def () payload = .to_json headers = { content_type: :json } post_request("/messages?access_token=#{@access_token}&application_id=#{@app_key}", payload, headers).body end |
#create_pack_message(pack_id, user_id, message_data) ⇒ Object
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/mercadolibre/core/messaging.rb', line 61 def (pack_id, user_id, ) url = "/messages/packs/#{pack_id}/sellers/#{user_id}?access_token=#{@access_token}" url += "&application_id=#{@app_key}" payload = .to_json headers = { content_type: :json } post_request(url, payload, headers).body end |
#get_attachment(attachment_id) ⇒ Object
50 51 52 53 |
# File 'lib/mercadolibre/core/messaging.rb', line 50 def () params = { access_token: @access_token } get_request("/messages/attachments/#{}", params, { api_response_kind: 'raw' }).body end |
#get_order_message(message_id) ⇒ Object
16 17 18 19 20 |
# File 'lib/mercadolibre/core/messaging.rb', line 16 def () params = { access_token: @access_token } get_request("/messages/#{}", params).body end |
#get_order_messages(order_id, filters = {}) ⇒ Object
4 5 6 7 8 |
# File 'lib/mercadolibre/core/messaging.rb', line 4 def (order_id, filters={}) filters.merge!({ access_token: @access_token }) get_request("/messages/orders/#{order_id}", filters).body end |
#get_pack_messages(pack_id, user_id, filters = {}) ⇒ Object
55 56 57 58 59 |
# File 'lib/mercadolibre/core/messaging.rb', line 55 def (pack_id, user_id, filters={}) filters.merge!({ access_token: @access_token }) get_request("/messages/packs/#{pack_id}/sellers/#{user_id}", filters).body end |
#get_unread_order_messages(filters = {}) ⇒ Object
10 11 12 13 14 |
# File 'lib/mercadolibre/core/messaging.rb', line 10 def (filters={}) filters.merge!({ access_token: @access_token }) get_request("/messages/unread", filters).body end |
#mark_order_message_as_read(message_ids) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/mercadolibre/core/messaging.rb', line 31 def () if .is_a?(Array) = .join(',') else = end headers = { content_type: :json } put_request("/messages/mark_as_read/#{}?access_token=#{@access_token}", { }, headers).body end |