def main(argv):
    # Authenticate and construct service.
    service, config, _ = common.init(argv, __doc__)
    merchant_id = config['merchantId']
    email = None
    if common.json_absent_or_false(config, 'accountSampleUser'):
        print(
            'Must specify the user email to remove in the samples configuration.'
        )
        sys.exit(1)
    email = config['accountSampleUser']

    # First we need to retrieve the existing set of users.
    account = service.accounts().get(merchantId=merchant_id,
                                     accountId=merchant_id,
                                     fields='users').execute()

    if common.json_absent_or_false(account, 'users'):
        print('No users in account %d.' % merchant_id)
        sys.exit(1)

    matched = [u for u in account['users'] if u['emailAddress'] == email]
    if not matched:
        print('User %s was not found.' % email)
        sys.exit(1)

    for u in matched:
        account['users'].remove(u)

    # Patch account with new user list.
    service.accounts().patch(merchantId=merchant_id,
                             accountId=merchant_id,
                             body=account).execute()

    print('User %s was removed from merchant ID %d' % (email, merchant_id))
def main(argv):
  # Authenticate and construct service.
  service, config, _ = common.init(argv, __doc__)
  merchant_id = config['merchantId']
  common.check_mca(config, False)

  request = service.productstatuses().list(
      merchantId=merchant_id, maxResults=MAX_PAGE_SIZE)

  while request is not None:
    result = request.execute()
    if common.json_absent_or_false(result, 'resources'):
      print('No products were found.')
      break
    else:
      statuses = result['resources']
      for status in statuses:
        print('- Product "%s" with title "%s":' % (status['productId'],
                                                   status['title']))
        if common.json_absent_or_false(status, 'dataQualityIssues'):
          print('  No data quality issues.')
        else:
          print('  Found %d data quality issues:' %
                len(status['dataQualityIssues']))
          for issue in status['dataQualityIssues']:
            if common.json_absent_or_false(issue, 'detail'):
              print('  - (%s) [%s]' % (issue['severity'], issue['id']))
            else:
              print('  - (%s) [%s] %s' % (issue['severity'], issue['id'],
                                          issue['detail']))
      request = service.productstatuses().list_next(request, result)
Пример #3
0
def main(argv):
    # Authenticate and construct service.
    service, config, flags = common.init(argv, __doc__, parents=[argparser])
    merchant_id = config['merchantId']
    account_id = flags.account_id

    if not account_id:
        account_id = merchant_id
    if merchant_id != account_id:
        common.check_mca(
            config,
            True,
            msg='Non-multi-client accounts can only set their own information.'
        )

    settings = sample.create_accounttax_sample(account_id)
    status = service.accounttax().update(merchantId=merchant_id,
                                         accountId=merchant_id,
                                         body=settings).execute()
    print('Account %s:' % status['accountId'])
    if common.json_absent_or_false(status, 'rules'):
        print('- No tax settings, so no tax is charged.')
    else:
        print('- Found %d tax rules:' % len(status['rules']))
        for issue in status['rules']:
            if not common.json_absent_or_false(issue, 'ratePercent'):
                print('  - For %s in %s: %s%%' %
                      (issue['locationId'], issue['country'],
                       issue['ratePercent']))
            if not common.json_absent_or_false(issue, 'useGlobalRate'):
                print('  - For %s in %s: using the global tax table rate.' %
                      (issue['locationId'], issue['country']))
            if not common.json_absent_or_false(issue, 'shippingTaxed'):
                print('   NOTE: Shipping charges are also taxed.')
def main(argv):
    # Authenticate and construct service.
    service, config, flags = common.init(argv, __doc__, parents=[argparser])
    merchant_id = config['merchantId']
    product_ids = flags.product_ids

    batch = {
        'entries': [{
            'batchId': i,
            'merchantId': merchant_id,
            'method': 'delete',
            'productId': v,
        } for i, v in enumerate(product_ids)],
    }

    request = service.products().custombatch(body=batch)
    result = request.execute()

    if result['kind'] == 'content#productsCustomBatchResponse':
        for entry in result['entries']:
            if common.json_absent_or_false(entry, 'errors'):
                print('Deletion of product %s (batch entry %d) successful.' %
                      (batch['entries'][entry['batchId']]['productId'],
                       entry['batchId']))
            else:
                print('Errors for batch entry %d:' % entry['batchId'])
                print(
                    json.dumps(entry['errors'],
                               sort_keys=True,
                               indent=2,
                               separators=(',', ': ')))

    else:
        print('There was an error. Response: %s' % result)
Пример #5
0
def main(argv):
    # Authenticate and construct service.
    service, config, flags = common.init(argv, __doc__, parents=[argparser])
    merchant_id = config['merchantId']
    account_ids = flags.account_ids
    common.check_mca(config, True)

    batch = {
        'entries': [{
            'batchId': i,
            'merchantId': merchant_id,
            'method': 'delete',
            'accountId': v,
        } for i, v in enumerate(account_ids)],
    }

    request = service.accounts().custombatch(body=batch)
    result = request.execute()

    if result['kind'] == 'content#accountsCustomBatchResponse':
        entries = result['entries']
        for entry in entries:
            if not common.json_absent_or_false(entry, 'errors'):
                print('Errors for batch entry %d:' % entry['batchId'])
                print(
                    json.dumps(entry['errors'],
                               sort_keys=True,
                               indent=2,
                               separators=(',', ': ')))
            else:
                print('Account %s deleted (batch entry %d).' %
                      (account_ids[entry['batchId']], entry['batchId']))
    else:
        print('There was an error. Response: %s' % result)
Пример #6
0
def main(argv):
    # Authenticate and construct service.
    service, config, _ = common.init(argv, __doc__)
    merchant_id = config['merchantId']
    adwords_id = None
    if common.json_absent_or_false(config, 'accountSampleAdWordsCID'):
        print(
            'Must specify the AdWords CID to link in the samples configuration.'
        )
        sys.exit(1)
    adwords_id = config['accountSampleAdWordsCID']

    # First we need to retrieve the existing set of users.
    response = service.accounts().get(merchantId=merchant_id,
                                      accountId=merchant_id,
                                      fields='adwordsLinks').execute()

    account = response

    # Add new user to existing user list.
    adwords_link = {'adwordsId': adwords_id, 'status': 'active'}
    account.setdefault('adwordsLinks', []).append(adwords_link)

    # Patch account with new user list.
    response = service.accounts().patch(merchantId=merchant_id,
                                        accountId=merchant_id,
                                        body=account).execute()

    print('AdWords ID %d was added to merchant ID %d' %
          (adwords_id, merchant_id))
Пример #7
0
def main(argv):
  # Authenticate and construct service.
  service, config, _ = common.init(argv, __doc__)
  merchant_id = config['merchantId']
  email = None
  if common.json_absent_or_false(config, 'accountSampleUser'):
    print('Must specify the user email to add in the samples configuration.')
    sys.exit(1)
  email = config['accountSampleUser']

  # First we need to retrieve the existing set of users.
  response = service.accounts().get(
      merchantId=merchant_id, accountId=merchant_id,
      fields='users').execute()

  account = response

  # Add new user to existing user list.
  new_user = {'emailAddress': email, 'admin': False}
  account['users'].append(new_user)

  # Patch account with new user list.
  response = service.accounts().patch(
      merchantId=merchant_id, accountId=merchant_id, body=account).execute()

  print('Account %s was added to merchant ID %d' % (email, merchant_id))
Пример #8
0
def main(argv):
    # Authenticate and construct service.
    service, config, flags = common.init(argv, __doc__, parents=[argparser])
    merchant_id = config['merchantId']
    account_id = flags.account_id

    if not account_id:
        account_id = merchant_id
    elif merchant_id != account_id:
        common.check_mca(
            config,
            True,
            msg='Non-multi-client accounts can only get their own information.'
        )

    settings = sample.create_shippingsettings_sample()
    service.shippingsettings().update(merchantId=merchant_id,
                                      accountId=merchant_id,
                                      body=settings).execute()
    status = service.shippingsettings().get(merchantId=merchant_id,
                                            accountId=merchant_id).execute()
    print('Account %s:' % status['accountId'])
    if common.json_absent_or_false(status, 'postalCodeGroups'):
        print('- No postal code groups.')
    else:
        print('- %d postal code group(s):' % len(status['postalCodeGroups']))
    if common.json_absent_or_false(status, 'services'):
        print('- No services.')
    else:
        print('- %d service(s):' % len(status['services']))
        for service in status['services']:
            print('  Service "%s":' % service['name'])
            print('  - Delivery country: %s' % service['deliveryCountry'])
            print('  - Currency: %s' % service['currency'])
            print('  - Active: %s' % service['active'])
            print('  - Delivery time: %d - %d days' %
                  (service['deliveryTime']['minTransitTimeInDays'],
                   service['deliveryTime']['maxTransitTimeInDays']))
            if common.json_absent_or_false(service, 'rateGroups'):
                print('  - No rate groups.')
            else:
                print('  - %d rate groups.' % len(service['rateGroups']))
def _list_all_orders(orders, merchant_id, **args):
    request = orders.list(merchantId=merchant_id, **args)
    while request is not None:
        result = request.execute()
        if common.json_absent_or_false(result, 'resources'):
            print('No orders were found.')
        else:
            order_resources = result['resources']
            for order in order_resources:
                utils.print_order(order)
            request = orders.list_next(request, result)
def main(argv):
    # Authenticate and construct service.
    service, config, _ = common.init(argv, __doc__)
    merchant_id = config['merchantId']
    common.check_mca(config, True)

    account_names = [
        'account%s' % common.get_unique_id() for i in range(BATCH_SIZE)
    ]
    batch = {
        'entries': [{
            'batchId': i,
            'merchantId': merchant_id,
            'method': 'insert',
            'account': {
                'name': v,
                'websiteUrl': 'https://%s.example.com/' % v,
            },
        } for i, v in enumerate(account_names)],
    }

    request = service.accounts().custombatch(body=batch)
    result = request.execute()

    if result['kind'] == 'content#accountsCustomBatchResponse':
        for entry in result['entries']:
            if not common.json_absent_or_false(entry, 'account'):
                account = entry['account']
                print('Account %s with name "%s" was created.' %
                      (account['id'], account['name']))
            elif not common.json_absent_or_false(entry, 'errors'):
                print('Errors for batch entry %d:' % entry['batchId'])
                print(
                    json.dumps(entry['errors'],
                               sort_keys=True,
                               indent=2,
                               separators=(',', ': ')))
    else:
        print('There was an error. Response: %s' % result)
def main(argv):
    # Authenticate and construct service.
    service, config, flags = common.init(argv, __doc__, parents=[argparser])
    merchant_id = config['merchantId']
    product_id = flags.product_id
    common.check_mca(config, False)

    status = service.productstatuses().get(merchantId=merchant_id,
                                           productId=product_id).execute()

    print('- Product "%s" with title "%s":' %
          (status['productId'], status['title']))
    if common.json_absent_or_false(status, 'dataQualityIssues'):
        print('  No data quality issues.')
    else:
        print('  Found %d data quality issues:' %
              len(status['dataQualityIssues']))
        for issue in status['dataQualityIssues']:
            if common.json_absent_or_false(issue, 'detail'):
                print('  - (%s) [%s]' % (issue['severity'], issue['id']))
            else:
                print('  - (%s) [%s] %s' %
                      (issue['severity'], issue['id'], issue['detail']))
Пример #12
0
def main(argv):
    # Authenticate and construct service.
    service, config, _ = common.init(argv, __doc__)
    merchant_id = config['merchantId']

    batch = {
        'entries': [{
            'batchId':
            i,
            'merchantId':
            merchant_id,
            'method':
            'insert',
            'datafeed':
            sample.create_datafeed_sample(config,
                                          'feed%s' % common.get_unique_id()),
        } for i in range(BATCH_SIZE)],
    }

    request = service.datafeeds().custombatch(body=batch)
    result = request.execute()

    if result['kind'] == 'content#datafeedsCustomBatchResponse':
        entries = result['entries']
        for entry in entries:
            if not common.json_absent_or_false(entry, 'datafeed'):
                print('Datafeed %s with name "%s" created.' %
                      (entry['datafeed']['id'], entry['datafeed']['name']))
            elif not common.json_absent_or_false(entry, 'errors'):
                print('Errors for batch entry %d:' % entry['batchId'])
                print(
                    json.dumps(entry['errors'],
                               sort_keys=True,
                               indent=2,
                               separators=(',', ': ')))
    else:
        print('There was an error. Response: %s' % result)
Пример #13
0
def main(argv):
  # Authenticate and construct service.
  service, config, _ = common.init(argv, __doc__)
  merchant_id = config['merchantId']

  batch = {
      'entries': [{
          'batchId': i,
          'merchantId': merchant_id,
          'method': 'insert',
          'product': sample.create_product_sample(
              config,
              'book#%s' % common.get_unique_id(),
              title='This is book number %d' % i,
              price={
                  'value': '%d.50' % i,
                  'currency': 'USD',
              }),
          } for i in range(BATCH_SIZE)],
  }

  request = service.products().custombatch(body=batch)
  result = request.execute()

  if result['kind'] == 'content#productsCustomBatchResponse':
    entries = result['entries']
    for entry in entries:
      if not common.json_absent_or_false(entry, 'product'):
        product = entry['product']
        print('Product "%s" with offerId "%s" and title "%s" was created.' %
              (product['id'], product['offerId'], product['title']))
      elif not common.json_absent_or_false(entry, 'errors'):
        print('Errors for batch entry %d:' % entry['batchId'])
        print(json.dumps(entry['errors'], sort_keys=True, indent=2,
                         separators=(',', ': ')))
  else:
    print('There was an error. Response: %s' % result)
Пример #14
0
def main(argv):
    # Authenticate and construct service.
    service, config, _ = common.init(argv, __doc__)
    merchant_id = config['merchantId']
    common.check_mca(config, True)

    request = service.accountstatuses().list(merchantId=merchant_id,
                                             maxResults=MAX_PAGE_SIZE)

    while request is not None:
        result = request.execute()
        if common.json_absent_or_false(result, 'resources'):
            print('No accounts were found.')
            break
        else:
            statuses = result['resources']
            for status in statuses:
                print('Account %s:' % status['accountId'])
                if common.json_absent_or_false(status, 'dataQualityIssues'):
                    print('- No data quality issues.')
                else:
                    print('- Found %d data quality issues:' %
                          len(status['dataQualityIssues']))
                    for issue in status['dataQualityIssues']:
                        print('  - (%s) [%s]' %
                              (issue['severity'], issue['id']))
                        if common.json_absent_or_false(issue, 'exampleItems'):
                            print('  - No example items.')
                        else:
                            print(
                                '  - Have %d examples from %d affected items:'
                                % (len(
                                    issue['exampleItems']), issue['numItems']))
                            for example in issue['exampleItems']:
                                print('    - %s: %s' %
                                      (example['itemId'], example['title']))
            request = service.accountstatuses().list_next(request, result)
def main(argv):
    # Authenticate and construct service.
    service, config, _ = common.init(argv, __doc__)
    merchant_id = config['merchantId']
    adwords_id = None
    if common.json_absent_or_false(config, 'accountSampleAdWordsCID'):
        print('Must specify the AdWords CID to unlink in the samples config.')
        sys.exit(1)
    adwords_id = config['accountSampleAdWordsCID']

    # First we need to retrieve the existing set of users.
    account = service.accounts().get(merchantId=merchant_id,
                                     accountId=merchant_id,
                                     fields='adwordsLinks').execute()

    if common.json_absent_or_false(account, 'adwordsLinks'):
        print('No AdWords accounts linked to account %d.' % merchant_id)
        sys.exit(1)

    matched = [
        l for l in account['adwordsLinks'] if l['adwordsId'] == adwords_id
    ]
    if not matched:
        print('AdWords account %d was not linked.' % adwords_id)
        sys.exit(1)

    for u in matched:
        account['adwordsLinks'].remove(u)

    # Patch account with new user list.
    service.accounts().patch(merchantId=merchant_id,
                             accountId=merchant_id,
                             body=account).execute()

    print('AdWords ID %d was removed from merchant ID %d' %
          (adwords_id, merchant_id))
def _print_line_item(item):
  """Factored out line item printing to reduce nesting depth."""

  def print_if_nonzero(value, text):
    if value > 0:
      print('  - %s: %s' % (text, value))

  print('  Line item %s' % item['id'])
  print('  - Product: %s (%s)' % (item['product']['id'],
                                  item['product']['title']))
  print('  - Price: %s %s' % (item['price']['value'],
                              item['price']['currency']))
  print('  - Tax: %s %s' % (item['tax']['value'], item['tax']['currency']))
  print_if_nonzero(item['quantityOrdered'], 'Quantity ordered')
  print_if_nonzero(item['quantityPending'], 'Quantity pending')
  print_if_nonzero(item['quantityShipped'], 'Quantity shipped')
  print_if_nonzero(item['quantityDelivered'], 'Quantity delivered')
  print_if_nonzero(item['quantityReturned'], 'Quantity returned')
  print_if_nonzero(item['quantityCanceled'], 'Quantity canceled')
  if not common.json_absent_or_false(item, 'shippingDetails'):
    print('  - Ship by date: %s' % item['shippingDetails']['shipByDate'])
    print('  - Deliver by date: %s' % item['shippingDetails']['deliverByDate'])
    method = item['shippingDetails']['method']
    print('  - Deliver via %s %s (%s - %s days).' %
          (method['carrier'], method['methodName'], method['minDaysInTransit'],
           method['maxDaysInTransit']))
  if not common.json_absent_or_false(item, 'cancellations'):
    print('  - %d cancellation(s):' % len(item['cancellations']))
    for cancel in item['cancellations']:
      print('    Cancellation:')
      if not common.json_absent_or_false(cancel, 'actor'):
        print('    - Actor: %s' % cancel['actor'])
      print('    - Creation date: %s' % cancel['creationDate'])
      print('    - Quantity: %d' % cancel['quantity'])
      print('    - Reason: %s' % cancel['reason'])
      print('    - Reason text: %s' % cancel['reasonText'])
  if (not common.json_absent_or_false(item, 'returnInfo') and
      item['returnInfo']['isReturnable']):
    print('  - Item is returnable.')
    print('    - Days to return: %s' % item['returnInfo']['daysToReturn'])
    print('    - Return policy is at %s.' % item['returnInfo']['policyUrl'])
  else:
    print('  - Item is not returnable.')
  if not common.json_absent_or_false(item, 'returns'):
    print('  - %d return(s):' % len(item['returns']))
    for ret in item['returns']:
      print('    Return:')
      if not common.json_absent_or_false(ret, 'actor'):
        print('    - Actor: %s' % ret['actor'])
      print('    - Creation date: %s' % ret['creationDate'])
      print('    - Quantity: %d' % ret['quantity'])
      print('    - Reason: %s' % ret['reason'])
      print('    - Reason text: %s' % ret['reasonText'])
Пример #17
0
def main(argv):
    # Authenticate and construct service.
    service, config, _ = common.init(argv, __doc__)
    merchant_id = config['merchantId']

    request = service.datafeeds().list(merchantId=merchant_id)

    while request is not None:
        result = request.execute()
        if common.json_absent_or_false(result, 'resources'):
            print('No datafeeds were found.')
            break
        else:
            datafeeds = result['resources']
            for datafeed in datafeeds:
                print('Datafeed %s with name "%s" was found.' %
                      (datafeed['id'], datafeed['name']))
        request = service.datafeeds().list_next(request, result)
def create_datafeed_sample(config, name, **overwrites):
    """Creates a sample datafeed object for the datafeed samples.

  Args:
      config: dictionary, Python version of config JSON
      name: string, name of the new datafeed
      **overwrites: dictionary, a set of datafeed attributes to overwrite

  Returns:
      A new datafeed in dictionary form.
  """
    website_url = 'https://feeds.myshop.com/'
    if not common.json_absent_or_false(config, 'websiteUrl'):
        website_url = config['websiteUrl']

    datafeed = {
        'name': name,
        'contentType': 'products',
        'attributeLanguage': 'en',
        'contentLanguage': _constants.CONTENT_LANGUAGE,
        'intendedDestinations': ['Shopping'],
        # The file name must be unique per account. We only use unique names in
        # these examples, so it's not an issue here.
        'fileName': name,
        'targetCountry': _constants.TARGET_COUNTRY,
        # You can schedule monthly, weekly or daily.
        #
        # Monthly - set day of month ('dayOfMonth') and hour ('hour')
        # Weekly - set day of week ('weekday') and hour ('hour')
        # Daily - set just the hour ('hour')
        'fetchSchedule': {
            'weekday': 'monday',
            'hour': 6,
            'timeZone': 'America/Los_Angeles',
            'fetchUrl': website_url + name
        },
        'format': {
            'fileEncoding': 'utf-8',
            'columnDelimiter': 'tab',
            'quotingMode': 'value quoting'
        }
    }
    datafeed.update(overwrites)
    return datafeed
Пример #19
0
def main(argv):
    # Authenticate and construct service.
    service, config, _ = common.init(argv, __doc__)
    merchant_id = config['merchantId']

    request = service.products().list(merchantId=merchant_id,
                                      maxResults=MAX_PAGE_SIZE)

    while request is not None:
        result = request.execute()
        if common.json_absent_or_false(result, 'resources'):
            print('No products were found.')
            break
        else:
            products = result['resources']
            for product in products:
                print('Product "%s" with title "%s" was found.' %
                      (product['id'], product['title']))

            request = service.products().list_next(request, result)
def main(argv):
    # Authenticate and construct service.
    service, config, _ = common.init(argv, __doc__)
    merchant_id = config['merchantId']
    common.check_mca(config, True)

    request = service.accounts().list(merchantId=merchant_id,
                                      maxResults=MAX_PAGE_SIZE)

    while request is not None:
        result = request.execute()
        if common.json_absent_or_false(result, 'resources'):
            print('No accounts were found.')
            break
        else:
            accounts = result['resources']
            for account in accounts:
                print('Account %s with name "%s" was found.' %
                      (account['id'], account['name']))
            request = service.accounts().list_next(request, result)
Пример #21
0
def main(argv):
  # Authenticate and construct service.
  service, config, flags = common.init(
      argv, __doc__, parents=[argparser])
  merchant_id = config['merchantId']
  product_ids = flags.product_ids

  new_status = {
      'availability': 'out of stock',
      'price': {
          'value': 3.14,
          'currency': 'USD'
      }
  }

  batch = {
      'entries': [{
          'batchId': i,
          'merchantId': merchant_id,
          'storeCode': v.split(':')[0],
          'productId': v,
          'inventory': new_status,
      } for i, v in enumerate(product_ids)],
  }

  request = service.inventory().custombatch(body=batch)
  result = request.execute()

  if result['kind'] == 'content#inventoryCustomBatchResponse':
    entries = result['entries']
    for entry in entries:
      if not common.json_absent_or_false(entry, 'errors'):
        print('Errors for batch entry %d:' % entry['batchId'])
        print(json.dumps(entry['errors'], sort_keys=True, indent=2,
                         separators=(',', ': ')))
      else:
        print('Successfully performed inventory update for product "%s".' %
              (product_ids[entry['batchId']]))
  else:
    print('There was an error. Response: %s' % result)
def print_order(order):
  """Prints out the given order with some human-readable indentation.

  Args:
    order: The Python representation of a Order resource.
  """
  print('Order %s:' % order['id'])
  print('- Status: %s' % order['status'])
  print('- Merchant: %s' % order['merchantId'])
  if not common.json_absent_or_false(order, 'merchantOrderId'):
    print('- Merchant order ID: %s' % order['merchantOrderId'])
  if not common.json_absent_or_false(order, 'customer'):
    print('- Customer information:')
    print('  - Full name: %s' % order['customer']['fullName'])
    print('  - Email: %s' % order['customer']['email'])
  print('- Placed on date: %s' % order['placedDate'])
  if not common.json_absent_or_false(order, 'netAmount'):
    print('- Name amount: %s %s' % (order['netAmount']['value'],
                                    order['netAmount']['currency']))
  print('- Payment status: %s' % order['paymentStatus'])
  if not common.json_absent_or_false(order, 'paymentMethod'):
    print('- Payment method:')
    print('  - Type: %s' % order['paymentMethod']['type'])
    print('  - Expiration date: %s/%s' %
          (order['paymentMethod']['expirationMonth'],
           order['paymentMethod']['expirationYear']))
  if common.json_absent_or_false(order, 'acknowledged'):
    print('- Acknowledged: no')
  else:
    print('- Acknowledged: yes')
  if not common.json_absent_or_false(order, 'lineItems'):
    print('- %d line item(s):' % len(order['lineItems']))
    for item in order['lineItems']:
      _print_line_item(item)
  print('- Shipping option: %s' % order['shippingOption'])
  if not common.json_absent_or_false(order, 'shippingCost'):
    print('- Shipping cost: %s %s' % (order['shippingCost']['value'],
                                      order['shippingCost']['currency']))
  if not common.json_absent_or_false(order, 'shippingCostTax'):
    print('- Shipping cost tax: %s %s' % (order['shippingCostTax']['value'],
                                          order['shippingCostTax']['currency']))
  if not common.json_absent_or_false(order, 'shipments'):
    print('- %d shipments(s):' % len(order['shipments']))
    for shipment in order['shipments']:
      print('  Shipment %s:' % shipment['id'])
      print('  - Creation date: %s:' % shipment['creationDate'])
      print('  - Carrier: %s:' % shipment['carrier'])
      print('  - Tracking ID: %s:' % shipment['trackingId'])
      if not common.json_absent_or_false(shipment, 'lineItems'):
        print('  - %d line item(s):' % len(shipment['lineItems']))
        for item in shipment['lineItems']:
          print('    %d of item %s' % (item['quantity'], item['lineItemId']))
      if not common.json_absent_or_false(shipment, 'deliveryDate'):
        print('  - Delivery date: %s' % shipment['deliveryDate'])