Class: Mercadopago::Order

Inherits:
MPBase
  • Object
show all
Defined in:
lib/mercadopago/resources/order.rb

Overview

Instance Method Summary collapse

Methods inherited from MPBase

#_check_headers, #_check_request_options, #_delete, #_get, #_post, #_put, #initialize

Constructor Details

This class inherits a constructor from Mercadopago::MPBase

Instance Method Details

#cancel(order_id, request_options: nil) ⇒ Object



35
36
37
# File 'lib/mercadopago/resources/order.rb', line 35

def cancel(order_id, request_options: nil)
  _post(uri: "/v1/orders/#{order_id}/cancel", data: nil, request_options: request_options)
end

#capture(order_id, request_options: nil) ⇒ Object



39
40
41
# File 'lib/mercadopago/resources/order.rb', line 39

def capture(order_id, request_options: nil)
  _post(uri: "/v1/orders/#{order_id}/capture", data: nil, request_options: request_options)
end

#create(order_data, request_options: nil) ⇒ Object

Raises:

  • (TypeError)


13
14
15
16
17
# File 'lib/mercadopago/resources/order.rb', line 13

def create(order_data, request_options: nil)
  raise TypeError, 'Param order_data must be a Hash' unless order_data.is_a?(Hash)

  _post(uri: '/v1/orders', data: order_data, request_options: request_options)
end

#get(order_id, request_options: nil) ⇒ Object



19
20
21
# File 'lib/mercadopago/resources/order.rb', line 19

def get(order_id, request_options: nil)
  _get(uri: "/v1/orders/#{order_id}", request_options: request_options)
end

#process(order_id, request_options: nil) ⇒ Object



23
24
25
# File 'lib/mercadopago/resources/order.rb', line 23

def process(order_id, request_options: nil)
  _post(uri: "/v1/orders/#{order_id}/process", data: nil,request_options: request_options)
end

#refund(order_id, refund_data: nil, request_options: nil) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/mercadopago/resources/order.rb', line 27

def refund(order_id, refund_data: nil, request_options: nil)
  unless refund_data.nil?
    raise TypeError, 'Param refund_data must be a Hash' unless refund_data.is_a?(Hash)
  end

  _post(uri: "/v1/orders/#{order_id}/refund", data: refund_data, request_options: request_options)
end

#search(filters: nil, request_options: nil) ⇒ Object



43
44
45
# File 'lib/mercadopago/resources/order.rb', line 43

def search(filters: nil, request_options: nil)
  _get(uri: '/v1/orders', params: filters, request_options: request_options)
end