Exemplo n.º 1
0
import constants
import saks_api_utils

#
#Note: This sample is a sequencial product catalog data extraction
#For more performatic example, look at the paralel product catalog extraction sample code
#

print ">>> Product catalog download and load process started ..."

parsed = saks_api_utils.getResource(constants.product_catalog_by_page_url + "1" + constants.api_key_product)

if parsed == None:
	saks_api_utils.printMainHttpError

resource = parsed['resource']
#Do something with your content, save it in your DB, extract the data you want, etc
#For the example, I am gonna print the product code only

print constants.product_catalog_by_page_url + "1"
print resource[0]['product_code']

counter = 1
# iterate through every product page
link_to_next_page = parsed['linkRepresentation']
while link_to_next_page != None:

	next_page = link_to_next_page['next']['href']
	parsed = saks_api_utils.getResource(next_page + constants.api_key_product)
	resource = parsed['resource']
Exemplo n.º 2
0
import constants
import saks_api_utils

print ">>> Inventory by upc download and load process started ..."

parsed = saks_api_utils.getResource(constants.product_catalog_by_page_url + "1" + constants.api_key_product)

if parsed == None:
	saks_api_utils.printMainHttpError

resource = parsed['resource']

print constants.product_catalog_by_page_url + "1"
#Note: I am assuming that the first product in the array has variants(upcs)
#If not, this will blow up
upc_code = resource[0]['variants'][0]['upc']
print upc_code

parsed = saks_api_utils.getResource(constants.inventory_by_variant_url + upc_code + constants.api_key_inventory)

#Do something with your content, save it in your DB, extract the data you want, etc
#For the example, I am gonna print some values
print parsed['upc'], parsed['in_stock'], parsed['on_order']

print ">>> Inventory by upc downloaded and loaded with success!"


Exemplo n.º 3
0
import constants
import saks_api_utils

print ">>> Events download and load process started ..."

parsed = saks_api_utils.getResource(constants.content_events_url + constants.api_key_events)

if parsed == None:
	saks_api_utils.printMainHttpError

resource = parsed['resource']

print constants.content_events_url
print resource['stores']['store']['name']

print ">>> Events downloaded and loaded with success!"