Module: PrintfulClientModule
- Included in:
- PrintfulClient
- Defined in:
- lib/printful_client.rb
Constant Summary collapse
- API_URL =
'https://api.theprintful.com/'
- USER_AGENT =
'Printful API Ruby Library 1.0'
Instance Attribute Summary collapse
-
#last_response ⇒ Object
Returns the value of attribute last_response.
-
#last_response_raw ⇒ Object
Returns the value of attribute last_response_raw.
Instance Method Summary collapse
-
#delete(path, params = nil) ⇒ Object
Perform a DELETE request to the API path - Request path (e.g. ‘orders’ or ‘orders/123’) params - Additional GET parameters as a hash.
-
#get(path, params = nil) ⇒ Object
Perform a GET request to the API path - Request path (e.g. ‘orders’ or ‘orders/123’) params - Additional GET parameters as a hash.
-
#initialize(key) ⇒ Object
Initialize API library key - Printful Store API key.
-
#item_count ⇒ Object
Returns total available item count from the last request if it supports paging (e.g order list) or nil otherwise.
-
#post(path, data = nil, params = nil) ⇒ Object
Perform a POST request to the API path - Request path (e.g. ‘orders’ or ‘orders/123’) data - Request body data as a hash params - Additional GET parameters as a hash.
-
#put(path, data = nil, params = nil) ⇒ Object
Perform a PUT request to the API path - Request path (e.g. ‘orders’ or ‘orders/123’) data - Request body data as a hash params - Additional GET parameters as a hash.
Instance Attribute Details
#last_response ⇒ Object
Returns the value of attribute last_response.
127 128 129 |
# File 'lib/printful_client.rb', line 127 def last_response @last_response end |
#last_response_raw ⇒ Object
Returns the value of attribute last_response_raw.
127 128 129 |
# File 'lib/printful_client.rb', line 127 def last_response_raw @last_response_raw end |
Instance Method Details
#delete(path, params = nil) ⇒ Object
Perform a DELETE request to the API path - Request path (e.g. ‘orders’ or ‘orders/123’) params - Additional GET parameters as a hash
47 48 49 |
# File 'lib/printful_client.rb', line 47 def delete(path, params=nil) request('DELETE', path, params) end |
#get(path, params = nil) ⇒ Object
Perform a GET request to the API path - Request path (e.g. ‘orders’ or ‘orders/123’) params - Additional GET parameters as a hash
39 40 41 |
# File 'lib/printful_client.rb', line 39 def get(path, params=nil) request('GET', path, params) end |
#initialize(key) ⇒ Object
Initialize API library key - Printful Store API key
26 27 28 |
# File 'lib/printful_client.rb', line 26 def initialize(key) @api_key = key end |
#item_count ⇒ Object
Returns total available item count from the last request if it supports paging (e.g order list) or nil otherwise
32 33 34 |
# File 'lib/printful_client.rb', line 32 def item_count return last_response && last_response.key?('paging') ? last_response['paging']['total'] : nil end |
#post(path, data = nil, params = nil) ⇒ Object
Perform a POST request to the API path - Request path (e.g. ‘orders’ or ‘orders/123’) data - Request body data as a hash params - Additional GET parameters as a hash
56 57 58 |
# File 'lib/printful_client.rb', line 56 def post(path, data=nil, params=nil) request('POST', path, params, data) end |
#put(path, data = nil, params = nil) ⇒ Object
Perform a PUT request to the API path - Request path (e.g. ‘orders’ or ‘orders/123’) data - Request body data as a hash params - Additional GET parameters as a hash
65 66 67 |
# File 'lib/printful_client.rb', line 65 def put(path, data=nil, params=nil) request('PUT', path, params, data) end |