# Path: oscar_mws/feeds/gateway.py
# OP_TYPE_UPDATE = 'Update'
# OP_TYPE_PARTIAL_UPDATE = 'PartialUpdate'
# OP_TYPE_DELETE = 'Delete'
# class MwsFeedError(BaseException):
# def handle_feed_submission_response(merchant, response, feed_xml=None):
# def submit_product_feed(products, marketplaces, dry_run=False,
#                         operation_type=OP_TYPE_UPDATE):
# def update_feed_submission(submission):
# def update_feed_submissions(merchant):
# def list_submitted_feeds(merchants=None):
# def cancel_submission(submission):
# def process_submission_results(submission):
# def update_product_identifiers(merchant, products):
# def switch_product_fulfillment(marketplace, products, dry_run=False):


from optparse import make_option
from django.conf import settings
from django.db.models import get_model
from django.utils.translation import ugettext_lazy as _
from django.core.management.base import NoArgsCommand
from oscar_mws.feeds import gateway



Product = get_model('catalogue', 'Product')


class Command(NoArgsCommand):
    option_list = NoArgsCommand.option_list + (
        make_option(
            '--lookup-asins',
            action='store_true',
            dest='lookup_asins',
            default=False,
            help=_('Updates the ASINs for all products without one.')
        ),
    )

    def handle_noargs(self, **options):
        if options.get('lookup_asins'):
            products = Product.objects.filter(
                amazon_profile__asin=''
            )
            gateway.update_product_identifiers(
                products,

# Path: oscar_mws/feeds/gateway.py
# OP_TYPE_UPDATE = 'Update'
# OP_TYPE_PARTIAL_UPDATE = 'PartialUpdate'
# OP_TYPE_DELETE = 'Delete'
# class MwsFeedError(BaseException):
# def handle_feed_submission_response(merchant, response, feed_xml=None):
# def submit_product_feed(products, marketplaces, dry_run=False,
#                         operation_type=OP_TYPE_UPDATE):
# def update_feed_submission(submission):
# def update_feed_submissions(merchant):
# def list_submitted_feeds(merchants=None):
# def cancel_submission(submission):
# def process_submission_results(submission):
# def update_product_identifiers(merchant, products):
# def switch_product_fulfillment(marketplace, products, dry_run=False):


# Path: oscar_mws/management/commands/mws_update_products.py
from optparse import make_option
from django.conf import settings
from django.db.models import get_model
from django.utils.translation import ugettext_lazy as _
from django.core.management.base import NoArgsCommand
from oscar_mws.feeds import gateway




Product = get_model('catalogue', 'Product')


class Command(NoArgsCommand):
    option_list = NoArgsCommand.option_list + (
        make_option(
            '--lookup-asins',
            action='store_true',
            dest='lookup_asins',
            default=False,
            help=_('Updates the ASINs for all products without one.')
        ),
    )

    def handle_noargs(self, **options):
        if options.get('lookup_asins'):
            products = Product.objects.filter(
                amazon_profile__asin=''
            )
            gateway.update_product_identifiers(
                products,

                marketplace_id=settings.MWS_MARKETPLACE_ID