<commit_before>import TransformingNetworkClient from '../../communication/TransformingNetworkClient';
import Seal from '../../types/Seal';
import { Amount, Links, Url } from '../global';
import Helper from '../Helper';
import Model from '../Model';
import { PaymentData } from '../payments/data';
import Payment, { transform as transformPayment } from '../payments/Payment';
import ChargebackHelper from './ChargebackHelper';

export interface ChargebackData extends Model<'chargeback'> {
  /**
   * The amount charged back by the consumer.
   *
   * @see https://docs.mollie.com/reference/v2/chargebacks-api/get-payment-chargeback?path=amount#response
   */
  amount: Amount;
  /**
   * This optional field will contain the amount that will be deducted from your account, converted to the currency your account is settled in. It follows the same syntax as the `amount` property.
   *
   * Note that for chargebacks, the `value` key of `settlementAmount` will be negative.
   *
   * Any amounts not settled by Mollie will not be reflected in this amount, e.g. PayPal chargebacks.
   *
   * @see https://docs.mollie.com/reference/v2/chargebacks-api/get-payment-chargeback?path=settlementAmount#response
   */
  settlementAmount: Amount;
  /**
   * The date and time the chargeback was issued, in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
   *
   * @see https://docs.mollie.com/reference/v2/chargebacks-api/get-payment-chargeback?path=createdAt#response
   */
  createdAt: string;
  /**
   * Reason for the chargeback as given by the bank.
   *
   * @see https://docs.mollie.com/reference/v2/chargebacks-api/get-payment-chargeback?path=reason#response
   */
  reason?: {
    /**
     * Bank code of the chargeback reason.
     *
     * @see https://docs.mollie.com/reference/v2/chargebacks-api/get-payment-chargeback?path=reason/code#response
     */
    code: string;
    /**
     * Detailed description of the reason.
     *
     * @see https://docs.mollie.com/reference/v2/chargebacks-api/get-payment-chargeback?path=reason/description#response
     */
    description: string;
  };
  /**
   * The date and time the chargeback was reversed if applicable, in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
   *
   * @see https://docs.mollie.com/reference/v2/chargebacks-api/get-payment-chargeback?path=reversedAt#response
   */
  reversedAt: string;
  /**
   * The unique identifier of the payment this chargeback was issued for. For example: `tr_7UhSN1zuXS`. The full payment object can be retrieved via the `payment` URL in the `_links` object.
   *
   * @see https://docs.mollie.com/reference/v2/chargebacks-api/get-payment-chargeback?path=paymentId#response
   */
  paymentId: string;
  _embedded?: {
    payment?: Omit<PaymentData, '_embedded'>;
  };
  /**
   * An object with several URL objects relevant to the chargeback. Every URL object will contain an `href` and a `type` field.
   *
   * @see https://docs.mollie.com/reference/v2/chargebacks-api/get-payment-chargeback?path=_links#response
   */
  _links: ChargebackLinks;
}

type Chargeback = Seal<
  Omit<ChargebackData, '_embedded'> & {
    _embedded?: {
      payment?: Payment;
    };
  },
  Helper<ChargebackData, Chargeback>
>;

export default Chargeback;

export interface ChargebackLinks extends Links {
  /**
   * The API resource URL of the payment this chargeback belongs to.
   *
   * @see https://docs.mollie.com/reference/v2/chargebacks-api/get-payment-chargeback?path=_links/payment#response
   */
  payment: Url;
  /**
   * The API resource URL of the settlement this payment has been settled with. Not present if not yet settled.
   *
   * @see https://docs.mollie.com/reference/v2/chargebacks-api/get-payment-chargeback?path=_links/settlement#response
   */
  settlement?: Url;
}

export enum ChargebackEmbed {
  payment = 'payment',
}

export function transform(networkClient: TransformingNetworkClient, input: ChargebackData): Chargeback {
  let _embedded: Chargeback['_embedded'];
  if (input._embedded != undefined) {
    _embedded = {};
    if (input._embedded.payment != undefined) {
      _embedded.payment = transformPayment(networkClient, input._embedded.payment);
    }
  }
  return Object.assign(Object.create(new ChargebackHelper(networkClient, input._links, _embedded)), input, { _embedded });
}
<commit_msg>Make chargeback.reason mandatory (in accordance with the docs).<commit_after>import TransformingNetworkClient from '../../communication/TransformingNetworkClient';
import Seal from '../../types/Seal';
import { Amount, Links, Url } from '../global';
import Helper from '../Helper';
import Model from '../Model';
import { PaymentData } from '../payments/data';
import Payment, { transform as transformPayment } from '../payments/Payment';
import ChargebackHelper from './ChargebackHelper';

export interface ChargebackData extends Model<'chargeback'> {
  /**
   * The amount charged back by the consumer.
   *
   * @see https://docs.mollie.com/reference/v2/chargebacks-api/get-payment-chargeback?path=amount#response
   */
  amount: Amount;
  /**
   * This optional field will contain the amount that will be deducted from your account, converted to the currency your account is settled in. It follows the same syntax as the `amount` property.
   *
   * Note that for chargebacks, the `value` key of `settlementAmount` will be negative.
   *
   * Any amounts not settled by Mollie will not be reflected in this amount, e.g. PayPal chargebacks.
   *
   * @see https://docs.mollie.com/reference/v2/chargebacks-api/get-payment-chargeback?path=settlementAmount#response
   */
  settlementAmount: Amount;
  /**
   * The date and time the chargeback was issued, in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
   *
   * @see https://docs.mollie.com/reference/v2/chargebacks-api/get-payment-chargeback?path=createdAt#response
   */
  createdAt: string;
  /**
   * Reason for the chargeback as given by the bank.
   *
   * @see https://docs.mollie.com/reference/v2/chargebacks-api/get-payment-chargeback?path=reason#response
   */
  reason: {
    /**
     * Bank code of the chargeback reason.
     *
     * @see https://docs.mollie.com/reference/v2/chargebacks-api/get-payment-chargeback?path=reason/code#response
     */
    code: string;
    /**
     * Detailed description of the reason.
     *
     * @see https://docs.mollie.com/reference/v2/chargebacks-api/get-payment-chargeback?path=reason/description#response
     */
    description: string;
  };
  /**
   * The date and time the chargeback was reversed if applicable, in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
   *
   * @see https://docs.mollie.com/reference/v2/chargebacks-api/get-payment-chargeback?path=reversedAt#response
   */
  reversedAt: string;
  /**
   * The unique identifier of the payment this chargeback was issued for. For example: `tr_7UhSN1zuXS`. The full payment object can be retrieved via the `payment` URL in the `_links` object.
   *
   * @see https://docs.mollie.com/reference/v2/chargebacks-api/get-payment-chargeback?path=paymentId#response
   */
  paymentId: string;
  _embedded?: {
    payment?: Omit<PaymentData, '_embedded'>;
  };
  /**
   * An object with several URL objects relevant to the chargeback. Every URL object will contain an `href` and a `type` field.
   *
   * @see https://docs.mollie.com/reference/v2/chargebacks-api/get-payment-chargeback?path=_links#response
   */
  _links: ChargebackLinks;
}

type Chargeback = Seal<
  Omit<ChargebackData, '_embedded'> & {
    _embedded?: {
      payment?: Payment;
    };
  },
  Helper<ChargebackData, Chargeback>
>;

export default Chargeback;

export interface ChargebackLinks extends Links {
  /**
   * The API resource URL of the payment this chargeback belongs to.
   *
   * @see https://docs.mollie.com/reference/v2/chargebacks-api/get-payment-chargeback?path=_links/payment#response
   */
  payment: Url;
  /**
   * The API resource URL of the settlement this payment has been settled with. Not present if not yet settled.
   *
   * @see https://docs.mollie.com/reference/v2/chargebacks-api/get-payment-chargeback?path=_links/settlement#response
   */
  settlement?: Url;
}

export enum ChargebackEmbed {
  payment = 'payment',
}

export function transform(networkClient: TransformingNetworkClient, input: ChargebackData): Chargeback {
  let _embedded: Chargeback['_embedded'];
  if (input._embedded != undefined) {
    _embedded = {};
    if (input._embedded.payment != undefined) {
      _embedded.payment = transformPayment(networkClient, input._embedded.payment);
    }
  }
  return Object.assign(Object.create(new ChargebackHelper(networkClient, input._links, _embedded)), input, { _embedded });
}

{'fraction_non_alphanumeric': 0.1243255653771094, 'fraction_numerical': 0.006658248191941224, 'mean_word_length': 3.6838709677419357, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 26, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6520978', 'n_tokens_mistral': 2718, 'n_tokens_neox': 2628, 'n_words': 671}