Skip to main content

Loop Returns Mock Server

Full mock implementation of the Loop Returns API. Returns, refunds, exchanges, and more.

Supported endpoints

Returns

EndpointMethods
/api/v1/warehouse/return/listGET
/api/v1/warehouse/return/{id}GET
/api/v1/returnPOST

Labels

EndpointMethods
/api/v1/labelPOST
/api/v1/label/{id}GET

Quick example

require 'mockworld'

Mockworld.configure do |config|
  config.api_key = ENV['MOKRA_API_KEY']
end

# List returns
uri = URI("https://api.loopreturns.com/api/v1/warehouse/return/list")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Get.new(uri)
request["X-Authorization"] = "any_key"

response = http.request(request)
returns = JSON.parse(response.body)

# => { "data": [{ "id": "ret_abc123", "status": "pending", ... }] }

Using with MockWorld Tests

world = mockworld(name: "Returns test", services: ["loop-returns"])

world.run do
  # Your returns processing code
  uri = URI("https://api.loopreturns.com/api/v1/warehouse/return/list")
  Net::HTTP.get(uri)
end

world.observe
# => "GET loop-returns/api/v1/warehouse/return/list"
# => "→ Retrieved 5 returns"

world.assert("returns were retrieved")

Seeding data

world.seed do |s|
  s.loop_returns.returns.create(
    id: "ret_test123",
    status: "pending",
    order_id: "order_456",
    items: [
      { sku: "WIDGET-001", quantity: 1, reason: "defective" }
    ]
  )
end

Stateful behavior

# Create a return
response = http.post(
  URI("https://api.loopreturns.com/api/v1/return"),
  { order_id: "order_123", items: [...] }.to_json
)
return_data = JSON.parse(response.body)

# Retrieve the same return
response = http.get(
  URI("https://api.loopreturns.com/api/v1/warehouse/return/#{return_data['id']}")
)
# => Same return object

Next steps