// SPDX-FileCopyrightText: 2025 Contributors to the CitrineOS Project
//
// SPDX-License-Identifier: Apache-2.0

/**
 * This file was automatically generated by json-schema-to-typescript.
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
 * and run json-schema-to-typescript to regenerate this file.
 */

import {
  ChargingStateEnumType,
  IdTokenEnumType,
  LocationEnumType,
  MeasurandEnumType,
  PhaseEnumType,
  ReadingContextEnumType,
  ReasonEnumType,
  TransactionEventEnumType,
  TriggerReasonEnumType,
} from '../enums/index.js';
import type { OcppRequest } from '../../../internal-types.js';

export interface TransactionEventRequest extends OcppRequest {
  customData?: CustomDataType | null;
  eventType: TransactionEventEnumType;
  /**
   * @minItems 1
   */
  meterValue?: [MeterValueType, ...MeterValueType[]] | null;
  /**
   * The date and time at which this transaction event occurred.
   *
   */
  timestamp: string;
  triggerReason: TriggerReasonEnumType;
  /**
   * Incremental sequence number, helps with determining if all messages of a transaction have been received.
   *
   */
  seqNo: number;
  /**
   * Indication that this transaction event happened when the Charging Station was offline. Default = false, meaning: the event occurred when the Charging Station was online.
   *
   */
  offline?: boolean | null;
  /**
   * If the Charging Station is able to report the number of phases used, then it SHALL provide it. When omitted the CSMS may be able to determine the number of phases used via device management.
   *
   */
  numberOfPhasesUsed?: number | null;
  /**
   * The maximum current of the connected cable in Ampere (A).
   *
   */
  cableMaxCurrent?: number | null;
  /**
   * This contains the Id of the reservation that terminates as a result of this transaction.
   *
   */
  reservationId?: number | null;
  transactionInfo: TransactionType;
  evse?: EVSEType | null;
  idToken?: IdTokenType | null;
}
/**
 * Represents OCPP CustomData.
 * Allows vendor-specific extension properties.
 */
export interface CustomDataType {
  vendorId: string;
  [k: string]: unknown;
}
/**
 * Meter_ Value
 * urn:x-oca:ocpp:uid:2:233265
 * Collection of one or more sampled values in MeterValuesRequest and TransactionEvent. All sampled values in a MeterValue are sampled at the same point in time.
 *
 */
export interface MeterValueType {
  customData?: CustomDataType | null;
  /**
   * @minItems 1
   */
  sampledValue: [SampledValueType, ...SampledValueType[]];
  /**
   * Meter_ Value. Timestamp. Date_ Time
   * urn:x-oca:ocpp:uid:1:569259
   * Timestamp for measured value(s).
   *
   */
  timestamp: string;
}
/**
 * Sampled_ Value
 * urn:x-oca:ocpp:uid:2:233266
 * Single sampled value in MeterValues. Each value can be accompanied by optional fields.
 *
 * To save on mobile data usage, default values of all of the optional fields are such that. The value without any additional fields will be interpreted, as a register reading of active import energy in Wh (Watt-hour) units.
 *
 */
export interface SampledValueType {
  customData?: CustomDataType | null;
  /**
   * Sampled_ Value. Value. Measure
   * urn:x-oca:ocpp:uid:1:569260
   * Indicates the measured value.
   *
   *
   */
  value: number;
  context?: ReadingContextEnumType | null;
  measurand?: MeasurandEnumType | null;
  phase?: PhaseEnumType | null;
  location?: LocationEnumType | null;
  signedMeterValue?: SignedMeterValueType | null;
  unitOfMeasure?: UnitOfMeasureType | null;
}
/**
 * Represent a signed version of the meter value.
 *
 */
export interface SignedMeterValueType {
  customData?: CustomDataType | null;
  /**
   * Base64 encoded, contains the signed data which might contain more then just the meter value. It can contain information like timestamps, reference to a customer etc.
   *
   */
  signedMeterData: string;
  /**
   * Method used to create the digital signature.
   *
   */
  signingMethod: string;
  /**
   * Method used to encode the meter values before applying the digital signature algorithm.
   *
   */
  encodingMethod: string;
  /**
   * Base64 encoded, sending depends on configuration variable _PublicKeyWithSignedMeterValue_.
   *
   */
  publicKey: string;
}
/**
 * Represents a UnitOfMeasure with a multiplier
 *
 */
export interface UnitOfMeasureType {
  customData?: CustomDataType | null;
  /**
   * Unit of the value. Default = "Wh" if the (default) measurand is an "Energy" type.
   * This field SHALL use a value from the list Standardized Units of Measurements in Part 2 Appendices.
   * If an applicable unit is available in that list, otherwise a "custom" unit might be used.
   *
   */
  unit?: string | null;
  /**
   * Multiplier, this value represents the exponent to base 10. I.e. multiplier 3 means 10 raised to the 3rd power. Default is 0.
   *
   */
  multiplier?: number | null;
}
/**
 * Transaction
 * urn:x-oca:ocpp:uid:2:233318
 *
 */
export interface TransactionType {
  customData?: CustomDataType | null;
  /**
   * This contains the Id of the transaction.
   *
   */
  transactionId: string;
  chargingState?: ChargingStateEnumType | null;
  /**
   * Transaction. Time_ Spent_ Charging. Elapsed_ Time
   * urn:x-oca:ocpp:uid:1:569415
   * Contains the total time that energy flowed from EVSE to EV during the transaction (in seconds). Note that timeSpentCharging is smaller or equal to the duration of the transaction.
   *
   */
  timeSpentCharging?: number | null;
  stoppedReason?: ReasonEnumType | null;
  /**
   * The ID given to remote start request (&lt;&lt;requeststarttransactionrequest, RequestStartTransactionRequest&gt;&gt;. This enables to CSMS to match the started transaction to the given start request.
   *
   */
  remoteStartId?: number | null;
}
/**
 * EVSE
 * urn:x-oca:ocpp:uid:2:233123
 * Electric Vehicle Supply Equipment
 *
 */
export interface EVSEType {
  customData?: CustomDataType | null;
  /**
   * Identified_ Object. MRID. Numeric_ Identifier
   * urn:x-enexis:ecdm:uid:1:569198
   * EVSE Identifier. This contains a number (&gt; 0) designating an EVSE of the Charging Station.
   *
   */
  id: number;
  /**
   * An id to designate a specific connector (on an EVSE) by connector index number.
   *
   */
  connectorId?: number | null;
}
/**
 * Contains a case insensitive identifier to use for the authorization and the type of authorization to support multiple forms of identifiers.
 *
 */
export interface IdTokenType {
  customData?: CustomDataType | null;
  /**
   * @minItems 1
   */
  additionalInfo?: [AdditionalInfoType, ...AdditionalInfoType[]] | null;
  /**
   * IdToken is case insensitive. Might hold the hidden id of an RFID tag, but can for example also contain a UUID.
   *
   */
  idToken: string;
  type: IdTokenEnumType;
}
/**
 * Contains a case insensitive identifier to use for the authorization and the type of authorization to support multiple forms of identifiers.
 *
 */
export interface AdditionalInfoType {
  customData?: CustomDataType | null;
  /**
   * This field specifies the additional IdToken.
   *
   */
  additionalIdToken: string;
  /**
   * This defines the type of the additionalIdToken. This is a custom type, so the implementation needs to be agreed upon by all involved parties.
   *
   */
  type: string;
}
