DSHDLib

Namespace

DSHDLib

Source:

Namespaces

Editors
TemplateCustomizationObjects

Methods

(static) configure(confignon-null)

Description:
  • Configure or re-configure the library context and settings
Source:
Examples
DSHDLib.configure({
    domain: "domain.com",
    access_token: "abc"
});
DSHDLib.configure({
    domain: "domain.com",
    client_id: "abc",
    guest: true
});
Parameters:
Name Type Description
config DSHDLib.LibraryConfig

(static) createProject(paramsnon-null, callbacknon-null)

Description:
  • Create a new user-specific project from a template or from scratch
Source:
Examples
DSHDLib.createProject({
    media_type: "print",
    dimensions: {
        width: 3.5,
        height: 2,
        unit_type: "in"
    }
}, function(err, data){
    console.log(data.project_id);
});
DSHDLib.createProject({
    template_id: 123,
    customizations: {
        classes: {
            "title": {
                text: "New Title"
            }
        }
    }
}, function(err, data){
    console.log(data.project_id);
});
Parameters:
Name Type Description
params Object See here for all possible inputs
callback DSHDLib.createProjectCallback

(static) createProject(paramsnon-null, config_overrideopt, callbacknon-null)

Description:
  • Create a new user-specific project from a template or from scratch
Source:
Example
DSHDLib.createProject({
    template_code: "abc"
}, { access_token: "abc" }, function(err, data){
    console.log(data.project_id);
});
Parameters:
Name Type Attributes Description
params Object See here for all possible inputs
config_override DSHDLib.LibraryConfig <optional>
callback DSHDLib.createProjectCallback

(static) getGuestAccessToken(config_overrideopt, callbacknon-null)

Description:
  • Retrieve a guest access token
Source:
Example
DSHDLib.getGuestAccessToken({}, function(err, access_token){
    console.log(access_token);
});
Parameters:
Name Type Attributes Description
config_override DSHDLib.LibraryConfig <optional>
callback DSHDLib.getGuestAccessTokenCallback

(static) getProject(project_idnon-null, callbacknon-null)

Description:
  • Retrieve project information
Source:
Example
DSHDLib.getProject("abc", function(err, project){
    console.log(project.project_title);
});
Parameters:
Name Type Description
project_id string The project to retrieve
callback DSHDLib.getProjectCallback

(static) getProject(project_idnon-null, paramsopt, callbacknon-null)

Description:
  • Retrieve project information
Source:
Example
DSHDLib.getProject("abc", { generate_latest_thumbnail: true }, function(err, project){
    console.log(project.thumbnail_url);
});
Parameters:
Name Type Attributes Description
project_id string The project to retrieve
params Object <optional>
See here for all possible inputs
callback DSHDLib.getProjectCallback

(static) getProject(project_idnon-null, paramsopt, config_overrideopt, callbacknon-null)

Description:
  • Retrieve project information
Source:
Example
DSHDLib.getProject("abc", { generate_latest_thumbnail: true }, { access_token: "abc" }, function(err, project){
    console.log(project.thumbnail_url);
});
Parameters:
Name Type Attributes Description
project_id string The project to retrieve
params Object <optional>
See here for all possible inputs
config_override DSHDLib.LibraryConfig <optional>
callback DSHDLib.getProjectCallback

(static) getProjects(callbacknon-null)

Description:
  • List Projects
Source:
Example
DSHDLib.getProjects(function(err, data){
    console.log(data.total);
});
Parameters:
Name Type Description
callback DSHDLib.getProjectsCallback

(static) getProjects(paramsopt, callbacknon-null)

Description:
  • List Projects
Source:
Example
DSHDLib.getProjects({ brand_id: 123, search: "Find Me" }, function(err, data){
    console.log(data.total);
});
Parameters:
Name Type Attributes Description
params Object <optional>
See here for all possible inputs
callback DSHDLib.getProjectsCallback

(static) getProjects(paramsopt, config_overrideopt, callbacknon-null)

Description:
  • List Projects
Source:
Example
DSHDLib.getProjects({}, { access_token: "abc" }, function(err, data){
    console.log(data.items.length);
});
Parameters:
Name Type Attributes Description
params Object <optional>
See here for all possible inputs
config_override DSHDLib.LibraryConfig <optional>
callback DSHDLib.getProjectsCallback

(static) getTemplates(callbacknon-null)

Description:
  • List Templates
Source:
Example
DSHDLib.getTemplates(function(err, data){
    console.log(data.total);
});
Parameters:
Name Type Description
callback DSHDLib.getTemplatesCallback

(static) getTemplates(paramsopt, callbacknon-null)

Description:
  • List Templates
Source:
Example
DSHDLib.getTemplates({ brand_id: 123, search: "Find Me" }, function(err, data){
    console.log(data.total);
});
Parameters:
Name Type Attributes Description
params Object <optional>
See here for all possible inputs
callback DSHDLib.getTemplatesCallback

(static) getTemplates(paramsopt, config_overrideopt, callbacknon-null)

Description:
  • List Templates
Source:
Example
DSHDLib.getTemplates({}, { access_token: "abc" }, function(err, data){
    console.log(data.items.length);
});
Parameters:
Name Type Attributes Description
params Object <optional>
See here for all possible inputs
config_override DSHDLib.LibraryConfig <optional>
callback DSHDLib.getTemplatesCallback

(static) getVariableTemplatePreviewURL(paramsnon-null, callbacknon-null)

Description:
  • Retrieve a URL to load a dynamically generated image based on the supplied Template and Template Customization Object (TCO)
Source:
Example
DSHDLib.getVariableTemplatePreviewURL({ template_id: 123, customizations_hash: "abc", width: 400 }, function(err, url){
    var img = new Image();
    img.src = url;
});
Parameters:
Name Type Description
params DSHDLib.VariableTemplatePreviewParams
callback DSHDLib.getVariableTemplatePreviewURLCallback

(static) getVariableTemplatePreviewURL(paramsnon-null, config_overrideopt, callbacknon-null)

Description:
  • Retrieve a URL to load a dynamically generated image based on the supplied Template and TCO
Source:
Example
DSHDLib.getVariableTemplatePreviewURL({ template_id: 123, customizations_hash: "abc", width: 400 }, { access_token: "abc" }, function(err, url){
    var img = new Image();
    img.src = url;
});
Parameters:
Name Type Attributes Description
params DSHDLib.VariableTemplatePreviewParams
config_override DSHDLib.LibraryConfig <optional>
callback DSHDLib.getVariableTemplatePreviewURLCallback

(static) storeTemplateCustomizationObject(paramsnon-null, callbacknon-null)

Description:
  • Store a Template Customization Object (TCO) for later use
Source:
Example
DSHDLib.storeTemplateCustomizationObject({
    object: {
        classes: {
            "title": {
                text: "New Title"
            }
        }
    }
}, function(err, data){
    console.log(data.object_hash);
});
Parameters:
Name Type Description
params Object
Properties
Name Type Attributes Description
object DSHDLib.TemplateCustomizationObjects.TemplateCustomizationObject The TCO
save_as_user_default bool <optional>
Specify whether to save this TCO as the user's default data for later use in project creation
callback DSHDLib.storeTemplateCustomizationObjectCallback

(static) storeTemplateCustomizationObject(paramsnon-null, config_overrideopt, callbacknon-null)

Description:
  • Store a Template Customization Object (TCO) for later use
Source:
Example
DSHDLib.storeTemplateCustomizationObject({
    object: {
        classes: {
            "title": {
                text: "New Title"
            }
        }
    }
}, { access_token: "abc" }, function(err, data){
    console.log(data.object_hash);
});
Parameters:
Name Type Attributes Description
params Object
Properties
Name Type Attributes Description
object DSHDLib.TemplateCustomizationObjects.TemplateCustomizationObject The TCO
save_as_user_default bool <optional>
Specify whether to save this TCO as the user's default data for later use in project creation
config_override DSHDLib.LibraryConfig <optional>
callback DSHDLib.storeTemplateCustomizationObjectCallback

Type Definitions

LibraryConfig

Description:
  • Context and settings for the library
Source:
Properties:
Name Type Attributes Default Description
domain string The domain of the Design Huddle environment
access_token string <optional>
A backend-generated user access token. Will override guest and visitor settings if set
client_id string <optional>
The client id of your Design Huddle app. Only required for guest and visitor user types
guest bool <optional>
false Value indicating whether this is a guest user. Will override visitor settings if set
visitor bool <optional>
false Value indicating whether this is a visitor user
admin bool <optional>
false Value indicating whether the library is used in the context of an admin user, leveraging the Admin API and the admin mode of the editor
guest_id string <optional>
Explicitly set a guest user id
gid_cookie_name string <optional>
Override the name of the first-party cookie storing the guest/visitor id
gid_cookie_domain string <optional>
Override the domain of the first-party cookie storing the guest/visitor id. Useful for making it available across subdomains
gid_cookie_days number <optional>
365 Override the default expiration of the first-party cookie storing the guest/visitor id
gid_cookie_refresh bool <optional>
false Force an existing guest/visitor id cookie expiration to be extended upon the first authenticated request
gat_cookie_name string <optional>
Override the name of the first-party cookie storing the guest/visitor access token
gat_cookie_domain string <optional>
Override the domain of the first-party cookie storing the guest/visitor access token. Useful for making it available across subdomains
gat_cookie_refresh bool <optional>
false Ignore an existing guest/visitor access token cookie and retrieve a new access token, extending its expiration, upon the first authenticated request
new_guest_on_non_guest_access_attempt bool <optional>
Value indicating whether a new guest user should be created if it's determined that the previously used guest has since been upgraded to a full user and the app is configured to no longer allow guest-based permission to it
template_customization_object_hash string <optional>
A previously acquired TemplateCustomizationObject hash to automatically apply on all createProject and getVariableTemplatePreviewURL requests where an object or hash is not explicitly supplied
template_customization_object DSHDLib.TemplateCustomizationObjects.TemplateCustomizationObject <optional>
A TemplateCustomizationObject to automatically apply on all createProject and getVariableTemplatePreviewURL requests where an object or hash is not explicitly supplied
Context and settings for the library

VariableTemplatePreviewParams

Description:
Source:
Properties:
Name Type Attributes Default Description
template_id number The auto-generated identifier associated with the template. Required if template_code is not provided
template_code string An optional user-assigned template identifier. Required if template_id is not provided
page_number number <optional>
1 Optionally return a specific page other than the first on multi-page projects
scene_number number <optional>
1 Optionally return a specific scene other than the first on multi-scene video projects
customizations_hash string The TCO hash previously created via LINK to storeTCO. Required if customizations is not provided
customizations DSHDLib.TemplateCustomizationObjects.TemplateCustomizationObject The TCO hash previously created via LINK to storeTCO. Required if customizations_hash is not provided
seed string <optional>
An optional value used to deterministically map array inputs in the TCO to specific variants, ensuring repeatable output across requests. A random value will be auto-generated if not supplied
width number <optional>
320 The width of the desired image. Set automatically based on the aspect ratio of the template if only height is provided
height number <optional>
The height of the desired image. Set automatically based on the aspect ratio of the template if only width is provided
fit string <optional>
"center" The desired cropping of the image if both width and height are provided but do not match the aspect ratio of the template. See all possible options here
product_image_url string <optional>
The URL to an externally hosted product image background (raster images only) to overlay the design on. Unique URLs are cached for 2 weeks (Doc)
product_image_width number <optional>
Optionally override the supplied image dimensions, setting a width relative to the canvas zone (Doc)
product_image_height number <optional>
Optionally override the supplied image dimensions, setting a height relative to the canvas zone. Ignored if product_image_width is supplied (the image's aspect ratio is always maintained) (Doc)
product_image_canvas_zone_dimensions string <optional>
Set the canvas zone dimensions relative to the product image background. Required when product_image_url is supplied (Doc)
product_image_canvas_zone_offset string <optional>
Set the canvas zone position relative to the product image background. Required when product_image_url is supplied (Doc)
product_image_canvas_zone_horizontal_align string <optional>
"center" If the canvas zone aspect ratio does not match the template aspect ratio, set horizontal alignment of the canvas within the canvas zone (Doc)
product_image_canvas_zone_vertical_align string <optional>
"center" If the canvas zone aspect ratio does not match the template aspect ratio, set vertical alignment of the canvas within the canvas zone (Doc)
The input options to generate a Variable Template Preview URL. Read full documentation here
Type:
  • Object

createProjectCallback(erroropt, data)

Description:
  • Callback after project creation
Source:
Parameters:
Name Type Attributes Description
error Error <optional>
An error returned upon an authorization or other server side issue
data Object
Properties
Name Type Description
project_id string The unique identifier of the newly created project

errorCallback(erroropt)

Description:
  • Callback for functions that return may return an error
Source:
Parameters:
Name Type Attributes Description
error Error <optional>
An error returned upon an authentication or other server side issue

getGuestAccessTokenCallback(erroropt, access_token)

Description:
  • Callback after retrieving a guest access token
Source:
Parameters:
Name Type Attributes Description
error Error <optional>
An error returned upon an authorization or other server side issue
access_token string

getProjectCallback(erroropt, project)

Description:
  • Callback after project retrieval
Source:
Parameters:
Name Type Attributes Description
error Error <optional>
An error returned upon an authorization or other server side issue
project Object See here for the full list of returned fields

getProjectsCallback(erroropt, data)

Description:
  • Callback after listing projects
Source:
Parameters:
Name Type Attributes Description
error Error <optional>
An error returned upon an authorization or other server side issue
data Object
Properties
Name Type Description
page number
limit number
total number
items Array.<Object> See here for the fields returned per project

getTemplatesCallback(erroropt, data)

Description:
  • Callback after listing templates
Source:
Parameters:
Name Type Attributes Description
error Error <optional>
An error returned upon an authorization or other server side issue
data Object
Properties
Name Type Description
page number
limit number
total number
items Array.<Object> See here for the fields returned per template

getVariableTemplatePreviewURLCallback(erroropt, url)

Description:
  • Callback for returning a dynamic Variable Template Preview image URL
Source:
Parameters:
Name Type Attributes Description
error Error <optional>
An error returned upon an authentication or other server side issue
url string The generated URL

storeTemplateCustomizationObjectCallback(erroropt, data)

Description:
  • Callback for returning the generated TCO Hash
Source:
Parameters:
Name Type Attributes Description
error Error <optional>
An error returned upon an authentication or other server side issue
data Object
Properties
Name Type Description
object_hash string The generated TCO Hash uniquely identifying the TCO for subsequent requests