Demandware Library

class dw.client.Demandware(params={})

Bases: object

Python Demandware SDK.

https://documentation.demandware.com/display/DOC131/Open+Commerce+API

_call(uri, extra_params=None)

Execute a request and save last response data.

Args:

uri: String that represents resource path.

_debug()

Lets inspect request and response data.

Returns:

Dictionary with request and response keys.

_reset()

Restore default values used to request a service.

Store cookie.

Remove cookie.

debug()

Lets inspect request and response data.

Returns:

Dictionary with request and response keys.

get(key=None)

Lets inspect current GET data.

Args:

key: String that represents key in GET that should be returned.

Returns:

Value for key or all GET dictionary.

get_basket()

Returns a limited set of basket information. Limited means that no checkout related information (i.e. addresses, shipping and payment method) are returned.

Returns:

If success then Basket as object otherwise None.

https://documentation.demandware.com/display/DOC131/Basket+resource#Basketresource-Getbasket

get_product(ids, arrayify=False, **kwargs)

Access products resource.

Args:

ids: String o Array of Strings that represents SKU of a product.

arrayify: Boolean thats indicate if a single product should be returned in a List.

kwarg expand: expands the result document, which may include any of the __expand values: https://documentation.demandware.com/display/DOC132/Product+resource

Returns:

Product as object if SKU exists otherwise None.

https://documentation.demandware.com/display/DOC131/Product+resource#Productresource-Getsingleproduct

get_request(as_dict=False)

Lets inspect last request.

Args:

as_dict: Boolean that indicates if should returns as object or dictionary.

Returns:

Last request as object or dictionary, it depends of as_dict.

get_response(as_dict=False)

Lets inspect last response.

Args:

as_dict: Boolean that indicates if should returns as object or dictionary.

Returns:

Last response as object or dictionary, it depends of as_dict.

get_user()

Get current customer data.

Returns:

Returns the account profile object, if an error occur then None.

https://documentation.demandware.com/display/DOC131/Account+resource#Accountresource-Getaccountprofile

header(key=None)

Lets inspect current HEADERS used to request an service.

Args:

key: String that represents a HEADER that should be returned.

Returns:

Value for key or all HEADERS dictionary.

login(username, password)

Action to login a customer.

Args:

username: String, customer username.

password:: String, customer password.

Returns:

If success then returns True otherwise False.

https://documentation.demandware.com/display/DOC131/Account+resource#Accountresource-Loginaction

logout()

Action to logout a customer.

Returns:

If success then returns True otherwise False.

https://documentation.demandware.com/display/DOC131/Account+resource#Accountresource-Logoutaction

post(key=None)

Lets inspect current POST data.

Args:

key: String that represents key in POST that should be returned.

Returns:

Value for key or all POST dictionary.

register(username, password, profile={})

Action to register an account.

Args:

username: String, account username.

password:: String, account password.

profile:: Dictionary, profile properties.

Returns:

Returns the account profile object, if an error occur then None.

https://documentation.demandware.com/display/DOC131/Account+resource#Accountresource-Registeraccount

search_category(category='root', levels=2)

Get online categories.

Args:

category: String, category Id.

levels: Integer, Specifies how many levels of nested sub-categories you want the server to return. The default value is 1.

Returns:

Categories as object, if an error occur then None.

https://documentation.demandware.com/display/DOC131/Category+resource#Categoryresource-Getcategory

search_product(query, **kwargs)

Provides keyword and refinement search functionality for products.

Args:

query: String, the query phrase to search for.

kwarg expand: expands the result document, which may include any of the __expand values: https://documentation.demandware.com/display/DOC132/Product+resource

Returns:

Search results as object, if an error occur then None.

https://documentation.demandware.com/display/DOC131/ProductSearch+resource#ProductSearchresource-SearchProducts

set_get(key, value)

Add or update GET data.

Args:

key: String that represents key in GET parameters. value: Value to be saved.

set_header(key, value)

Add or update HEADERS data.

Args:

key: String that represents key in HEADERS parameters.

value: Value to be saved.

set_post(key, value)

Add or update POST data.

Args:

key: String that represents key in POST parameters.

value: Value to be saved.