Last active
October 12, 2015 18:18
-
-
Save underscorephil/4067364 to your computer and use it in GitHub Desktop.
Retrieve required price options
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SoftLayer | |
apiUsername = '' | |
apiKey = '' | |
package = 46 | |
client = SoftLayer.Client(username=apiUsername, api_key=apiKey) | |
categoryObjectMask = "mask[isRequired, itemCategory[id, name]]" | |
configurations = client['Product_Package'].getConfiguration( | |
id=package, mask=categoryObjectMask) | |
pricesObjectMask = "mask[id;item.description;categories.id]" | |
prices = client['Product_Package'].getItemPrices( | |
id=package, mask=pricesObjectMask) | |
headerFormat = '%s - %s:' | |
priceFormat = ' %s -- %s' | |
for configuration in configurations: | |
if (not configuration['isRequired']): | |
continue | |
print headerFormat % (configuration['itemCategory']['name'], | |
configuration['itemCategory']['id']) | |
for price in prices: | |
if ('categories' not in price): | |
continue | |
if any((category.get('id') == configuration['itemCategory']['id'] | |
for category in price['categories'])): | |
print priceFormat % (price['id'], price['item']['description']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment