openapi: 3.0.0
info:
  title: Energy Offer Integration Layer
  version: 0.0.1
  description: This is the documentation of the energy offer integration layer api
servers:
  - url: http://localhost:8080/api
tags:
  - name: customer
    description: Customer requests
  - name: meteringpoints
    description: Metering points requests
  - name: offer
    description: Offer requests
paths:
  /customer:
    post:
      tags:
        - customer
      summary: Create or update a customer
      description: Create or update a customer
      requestBody:
        description: The customer object which shall be created or updated
        required: true
        content:
          application/json: 
            schema:
              $ref: '#/components/schemas/Customer'
      responses:
        '201':
          description: Succesfully created or updated customer
        '400':
          description: >-
            Bad request. Mandatory fields are missing or does not have the right type, format or value.
          content:
            application/json: 
              schema:
                $ref: '#/components/schemas/ErrorPayload'
        '401':
          description: Unauthorized. The token for an authorized access is either missing or invalid
          content:
            application/json: 
              schema:
                $ref: '#/components/schemas/ErrorPayload'
        '500':
          description: Internal server error. Something went wrong internally.
          content:
            application/json: 
              schema:
                $ref: '#/components/schemas/ErrorPayload'
  /meteringpoints:
    post:
      tags:
        - meteringpoints
      summary: Create or update multiple metering points
      description: Create or update multiple metering points
      requestBody:
        description: The metering point objects which shall be created or updated
        required: true
        content:
          application/json: 
            schema:
              type: array
              description: Multiple metering points
              minItems: 0
              items:
                $ref: '#/components/schemas/MeteringPoint'
      responses:
        '201':
          description: Succesfully created or updated metering point
        '400':
          description: >-
            Bad request. Mandatory fields are missing or does not have the right type, format or value.
          content:
            application/json: 
              schema:
                $ref: '#/components/schemas/ErrorPayload'
        '401':
          description: Unauthorized. The token for an authorized access is either missing or invalid
          content:
            application/json: 
              schema:
                $ref: '#/components/schemas/ErrorPayload'
        '422':
          description: Unprocessable Entity. A referenced value could not be found. The value is either unknown or not unique
          content:
            application/json: 
              schema:
                $ref: '#/components/schemas/ErrorPayload'
        '500':
          description: Internal server error. Something went wrong internally.
          content:
            application/json: 
              schema:
                $ref: '#/components/schemas/ErrorPayload'
  /pricingoffer:
    post:
      tags:
        - offer
      summary: Create a new pricing offer and its variants
      description: Create a new pricing offer and its variants
      requestBody:
        description: The pricing offer which shall be created or updated
        required: true
        content:
          application/json: 
            schema:
              $ref: '#/components/schemas/PricingHeader'
      responses:
        '201':
          description: Succesfully created pricing offer
        '400':
          description: >-
            Bad request. Mandatory fields are missing or does not have the right type, format or value.
          content:
            application/json: 
              schema:
                $ref: '#/components/schemas/ErrorPayload'
        '401':
          description: Unauthorized. The token for an authorized access is either missing or invalid
          content:
            application/json: 
              schema:
                $ref: '#/components/schemas/ErrorPayload'
        '422':
          description: Unprocessable Entity. A referenced value could not be found. The value is either unknown or not unique
          content:
            application/json: 
              schema:
                $ref: '#/components/schemas/ErrorPayload'
        '500':
          description: Internal server error. Something went wrong internally.
          content:
            application/json: 
              schema:
                $ref: '#/components/schemas/ErrorPayload'
components:
  schemas:
    ErrorPayload:
      description: The error payload in case the request cannot be processed successfully
      type: object
      properties:
        status:
          type: number
          format: int32
          description: The status code of the http response
        statusMessage:
          type: string
          description: The text message of the status code
        code:
          type: string
          description: The service error code
        message:
          type: string
          description: The service error message
    Customer:
      description: A customer
      type: object
      required:
        - glnCode
        - validFrom
        - name
      properties:
        glnCode:
          type: string
          description: The GLN code of the customer
        bdewCode:
          type: string
          description: The BDEW code of the customer
        dvwgCode:
          type: string
          description: The DVWG code of the customer
        eic:
          type: string
          description: The EIC of the customer
        validFrom:
          type: string
          format: date-time
          description: The date from which the changes will be applied as ISO 8601
            formatted string defined by date-time - RFC 3339
        validUntil:
          type: string
          format: date-time
          description: The date up to which the changes will be applied as ISO 8601
            formatted string defined by date-time - RFC 3339
        name:
          type: string
          description: The last name
        firstName:
          type: string
          description: The frist name
        street:
          type: string
          description: The street
        houseNumber:
          type: string
          description: The house number. It is recommended to use numeric characters only. For alpahnumeric characters use the appendix property
        appendix:
          type: string
          description: The appendix for the housenumber
        postOfficeBox:
          type: string
          description: The post office box
        zipCode:
          type: string
          description: The zip code
        city:
          type: string
          description: The city
        district:
          type: string
          description: The district
        region:
          type: string
          description: The region
        country:
          type: string
          description: The country
        email:
          type: string
          description: The valid formatted email address
        phone:
          type: string
          description: The phone number
        fax:
          type: string
          description: The fax number
        customFields:
          $ref: '#/components/schemas/CustomFields'
    MeteringPoint:
      type: object
      description: Basic metering point properties
      required:
        - marketLocationId
        - validFrom
        - timezone
        - commodity
        - type
        - meteringMethod
        - settlementMethod
        - holidayProfile
        - extractionType
      properties:
        marketLocationId:
          type: string
          description: >-
            The market location id of the metering point
        newMarketLocationId:
          type: string
          description: >-
            The new market location id of the metering point in case the id shall be updated
        crmId:
          type: string
          description: The CRM ID of the metering point
        meteringCode:
          type: string
          description: The metering code of the metering point
        validFrom:
          type: string
          format: date-time
          description: The date from which the changes will be applied as ISO 8601
            formatted string defined by date-time - RFC 3339
        validUntil:
          type: string
          format: date-time
          description: The date up to which the changes will be applied as ISO 8601
            formatted string defined by date-time - RFC 3339
        customer:
          type: string
          description: >-
            The customer gln code which shall be connected to the metering
            point. The customer has to exist already.
        timezone:
          type: string
          description: The time zone of the metering point. E.g. "Europe/Berlin"
        timeSeriesTemplate:
          type: string
          description: The time series template name of the metering point
        holidayProfile:
          type: string
          description: The holiday profile name of the metering point
        extractionType:
          $ref: '#/components/schemas/MeteringPointExtractionType'
        street:
          type: string
          description: The street
        houseNumber:
          type: string
          description: The house number. It is recommended to use numeric characters only. For alpahnumeric characters use the appendix property
        appendix:
          type: string
          description: The appendix for the housenumber
        postOfficeBox:
          type: string
          description: The post office box
        zipCode:
          type: string
          description: The zip code
        city:
          type: string
          description: The city
        district:
          type: string
          description: The district
        region:
          type: string
          description: The region
        country:
          type: string
          description: The ISO 3166 2-letter country code
        customFields:
          $ref: '#/components/schemas/CustomFields'
    MeteringPointExtractionType:
      description: The extraction type of the metering point.
      oneOf:
      - $ref: '#/components/schemas/MeteringPointExtractionType_SLP_GAS'
      - $ref: '#/components/schemas/MeteringPointExtractionType_RLM_GAS'
      - $ref: '#/components/schemas/MeteringPointExtractionType_SLP_LST_GAS'
      - $ref: '#/components/schemas/MeteringPointExtractionType_RLM_PRF_GAS'
      - $ref: '#/components/schemas/MeteringPointExtractionType_SLP_POWER'
      - $ref: '#/components/schemas/MeteringPointExtractionType_RLM_POWER'
      - $ref: '#/components/schemas/MeteringPointExtractionType_TLP_POWER'
      - $ref: '#/components/schemas/MeteringPointExtractionType_SLP_LST_POWER'
      - $ref: '#/components/schemas/MeteringPointExtractionType_RLM_PRF_POWER'
      discriminator:
        propertyName: name
        mapping:
          SLP_GAS: '#/components/schemas/MeteringPointExtractionType_SLP_GAS'
          RLM_GAS: '#/components/schemas/MeteringPointExtractionType_RLM_GAS'
          SLP_LST_GAS: '#/components/schemas/MeteringPointExtractionType_SLP_LST_GAS'
          RLM_PRF_GAS: '#/components/schemas/MeteringPointExtractionType_RLM_PRF_GAS'
          SLP_POWER: '#/components/schemas/MeteringPointExtractionType_SLP_POWER'
          RLM_POWER: '#/components/schemas/MeteringPointExtractionType_RLM_POWER'
          TLP_POWER: '#/components/schemas/MeteringPointExtractionType_TLP_POWER'
          SLP_LST_POWER: '#/components/schemas/MeteringPointExtractionType_SLP_LST_POWER'
          RLM_PRF_POWER: '#/components/schemas/MeteringPointExtractionType_RLM_PRF_POWER'
    MeteringPointExtractionType_SLP_GAS:
      description: The metering point type for SLP Gas metering points
      required:
      - name
      - customerValue
      - extractionLoadProfile
      - weatherStation
      allOf:
      - type: object
        properties:
          name:
            type: string
            description: The name of the metering point type has to be 'SLP_GAS'
            enum:
            - SLP_GAS
          customerValue:
            type: number
            format: double
            description: The customer value which represents a location independent annual consumption
          extractionLoadProfile:
            type: string
            description: The short name of the extraction load profile
          weatherStation:
            type: string
            description: The name of the weather station
      - $ref: '#/components/schemas/MeteringPointExtractionType_GAS_BASE'
    MeteringPointExtractionType_RLM_GAS:
      description: The metering point type for RLM Gas metering points
      required:
      - name
      allOf:
      - type: object
        properties:
          name:
            type: string
            description: The name of the metering point type has to be 'RLM_GAS'
            enum:
            - RLM_GAS
          weatherStation:
            type: string
            description: The name of the weather station
      - $ref: '#/components/schemas/MeteringPointExtractionType_GAS_BASE'
    MeteringPointExtractionType_SLP_LST_GAS:
      description: The metering point type for SLP Gas metering points
      required:
      - name
      - customerValue
      - extractionLoadProfile
      allOf:
      - type: object
        properties:
          name:
            type: string
            description: The name of the metering point type has to be 'SLP_LST_GAS'
            enum:
            - SLP_LST_GAS
          customerValue:
            type: number
            format: double
            description: The customer value which represents a location independent annual consumption
          extractionLoadProfile:
            type: string
            description: The short name of the extraction load profile
          weatherStation:
            type: string
            description: The name of the weather station
      - $ref: '#/components/schemas/MeteringPointExtractionType_GAS_BASE'
    MeteringPointExtractionType_RLM_PRF_GAS:
      description: The metering point type for RLM Gas metering points
      required:
      - name
      - customerValue
      - extractionLoadProfile
      allOf:
      - type: object
        properties:
          name:
            type: string
            description: The name of the metering point type has to be 'RLM_PRF_GAS'
            enum:
            - RLM_PRF_GAS
          customerValue:
            type: number
            format: double
            description: The customer value which represents a location independent annual consumption
          extractionLoadProfile:
            type: string
            description: The short name of the extraction load profile
          weatherStation:
            type: string
            description: The name of the weather station
      - $ref: '#/components/schemas/MeteringPointExtractionType_GAS_BASE'
    MeteringPointExtractionType_GAS_BASE:
      description: The base properties of any metering point gas
      required:
      - pressureLevel
      properties:
        pressureLevel:
          type: string
          description: The pressure level name of the metering point
    MeteringPointExtractionType_SLP_POWER:
      description: The metering point type for SLP Power metering points
      required:
      - name
      - annualConsumption
      - extractionLoadProfile
      allOf:
      - type: object
        properties:
          name:
            type: string
            description: The name of the metering point type has to be 'SLP_POWER'
            enum:
            - SLP_POWER
          annualConsumption:
            type: number
            format: double
            description: The annual consumption
          extractionLoadProfile:
            type: string
            description: The short name of the extraction load profile
      - $ref: '#/components/schemas/MeteringPointExtractionType_POWER_BASE'
    MeteringPointExtractionType_RLM_POWER:
      description: The metering point type for RLM Power metering points
      required:
      - name
      allOf:
      - type: object
        properties:
          name:
            type: string
            description: The name of the metering point type has to be 'RLM_POWER'
            enum:
            - RLM_POWER
          weatherStation:
            type: string
            description: The name of the weather station
      - $ref: '#/components/schemas/MeteringPointExtractionType_POWER_BASE'
    MeteringPointExtractionType_TLP_POWER:
      description: The metering point type for TLP Power metering points
      required:
      - name
      - activeEnergy
      - extractionLoadProfile
      - weatherStation
      allOf:
      - type: object
        properties:
          name:
            type: string
            description: The name of the metering point type has to be 'TLP_POWER'
            enum:
            - TLP_POWER
          activeEnergy:
            type: number
            format: double
            description: The active energy
          extractionLoadProfile:
            type: string
            description: The short name of the extraction load profile
          weatherStation:
            type: string
            description: The name of the weather station
      - $ref: '#/components/schemas/MeteringPointExtractionType_POWER_BASE'
    MeteringPointExtractionType_SLP_LST_POWER:
      description: The metering point type for SLP Power metering points
      required:
      - name
      - annualConsumption
      - extractionLoadProfile
      allOf:
      - type: object
        properties:
          name:
            type: string
            description: The name of the metering point type has to be 'SLP_LST_POWER'
            enum:
            - SLP_LST_POWER
          annualConsumption:
            type: number
            format: double
            description: The annual consumption
          extractionLoadProfile:
            type: string
            description: The short name of the extraction load profile
          weatherStation:
            type: string
            description: The name of the weather station
      - $ref: '#/components/schemas/MeteringPointExtractionType_POWER_BASE'
    MeteringPointExtractionType_RLM_PRF_POWER:
      description: The metering point typefor RLM Power metering points
      required:
      - name
      - activeEnergy
      - annualConsumption
      - extractionLoadProfile
      allOf:
      - type: object
        properties:
          name:
            type: string
            description: The name of the metering point type has to be 'RLM_PRF_POWER'
            enum:
            - RLM_PRF_POWER
          activeEnergy:
            type: number
            format: double
            description: The active energy
          annualConsumption:
            type: number
            format: double
            description: The annual consumption
          extractionLoadProfile:
            type: string
            description: The short name of the extraction load profile
          weatherStation:
            type: string
            description: The name of the weather station
      - $ref: '#/components/schemas/MeteringPointExtractionType_POWER_BASE'
    MeteringPointExtractionType_POWER_BASE:
      description: The base properties of any metering point power
      required:
      - voltageLevel
      properties:
        voltageLevel:
          type: string
          description: The voltage level name of the metering point VoltageLevelMeteringId
        voltageLevelMetering:
          type: string
          description: The voltage level metering name of the metering point
        tariffProfile:
          type: string
          description: The tariff profile name of the metering point
    PricingHeader:
      type: object
      description: The pricing header containing multiple variants of a pricing offer
      required:
      - name
      - customer
      - variants
      properties:
        name:
          type: string
          description: The name of the pricing header
        customer:
          type: string
          description: The gln code of the customer
        pricingVariants:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/PricingVariant'
    PricingVariant:
      type: object
      description: A pricing offer variant for one or more metering points
      required:
      - name
      - submissionDate
      - deliveryFrom
      - deliveryUntil
      - commodity
      - pricingTemplate
      - bindingPeriod
      - meteringPointPriceCalculations
      properties:
        name:
          type: string
          description: The name of the pricing variant
        submissionDate:
          type: string
          format: date-time
          description: The date and time of the submission as ISO 8601 formatted string defined by date-time - RFC 3339. The date has to be at least one day in the future
        deliveryFrom:
          type: string
          format: date
          description: The inclusive start date of the pricing variant as ISO 8601 formatted string defined by full-date - RFC 3339. The date has to be at least one day in the future
        deliveryUntil:
          type: string
          format: date
          description: The inclusive end date of the pricing variant as ISO 8601 formatted string defined by full-date - RFC 3339. The date has to be at least one day in the future.
        commodity:
          type: string
          description: The commodity of the pricing variant. Valid values are either 'Strom' or 'Gas'
        pricingTemplate:
          type: string
          description: The name of a pricing template. The commodity of the pricing template needs to be the same commodity as defined for the pricing variant
        bindingPeriod:
          oneOf:
          - $ref: '#/components/schemas/BindingPeriodDate'
          - $ref: '#/components/schemas/BindingPeriodDay'
          - $ref: '#/components/schemas/BindingPeriodHour'
          discriminator:
            propertyName: bindingPeriodType
            mapping:
              DATE: BindingPeriodDate
              DAY: BindingPeriodDay
              HOUR: BindingPeriodHour
        settings:
          $ref: '#/components/schemas/Settings'
        customFields:
          $ref: '#/components/schemas/CustomFields'
        meteringPointPriceCalculations:
          type: array
          description: Multiple metering point price calculation of a pricing variant
          minItems: 1
          items:
            $ref: '#/components/schemas/MeteringPointPriceCalculation'
    BindingPeriodDate:
      description: A binding period by date
      type: object
      required:
      - bindingPeriodType
      - bindingPeriodDate
      properties:
        bindingPeriodType: 
          type: string
          description: The binding period type has to be 'DATE'
          enum:
          - DATE
        bindingPeriodDate:
          type: string
          format: date-time
          description: The binding period date as ISO 8601 formatted string defined by date-time - RFC 3339
    BindingPeriodDay:
      description: A binding period by days
      type: object
      required:
      - bindingPeriodType
      - bindingPeriodDays
      properties:
        bindingPeriodType: 
          type: string
          description: The binding period type has to be 'DAY'
          enum:
          - DAY
        bindingPeriodDays:
          type: number
          format: double
          description: The number of days used for the binding period 
    BindingPeriodHour:
      description: A binding period by hours
      type: object
      required:
      - bindingPeriodType
      - bindingPeriodHours
      properties:
        bindingPeriodType: 
          type: string
          description: The binding period type has to be 'HOUR'
          enum:
          - HOUR
        bindingPeriodHours:
          type: number
          format: double
          description:  The number of hours used for the binding period 
    MeteringPointPriceCalculation:
      type: object
      description: A metering point price calculation of a pricing variant. The commodity of the metering point used for this price calculation has to have the same commodity as the pricing variant
      required: 
      - marketLocationId
      properties:
        marketLocationId:
          type: string
          description: The market location id of the metering point
        deliveryFrom:
          type: string
          format: date
          description: The inclusive start date of the metering point price calculation as ISO 8601 formatted string defined by full-date - RFC 3339. The date has to be in the range of the deliveryFrom and deliveryUntil dates of the pricing variant
        deliveryUntil:
          type: string
          format: date
          description: The inclusive end date of the metering point price calculation as ISO 8601 formatted string defined by full-date - RFC 3339. The date has to be in the range of the deliveryFrom and deliveryUntil dates of the pricing variant
        settings:
          $ref: '#/components/schemas/Settings'
        customFields:
          $ref: '#/components/schemas/CustomFields'
    Settings:
      type: array
      description: A collection of settings. 
      items:
        oneOf:
        - $ref: '#/components/schemas/PriceSheetSetting'
        - $ref: '#/components/schemas/DecimalSetting'
        - $ref: '#/components/schemas/LongSetting'
        - $ref: '#/components/schemas/BooleanSetting'
        - $ref: '#/components/schemas/TextSetting'
        - $ref: '#/components/schemas/TimestampSetting'
        discriminator:
          propertyName: settingType
          mapping:
            PRICESHEET: PriceSheetSetting
            DECIMAL: DecimalSetting
            LONG: LongSetting
            BOOLEAN: BooleanSetting
            TEXT: TextSetting
            TIMESTAMP: TimestampSetting
    PriceSheetSetting:
      description: A price sheet setting
      type: object
      required:
      - settingType
      - settingName
      - priceSheetValue
      properties:
        settingType:
          type: string
          description: The type of the price sheet setting has to be 'PRICESHEET'
          enum:
          - PRICESHEET
        settingName:
          type: string
          description: The name of the setting
        priceSheetValue:
          type: string
          description: The name of the price sheet
    DecimalSetting:
      description: A a decimal setting
      type: object
      required:
      - settingType
      - settingName
      - decimalValue
      properties:
        settingType:
          type: string
          description: The type of the decimal setting has to be 'DECIMAL'
          enum:
          - DECIMAL
        settingName:
          type: string
          description: The name of the setting
        decimalValue:
          type: number
          format: double
          description: The decimal value of the setting
    LongSetting:
      description: A long setting
      type: object
      required:
      - settingType
      - settingName
      - longValue
      properties:
        settingType:
          type: string
          description: The type of the long setting has to be 'LONG'
          enum:
          - LONG
        settingName:
          type: string
          description: The name of the setting
        longValue:
          type: number
          format: int64
          description: The long value of the setting
    BooleanSetting:
      description: A boolean setting
      type: object
      required:
      - settingType
      - settingName
      - booleanValue
      properties:
        settingType:
          type: string
          description: The type of the boolean setting has to be 'BOOLEAN'
          enum:
          - BOOLEAN
        settingName:
          type: string
          description: The name of the setting
        booleanValue:
          type: boolean
          description: The boolean value of the setting
    TextSetting:
      description: A text setting
      type: object
      required:
      - settingType
      - settingName
      - textValue
      properties:
        settingType:
          type: string
          description: The type of the text setting has to be 'TEXT'
          enum:
          - TEXT
        settingName:
          type: string
          description: The name of the setting
        textValue:
          type: string
          description: The text value of the setting
    TimestampSetting:
      description: A text setting
      type: object
      required:
      - settingType
      - settingName
      - timestampValue
      properties:
        settingType:
          type: string
          description: The type of the timestamp setting has to be 'TIMESTAMP'
          enum:
          - TIMESTAMP
        settingName:
          type: string
          description: The name of the setting
        timestampValue:
          type: string
          format: date-time
          description: The date-time value of the setting as ISO 8601 formatted string defined by date-time - RFC 3339
    CustomFields:
      type: array
      description: A collection of custom fields. 
      items:
        type: object
        description: A custom field maps a value to a free text or key field by using a meaningful name. Custom field can only be used, if a mapping is configured for the service.
        properties:
          name:
            type: string
            description: The name of the custom field
          value:
            type: string
            description: The value of the custom field