(Quick Reference)

17 Categories of customers - Reference Documentation

Version: 2.1

17 Categories of customers

17.1 List

Service: List

Description: This web service return the list of customers categories in JSON format

URL:

https://BASE_URL/api/VERSION/customerCategories

Method: GET

Parameters:

Pagination parameters:

NameDescriptionTypeRequiredPossible values
offsetTells where to start returning records from the entire set of resultsIntegerNo 
maxlimits the number of resources requested to returnIntegerNo 
sortOrders the results by the specified fieldStringNo 
orderOrders ascending (ASC) or descending DESCIntegerNoasc, desc

Filters parameters:

NameDescriptionTypeRequiredExample values
dateCreated_gtFilters by the resource's creation date time and operator greater thanDateno2016-08-15T14:52:48Z
dateCreated_gteFilters by the resource's creation date time and operator greater than or equalDateno 
dateCreated_ltFilters by the resource's creation date time and operator less thanDateno 
dateCreated_lteFilters by the resource's creation date time and operator less than or equalDateno 
lastUpdated_gtFilters by the resource's last-modified date time and operator greater thanDateno 
lastUpdated_gteFilters by the resource's last-modified date time and operator greater than or equalDateno 
lastUpdated_ltFilters by the resource's last-modified date time and operator less thanDateno 
lastUpdated_lteFilters by the resource's last-modified date time and operator less than or equalDateno 
referenceWildcard search by the resource's referenceStringnoreference=Ref-6* , reference=*ef-6 , reference=*ef-6*
nameWildcard search by the resource's nameStringno 

Success Output

Success case: response.status=200

{
    "paging": {
        "total": 7,
        "max": 100,
        "offset": 0,
        "previous": null,
        "next": null
    },
    "data": [
        {
            "id": 2,
            "name": "Home",
            "isRoot": true,
            "parentId": null,
            "parentCategory": null,
            "reference": "Ref-01",
            "description": "Home",
            "image": "BASE_URL/Nice-1444810602520/photoCustomerCategory/1455207900621_users_crowd.png",
            "organization": "Lyon",
            "dateCreated": "2015-10-13T10:12:40Z",
            "lastUpdated": "2016-02-11T16:25:00Z"
        },
        {
            "id": 9,
            "name": "TPE",
            "isRoot": false,
            "parentId": 2,
            "parentCategory": {
                "id": 2,
                "reference": "Ref-01",
                "name": "Home",
                "href": "/api/v1.0/customerCategories/2"
            },
            "reference": "Ref-02",
            "description": "Trés petites entreprises ",
            "image": "BASE_URL/Nice-1444810602520/photoCustomerCategory/1455207886452_users_crowd.png",
            "organization": "Lyon",
            "dateCreated": "2015-10-30T10:19:40Z",
            "lastUpdated": "2016-02-11T16:24:46Z"
        },
        {
            "id": 10,
            "name": "PME",
            "isRoot": false,
            "parentId": 2,
            "parentCategory": {
                "id": 2,
                "reference": "Ref-01",
                "name": "Home",
                "href": "/api/v1.0/customerCategories/2"
            },
            "reference": "Ref-03",
            "description": "Petites et moyennes entreprises",
            "image": "BASE_URL/Nice-1444810602520/photoCustomerCategory/1455176799278_88c0f2f7d904fecacecaf4e585abcc45.png",
            "organization": "Lyon",
            "dateCreated": "2015-10-30T10:20:24Z",
            "lastUpdated": "2016-02-11T07:46:40Z"
        },
        {
            "id": 11,
            "name": "TGE",
            "isRoot": false,
            "parentId": 2,
            "parentCategory": {
                "id": 2,
                "reference": "Ref-01",
                "name": "Home",
                "href": "/api/v1.0/customerCategories/2"
            },
            "reference": "Ref-04",
            "description": "Trés grande entreprise",
            "image": "BASE_URL/Nice-1444810602520/photoCustomerCategory/1455207868614_users_crowd.png",
            "organization": "Lyon",
            "dateCreated": "2015-10-30T10:21:38Z",
            "lastUpdated": "2016-02-11T16:24:29Z"
        },…
    ]
}

To get resized images, add prefix small_ or medium_ to the link url before the image's name, for example:
<BASE_URL>/Nice-1444810602520/photoCustomerCategory/small_1455207868614_users_crowd.png

Failure Output

Failure case:response.status = 400
{
   "error": "invalid_param",
   "error_description": "The parameters [dateCreated_gta] you provided are not valid for this request."
}
{
    "error": "invalid_datetime_format",
    "error_description": "Invalid datetime filter (not ISO-8601 formatted): [2016-08-1Z]"
}

Failure case:response.status = 500
{
   "error": "server_error",
   "error_description": "Oops! Something went wrong..."
}

17.2 Show

Service: Show

Description: This web service return a customer category details of the specified id in JSON format

URL:

https://BASE_URL/api/VERSION/customerCategories/{id}

URL with external_id:

https://BASE_URL/api/VERSION/customerCategories/reference/{id}

Method: GET

Parameters:

NameDescriptionTypeRequiredExample values
idid of the wanted customer categoryLong/StringYes777

Success Output

Success case: response.status=200
{
    "id": 2,
    "name": "Home",
    "isRoot": true,
    "parentId": null,
    "parentCategory": null,
    "reference": "Ref-01",
    "description": "Home",
    "image": "BASE_URL/Nice-1444810602520/photoCustomerCategory/1455207900621_users_crowd.png",
    "organization": "Lyon",
    "dateCreated": "2015-10-13T10:12:40Z",
    "lastUpdated": "2016-02-11T16:25:00Z"
}

To get resized images, add prefix small_ or medium_ to the link url before the image's name, for example:
<BASE_URL>/Nice-1444810602520/photoCustomerCategory/small_1455207868614_users_crowd.png

Failure Output

Failure case:response.status = 400
{
    "error": "invalid_param_type",
    "error_description": "The type of parameter id you provided is not valid for this request."
}

Failure case:response.status = 404
{
    "error": "not_found",
    "error_description": "The customer category with the id 999 doesn't exist."
}

17.3 Delete

Service: Delete

Description: This web service is used in order to delete a customer category object from the database

URL:

https://BASE_URL/api/VERSION/customerCategories/{id}

URL with external_id:

https://BASE_URL/api/VERSION/customerCategories/reference/{id}

Method: DELETE

Parameters:

NameDescriptionTypeRequiredExamples values
idId of the desired customer category to deleteLong/StringYes777

Success Output

Success case: response.status=200
{
    "success": "true",
    "success_description": "Instance deleted successfully"
}

Failure Output

Failure case:response.status = 400
{
    "error": "invalid_param_type",
    "error_description": "The type of parameter id you provided is not valid for this request."
}
{
    "error": "delete_not_authorized",
    "error_description": "Root category must not be deleted"
}
{
    "error": "delete_failed",
    "error_description": "Failed to delete instance"
}

Failure case:response.status = 404
{
    "error": "not_found",
    "error_description": "The customer category with the id 1 doesn't exist."
}

Failure case:response.status = 500
{
    "error": "server_error",
    "error_description": "Oops! Something went wrong..."
}

17.4 Update

Service: Update

Description: This web service is used in order to update an existing customer category object into the database

URL:

https://BASE_URL/api/VERSION/customerCategories/{id}

URL with external_id:

https://BASE_URL/api/VERSION/customerCategories/reference/{id}

Method: POST

Request content type: application/x-www-form-urlencoded or multipart/form-data

Parameters:

NameDescriptionTypeRequiredexample values
idid of the desired customer category to updateLong/StringYes777
referencethe new reference valueStringYes 
namethe new name valueStringYes 
descriptionthe new description valueStringNo 
imageimage specified to the new customer category it can be jpg, gif, png, bmpmultipartNo 
reference must be unique

Success Output

Success case: response.status=200
{
    "paging": {
        "total": 1,
        "max": 100,
        "offset": 0,
        "previous": null,
        "next": null
    },
    "data": [
        {
            "id": 3,
            "name": "new Categ",
            "isRoot": false,
            "parentId": 3,
            "parentCategory": {
                "id": 3,
                "reference": "101",
                "name": "new Categ",
                "href": "/api/v1.0/customerCategories/3"
            },
            "reference": "101",
            "description": "Home",
            "image": null,
            "organization": "Lyon",
            "dateCreated": "2015-10-13T10:12:40Z",
            "lastUpdated": "2016-08-16T13:19:11Z"
        }
    ]
}

To get resized images, add prefix small_ or medium_ to the link url before the image's name, for example:
<BASE_URL>/Nice-1444810602520/photoCustomerCategory/small_1455207868614_users_crowd.png

Failure Output

Failure case:response.status = 400
{
    "error": "invalid_param_type",
    "error_description": "The type of parameter id you provided is not valid for this request."
}
{
    "error": "missing_param",
    "error_description": "reference parameter is missing"
}
{
    "error": "not_unique",
    "error_description": "reference already used"
}
{
     "error" : "invalid_param_type",
     "error_description" : "An invalid value was specified for parameter: isRoot (must be a boolean: true or false)"
}
{
     "error": "exceeded_file_size",
     "error_description": "image size should not exceed 2Mo"
}
{
     "error": "unsupported_file_type",
     "error_description": "image format not supported."
}
{
  "error": "update_not_authorized",
  "error_description": "Organization should have only one root category ofcustomer."
}
{
  "error": "update_not_authorized",
  "error_description": "Organization should have at least one and only root category of customer."
}
{
     "error": "save_failed",
     "error_description": "Failed to save instance"
}

Failure case:response.status = 404
{
    "error": "not_found",
    "error_description": "The customer category with the id 1 doesn't exist."
}

Failure case:response.status = 500
{
     "error": "server_error",
     "error_description": "Oops! Something went wrong..."
}

17.5 Upsert

Service: Save

Description: This web service is used to insert an customer category object to the database if it does not already exist, or update it.

URL with external_id:

https://BASE_URL/api/VERSION/customerCategories/reference/{id}

Method: POST

Request content type: application/x-www-form-urlencoded or multipart/form-data

Parameters:

NameDescriptionTypeRequiredExample values
namethe name of the new customer categoryStringYes 
isRootdestined to declare if the new category is a root or notBooleanNo 
parentIdrepresent the Id of the parent customer categoryLong/StringYes if isRoot= false or isRoot=null 
imageimage specified to the new customer category it can be jpg, gif, png, bmpmultipartNo 
reference must be unique
the default value of isRoot is set to false, parentId is required only if isRoot = false or isRoot = null

Success Output

Success case: response.status=201
{
    "id": 60,
    "name": "Preferred Customers",
    "isRoot": false,
    "parentId": 3,
    "parentCategory": {
        "id": 3,
        "reference": "101",
        "name": "new Categ",
        "href": "/api/v1.0/customerCategories/3"
    },
    "reference": "102",
    "description": null,
    "image": null,
    "organization": "Lyon",
    "dateCreated": "2016-08-16T13:51:39Z",
    "lastUpdated": "2016-08-16T13:51:39Z"
}

To get resized images, add prefix small_ or medium_ to the link url before the image's name, for example:
<BASE_URL>/Nice-1444810602520/photoCustomerCategory/small_1455207868614_users_crowd.png

Failure Output

Failure case:response.status = 400
{
    "error": "missing_param",
    "error_description": "reference parameter is missing"
}
{
    "error": "not_unique",
    "error_description": "reference already used"
}
{
     "error" : "invalid_param_type",
     "error_description" : "An invalid value was specified for parameter: isRoot (must be a boolean: true or false)"
}
{
     "error": "exceeded_file_size",
     "error_description": "image size should not exceed 2Mo"
}
{
     "error": "unsupported_file_type",
     "error_description": "image format not supported."
}
{
  "error": "save_not_authorized",
  "error_description": "Organization should have only one root category of customer."
}
{
     "error": "save_failed",
     "error_description": "Failed to save instance"
}

Failure case:response.status = 404
{
     "error":"not_found",
     "error_description": "The parent customer category with the id 9999 doesn't exist."
}

Failure case:response.status = 500
{
     "error": "server_error",
     "error_description": "Oops! Something went wrong..."
}

17.6 Create

Service: Save

Description: This web service is used to add a new customer category object to the database

URL:

https://BASE_URL/api/VERSION/customerCategories

Method: POST

Request content type: application/x-www-form-urlencoded or multipart/form-data

Parameters:

NameDescriptionTypeRequiredExample values
referencethe reference of the new customer categoryStringYes 
namethe name of the new customer categoryStringYes 
isRootdestined to declare if the new category is a root or notBooleanNo 
parentIdrepresent the Id of the parent customer categoryLong/StringYes if isRoot= false or isRoot=null 
imageimage specified to the new customer category it can be jpg, gif, png, bmpmultipartNo 
useExternalIdBy default, it is set to false. set it to true if you want to use external ids.Booleannotrue , false
reference must be unique
the default value of isRoot is set to false, parentId is required only if isRoot = false or isRoot = null

Success Output

Success case: response.status=201
{
    "id": 60,
    "name": "Preferred Customers",
    "isRoot": false,
    "parentId": 3,
    "parentCategory": {
        "id": 3,
        "reference": "101",
        "name": "new Categ",
        "href": "/api/v1.0/customerCategories/3"
    },
    "reference": "102",
    "description": null,
    "image": null,
    "organization": "Lyon",
    "dateCreated": "2016-08-16T13:51:39Z",
    "lastUpdated": "2016-08-16T13:51:39Z"
}

To get resized images, add prefix small_ or medium_ to the link url before the image's name, for example:
<BASE_URL>/Nice-1444810602520/photoCustomerCategory/small_1455207868614_users_crowd.png

Failure Output

Failure case:response.status = 400
{
    "error": "missing_param",
    "error_description": "reference parameter is missing"
}
{
    "error": "not_unique",
    "error_description": "reference already used"
}
{
     "error" : "invalid_param_type",
     "error_description" : "An invalid value was specified for parameter: isRoot (must be a boolean: true or false)"
}
{
     "error": "exceeded_file_size",
     "error_description": "image size should not exceed 2Mo"
}
{
     "error": "unsupported_file_type",
     "error_description": "image format not supported."
}
{
  "error": "save_not_authorized",
  "error_description": "Organization should have only one root category of customer."
}
{
     "error": "save_failed",
     "error_description": "Failed to save instance"
}

Failure case:response.status = 404
{
     "error":"not_found",
     "error_description": "The parent customer category with the id 9999 doesn't exist."
}

Failure case:response.status = 500
{
     "error": "server_error",
     "error_description": "Oops! Something went wrong..."
}