Printful

Unofficial Ruby wrapper for Printful's API. forked from dluxemburg/printful

Installation

Add this line to your application's Gemfile:

gem 'simple-printful', '~> 0.0.2'

And then execute:

$ bundle

Usage

Initialize the API key in rails For example

/config/initializers/printful.rb   <- You create this file
Printful.api_key = 'aioertjoraatr:artaertfg'  <- The API key you retrieve from the printful website

Now you can call HTTP requests and retrieve the responses using Printful::Client For example, let's say you was a list of all variants of a product from the printful webstore

/controllers/YOURCONTROLLER
@YourHashName = Printful::Client.get("path", params) <- This is a hash of JSON. It returns a JSON HASH

OR   

/models/YOURMODEL
@YourHashName = Printful::Client.get("path", params) <- This is a hash of JSON

You can also call predefined methods that are specific to what you need such as

@YourHashName = Printful::Product.find('995') #"returns a hash of the product....."

When initializing a new object that inherits from the model class, it may be needed to pass in an empty hash

@YourHashName = Printful::Shipping.new({}) # ...new({}).SomeMethod

To set the values needed is self explanatory in the files

@printful = Printful::Shipping.new({}) <- init
@printful.recipient = {attributes_of_recipient: "whatever the attributes are"}
@printful.items = []
@printful.currency = ""
Printful::Shipping.rates(@printful.payload)

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request