Пример #1
0
#!/usr/bin/env python
import sys
from gilt.rest import GiltApiClient
from gilt.util import print_sale_details

try:
    store = sys.argv.pop(1)
    sale_key = sys.argv.pop(1)
except IndexError:
    print "usage: python %s <store> <sale_key>" % sys.argv[0]
    print
    print "for examples, run:"
    print "  python samples/list-active-sales.py"
    print
    sys.exit(1)

sale = GiltApiClient().sales.detail(store, sale_key)
print_sale_details(sale)
Пример #2
0
#!/usr/bin/env python
from gilt.rest import GiltApiClient

# Get the first active sale in the womens store that has products
client = GiltApiClient(
    api_key='4bc9ea982749056525a630ff9eb6deda9f737c2a94492963f29e32f077ed766f')
for sale in client.sales.active('women'):
    product_urls = sale.products[0:3]
    if not product_urls: continue

    print 'First %d products (of %d) of sale "%s"' % (
        len(product_urls), len(sale.products), sale.name)

    for url in product_urls:
        product = client.products.get(url=url)
        print
        print '  %s:' % product.name
        print '    Web:    %s' % product.url
        print '    Brand:  %s' % product.brand
        print '    Origin: %s' % product.content.origin
        print '    Images in %d resolution(s): %s' % (len(
            product.image_urls), ', '.join([
                "%s x %s" % (w, h) for (w, h) in product.image_urls.image_sizes
            ]))
        for sku in product.skus:
            if 'color' in sku.attribute_names(
            ) and 'size' in sku.attribute_names():
                desc = 'Sku %s is %s size %s' % (sku.id,
                                                 sku.attribute('color').value,
                                                 sku.attribute('size').value)
            else:
Пример #3
0
#!/usr/bin/env python
from gilt.rest import GiltApiClient

for sale in GiltApiClient().sales.active():
    print "%s:" % sale.name
    print "  Store:    %s" % sale.store
    print "  Key:      %s" % sale.sale_key
    print "  Begins:   %s" % sale.begins
    print "  Visit:    %s" % sale.sale_url
    print "  For details:"
    print "    python samples/get-sale-detail.py %s %s" % (sale.store,
                                                           sale.sale_key)
    print
Пример #4
0
#!/usr/bin/env python
from gilt.rest import GiltApiClient

# Get the first active sale in the womens store that has products
client = GiltApiClient()
for sale in client.sales.active('women'):
    product_urls = sale.products[0:3]
    if not product_urls: continue

    print 'First %d products (of %d) of sale "%s"' % (
        len(product_urls), len(sale.products), sale.name)

    for url in product_urls:
        product = client.products.get(url=url)
        print
        print '  %s:' % product.name
        print '    Web:    %s' % product.url
        print '    Brand:  %s' % product.brand
        print '    Origin: %s' % product.content.origin
        print '    Images in %d resolution(s): %s' % (len(
            product.image_urls), ', '.join([
                "%s x %s" % (w, h) for (w, h) in product.image_urls.image_sizes
            ]))
        for sku in product.skus:
            if 'color' in sku.attribute_names(
            ) and 'size' in sku.attribute_names():
                desc = 'Sku %s is %s size %s' % (sku.id,
                                                 sku.attribute('color').value,
                                                 sku.attribute('size').value)
            else:
                desc = 'Sku %s: %s' % (sku.id, ', '.join(
Пример #5
0
#!/usr/bin/env python
from gilt.rest import GiltApiClient
from gilt.util import by_sale_name
from gilt.util import by_sale_begins

sales = GiltApiClient().sales.active()
stores = set(sale.store for sale in sales)
sales_per_store = [(store, sum(1 if sale.store==store else 0 for sale in sales)) for store in stores]

print "Retrieved all active sales"
print "  Total:       %d sales" % len(sales)
for count in sales_per_store:
  print "    %-9s  %d sales" % (count[0].title()+':', count[1])
print

print "First 5, in alphabetical order:"
sales.sort(by_sale_name)
for sale in sales[0:5]:
  print "  %-60s  Begins: %s" % (sale.name, sale.begins)
print

print "First 5, by begin time:"
sales.sort(by_sale_begins)
for sale in sales[0:5]:
  print "  %-60s  Begins: %s" % (sale.name, sale.begins)
print

Пример #6
0
#!/usr/bin/env python
from gilt.rest import GiltApiClient
from gilt.util import by_sale_name
from gilt.util import by_sale_begins

sales = GiltApiClient().sales.active()
stores = set(sale.store for sale in sales)
sales_per_store = [(store,
                    sum(1 if sale.store == store else 0 for sale in sales))
                   for store in stores]

print "Retrieved all active sales"
print "  Total:       %d sales" % len(sales)
for count in sales_per_store:
    print "    %-9s  %d sales" % (count[0].title() + ':', count[1])
print

print "First 5, in alphabetical order:"
sales.sort(by_sale_name)
for sale in sales[0:5]:
    print "  %-60s  Begins: %s" % (sale.name, sale.begins)
print

print "First 5, by begin time:"
sales.sort(by_sale_begins)
for sale in sales[0:5]:
    print "  %-60s  Begins: %s" % (sale.name, sale.begins)
print
Пример #7
0
#!/usr/bin/env python
from gilt.rest import GiltApiClient

for sale in GiltApiClient().sales.active('women'):
  print "%s:" % sale.name
  if sale.description: print "  %s" % sale.description[0:80]
  if sale.products: print "  %d products" % len(sale.products)
  print "  Begins:   %s" % sale.begins
  print "  Ends:     %s" % sale.ends
  print "  Duration: %s" % (sale.ends-sale.begins)
  print