sofa / sofa-catalog-service

0 stars 0 forks source link

Service Draft #1

Open CrashKid opened 9 years ago

CrashKid commented 9 years ago

sofa.CatalogService

About

We're recreating the former couch-service (now properly named catalog-service) which will handle all catalog-related requests to the new API.

Features

Product-related

getProductListing(config) API endpoint: tbd Request Type: POST param config {object}

config: {
    categoryId: {string} // optional, but recommended unless there is a searchTerm
    searchTerm: {string}, // optional, but recommended if there's no categoryId
    pagination: { // optional, fallback is default pagination (server-side). 
        page: {integer}, // the requested page
        pageSize: {integer} // how many items per page
    },
    // TBD: to allow multiple sorting options for any future use cases, this should better be an array
    sorting: { // optional, fallback is default sorting (server-side)
        name: {string} // attribute name, e.g. 'price'
        order: {string} // either 'asc' or 'desc'
    },
    filterState: [{ // optional, list of active filters
        name: {string}, //  attribute name, e.g. 'color',
        // if type is 'single' or 'multiple'
        values: [
            'red', //  attribute values
            'black',
            'white'
        ]
        // if type is 'range'
        range: {
            from: {float},
            to: {float}
        }
    }, {...}]
}

returns {promise} Resolving to {object} :

data: {
    filterConfig: [{
        // filter attribute
        name: {string}, //  attribute name, e.g. 'color'
        label: {string}, // localized view label, e.g. 'Farbe'
        type: {string}, // one of: ['single', 'multiple', 'range']
        // if type === 'range' we need some additional information on the range's limits:
        limits: {
            min: {float}, // the min value of the range, e.g. 24.95 (most likely, this will always be a price value)
            max: {float}, // the max value of the range, e.g. 299.00
            from: {float}, // the preset value for min if given, otherwise =min
            to: {float} // the preset value for max if given, otherwise =max 
        },
        // else
        options: [{
            value: {string}, //  attribute value, e.g. 'red'
            label: {string}, // localized view label, e.g. 'Rot'
            remaining: {integer}, // remaining amount of items if this filter is being activated
            active: {boolean} // whether this filter option has been applied or not
        }, {...}] // next filter attribute's option
        order: {integer}, // sorting order
    }, {...}], // next filter attribute
    items: {array},
    // collection of product instances, either limited to a category (categoryId was provided), 
    // to a search result (searchTerm was provided) or to the overall product data 
    // (none of the latter was provided) 
    pagination: {
        page: {integer}, // the requested page
        pageSize: {integer}, // how many items per page
        pageCount: {integer} // overall number of pages for the given pageSize
    },
}

getProduct('id') API endpoint: tbd Request Type: GET param id {string} The product id returns {promise} Resolving to {object} The product instance for the given id.

getProductsById(ids) API endpoint: tbd Request Type: GET param ids {array} List of product ids returns {promise} Resolving to {array} A collection of product instances for the given ids.

Category-related

janpantel commented 9 years ago

For the search request, i'd like to change the pagination params. Let's use page and pageSize and the api will return a boolean that states if there is a next page.