Class: Mintsoft::Resources::Returns

Inherits:
BaseResource show all
Defined in:
lib/mintsoft/resources/returns.rb

Instance Method Summary collapse

Methods inherited from BaseResource

#initialize

Constructor Details

This class inherits a constructor from Mintsoft::Resources::BaseResource

Instance Method Details

#add_item(return_id, item_attributes) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/mintsoft/resources/returns.rb', line 23

def add_item(return_id, item_attributes)
  validate_return_id!(return_id)
  validate_item_attributes!(item_attributes)

  payload = format_item_payload(item_attributes)
  response = post_request("/api/Return/#{return_id}/AddItem", body: payload)
  response_data = handle_response(response)

  Objects::Return.new(response_data)
end

#create(order_id) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/mintsoft/resources/returns.rb', line 14

def create(order_id)
  validate_order_id!(order_id)

  response = post_request("/api/Return/CreateReturn/#{order_id}")
  response_data = handle_response(response)

  Objects::Return.new(response_data)
end

#reasonsObject



8
9
10
11
12
# File 'lib/mintsoft/resources/returns.rb', line 8

def reasons
  response = get_request("/api/Return/Reasons")
  response_data = handle_response(response)
  parse_reasons(response_data)
end

#retrieve(return_id) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/mintsoft/resources/returns.rb', line 34

def retrieve(return_id)
  validate_return_id!(return_id)

  response = get_request("/api/Return/#{return_id}")

  if response.status == 404
    nil # Return nil for not found returns
  else
    response_data = handle_response(response)
    Objects::Return.new(response_data)
  end
end