Skip to content

Commit 3f62a03

Browse files
authored
Merge pull request #224 from Shopify/readme-advanced-usage
Add advanced usage examples to README
2 parents 539c9f0 + 75d1fb1 commit 3f62a03

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,33 @@ these steps:
193193
shopify.ShopifyResource.clear_session()
194194
```
195195

196+
### Advanced Usage
197+
It is recommended to have at least a basic grasp on the principles of [ActiveResource](https://apidock.com/rails/ActiveResource/Base). The [pyactiveresource](https://github.com/Shopify/pyactiveresource) library, which this package relies heavily upon is a port of rails/ActiveResource to Python.
198+
199+
Instances of `pyactiveresource` resources map to RESTful resources in the Shopify API.
200+
201+
`pyactiveresource` exposes life cycle methods for creating, finding, updating, and deleting resources which are equivalent to the `POST`, `GET`, `PUT`, and `DELETE` HTTP verbs.
202+
203+
```python
204+
product = shopify.Product()
205+
product.title = "Shopify Logo T-Shirt"
206+
product.id # => 292082188312
207+
product.save() # => True
208+
209+
shopify.Product.exists(product.id) # => True
210+
211+
product = shopify.Product.find(292082188312)
212+
# Resource holding our newly created Product object
213+
# Inspect attributes with person.attributes
214+
215+
product.price = 19.99
216+
product.save() # => True
217+
product.destroy()
218+
# Delete the resource from the remote server (i.e. Shopify)
219+
```
220+
221+
The [tests for this package](https://github.com/Shopify/shopify_python_api/tree/master/test) also serve to provide advanced examples of usage.
222+
196223
### Console
197224

198225
This package also includes the `shopify_api.py` script to make it easy to

0 commit comments

Comments
 (0)