Bases: shopify_trois.engines.http.oauth_engine.OAuthEngine
The Json engine implements an HTTP transport using JSON with OAuth authentication.
Parameters: |
|
---|
Add the model instance to the store.
Parameters: |
|
---|
example usage:
from shopify_trois.engines.http import Json as Shopify
from shopify_trois import Credentials
from shopify_trois.models import Blog
credentials = Credentials(...)
shopify = Shopify(store_name="test", credentials=credentials)
blog = Blog(title="Awesome")
shopify.add(blog)
Generates the oauth authorization url.
Return the count of a model, filtered by parameters
example usage:
from shopify_trois.engines.http import Json as Shopify
from shopify_trois import Credentials
from shopify_trois.models import Blog
credentials = Credentials(...)
shopify = Shopify(store_name="test", credentials=credentials)
blogs = shopify.count(Blog)
Executes a custom post method on an instance.
Parameters: |
|
---|
Delete a model instance.
An InvalidRequestException will be raised if the instance does not yet exists.
Parameters: |
|
---|
example usage:
from shopify_trois.engines.http import Json as Shopify
from shopify_trois import Credentials
from shopify_trois.models import Blog
credentials = Credentials(...)
shopify = Shopify(store_name="test", credentials=credentials)
blog = Blog(id=3)
shopify.delete(blog)
Get a specific model instance by primary key.
Parameters: |
|
---|
example usage:
from shopify_trois.engines.http import Json as Shopify
from shopify_trois import Credentials
from shopify_trois.models import Blog
credentials = Credentials(...)
shopify = Shopify(store_name="test", credentials=credentials)
blog = shopify.fetch(Blog, 2)
Fetch the index for a given model and supplied parameters.
Parameters: |
|
---|
example usage:
from shopify_trois.engines.http import Json as Shopify
from shopify_trois import Credentials
from shopify_trois.models import Blog
credentials = Credentials(...)
shopify = Shopify(store_name="test", credentials=credentials)
blogs = shopify.index(Blog)
for blog in blogs:
print(blog.to_dict())
Fetch the OAuth access token from shopify.
setup_access_token() should be used.
Generate the OAuth access token url.
Generates the oauth authorize url.
Parameters: | redirect_to – URL shopify will redirect to once authorized. |
---|
Utility function wrapping getting the oauth token and setting the credential values.
Utility method to sync the credentials access token with the HTTP session.
Update a model instance.
An InvalidRequestException will be raised if the instance has not been marked as existing.
Parameters: |
|
---|
example usage:
from shopify_trois.engines.http import Json as Shopify
from shopify_trois import Credentials
from shopify_trois.models import Blog
credentials = Credentials(...)
shopify = Shopify(store_name="test", credentials=credentials)
blog = shopify.fetch(Blog, 4)
blog.commentable = False
shopify.update(blog)
Generates the url for the provided request.
Parameters: | req – See Request |
---|
Verify the signature provided with the query parameters.
http://docs.shopify.com/api/tutorials/oauth
example usage:
from shopify_trois import Credentials
from shopify_trois.engines import Json as Shopify
from urllib.parse import parse_qsl
credentials = Credentials(
api_key='your_api_key',
scope=['read_orders'],
secret='your_app_secret'
)
shopify = Shopify(shop_name="your_store_name", credentials= credentials)
query_parameters = parse_qsl("code=238420989938cb70a609f6ece2e2586b&shop=yourstore.myshopify.com×tamp=1373382939&signature=6fb122e33c21851c465345b8cb97245e")
if not shopify.verify_signature(query_parameters):
raise Exception("invalid signature")
credentials.code = dict(query_parameters).get('code')
shopify.setup_access_token()
Returns: | Returns True if the signature is valid. |
---|