# CatalogController

# Overview

# Description

Path /v2/catalogs

Handles all request regarding catalog: creating, updating, deleting.

# Catalog JSON Object

An example for a catalog JSON object.

{  
    "name":"testCatalog", 
    "description":"aDescription", 
    "translations":[{"language":"DE",
        "description":"DEdescription",
        "label":"DElable",
        "created":"2017-05-27T09:28:12.733Z",
        "updated":"2016-04-25T09:28:13.723Z"}], 
    "restrictedToCountries":["at"] ,
    "draftOf":"liveCatalog",
    "draftStatus": {
         "importLog": "some log messages",
         "progress": 80,
         "status": 2,
         "mergePolicies": {
           "items": "replace",
           "components": "merge",
           "materials": "replace",
           "tags": "merge"
         }
     }
}

# Concepts

# CatalogDrafts

It is possible to create drafts of catalogs for updating data without directly changing live data. A catalog can have multiple drafts simultaneously. Each draft belongs to exactly one catalog.

Each Draft has an associated CatalogDraftStatus. The status contains additional information like

  • progress (mainly used when the draft is created by an import)
  • status (ready to publish, in progress, failed, published ...)
  • sourceFiles in case of an import
  • mergePolicies to be used when the draft is published

The draftstatus can be updated by including the status object in the PUT /:draftId (updating the catalogDraft directly).

Possible Status of the draft:

  • FAILED(-1)
  • CREATED(0)
  • UPLOADED(1)
  • PROGRESS(2)
  • READY_TO_PUBLISH(3)
  • PUBLISHED(4)

# publishing

For publishing a draft, its status must first be set to readyToPublish. Any draft with this status can be published by sending a POST /:productionCatalogId/drafts/:draftId/publish where productionCatalogId is the id of the live catalog.

When a draft is published, the data of the draft is moved to the live catalog according to the merge policies. The draft Catalog is completly removed but a archived catalog is created with the same id as the draft catalog. The archived version includes a snapshot of the catalog before the publish. Also including the draftStatus from the original draft with the status updated to PUBLISHED.

# Visibility

A short description how our catalog visibility currently works and what the thoughts behind are.

We differ between two aspects for each element (item, material, tags, etc.)

  1. allowed to see an element
  2. wants to see an element (will be referred as visible in further explanation)

Every request will be checked if the requester is allowed to see requested elements. The second check will be different based on what the requester is actually asking. To have a better base to explane take a look at following sketch.

               Catalog
     /       /        \         \
Material -- Tags -- Items -- Components
    |                  |
Textures           AdditionalContent        

All requests which will go down in the hierarchy for example v2/catalogs/:id/items will return all items which the requester is allowed to see and not only visible. That means - there may be more items in the result set, than the requester wants to show in the catalog. Therefore a property like hiddenis set on the element and the requester has to decide.

All requests which are sideways like v2/items/:id/tags or v2/tags/:id/materials will return all tags or material which are assigned to that tag and will be restricted to allowed to see and only visible elements. That means - the requester only gets elements it wants to see.

The last possible way to query elements is by attaching a filter. For example an ids[] filter. Which will return an element if the requester is allowed to see that element. If the requester is instead asking for all items or materials via v2/items or v2/materials only elements which are allowed to see and are visible will be returned.

# Batch Uploader Feedback Codes

We differentiate between three different types.

  • infos
  • warnings
  • errors

Whereby infos are more infos about the process (currently not used) and warnings is a report, that something expected was missing but will not stop the process.

There are feedbacks with additional information like which column and line number this feedback is meant for, but there are also more general errors like not being able to read a ZIP file.

The Expected batch upload document is utf8, if the encoding is not utf8 we try guessing the encoding and then we return a warning.

# Warnings

Code Description
1020 File structure in ZIP is not supported
1021 File in ZIP not found
1022 File in ZIP is not used by the data within CSV
1023 Folder in ZIP is not a valid combined id
1120 Expected but not mandatory field is empty
1130 One or more given tag ids not found
1024 Ignored data found
1012 Unsupported encoding
1126 old id used

# Errors

Code Description
2000 Wrong separator used, please use , instead
2001 Missing rights
2002 Limit reached
2010 CSV file is missing
2011 CSV file is not readable
2020 ZIP file is missing
2021 ZIP file is not readable
2022 ZIP file does not contain a CSV file
2023 ZIP file does not contain needed file
2100 Could not find element with id
2110 Invalid line
2111 Invalid line - wrong number of columns
2112 Invalid line - multiple lines with same id
2120 Mandatory ID column is empty
2121 Mandatory column is empty
2122 Invalid json in column
2123 Mismatching ids in json and ID column
2124 Missing file scheme in column
2125 column is invalid (probably contains '😂
2126 Old id used
2127 invalid id, id start with catalog id
2130 Error selecting element
2131 Error adding element
2132 Not allowed to override, please set allowUpdate
2133 Error updating element
2200 DAP job is already processing
2210 No valid file entry was found in given data. No DAP job got created
2211 Error on preparing DAP job
2220 Error on creating DAP job
2300 Error sending prices to price engine
2301 Error creating prices on price engine

# API Reference

# GET /:id/items

Generates: json, csv

Returns all items of requested catalog

query-param:

  • deltaSince: has to be a date string with timezone. This string has to match following example 2016-06-01T07:54:07.000Z. Only if given date string is matching this format, the response will be reduced to only updated items after given date.

Response:

Item objects are described in Section Item JSON Object

{
    "items": [
        itemObject1,
        itemObject2,
        ...
    ],
    "meta": {
        "lastUpdated": "2018-01-23T09:15:39.000Z",
        "cached": false,
        "total": 2,
        "serverTime": "2019-03-14T12:29:08.549Z"
    }
}

# CSV fields

  • id: identifier of an item (Deprecated)
  • item_id : identifier of an item
  • Translations can be multiple, we always return all the available translations in the form of multiple column pairs. If no translations are available, we insert in the CSV reference columns label_en and description_en.
    • label_{languageCode}: languageCode in ISO standard can be "en" or "de" for example and will be the current value of this language in the ItemTranslation.
    • description_{languageCode}: languageCode in ISO standard can be "en" or "de" for example and will be the current value of this language in the ItemTranslation.
  • type: for example "seating" or "table"
  • detailType: for example "sofa", "chair" or "table"
  • width: width of the item in millimeters
  • depth: depth of the item in millimeters
  • height: height of the item in millimeters
  • layer: can be an integer or null, if there is no value for this field
  • sort: can be an integer or null, if there is no value for this field
  • scaleable: indicates if the item is scalable or not
  • flipable: indicates if the item can be flipped or not
  • colorable: indicates if the item can be colored or not
  • hidden: indicates if the item is hidden
  • manufacturerSKU:
  • tag_ids: all tag ids separated by ' ' (whitespace)
  • configuration: the configuration of the item
  • visibilityStatus : possible values (0, 1, 2)
    • 0 : "shown everywhere (planner, catalog)"
    • 1 : "shown only in Rubens Admin, hidden in planner, catalog"
    • 2 : "hidden everywhere"

# POST /:id/items

Accepts: multipart-formdata

Generates: json

Batch uploading items

Parameters:

  • file: a csv file
  • allowUpdate: boolean whether or not existing materials are allowed to be updated/overriden. default is false.

If any error occurs, no changes are made. If the content contains an existing id, but allowUpdate = false, this is interpreted as an error and nothing is changed.

# CSV fields

Contains all field specified in {GET /:id/items}, but ignores the content of tag_ids, additionally it includes the (optional) fields

  • tag_ids_to_add : all tags ids to add separated by ' ' (whitespace).
  • tag_ids_to_remove : all tags ids to remove separated by ' ' (whitespace).

# GET /:id/itemBatch Deprecated

use /:id/items instead with header accept = text/csv

# POST /:id/itemBatch Deprecated

use /:id/items instead with header accept = text/csv

# PUT /:id/itemBatch Deprecated

use POST /:id/items instead with header accept = text/csv and query parameter allowUpdates = true

# GET /:id/allTags

Generates: json

Returns all tags of requested catalog

Response:

Tag objects are described in Section Tag JSON Object

{
    "tags": [
        tagObject1,
        tagObject2,
        ...
    ],
    "meta": {
        "total": 2,
        "serverTime": "2019-03-14T12:29:08.549Z"
    }
}

# GET /:id/materials

Generates: json, csv

query-param:

  • embedTextures: true/false if true the materials contain textureObjects additionally to the textures array (with the ids) so that the client doesn't have to request them seperatly

returns all materials from the given catalog, when in cms-context this returns all the hidden and inactive material as well.

# CSV fields

  • material_id
  • Translations - we always return all the available translations in the form of multiple column pairs. If no translations are available, we insert in the CSV reference columns label_en and description_en.
    • label_{languageCode}: languageCode in ISO standard can be "en" or "de" for example and will be the current value of this language in the MaterialTranslation.
    • description_{languageCode}: languageCode in ISO standard can be "en" or "de" for example and will be the current value of this language in the MaterialTranslation.
  • shading - contains the serialized shading object, if present in the database
  • tag_ids - contains a list of tag ids connected with this material
  • active - boolean value if the material is active
  • Embeded textures - can be multiple, repeating with different prefix - tex0_ , tex1_, .... We always have a set of the following
    • tex0_mapping
    • tex0_height
    • tex0_width
    • tex0_mmHeight
    • tex0_mmWidth
    • tex0_tileable
  • visibilityStatus : possible values (0, 1, 2)
    • 0 : "shown everywhere (planner, catalog)"
    • 1 : "shown only in Rubens Admin, hidden in planner, catalog"
    • 2 : "hidden everywhere" - item is archived

# POST /:id/materials

Accepts: multipart-formdata

Generates: json

Batch uploading materials

Parameters:

  • file: either a csv or a zip with a csv within and additional files like images.
  • allowUpdate: boolean whether or not existing materials are allowed to be updated/overriden. default is false.

If any error occurs, no changes are made. If the content contains an existing id, but allowUpdate = false, this is interpreted as an error and nothing is changed.

# CSV fields

Contains all field specified in {/:id/materials} csv including the (optional) fields

  • tag_ids_to_add : all tag ids to add separated by ' ' (whitespace).
  • tag_ids_to_remove : all tag ids to remove separated by ' ' (whitespace).

# fields:

  • material_id : extId of the material
  • shading: shadingJson of the material
  • label_<language>: labels for the materials, language being the iso code. if any label is provided the existing labels are removed and replaced with the given ones
  • thumbnail: has to start with zip://. if data is provided this must be a filename relative in the zip to be uploaded as thumbnail

if texturefields are provided, all existing textures for the given materials are removed and replaced with the given textures

  • tex<N>_mmwidth
  • tex<N>_mmheight
  • tex<N>_tileable: 0 for false, 1 for true
  • tex<N>_mapping: the mapping for the texture (e.g. "RGB", "RGBA", "XYZ" ...)
  • tex<N>_image: has to start with zip://. relative path in the zip for the image to be used

# GET /:id/tags

Generates: csv

returns all tags from the given catalog in csv representation. requested user has to have catalog management rights for the given catalog.

tag fields:

  • id: identifier of a tag (deprecated)
  • tag_id : identifier of the tag
  • Translations can be multiple, we always return all the available translations in the form of multiple column pairs. If no translations are available, we insert in the CSV reference columns label_en and description_en.
    • label_{languageCode}: languageCode in ISO standard can be "en" or "de" for example and will be the current value of this language in the TagTranslation.
    • description_{languageCode}: languageCode in ISO standard can be "en" or "de" for example and will be the current value of this language in the TagTranslation.
  • png_icon: current png icon for this tag
  • svg_icon: current svg icon for this tag
  • inspiration_image: current inspiration image for this tag
  • global: is the tag global visible?
  • hidden: is the tag hidden?
  • sort: can be an integer or null, if there is no value for this field
  • material_ids: all material combined ids separated by ' ' (whitespace)

# POST /:id/tags

Accepts: multipart-formdata

Generates: json

Batch uploading tags

Parameters:

  • file: inputfile for the upload (.csv)
  • allowUpdate: boolean whether or not existing tags are allowed to be updated/overriden. default is false.

If any error occurs, no changes are made.

# CSV fields

Contains all field specified in {GET /:id/tags}, but ignores the entries item_ids and material_ids, additionally includes the (optional) fields

  • material_ids_to_add : all material ids to add separated by ' ' (whitespace).
  • material_ids_to_remove : all material ids to remove separated by ' ' (whitespace).
  • items_ids_to_add : all items ids to add separated by ' ' (whitespace).
  • items_ids_to_remove : all items ids to remove separated by ' ' (whitespace).

# GET /:id/tagBatch Deprecated

use /:id/tags instead with header accept = text/csv

# POST /:id/tagBatch Deprecated

use /:id/tags instead with header accept = text/csv

# PUT /:id/tagBatch Deprecated

use POST /:id/tags instead with header accept = text/csv and query parameter allowUpdates = true

# GET /:id/components

Generates: json or csv

returns all components from the given catalog in csv representation. requested user has to have catalog management rights for the given catalog.

component fields:

  • id: identifier of a component (deprecated)
  • component_id : identifier of the component
  • Translations can be multiple, we always return all the available translations in the form of multiple column pairs. If no translations are available, we insert in the CSV reference columns label_en and description_en.
    • label_{languageCode}: languageCode in ISO standard can be "en" or "de" for example and will be the current value of this language in the ComponentTranslation.
    • description_{languageCode}: languageCode in ISO standard can be "en" or "de" for example and will be the current value of this language in the ComponentTranslation.
  • active: boolean (1 or 0) which indicates if the component is active or inactive.
  • perspectiveImage: an url to the perspective image
  • type: for example "seating" or "table"
  • detailType: for example "sofa", "chair" or "table"
  • layer: can be an integer or null, if there is no value for this field
  • sort: can be an integer or null, if there is no value for this field
  • tag_ids: all tag ids separated by ' ' (whitespace)

# POST /:id/components

Accepts: multipart-formdata

Generates: json

Batch uploading components

Parameters:

  • file: inputfile for the upload (.csv) or (.zip)
  • allowUpdate: boolean whether or not existing components are allowed to be updated/overriden. default is false.

ZIP explanation:

The .zip file has to contain a .csv file and component definitions as .json files. In order correctly detect your wanted component definition file, you have to add a column "component_definition" to your .csv file. As values the columns should contain zip://fileName.json. The value could also contain a directory structure to better organize your .zip file. Which could yield to following value zip://aFolder/aSecondFolder/component1.json

Should there be any error like not prefixing with zip:// or just having a typo or forgot to add files to your zip, an bad request (400) will be thrown and an import log will be attached. In the import log you should be able to read, what went wrong or has to be adjusted.

If any error occurs, no changes are made. If the content contains an existing id and allowUpdate = false a conflict (409) will be returned with an import log.

# CSV fields

Contains all field specified in {/:id/components} csv, but ignores the tag_ids, additionally includes the (optional) fields

  • tag_ids_to_add : all tags ids to add separated by ' ' (whitespace).
  • tag_ids_to_remove : all tags ids to remove separated by ' ' (whitespace).

# GET /:id/componentBatch Deprecated

use /:id/components instead with header accept = text/csv

# POST /:id/componentBatch Deprecated

use /:id/components instead with header accept = text/csv

# PUT /:id/componentBatch Deprecated

use POST /:id/components instead with header accept = text/csv and query parameter allowUpdates = true

# POST /:id/threeDimensionalAssets

Accepts: multipart-formdata

Generates: json

Batch uploading item assets, which will be splitted up in item packages and forwarded to our asset pipe.

Parameters:

  • file: inputfile for the upload .zip

ZIP explanation:

The .zip file has to contain a folder structure as described below:

- extItem1/
    - anyFileNameForExtItem1.fbx
- extItem2/
    - anyFileNameForExtItem2.fbx
    - someImage.jpg

Where extItem1 and extItem2 are real external identifiers for the corresponding items in this catalog. The folder structure must align with this examples, there are no additional levels of folders allowed. We will preprocess uploaded .zip file and check if given items do exist, are not already processing. After those checks we will generate the item packages which can be forwarded to our asset pipe.

If any error occurs during this process (preprocessing, checking and creating packages), the request will be canceled and a detailed import log with warnings and errors will be returned as JSON.

# GET /:id/prices

Generates: csv

Returns all prices from the given catalog in csv representation. Requested user has to have admin rights for the given catalog.

price fields:

  • article_number
  • price: default price for this article number. default means if a country gets requested, where there is no specific entry this default price will be returned
  • currency_symbol: default currency symbol for this article number. default means if a country gets requested, where there is no specific entry this default currency symbol will be returned
  • price_{countryCode}: countryCode can be "at", "de" and so on. Represents a specific price entry for this country
  • currency_symbol_{countryCode}: countryCode can be "at", "de" and so on. Represents a specific currency symbol for this country

# POST /:id/prices

Accepts: multipart-formdata

Generates: csv

Batch uploading prices

Side information:

Given CSV will be parsed and converted to fit our price engine needs and then forwarded to it. There can be errors where the upload is correct but we encounter problems when accessing our price engine.

# POST /:id/drafts - import

Accepts: multipart-formdata

Generates: application/json

used to create a draft of this catalog for automatic importing.

Send a zip and type to this endpoint for starting the automatic import. will happen asynchronosly.

bodyparameters:

  • file: zip file to import from
  • type: type id of the source format. currently supported: bb, idmp,idmw