Shirtsio
A Ruby wrapper around the shirts.io API
Documentation
You can view detailed documentation of this library at http://rdoc.info/github/anthonator/shirtsio/frames. We try to make sure that our documentation is up-to-date and thorough. However, we do recommend keeping the shirts.io API documentation handy.
If you find any discrepency in our documentation please file an issue.
Installation
Add this line to your application's Gemfile:
gem 'shirtsio'
And then execute:
$ bundle
Or install it yourself as:
$ gem install shirtsio
Quick Start Guide
Before you can start ordering some sweet shirts you'll need to tell shirts.io who you are.
Grab your super secret API key from the shirts.io dashboard.
Sprinkle some pixie-dust...
Shirtsio.configure do |config|
config.api_key = YOUR_API_KEY
end
BAM! Print some shirts!
Shirtsio::Order.create do |order|
...
end
Product API
# Return details about a specific product
product = Shirtsio::Product.find(3)
# Return a list of categories
categories = Shirtsio::Product::Category.list
# Return a list of products for a specific category
products = categories[0].products
# Since shirts.io doesn't return full product data when requesting from a category, return it now
product = products[0].full_product
Quote API
# Assembling the parameters necessary to generate a quote is messy
# business. Luckily there's a DSL for that.
quote = Shirtsio::Quote.create do |quote|
quote.print_type 'Digital Print'
quote.garment do |garment|
garment.product_id 3
garment.color 'Black'
garment.sizes do |size|
size.med 1
end
end
quote.print do |print|
print.front do |front|
front.color_count 1
front.colors ['Black']
end
print.back do |back|
back.color_count 1
back.colors ['Black']
end
end
end
Order API
# Yep, there's one for orders too
order = Shirtsio::Order.create do |order|
order.test true
order.price 18.99
order.print_type 'Digital Print'
order.extra_screens 'None'
order.ship_type 'Standard'
order.garment do |garment|
garment.product_id 3
garment.color 'Black'
garment.sizes do |size|
size.med 1
end
end
order.print do |print|
print.front do |front|
front.artwork File.new('/path/to/file.png')
front.proof File.new('/path/to/file.jpg')
front.color_count 1
front.colors ['Black']
front.dimensions '5.0 inches wide'
front.placement '4.0 inches below bottom of collar'
end
end
order.personalization do |personalization|
personalization.size 'med'
personalization.batch 1
personalization.number 1
personalization.number_size 2
personalization.name 'Bob'
personalization.name_size 1
end
order.addresses do |address|
address.name 'Bob'
address.company 'Sticksnleaves'
address.address '1234 Hopes and Dreams Ln.'
address.address2 'Apt. <3'
address.city 'Indianapolis'
address.state 'IN'
address.country 'US'
address.batch 1
address.sizes do |size|
size.med 1
end
end
end
Status API
# Get an order's status
status = Shirtsio::Status.find(1234)
# Register a status webhook
Shirtsio::Status::Webhook.create('http://www.example.com') #returns true or false
# List webhooks
webhooks = Shirtsio::Status::Webhook.list
# Delete a webhook
Shirtsio::Status::Webhook.delete('http://www.example.com')
# or
webhooks[0].delete
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Credits
Shirtsio is maintained and funded by Sticksnleaves
Thanks to all of our contributors