How to use the bigcommerce.resource.Resource function in bigcommerce

To help you get started, we’ve selected a few bigcommerce examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bigcommerce / bigcommerce-api-python / bigcommerce / resource.py View on Github external
class OrderStatus(Resource):
    res_name = "orderstatuses"
    
class OrderStatuses(ResourceSet):
    res_name = "orderstatuses"
    resource_class = OrderStatus

class CustomerGroup(Resource):
    res_name = "customer_groups"
    
class CustomerGroups(ResourceSet):
    res_name = "customer_groups"
    resource_class = CustomerGroup

class Coupon(Resource):
    res_name = "coupons"
    
class Coupons(ResourceSet):
    res_name = "coupons"
    resource_class = Coupon

class Store(Resource):
    res_name = "store"
    
class Stores(ResourceSet):
    """Only supports GET /store.json, according to documentation."""
    res_name = "store"
    resource_class = Store

class Country(ParentResource):
    res_name = "countries"
github bigcommerce / bigcommerce-api-python / bigcommerce / resource.py View on Github external
class Order(ParentResource):
    res_name = "orders"
    
class Orders(ResourceSet):
    res_name = "orders"
    resource_class = Order

class Product(ParentResource):
    res_name = "products"
 
class Products(ResourceSet):
    res_name = "products"
    resource_class = Product
    
class Redirect(Resource):
    res_name = "redirects"
    
class Redirects(ResourceSet):
    res_name = "redirects"
    resource_class = Redirect
    
class Shipping(ParentResource):
    """Only GET"""
    res_name = "shipping"
github bigcommerce / bigcommerce-api-python / bigcommerce / resource.py View on Github external
new_fields = self.client.put('/{}/{}.json'.format(self.res_name, self.id), body, **options)
        # commit changes locally
        self._replace_fields(new_fields)
        
    def _copy_dict(self):
        copy_d = self.__dict__.copy()
        if copy_d.has_key('id'):
            del copy_d['id']
        del copy_d['_fields']
        return copy_d

    def _replace_fields(self, new_fields):
        self._fields = new_fields if new_fields else {}
        self.__dict__ = {'_fields' : self._fields}
 
class ParentResource(Resource):
    """
    A Resource class that has subresources. 

    Implements subresource related operations that do not
    require a specific instance of a ParentResource.
    Contains a SubResourceManager for operations that do.
    """
    # in future, should allow the get methods to take names of the subresources, rather than just class
    # also in future - should move some of these methods to mixins, or otherwise restrict them
    # for resources that do not support some methods ...
    
    def __init__(self, fields=None):
        super(ParentResource, self).__init__(fields)
        self.subresources = SubResourceManager(self)

    @classmethod
github bigcommerce / bigcommerce-api-python / bigcommerce / resource.py View on Github external
class Category(Resource):
    res_name = "categories"
    
class Categories(ResourceSet):
    res_name = "categories"
    resource_class = Category
    
class OrderStatus(Resource):
    res_name = "orderstatuses"
    
class OrderStatuses(ResourceSet):
    res_name = "orderstatuses"
    resource_class = OrderStatus

class CustomerGroup(Resource):
    res_name = "customer_groups"
    
class CustomerGroups(ResourceSet):
    res_name = "customer_groups"
    resource_class = CustomerGroup

class Coupon(Resource):
    res_name = "coupons"
    
class Coupons(ResourceSet):
    res_name = "coupons"
    resource_class = Coupon

class Store(Resource):
    res_name = "store"
github bigcommerce / bigcommerce-api-python / bigcommerce / resource.py View on Github external
Equivalent to PUT /resource/res_id/subresource/sres_id
        """
        body = sres._copy_dict()
        body = json.dumps(body)
        new_fields = self.client.put('/{}/{}/{}/{}.json'.format(self.res_name, 
                                                                self.id, 
                                                                sres.res_name, 
                                                                sres.id), 
                                     body,
                                     **options)
        # commit changes locally
        sres._replace_fields(new_fields)

# Resources and ResourceSets

class Brand(Resource):
    res_name = "brands"
    
class Brands(ResourceSet):
    res_name = "brands"
    resource_class = Brand

class Category(Resource):
    res_name = "categories"
    
class Categories(ResourceSet):
    res_name = "categories"
    resource_class = Category
    
class OrderStatus(Resource):
    res_name = "orderstatuses"
github bigcommerce / bigcommerce-api-python / bigcommerce / resource.py View on Github external
class Brand(Resource):
    res_name = "brands"
    
class Brands(ResourceSet):
    res_name = "brands"
    resource_class = Brand

class Category(Resource):
    res_name = "categories"
    
class Categories(ResourceSet):
    res_name = "categories"
    resource_class = Category
    
class OrderStatus(Resource):
    res_name = "orderstatuses"
    
class OrderStatuses(ResourceSet):
    res_name = "orderstatuses"
    resource_class = OrderStatus

class CustomerGroup(Resource):
    res_name = "customer_groups"
    
class CustomerGroups(ResourceSet):
    res_name = "customer_groups"
    resource_class = CustomerGroup

class Coupon(Resource):
    res_name = "coupons"
github bigcommerce / bigcommerce-api-python / bigcommerce / resource.py View on Github external
sres.id), 
                                     body,
                                     **options)
        # commit changes locally
        sres._replace_fields(new_fields)

# Resources and ResourceSets

class Brand(Resource):
    res_name = "brands"
    
class Brands(ResourceSet):
    res_name = "brands"
    resource_class = Brand

class Category(Resource):
    res_name = "categories"
    
class Categories(ResourceSet):
    res_name = "categories"
    resource_class = Category
    
class OrderStatus(Resource):
    res_name = "orderstatuses"
    
class OrderStatuses(ResourceSet):
    res_name = "orderstatuses"
    resource_class = OrderStatus

class CustomerGroup(Resource):
    res_name = "customer_groups"
github bigcommerce / bigcommerce-api-python / bigcommerce / resource.py View on Github external
class CustomerGroup(Resource):
    res_name = "customer_groups"
    
class CustomerGroups(ResourceSet):
    res_name = "customer_groups"
    resource_class = CustomerGroup

class Coupon(Resource):
    res_name = "coupons"
    
class Coupons(ResourceSet):
    res_name = "coupons"
    resource_class = Coupon

class Store(Resource):
    res_name = "store"
    
class Stores(ResourceSet):
    """Only supports GET /store.json, according to documentation."""
    res_name = "store"
    resource_class = Store

class Country(ParentResource):
    res_name = "countries"
        
class Countries(ResourceSet):
    res_name = "countries"
    resource_class = Country

class Customer(ParentResource):
    res_name = "customers"