1 Star 0 Fork 0

Adolph/shopify_python_api

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
mixins.py 1.08 KB
Copy Edit Raw Blame History
Julien Heller authored 2016-04-18 12:11 +08:00 . Enabled accessing count on metafields
import shopify.resources
class Countable(object):
@classmethod
def count(cls, _options=None, **kwargs):
if _options is None:
_options = kwargs
return int(cls.get("count", **_options))
class Metafields(object):
def metafields(self, _options=None, **kwargs):
if _options is None:
_options = kwargs
return shopify.resources.Metafield.find(resource=self.__class__.plural, resource_id=self.id, **_options)
def metafields_count(self, _options=None, **kwargs):
if _options is None:
_options = kwargs
return int(self.get("metafields/count", **_options))
def add_metafield(self, metafield):
if self.is_new():
raise ValueError("You can only add metafields to a resource that has been saved")
metafield._prefix_options = dict(resource=self.__class__.plural, resource_id=self.id)
metafield.save()
return metafield
class Events(object):
def events(self):
return shopify.resources.Event.find(resource=self.__class__.plural, resource_id=self.id)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/chen_guo_hong/shopify_python_api.git
git@gitee.com:chen_guo_hong/shopify_python_api.git
chen_guo_hong
shopify_python_api
shopify_python_api
master

Search