当前位置: 首页>>代码示例>>Python>>正文


Python Client.get_info方法代码示例

本文整理汇总了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
开发者ID:atkinson,项目名称:django-spreedly,代码行数:31,代码来源:views.py

示例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")
开发者ID:robot-republic,项目名称:django-spreedly,代码行数:33,代码来源:views.py

示例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
开发者ID:robot-republic,项目名称:django-spreedly,代码行数:14,代码来源:functions.py

示例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
开发者ID:jsmelquist,项目名称:django-spreedly,代码行数:22,代码来源:views.py

示例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
开发者ID:,项目名称:,代码行数:25,代码来源:


注:本文中的spreedly.pyspreedly.api.Client.get_info方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。