NextGen APIs

POST /integration/assets/r1/accounts

Http Verb

POST

Url

/integration/assets/r1/accounts

Permissions required

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

Facility Configuration: View (fsm.core.technicalobject.configuration.view)

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

Customer: Edit (fsm.core.technicalobject.customer.edit)

Resource: View (fsm.core.resource.view)

ATTENTION: In addition, it is possible to configure the system property integrationlayer.integration-api.account.meter.disable-not-in-request (default ‘false’) to automatically disable the account’s meters not in request

Last Modified Version

r1

Tech Tags


Available Async

Yes


BPMN Diagram

diagram (17).svg


Business Logic

This Integration API creates or updates an Account.

System evaluates the uniqueness of property contacts.typeCode because it’s forbidden to have multiple Contacts with same type.

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 - Account Existence

System takes Input fields and checks their existence.

API Verb: GET

Resource: Accounts

Input: account.code

Output: accountId

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

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

Error Type:

STEP 3 - Account Creation

Go to Step account-creation

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

System compares accountId in Output with the one obtained from ‘Account ExistenceSTEP because it’s forbidden to have the same Meter related to multiple accounts.

API Verb: GET

Resource: Meters

Input: meter.serialNumber

Output: meterId, accountId<>Account Existence.accountId

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

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

Error Type:

STEP 5 - Country Validation

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

This step is skipped if Input fields are absent.

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 6 - District Validation

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

This step is skipped if districtAcronym and districtCode are both absent.

API Verb: GET

Resource: Districts

Input: [districtAcronym] OR [districtCode], 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 7 - Operation Center Validation

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

This step is skipped if Input fields are absent.

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 8 - Contact Type Validation

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

This step is repeated for each Account’s Contacts.

API Verb: GET

Resource: Contact Types

Input: contact.typeCode

Output: contactTypeId

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 - Meter Type Validation

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

System verifies also the validity of the type.

This step is repeated for each Account’s Meters.

API Verb: GET

Resource: Meter Types

Input: meter.typeCode

Output: meterTypeId, validityBegin, validityEnd

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 10 - Meter Brand Validation

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

This step is repeated for each Account’s Meters.

API Verb: GET

Resource: Meter Brands

Input: meter.brandCode, active=true

Output: meterBrandId

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 11 - Meter Location Validation

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

This step is repeated for each Account’s Meters.

API Verb: GET

Resource: Meter Locations

Input: meter.locationCode, active=true

Output: meterLocationId

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 12 - Meter Class Validation

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

This step is repeated for each Account’s Meters.

API Verb: GET

Resource: Meter Classes

Input: meter.classCode

Output: meterClassId

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 13 - Address Validation (from Account)

System takes Input fields and retrieve the address of the asset.

API Verb: GET

Resource: Addresses

Input: targetId=<accountId>

Output: addressId

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 14 - Address Update

System takes Input fields and update the Address of the Asset.

This step is skipped if Input fields are absent.

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 15 - Address Normalization

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

This step is skipped if xCoordinate and yCoordinate are present or both NULL.

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 16 - Account Update

System takes Input fields and updates the Account.

API Verb: PATCH

Resource: Accounts

Input: operationCenterId, description, fiscalCode, note, birthDate

Output: accountId, 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 17 - Contacts Creation or Update

The following steps are executed for each Contact in Input.

STEP 17a - Contact Existence

System takes Input fields to check Contact existence and creates or updates the Account’s Contacts.

API Verb: GET

Resource: Account Contacts

Input: accountId, contactTypeId

Output: contactId

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

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

Error Type:

STEP 17b - Contact Creation

The following steps are executed for each Contacts in Input.

System takes Input fields, validate them and creates the Account’s Contacts.

Furthermore system creates the link between Account, Account Address and its Contacts.

API Verb: POST

Resource: Account Contacts

Input: accountId, contactTypeId, code, contact

Output: contactId, Response State

If Response State is SUCCESS → continue to step Meters Creation or Update.

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

Error Type:

STEP 17c - Contact Update

The following steps are executed for each Contacts in Input.

System takes Input fields, validate them and creates the Account’s Contacts.

Furthermore system creates the link between Account, Account Address and its Contacts.

API Verb: PATCH

Resource: Account Contacts

Input: accountId, contactTypeId, code, contact

Output: contactId, 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 18 - Meters Creation or Update

The following steps are executed for each Meters in Input.

STEP 18a - Meter Existence

System takes Input fields to check Meter existence and creates or updates the Account’s Meters.

System checks the presence of meter.brandCode then:

  • If meter.brandCode is present: The system evaluates the existence of a unique combined couple (meter.serialNumber, meter.brandCode), as it is forbidden to manage updates of multiple records with pairs with the same values.

  • If meter.brandCode is NOT present: The system evaluates the existence of a unique meter.serialNumber property alone, as it is forbidden to manage updates of multiple records with serial numbers with the same value.

API Verb: GET

Resource: Account Meters

Input: [accountId, serialNumber, meterBrandId, active = true]

Output: meterId

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

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

Error Type:

STEP 18b - Meter Creation

System takes Input fields and creates the Account’s Meters.

Furthermore system creates the link between Account, Account Address and its Meters.

API Verb: POST

Resource: Account Meters

Input: accountId, productionYear, serialNumber, digitNumber, acronym, note, active=true, minReading, maxReading, lastReadingDate, lastReading, meterBrandId, meterLocationId, meterTypeId, meterClassId, model, capacity

Output: contactId, Response State

If Response State is SUCCESS → continue to step Converter Type.

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

Error Type:

  • Others - see link in Resource

STEP 18c - Converter Type Validation

System takes Input fields and updates the Account’s Converter Type.

This step is skipped if converter object inside meter is null or typeCode is null.

API Verb: GET

Resource: Converter Types

Input: typeCode, active(=true)

Output: typeId, Response State

If Response State is SUCCESS → elaboration is stopped. See Converter Creation.

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

Error Type:

STEP 18d - Converter Creation

System takes Input fields and creates the Account’s Meter’s Converter.

This step is skipped if converter object inside meter is null.

API Verb: POST

Resource: Account Meter Converter

Input: accountId, meterId, serialNumber, typeId, minReading, maxReading, lastReading, digitNumber, confirmDigitNumber

Output: converterId, 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

STEP 18e - Meter Update

System takes Input fields and updates the Account’s Meters.

Furthermore system creates the link between Account, Account Address and its Meters.

API Verb: PATCH

Resource: Account Meters

Input: accountId, productionYear, serialNumber, digitNumber, acronym, note, active=true, minReading, maxReading, lastReadingDate, lastReading, meterBrandId, meterLocationId, meterTypeId, meterClassId, active, model, capacity

Output: contactId, Response State

If Response State is SUCCESS → elaboration is stopped. See Converter Type.

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

Error Type:

  • Others - see link in Resource

STEP 18f - Converter Type

System takes Input fields and updates the Account’s Converter Type.

This step is skipped if converter object inside meter is null.

API Verb: GET

Resource: Converter Types

Input: typeCode, active(=true)

Output: typeId, Response State

If Response State is SUCCESS → elaboration is stopped. See Converter Existence.

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

Error Type:

STEP 18g - Converter Existence

System takes Input fields and checks if converter already exists.

This step is skipped if converter object inside meter is null.

API Verb: GET

Resource: Converters

Input: code

Output: typeId, Response State

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

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

Error Type:

  • Others - see link in Resource

STEP 18h - Converter Creation

System takes Input fields and creates the Account’s Meter’s Converter.

This step is skipped if converter object inside meter is null.

API Verb: POST

Resource: Account Meter Converter

Input: accountId, meterId, serialNumber, typeId, minReading, maxReading, lastReading, digitNumber, confirmDigitNumber

Output: converterId, 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

STEP 18i - Converter Update

System takes Input fields and updates the Account’s Meter’s Converter.

This step is skipped if converter object inside meter is null.

API Verb: PATCH

Resource: Account Meter Converter

Input: accountId, meterId, serialNumber, typeId, minReading, maxReading, lastReading, digitNumber, confirmDigitNumber

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

STEP 19 - Meter Deactivation

System checks the system property integrationlayer.integration-api.account.meter.disable-not-in-request to decide which path to follow regarding the treatment of the meters:

  • integrationlayer.integration-api.account.meter.disable-not-in-request=false → elaboration is stopped

  • integrationlayer.integration-api.account.meter.disable-not-in-request=true → go to nest Step

STEP 19a - Meter List Comparison

System takes the list of Account’s Meters active and compares this list with the meters in input.

API Verb: GET

Resource: Account Meters

Input: [accountId, active=true]

Output: list of [id, serialNumber, brandId]

If System can obtain the Output fields and some serialNumber is not present in input → continue to step Meter Deactivation

If System can obtain the Output fields and all serialNumber is present in input → elaboration is stopped

If System can’t obtain the Output fields → elaboration is stopped

Error Type:

  • Others - see link in Resource

STEP 19b - Meter Deactivation

System takes Input fields and updates the Account’s Meters not present in input.

API Verb: PATCH

Resource: Account Meters Batch

Input: accountId, list of [id, active=false]

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

account


externalSystemCode

External System Code

Y

Not Blank

2


code

Account Code

Y

Not Blank

3


typeCode

Account Type Code

N

Absent or Not Blank

4


operationCenterCode

Operation Center Code

N

Absent or Null or Not Blank

5


description

Account Description

N

Absent or Not Blank

6


fiscalCode

Account Fiscal Code

N


7


note

Account Note

N


8


birthDate

Account Birth Date

N


9


externalCode

Account External Code

N


10


phoneNumberCode

Code of Phone Number Mandatory (Contact with fixed type PHONE)

N


11


phoneNumberContact

Phone Number Mandatory (Contact with fixed type PHONE)

N

Absent or Not Blank

12

address


countryIsoAlphaCode

Acronym of Nation (2 or 3 letters acronym)

N

Absent or Not Blank

13


districtAcronym

Acronym of District

N

Absent or Null or Not Blank

14


districtCode

Code of District

N

Absent or Not Blank

15


municipality

Municipality

N

Absent or Not Blank

16


municipalityCode

Municipality code

N


17


locality

Locality

N


18


postalCode

PostalCode

N


19


toponym

Toponym

N


20


street

Street

N


21


streetNumber

StreetNumber

N


22


streetNumberExtension

Street number extension

N


23


floor

Floor

N


24


lot

Lot

N


25


staircase

Staircase

N


26


apartment

Apartment

N


27


directions

Directions

N


28


description

Address Description

N


29


yCoordinate

Latitude

N


30


xCoordinate

Longitude

N


31

contacts

(minOccurs=0,

maxOccurs=N)


typeCode

Contact Type Code

Y

Not Blank

32


code

Contact Code

N


33


contact

Contact

N

Absent or Not Blank

34

meters

(minOccurs=0,

maxOccurs=N)


typeCode

Meter Type Code

N

Absent or Null or Not Blank

35


brandCode

Meter Brand Code

N

Absent or Null or Not Blank

36


locationCode

Meter Location Code

N

Absent or Null or Not Blank

37


classCode

Meter Class Code

N

Absent or Null or Not Blank

38


productionYear

Meter Production Year

N


39


serialNumber

Meter Serial Number

Y


40


digitNumber

Meter Digit Number

N


41


acronym

Meter Acronym

N


42


note

Meter Note

N


43


minReading

Meter Min Reading

N


44


maxReading

Meter Max Reading

N


45


lastReadingDate

Meter Last Reading Date

N


46


lastReading

Meter Last Reading

N


47


active

Flag for activation/deactivation (default ‘true’)

N

Absent or Not Null

48


model

Model

N


49


capacity

Capacity

N


50


converter

serialNumber

Converter Serial Number

N

Not Blank

51


lastReading

Converter Last Reading

N


52


minReading

Converter Min Reading

N


53


maxReading

Converter Max Reading

N


54


digitNumber

Converter Digit Number

N


55


confirmDigitNumber

Converter Confirm Digit Number

N


56


typeCode

Converter Type Code

N


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

JSON
{
  "extension": {},
   "account":{
      "extension":{
         "myFieldName":"myValue"
      },
      "externalSystemCode":"SAP",
      "code":"ADR_ACCOUNT_05"
   },
   "address":{
      "extension":{
         "myFieldName":"myValue"
      },
      "streetNumber":10,
      "toponym":"via",
      "street":"Trieste",
      "countryIsoAlphaCode":"IT",
      "postalCode":"33080",
      "municipality":"Fiume Veneto",
      "districtAcronym":"PN"
   },
   "contacts":[{
      "extension": {},
       "typeCode":"EMAIL",
       "code": "String",
       "contact": "test@gmail.com"
     }
   ],
   "meters":[
      {  
        "extension": {},
         "converter":{
           "extension": {},
            "serialNumber":"124123"
         },
         "typeCode":"TYPE1"
      }
   ]
}

 

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

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/assets/r1/accounts",
  "code": "IA001_001"
}

 

Response error codes