Tophatter Merchant API
Full documentation is available here.
Installation
gem 'tophatter-merchant', require: 'tophatter_merchant'
Console Testing (Development)
echo http://tophatter.dev/merchant_api/v1 > .api_path
echo 293da6763df7cb3b894a1831addcb52d > .access_token
bin/console
API Authentication
TophatterMerchant.access_token = <YOUR ACCESS TOKEN>
Products
List all of the products in your inventory.
TophatterMerchant::Product.all(page: 1, per_page: 100)
Search for products.
TophatterMerchant::Product.search(query: 'Shirt', page: 1, per_page: 100)
Retrieve a specific product.
TophatterMerchant::Product.retrieve('WAH5282')
Create a product.
TophatterMerchant::Product.create(
identifier: '6631A',
category: 'Electronics|Hardware (Computers/Tablets/Phones)|Mobile',
title: 'Apple iPhone 6S',
description: 'This is the description.',
condition: 'Refurbished - Manufacturer',
starting_bid: 1,
buy_now_price: 150,
cost_basis: 75,
shipping_price: 5.0,
success_fee_bid: 0.5,
shipping_origin: 'United States',
weight: 6,
days_to_fulfill: 3,
days_to_deliver: 5,
variations: {
'6631A-WHITE': { identifier: '6631A-WHITE', color: 'White', quantity: 1 },
'6631A-BLACK': { identifier: '6631A-BLACK', color: 'Black', quantity: 2 }
},
primary_image: 'https://d38eepresuu519.cloudfront.net/b2aa7d2708324f756ffee551ba43a74f/original.jpg',
extra_images: 'https://d38eepresuu519.cloudfront.net/e615c55184c06f391dbd768f855904e6/original.jpg|https://d38eepresuu519.cloudfront.net/7cd125f0fa42c965675eabaf3309aa6d/original.jpg'
)
Update a product.
TophatterMerchant::Product.update('6631A', buy_now_price: 100)
Disable an enabled product.
TophatterMerchant::Product.disable('6631A')
Enable a disabled product.
TophatterMerchant::Product.enable('6631A')
Variations
Retrieve a specific variation.
TophatterMerchant::Variation.retrieve('6631A-BLACK')
Create a variation.
TophatterMerchant::Variation.create(product_identifier: '6631A', identifier: '6631A-PINK', color: 'Pink', quantity: 33)
Update a variation.
TophatterMerchant::Variation.update('6631A-PINK', quantity: 999)
Orders
List all orders.
TophatterMerchant::Order.all(filter: 'unfulfilled', page: 1, per_page: 100)
Retrieve a specific order.
TophatterMerchant::Order.retrieve(1035509247)
Fulfill an order.
TophatterMerchant::Order.fulfill(1035509247, carrier: 'USPS', tracking_number: '9400111899562173406594')
Refund the shipping fee for an order.
TophatterMerchant::Order.refund(1035509249, type: 'partial', reason: 'delay_in_shipping', fees: ['shipping_fee'])
Refund an order in full.
TophatterMerchant::Order.refund(1035509249, type: 'full', reason: 'out_of_stock')