NextGen APIs

Step account-creation

Last Modified Version

r1

Tech Tags


Available Async

No

BPMN Diagram

diagram (17).svg

Business Logic

This Integration API creates a new Customer/Account.

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

System checks the presence of meter.brandCode then:

  • If meter.brandCode is present: The system evaluates the uniqueness of the combined couple (meter.serialNumber, meter.brandCode), as it is forbidden to have multiple pairs with the same values.

  • If meter.brandCode is NOT present: The system evaluates the uniqueness of the meter.serialNumber property alone, as it is forbidden to have multiple serial numbers with the same value.

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 in internal configuration because it’s forbidden to have multiple Accounts with the same code.

API Verb: GET

Resource: Accounts

Input: account.code

Output: 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 3 - Address Existence

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

System uses a calculated Code for the Address ('ACCOUNT_' + account.code) to manage the retry of the request.

API Verb: GET

Resource: Addresses

Input: code=ACCOUNT_account.code

Output: addressId, targetId

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

If System can obtain the Output fields and targetId is absent → continue to next step.

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

Error Type:

STEP 4 - Account Type Validation

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

API Verb: GET

Resource: Account Types

Input: account.typeCode, active=true

Output: accountTypeId

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 - Operation Center Validation

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

This step is skipped if Input fields are absent so Account will be not related with an Operation Center.

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

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

This step is repeated for each Account’s Meters and skipped when meter.brandCode is absent

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 10 - Meter Existence

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

System checks the presence of meter.brandCode then:

  • If meter.brandCode is present: The system evaluates the uniqueness of the combined couple (meter.serialNumber, meter.brandCode), as it is forbidden to have multiple pairs with the same values.

  • If meter.brandCode is NOT present: The system evaluates the uniqueness of the meter.serialNumber property alone, as it is forbidden to have multiple serial numbers with the same value.

API Verb: GET

Resource: Meters

Input: list of [meter.serialNumber, meter.meterBrandId, active=true]

Output: meterId

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 11 - 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 12 - 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 13 - 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, active=true

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

System evaluates the response obtained from Address Existence STEP.

If addressId exists but targetId is absent → continue to step Address Update.

If addressId doesn’t exist → continue to step Address Creation.

STEP 14a - Address Creation

System takes Input fields and creates an Address in internal configuration.

System uses a calculated Code for the Address ('ACCOUNT_' + account.code) to manage the retry of the request.

API Verb: POST

Resource: Addresses

Input: code=ACCOUNT_account.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 14b - 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 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.

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 Creation

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

Furthermore system creates the link between Account and its Address.

API Verb: POST

Resource: Accounts

Input: operationCenterId, typeId, externalSystemId, addressId, code, description, fiscalCode, note, birthDate, externalCode

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 - Mandatory Contact Creation

System takes Input fields, validate them and creates one mandatory Account’s Contact. This contact has the fixed contactTypeId='PHONE'.

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

API Verb: POST

Resource: Account Contacts

Input: accountId, contactTypeId=1, phoneNumberCode, phoneNumberContact

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 - Not Mandatory 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 next step.

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

Error Type:

STEP 19 - Meter Creation

The following steps are executed for each Meters in Input.

System takes Input fields, validate them 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, active, model, capacity

Output: meterId, Response State

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

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

Error Type:

  • Others - see link in Resource

STEP 20 - 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:

  • Others - see link in Resource

STEP 21 - 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

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

Y

Not Blank

4


operationCenterCode

Operation Center Code

N

Null or Not Blank

5


description

Account Description

Y

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)

Y

Not Blank

12

address


countryIsoAlphaCode

Acronym of Nation (2 or 3 letters acronym)

Y

Not Blank

13


districtAcronym

Acronym of District

N

Null or Not Blank

14


districtCode

Code of District

N

Null or Not Blank

15


municipality

Municipality

Y

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

Y

Not Blank

34

meters

(minOccurs=0,

maxOccurs=N)


typeCode

Meter Type Code

N

Null or Not Blank

35


brandCode

Meter Brand Code

N

Null or Not Blank

36


locationCode

Meter Location Code

N

Null or Not Blank

37


classCode

Meter Class Code

N

Null or Not Blank

38


productionYear

Meter Production Year

N


39


serialNumber

Meter Serial Number

Y

Not Blank

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


48


model

Model

N

 

49


capacity

Capacity

N


50


converter

serialNumber

Converter Serial Number

N

Absent or 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


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"
    },
    "code": "ADR_ACCOUNT_07",
    "description": "account description",
    "typeCode": "GAS-DIG",
    "externalSystemCode": "SAP",
    "phoneNumberContact": "32455656",
    "operationCenterCode": "1606",
    "fiscalCode": "RFEGTTY",
    "note": "NOTE OF THE ACCOUNT",
    "externalCode": "ext_adr_00",
    "phoneNumberCode": "CELL"
  },
  "address": {
    "extension": {
        "myFieldName": "myValue"
    },
    "streetNumber": 10,
    "toponym": "via",
    "street": "Roma",
    "countryIsoAlphaCode": "IT",
    "postalCode": "33080",
    "municipality": "Fiume Veneto",
    "districtAcronym": "PN"
  },
  "contacts": [
    {
      "extension": {
        "myFieldName": "myValue"
      },
      "contact": "account_00@gmail.com",
      "typeCode": "EMAIL",
      "code": "E-MAIL"
    }
  ],
  "meters": [
    {
      "extension": {
        "myFieldName": "myValue"
      },
      "serialNumber": "ADR_0123456",
      "classCode": "1",
      "productionYear": "2021",
      "digitNumber": 2,
      "acronym": "MTR_12345",
      "converter":{
            "serialNumber":"124123",
            "typeCode": "AT",
            "confirmDigitNumber": 1
         },
    }
  ]
}

 

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