NextGen APIs

POST /integration/workforce/r2/resources

Http Verb

POST

Url

/integration/workforce/r2/resources

Permissions required

Core Additional Parameters: Edit (fsm.core.additionalparameter.edit)

Resource Configuration: Edit (fsm.core.resource.configuration.edit)

Organizational Structure Entities: View (fsm.core.structure.view)

or

Organizational Structure Entities: Edit (fsm.core.structure.edit)

WO Configuration: View (fsm.core.workorder.configuration.view)

or

WO Configuration: Edit (fsm.core.workorder.configuration.edit)

Last Modified Version

r2

Tech Tags


Available Async

No

BPMN Diagram

diagram.svg


Business Logic

This Integration API inserts or updates a Resource with his addresses.

Insert Only Validations

System verifies that if startAddressFromOperationCenter or endAddressFromOperationCenter has been provided (value=true), then operationCenterCode must have been provided.

Upsert Validations

System verifies that if startAddressFromOperationCenter or endAddressFromOperationCenter has been provided, then operationCenterCode must have been provided.

System verifies that endDate is greater than startDate and sysdate.

System verifies Permission Required and starts the elaboration that is organized in steps.

STEP 1 - External System Validation

System takes Input fields and checks their existence in internal configuration.

API Verb: GET

Resource: External Systems

Input: externalSystemCode, active=true

Output: externalSystemId

If System can obtain the Output fields → continue to next step.

If System can’t obtain the Output fields → responds with error. Elaboration is stopped.

Error Type:

STEP 2 - Operation Center Validation

System takes Input fields and checks their existence in internal configuration.

API Verb: GET

Resource: Operation Centers

Input: operationCenterCode, active=true

Output: operationCenterId

If System can obtain the Output fields → continue to next step.

If System can’t obtain the Output fields → responds with error. Elaboration is stopped.

Error Type:

STEP 3 - Work Center Validation

System takes Input fields and checks their existence.

This step is skipped if Input fields are absent.

API Verb: GET

Resource: Work Centers

Input: workCenterCode, active=true

Output: workCenterId

If System can obtain the Output fields → continue to next step.

If System can’t obtain the Output fields → responds with error. Elaboration is stopped.

Error Type:

STEP 4 - Resource Type Validation

System takes Input fields and checks their existence.

API Verb: GET

Resource: Resource Type

Input: resource.typeCode, visible=true

Output: resourceTypeId

If System can obtain the Output fields → continue to next step.

If System can’t obtain the Output fields → responds with error. Elaboration is stopped.

Error Type:

STEP 5 - Vehicle Validation

System takes Input fields and checks their existence. System verifies also the validity of the Vehicle.

This step is skipped if Input fields are absent.

API Verb: GET

Resource: Vehicles

Input: vehicleCode

Output: vehicleId, startDate, endDate

If System can obtain the Output fields → continue to next step.

If System can’t obtain the Output fields → responds with error. Elaboration is stopped.

Error Type:

STEP 6 - User Type Validation

System takes Input fields and checks their existence.

This step is skipped if Input fields are absent.

API Verb: GET

Resource: /api/configurations/identity/r1/user-types (Foundation)

Input: userTypeCode

Output: userTypeId

If System can obtain the Output fields → continue to next step.

If System can’t obtain the Output fields → responds with error. Elaboration is stopped.

Error Type:

STEP 7 - Operation Center Address Retrieval

System takes Input fields and retrieve the address.

This step is skipped if startAddressFromOperationCenter is false and endAddressFromOperationCenter is false.

STEP 7a- Operation Center Start Address Retrieval

System takes Input fields and retrieve the start address.

  • If startAddressCode is not provided:

    • The system will retrieve the default address from the operating center.

      • main=true and description=null

  • If startAddressCode is provided:

    • The system searches for the operating center address that matches that specific code.

      • main=null and description=startAddressCode

This step is skipped if startAddressFromOperationCenter is false.

API Verb: GET

Resource: Addresses

Input: operationCenterId, main=(true OR null), description=(startAddressCode OR null)

Output: startAddressId

If System can obtain the Output fields → continue to next step.

If System can’t obtain the Output fields → responds with error. Elaboration is stopped.

Error Type:

STEP 7b - Operation Center End Address Retrieval

System takes Input fields and retrieve the end address.

  • If endAddressCode is not provided:

    • The system will retrieve the default address from the operating center.

      • main=true and description=null

  • If endAddressCode is provided:

    • The system searches for the operating center address that matches that specific code.

      • main=null and description=endAddressCode

This step is skipped if endAddressFromOperationCenter is false.

API Verb: GET

Resource: Addresses

Input: operationCenterId, main=(true OR null), description=(endAddressCode OR null)

Output: endAddressId

If System can obtain the Output fields → continue to next step.

If System can’t obtain the Output fields → responds with error. Elaboration is stopped.

Error Type:

STEP 8 - Address Validation

The following steps are executed for each Address in Input.

STEP 8a - Country Validation

System takes Input fields and checks their existence in internal configuration.

API Verb: GET

Resource: Countries

Input: countryIsoAlphaCode

Output: countryCode

If System can obtain the Output fields → continue to next step.

If System can’t obtain the Output fields → responds with error. Elaboration is stopped.

Error Type:

STEP 8b - District Validation

System takes Input fields and checks their existence in internal configuration.

API Verb: GET

Resource: Districts

Input: districtAcronym, countryCode

Output: districtCode

If System can obtain the Output fields → continue to next step.

If System can’t obtain the Output fields → responds with error. Elaboration is stopped.

Error Type:

STEP 9 - Resource Existence

System takes Input fields and checks their existence.

API Verb: GET

Resource: Resource

Input: identificationNumber

Output: resourceId, operationCenterId, loan

If System can’t obtain the Output fields → Creation → continue to step Resource Creation

If System can obtain the Output fields → system evaluates the operationCenterId in Input:

  • if operationCenterId in Input is not present, system takes only the resource in output with loan=false → Update → continue to next step.

  • if operationCenterId in Input is present, System verifies that in output

    • if resource not exist → Creation → continue to step Resource Creation

    • If a resource exists, the system verify if exist a resource with same operationCenter

      • if exists selects the one with loan=false→ Update → continue to step next step.

      • if not exist → responds with error. Elaboration is stopped.

Error Type:

STEP 10 - Resource’s Address - Start Address Validation

System takes Input fields and checks their existence in internal configuration.

This step is skipped if Input fields are absent or if the startAddressFromOperationCenter field is set to true or if the startAddressCode appears also in ‘Addresses’ object.

API Verb: GET

Resource: /workforce/resources/r1/resources/{resourceId}/addresses

Input: resourceId, description=startAddressCode

Output: startAddressId

If System can obtain the Output fields → continue to next step.

If System can’t obtain the Output fields → responds with error. Elaboration is stopped.

Error Type:

  • Others - see link in Resource

STEP 11 - Resource’s Address - End Address Validation

System takes Input fields and checks their existence in internal configuration.

This step is skipped if Input fields are absent or if the endAddressFromOperationCenter field is set to true or if the endAddressCode appears also in ‘Addresses’ object.

API Verb: GET

Resource: /workforce/resources/r1/resources/{resourceId}/addresses

Input: resourceId, description=endAddressCode

Output: endAddressId

If System can obtain the Output fields → continue to next step.

If System can’t obtain the Output fields → responds with error. Elaboration is stopped.

Error Type:

  • Others - see link in Resource

STEP 12 - Resource Creation

System takes Input fields and creates the entity (only not on loan).

API Verb: POST

Resource: Resource

Input: surname, name, birthDate, email, operationCenterId, mobilePhone, identificationNumber, secondaryIdentificationNumber, resourceTypeId, color, vehicleId, order, workCenterId, startDate, endDate

Output: Response State, resourceId (only for SUCCESS)

If Response State is SUCCESS → continue to step User Update.

If Response State is ERROR → elaboration is stopped. See Response payload fields.

Error Type:

  • Others - see link in Resource

STEP 13 - Resource Update

System takes Input fields and updates the entity (only not on loan).

This step is skipped if Input fields are absent.

API Verb: PATCH

Resource: Resource

Input: resourceId, surname, name, birthDate, email, mobilePhone, identificationNumber, secondaryIdentificationNumber, resourceTypeId, color, vehicleId, order, workCenterId, startDate, endDate

Output: Response State

If Response State is SUCCESS → continue to next step.

If Response State is ERROR → elaboration is stopped. See Response payload fields.

Error Type:

  • Others - see link in Resource

STEP 14 - User Update

System takes Input fields and updates the entity.

This step is skipped if Input fields are absent.

API Verb: PATCH

Resource: /api/configurations/identity/r1/users/{userId}

Input: resourceId, username, userTypeId

Output: Response State

If Response State is SUCCESS → continue to next step.

If Response State is ERROR → elaboration is stopped. See Response payload fields.

Error Type:

  • Others - see link in Resource

Step 15 - Address Management

The following steps are executed for each Address in Input.

This step is skipped if addresses are absent.

STEP 15a - Address Existence

System takes Input fields and checks their existence in internal configuration.

The system filters the records to be processed based on these two filters:

  • startAddressCode if they appear in ‘Addresses’ object and the startAddressFromOperationCenter field is not true

  • endAddressCode if they appear in ‘Addresses’ object and the endAddressFromOperationCenter field is not true

API Verb: GET

Resource: /workforce/resources/r1/resources/{resourceId}/addresses

Input: resourceId, description=address.code

Output: addressId

If System can obtain the Output fields → Update → continue to step Address Update.

If System can’t obtain the Output fields → Creation → continue to next step.

Error Type:

  • Others - see link in Resource

STEP 15b - Address Creation

System takes Input fields and creates the entity.

API Verb: POST

Resource: Addresses

Input: code=address.code, description=address.code, countryCode, districtCode, municipality, municipalityCode, postalCode, locality, toponym, street, streetNumber, streetNumberExtension, floor, lot, staircase, apartment, directions, xCoordinate, yCoordinate, description

Output: Response State, addressId (only for SUCCESS)

If Response State is SUCCESS → continue to step Address Normalization.

If Response State is ERROR → elaboration is stopped. See Response payload fields.

Error Type:

  • Others - see link in Resource

STEP 15c - Address Update

System takes Input fields and updates the entity.

API Verb: PATCH

Resource: Addresses

Input: addressId, countryCode, districtCode, municipality, municipalityCode, postalCode, locality, toponym, street, streetNumber, streetNumberExtension, floor, lot, staircase, apartment, directions, xCoordinate, yCoordinate, description

Output: Response State

If Response State is SUCCESS → continue to next step.

If Response State is ERROR → elaboration is stopped. See Response payload fields.

Error Type:

  •  Others - see link in Resource

STEP 15d - Address Normalization

System evaluates input fields xCoordinate and yCoordinate to decide if Address Normalization is necessary.

This step is skipped if Input fields are absent.

API Verb: POST

Resource: Addresses/{addressId}/geocoding

Input: addressId

Output: Response State

If Response State is SUCCESS → continue to next step.

If Response State is ERROR → elaboration is stopped. See Response payload fields.

Error Type:

  •  Others - see link in Resource

STEP 15e - Address Resource Relationship Existence

System takes Input fields and retrieve the addresses related with the resource.

API Verb: GET

Resource: {resourceId}/addresses/{addressId}

Input: resourceId, addressId

Output: resourceId, addressId

If System can obtain the Output fields → Update → continue to step Address Resource Relationship Update.

If System can’t obtain the Output fields → Creation → continue to next step.

Error Type:

  • Others - see link in Resource

STEP 15f - Address Resource Relationship Creation

System takes Input fields and creates the entity.

API Verb: POST

Resource: {resourceId}/addresses

Input: resourceId, addressId, resourceAddressDescription

Output: Response State, relationshipId (only for SUCCESS)

If Response State is SUCCESS → continue to step Route Addresses

If Response State is ERROR → elaboration is stopped. See Response payload fields.

Error Type:

  • Others - see link in Resource

STEP 15g - Address Resource Relationship Update

System takes Input fields and retrieve the address.

API Verb: PATCH

Resource: {resourceId}/addresses/{addressId}

Input: resourceId, addressId, resourceAddressDescription

Output: Response State

If Response State is SUCCESS → continue to next step.

If Response State is ERROR → elaboration is stopped. See Response payload fields.

Error Type:

  • Others - see link in Resource

STEP 16 - Start/End Address Validation

This step is executed if one or both of the following variable startAddressId and endAddressId are null.

STEP 16a - Resource’s Address - Start Address Validation

System takes Input fields and checks their existence in internal configuration.

This step is skipped if the startAddressId variable is already populated or if Input fields are absent or if the startAddressFromOperationCenter field is set to true

API Verb: GET

Resource: /workforce/resources/r1/resources/{resourceId}/addresses

Input: resourceId, description=startAddressCode

Output: startAddressId

If System can obtain the Output fields → continue to next step.

If System can’t obtain the Output fields → responds with error. Elaboration is stopped.

Error Type:

  • Others - see link in Resource

STEP 16b - Resource’s Address - End Address Validation

System takes Input fields and checks their existence in internal configuration.

This step is skipped if the endAddressId variable is already populated or if Input fields are absent or if the endAddressFromOperationCenter field is set to true

API Verb: GET

Resource: /workforce/resources/r1/resources/{resourceId}/addresses

Input: resourceId, description=endAddressCode

Output: endAddressId

If System can obtain the Output fields → continue to next step.

If System can’t obtain the Output fields → responds with error. Elaboration is stopped.

Error Type:

  • Others - see link in Resource

STEP 17 - Route Addresses

System takes Input fields and creates/update the entity.

API Verb: POST

Resource: resources/{resourceId}/route-addresses

Input: resourceId, startAddressId, endAddressId

Output: Response State

If Response State is SUCCESS → elaboration is stopped. See Response payload fields.

If Response State is ERROR → elaboration is stopped. See Response payload fields.

Error Type:

  • Others - see link in Resource

Path Parameters

As their name suggests, they are included in the URL path of the endpoint.

Not applicable.

Query String Parameters

Start with a ? and includes parameters listed one after the another separated by &.

Not applicable.

Header Parameters

Parameters included in the request headers. Generally, request headers are used to keep authorization parameters.

Default.

Request Body Parameters

Request body parameters are used when clients send data to the API. They are shipped in a JSON Object only in POST, PUT, or PATCH requests.

 

Field

Description

Mandatory

Constraint

1

resource

externalSystemCode

External System Code

Y

Not Blank

2

surname

Surname

(Mandatory in Creation)

N

Absent or Not Blank

3

name

Name

(Mandatory in Creation)

N

Absent or Not Blank

4

birthDate

BirthDate

N


5

email

Email

N


6

mobilePhone

Mobile Phone Number

N


7

identificationNumber

Identification Number

Y

Not Blank

8

secondaryIdentificationNumber

Secondary Identification Number

N

Absent or Not Blank

9

typeCode

Resource Type Code

N

Absent or Not Blank

10

color

Color

N


11

vehicleCode

Vehicle Code

N

Absent or Null or Not Blank

12

order

Order

N


13

operationCenterCode

Operation Center Code

(Mandatory in Creation)

N

Absent or Not Blank

14

workCenterCode

Work Center Code

N

Absent or Null or Not Blank

15

startDate

Resource Start Date

N


16

endDate

Resource End Date

N


17

startAddressCode

Code of the start address of the resource

N

Absent or Not Blank

18

endAddressCode

Code of the end address of the resource

N

Absent or Not Blank

19

startAddressFromOperationCenter

Flag that specifies if the start address should be taken from the operation center

N

Absent or Not Null

20

endAddressFromOperationCenter

Flag that specifies if the end address should be taken from the operation center

N

Absent or Not Null

21

username

Resource username

N

Absent or Not Null

22

userTypeCode

User Type Code

N

Absent or Not Null

23

addresses

(minOccurs=0,

maxOccurs=N)

code

Code of the Address.

Should

Y

Not Blank

24

countryIsoAlphaCode

Acronym of Nation (2 or 3 letters acronym)

(Mandatory in Creation)

N

Absent or Not Blank

25

districtAcronym

Acronym of District

N

Absent or Null or Not Blank

26

municipality

Municipality

N

Absent or Not Blank

27

municipalityCode

Municipality code

(Mandatory in Creation)

N


28

locality

Locality

N


29

postalCode

PostalCode

N


30

toponym

Toponym

N


31

street

Street

N


32

streetNumber

StreetNumber

N


33

streetNumberExtension

Street number extension

N


34

floor

Floor

N


35

lot

Lot

N


36

staircase

Staircase

N


37

apartment

Apartment

N


38

directions

Directions

N


39

description

Address Description

N


40

yCoordinate

Latitude

N


41

xCoordinate

Longitude

N


42

resourceAddressDescription

Description for the address related with the resource

N

Absent or Not Blank

The objects in input could have also the extension object that allows to add additional, customized data to this API. More info here How to use APIs: Custom data via Extension.

Request example

Insert

JSON
{
  "extension": {},
  "resource": {
    "extension": {
        "myFieldName": "myValue"
    },
    "externalSystemCode": "SAP",
    "surname": "Rossi",
    "name": "Mario",
    "birthDate": "1970-01-01",
    "email": "mario.rossi@gmail.com",
    "mobilePhone": "34111",
    "identificationNumber": "mario.rossi",
    "typeCode": "RESTYPE",
    "color": "#FF990C",
    "vehicleId": 
    "order": 10,
    "operationCenterCode": "OPCODE",
    "workCenterCode": "WRKCNTCODE",
    "startAddressCode": "HOUSE1",
    "endAddressCode": "HOUSE2",
    "startAddressFromOperationCenter": false,
    "endAddressFromOperationCenter": false
  },
  "addresses": [
    {
      "extension": {
         "myFieldName": "myValue"
      },
      "code": "HOUSE1",
      "countryIsoAlphaCode": "IT",
      "districtAcronym": "PN",
      "municipality": "Fiume Veneto",
      "postalCode": "33080",
      "toponym": "via",
      "street": "Bassi",
      "streetNumber": 101,
      "resourceAddressDescription": "mario.rossi Primary HOUSE"
    }
  ]
}

Update

JSON
{
  "extension": {},
  "resource": {
    "extension": {
        "myFieldName": "myValue"
    },
    "externalSystemCode": "SAP",
    "identificationNumber": "mario.rossi",
    "startAddressCode": "mario.rossi HOUSE 2",
    "endAddressCode": "mario.rossi HOUSE 2",
    "startAddressFromOperationCenter": false,
    "endAddressFromOperationCenter": false
  },
  "addresses": [
    {
      "extension": {
         "myFieldName": "myValue"
      },
      "code": "HOUSE3",
      "countryIsoAlphaCode": "IT",
      "districtAcronym": "RM",
      "municipality": "Roma",
      "toponym": "via",
      "street": "Roma",
      "streetNumber": 50,
      "resourceAddressDescription": "mario.rossi Third HOUSE"
    }
  ]
}

Response documentation

Response payload fields

Compliant with RFC Standard https://www.rfc-editor.org/rfc/rfc9457.html

Extension fields:

Field

Description

Note

id

Id of the resource created

Only for SUCCESS in Insert case

code

Extension member of a Problem Details Object that contains the error code

Only for ERROR

Response example

JSON
{
  "id": 123456
}
JSON
{
  "type": "about:blank",
  "title": "Not Found",
  "status": 404,
  "detail": "External system string does not exist",
  "instance": "/integration/workforce/r1/resources",
  "code": "IA001_001"
}

 

Response error codes