本文整理匯總了Python中spreedly.pyspreedly.api.Client.get_info方法的典型用法代碼示例。如果您正苦於以下問題:Python Client.get_info方法的具體用法?Python Client.get_info怎麽用?Python Client.get_info使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類spreedly.pyspreedly.api.Client
的用法示例。
在下文中一共展示了Client.get_info方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: spreedly_listener
# 需要導入模塊: from spreedly.pyspreedly.api import Client [as 別名]
# 或者: from spreedly.pyspreedly.api.Client import get_info [as 別名]
def spreedly_listener(request):
if request.method == 'POST':
# Try to extract customers' IDs
if request.POST.has_key('subscriber_ids'):
subscriber_ids = request.POST['subscriber_ids'].split(',')
if len(subscriber_ids):
client = Client(settings.SPREEDLY_AUTH_TOKEN, settings.SPREEDLY_SITE_NAME)
for id in subscriber_ids:
# Now let's query Spreedly API for the actual changes
data = client.get_info(int(id))
try:
user = User.objects.get(pk=id)
subscription, created = Subscription.objects.get_or_create(user=user)
for k, v in data.items():
if hasattr(subscription, k):
setattr(subscription, k, v)
subscription.save()
signals.subscription_update.send(sender=subscription, user=User.objects.get(id=id))
except User.DoesNotExist:
# TODO not sure what exactly to do here. Delete the subscripton on spreedly?
pass
#handle gifts
for gift in Gift.objects.filter(to_user__pk__in=subscriber_ids):
gift.send_activation_email()
return HttpResponse() #200 OK
示例2: spreedly_listener
# 需要導入模塊: from spreedly.pyspreedly.api import Client [as 別名]
# 或者: from spreedly.pyspreedly.api.Client import get_info [as 別名]
def spreedly_listener(request):
if request.method == 'POST':
# Try to extract customers' IDs
if request.POST.has_key('subscriber_ids'):
subscriber_ids = request.POST['subscriber_ids'].split(',')
failed_ids = []
if len(subscriber_ids):
client = Client(settings.SPREEDLY_AUTH_TOKEN_SECRET, settings.SPREEDLY_SITE_NAME)
for id in subscriber_ids:
# Now let's query Spreedly API for the actual changes
data = client.get_info(int(id))
try:
user = User.objects.get(pk=id)
subscription, created = Subscription.objects.get_or_create(user=user)
for k, v in data.items():
if hasattr(subscription, k):
setattr(subscription, k, v)
subscription.save()
except User.DoesNotExist, e:
failed_ids.append(id)
if failed_ids:
links = "\n".join([subscriber_url(id) for id in failed_ids])
mail_admins(
subject="Could not update Spreedly Subscriptions",
message="The following subscribers changed on Spreedly, but there's no corresponding User:\n%s" % links
)
return HttpResponse("OK")
示例3: get_subscription
# 需要導入模塊: from spreedly.pyspreedly.api import Client [as 別名]
# 或者: from spreedly.pyspreedly.api.Client import get_info [as 別名]
def get_subscription(user):
client = Client(settings.SPREEDLY_AUTH_TOKEN_SECRET, settings.SPREEDLY_SITE_NAME)
data = client.get_info(user.id)
subscription, created = Subscription.objects.get_or_create(
user=user
)
for k, v in data.items():
if hasattr(subscription, k):
setattr(subscription, k, v)
subscription.save()
return subscription
示例4: spreedly_listener
# 需要導入模塊: from spreedly.pyspreedly.api import Client [as 別名]
# 或者: from spreedly.pyspreedly.api.Client import get_info [as 別名]
def spreedly_listener(request):
if request.method == 'POST':
# Try to extract customers' IDs
if request.POST.has_key('subscriber_ids'):
subscriber_ids = request.POST['subscriber_ids'].split(',')
if len(subscriber_ids):
client = Client(settings.SPREEDLY_AUTH_TOKEN_SECRET, settings.SPREEDLY_SITE_NAME)
for id in subscriber_ids:
# Now let's query Spreedly API for the actual changes
data = client.get_info(int(id))
subscription, created = Subscription.objects.get_or_create(
user__pk=id
)
for k, v in data.items():
if hasattr(subscription, k):
setattr(subscription, k, v)
subscription.save()
return HttpResponse("OK")
raise Http404
示例5: get_subscription
# 需要導入模塊: from spreedly.pyspreedly.api import Client [as 別名]
# 或者: from spreedly.pyspreedly.api.Client import get_info [as 別名]
def get_subscription(user, site=DEFAULT_SITE_ALIAS):
site=get_site(site)
cache_key = 'spreedly-subscription-%d' % user.id
subscription = cache.get(cache_key)
if not subscription:
client = Client(site['SPREEDLY_AUTH_TOKEN_SECRET'], site['SPREEDLY_SITE_NAME'])
data = client.get_info(user.id)
subscription, created = Subscription.objects.get_or_create(
user=user,
spreedly_site_name=site['SPREEDLY_SITE_NAME']
)
for k, v in data.items():
if hasattr(subscription, k):
setattr(subscription, k, v)
subscription.save()
cache.set(cache_key, subscription, 60 * 60)
return subscription