import { HttpMethod } from '@activepieces/pieces-common';
import { createAction, Property } from '@activepieces/pieces-framework';
import { ampecoAuth } from '../../../common/auth';
import { handleApiError, makeAmpecoApiCall, prepareQueryParams, prepareRequestBody, processPathParameters } from '../../../common/utils';
import { SubscriptionPlanUpdateResponse } from '../../../models/responses';

/**
 * Generated from API version: 3.96.4
 */

// Endpoint: PATCH /public-api/resources/subscription-plans/v2.0/{subscriptionPlan}
export const subscriptionPlanUpdateAction = createAction({
  auth: ampecoAuth,
  name: 'subscriptionPlanUpdate',
  displayName: 'Resources - Subscription Plans - Update',
  description: 'Update a Subscription plan.',
  audience: 'both',
  aiMetadata: { description: 'Modify an existing AMPECO subscription plan by its numeric ID, changing localized name/description, renewal cycle, pre-paid/post-paid type, fees, allowance (kWh and country/partner restrictions), visibility restrictions, and enabled/disabled status. Not idempotent: it edits a plan that must already exist, and localized name/description entries omitted on update are deleted, so always send all locales you want to keep.', idempotent: false },
  props: {
        
  subscriptionPlan: Property.Number({
    displayName: 'Subscription Plan',
    description: '',
    required: true,
  }),

  name: Property.Array({
    displayName: 'Name',
    description: 'Locales that have been created and are not provided on an update will be deleted. Please provide values in all locales that you wish to keep.',
    required: false,
    properties: { 
         
  locale: Property.ShortText({
    displayName: 'Locale',
    description: 'valid locale.',
    required: false,
  }),

  translation: Property.ShortText({
    displayName: 'Translation',
    description: '',
    required: false,
  }), 
    },
  }),

  description: Property.Array({
    displayName: 'Description',
    description: 'Locales that have been created and are not provided on an update will be deleted. Please provide values in all locales that you wish to keep.',
    required: false,
    properties: { 
         
  locale: Property.ShortText({
    displayName: 'Locale',
    description: 'valid locale.',
    required: false,
  }),

  translation: Property.ShortText({
    displayName: 'Translation',
    description: '',
    required: false,
  }), 
    },
  }),

  renewalCycle: Property.StaticDropdown({
    displayName: 'Renewal Cycle',
    description: '',
    required: false,
    options: {
      options: [
      { label: 'monthly', value: 'monthly' },
      { label: 'annually', value: 'annually' }
      ],
    },
  }),

  freeRenewalPeriods: Property.Number({
    displayName: 'Free Renewal Periods',
    description: 'The number of renewal periods that are free of charge. This is only applicable for pre-paid plans.',
    required: false,
  }),

  type: Property.StaticDropdown({
    displayName: 'Type',
    description: 'Required when Post-paid Subscription plans has been enabled for the system.',
    required: false,
    options: {
      options: [
      { label: 'pre-paid', value: 'pre-paid' },
      { label: 'post-paid', value: 'post-paid' }
      ],
    },
  }),

  baseFee: Property.Number({
    displayName: 'Base Fee',
    description: 'For pre-paid plans this is the price, for post-paid plans this is the base fee.',
    required: false,
  }),

  feePerEachPersonalChargePoint: Property.Number({
    displayName: 'Fee Per Each Personal Charge Point',
    description: 'Applies separately per each personal charge point owned by the subscriber that requires this Subscription plan.',
    required: false,
  }),

  postPaidChargingSessionsAccumulation: Property.StaticDropdown({
    displayName: 'Post Paid Charging Sessions Accumulation',
    description: 'Indicates if charging sessions at personal, commercial+personal charge points are included in the post-paid subscription and would be billed at the end of the billing cycle or when a threshold is met, if there is such.',
    required: false,
    options: {
      options: [
      { label: 'none', value: 'none' },
      { label: 'personal', value: 'personal' },
      { label: 'personal_commercial', value: 'personal_commercial' }
      ],
    },
  }),

  billingUsageThreshold: Property.Number({
    displayName: 'Billing Usage Threshold',
    description: 'If this threshold is reached, the amount due for the subscription would be billed immediately instead of waiting for the end of the billing period.',
    required: false,
  }),

  billingType: Property.StaticDropdown({
    displayName: 'Billing Type',
    description: 'Applicable only for post-paid subscription plans when external billing is enabled. Controls the billing method used for this subscription plan.',
    required: false,
    options: {
      options: [
      { label: 'default', value: 'default' },
      { label: 'internal', value: 'internal' },
      { label: 'external', value: 'external' }
      ],
    },
  }),

  status: Property.StaticDropdown({
    displayName: 'Status',
    description: 'A change from disabled to enabled is only possible for Subscription plans that are not replaced with another plan.',
    required: false,
    options: {
      options: [
      { label: 'enabled', value: 'enabled' },
      { label: 'disabled', value: 'disabled' }
      ],
    },
  }),

  allowance__resetCycle: Property.StaticDropdown({
    displayName: 'Allowance - Reset Cycle',
    description: '',
    required: false,
    options: {
      options: [
      { label: 'as_renewal_cycle', value: 'as_renewal_cycle' },
      { label: 'after_each_session', value: 'after_each_session' },
      { label: 'after_24_hours', value: 'after_24_hours' },
      { label: 'after_each_week', value: 'after_each_week' },
      { label: 'after_each_month', value: 'after_each_month' },
      { label: 'after_each_year', value: 'after_each_year' }
      ],
    },
  }),

  allowance__type: Property.StaticDropdown({
    displayName: 'Allowance - Type',
    description: '',
    required: false,
    options: {
      options: [
      { label: 'none', value: 'none' },
      { label: 'combined', value: 'combined' },
      { label: 'separate', value: 'separate' }
      ],
    },
  }),

  allowance__homeChargersOnly: Property.StaticDropdown({
    displayName: 'Allowance - Home Chargers Only',
    description: 'When true the allowance can only be used on the home charge points owned by the user. In that case all other allowance restrictions have no effect.',
    required: false,
    options: {
      options: [
      { label: 'true', value: 'true' },
      { label: 'false', value: 'false' }
      ],
    },
  }),

  allowance__includedCountries: Property.StaticMultiSelectDropdown({
    displayName: 'Allowance - Included Countries',
    description: 'The allowance can only be used on charge points in countries in this list. When empty the allowance is valid for charge points in all countries, except the ones explicitly listed in the excludedCountries.',
    required: false,
    options: {
      options: [
      { label: 'AF', value: 'AF' },
      { label: 'AX', value: 'AX' },
      { label: 'AL', value: 'AL' },
      { label: 'DZ', value: 'DZ' },
      { label: 'AS', value: 'AS' },
      { label: 'AD', value: 'AD' },
      { label: 'AO', value: 'AO' },
      { label: 'AI', value: 'AI' },
      { label: 'AQ', value: 'AQ' },
      { label: 'AG', value: 'AG' },
      { label: 'AR', value: 'AR' },
      { label: 'AM', value: 'AM' },
      { label: 'AW', value: 'AW' },
      { label: 'AU', value: 'AU' },
      { label: 'AT', value: 'AT' },
      { label: 'AZ', value: 'AZ' },
      { label: 'BS', value: 'BS' },
      { label: 'BH', value: 'BH' },
      { label: 'BD', value: 'BD' },
      { label: 'BB', value: 'BB' },
      { label: 'BY', value: 'BY' },
      { label: 'BE', value: 'BE' },
      { label: 'BZ', value: 'BZ' },
      { label: 'BJ', value: 'BJ' },
      { label: 'BM', value: 'BM' },
      { label: 'BT', value: 'BT' },
      { label: 'BO', value: 'BO' },
      { label: 'BQ', value: 'BQ' },
      { label: 'BA', value: 'BA' },
      { label: 'BW', value: 'BW' },
      { label: 'BV', value: 'BV' },
      { label: 'BR', value: 'BR' },
      { label: 'IO', value: 'IO' },
      { label: 'BN', value: 'BN' },
      { label: 'BG', value: 'BG' },
      { label: 'BF', value: 'BF' },
      { label: 'BI', value: 'BI' },
      { label: 'KH', value: 'KH' },
      { label: 'CM', value: 'CM' },
      { label: 'CA', value: 'CA' },
      { label: 'CV', value: 'CV' },
      { label: 'KY', value: 'KY' },
      { label: 'CF', value: 'CF' },
      { label: 'TD', value: 'TD' },
      { label: 'CL', value: 'CL' },
      { label: 'CN', value: 'CN' },
      { label: 'CX', value: 'CX' },
      { label: 'CC', value: 'CC' },
      { label: 'CO', value: 'CO' },
      { label: 'KM', value: 'KM' },
      { label: 'CG', value: 'CG' },
      { label: 'CD', value: 'CD' },
      { label: 'CK', value: 'CK' },
      { label: 'CR', value: 'CR' },
      { label: 'CI', value: 'CI' },
      { label: 'HR', value: 'HR' },
      { label: 'CU', value: 'CU' },
      { label: 'CW', value: 'CW' },
      { label: 'CY', value: 'CY' },
      { label: 'CZ', value: 'CZ' },
      { label: 'DK', value: 'DK' },
      { label: 'DJ', value: 'DJ' },
      { label: 'DM', value: 'DM' },
      { label: 'DO', value: 'DO' },
      { label: 'EC', value: 'EC' },
      { label: 'EG', value: 'EG' },
      { label: 'SV', value: 'SV' },
      { label: 'GQ', value: 'GQ' },
      { label: 'ER', value: 'ER' },
      { label: 'EE', value: 'EE' },
      { label: 'ET', value: 'ET' },
      { label: 'FK', value: 'FK' },
      { label: 'FO', value: 'FO' },
      { label: 'FJ', value: 'FJ' },
      { label: 'FI', value: 'FI' },
      { label: 'FR', value: 'FR' },
      { label: 'GF', value: 'GF' },
      { label: 'PF', value: 'PF' },
      { label: 'TF', value: 'TF' },
      { label: 'GA', value: 'GA' },
      { label: 'GM', value: 'GM' },
      { label: 'GE', value: 'GE' },
      { label: 'DE', value: 'DE' },
      { label: 'GH', value: 'GH' },
      { label: 'GI', value: 'GI' },
      { label: 'GR', value: 'GR' },
      { label: 'GL', value: 'GL' },
      { label: 'GD', value: 'GD' },
      { label: 'GP', value: 'GP' },
      { label: 'GU', value: 'GU' },
      { label: 'GT', value: 'GT' },
      { label: 'GG', value: 'GG' },
      { label: 'GN', value: 'GN' },
      { label: 'GW', value: 'GW' },
      { label: 'GY', value: 'GY' },
      { label: 'HT', value: 'HT' },
      { label: 'HM', value: 'HM' },
      { label: 'VA', value: 'VA' },
      { label: 'HN', value: 'HN' },
      { label: 'HK', value: 'HK' },
      { label: 'HU', value: 'HU' },
      { label: 'IS', value: 'IS' },
      { label: 'IN', value: 'IN' },
      { label: 'ID', value: 'ID' },
      { label: 'IR', value: 'IR' },
      { label: 'IQ', value: 'IQ' },
      { label: 'IE', value: 'IE' },
      { label: 'IM', value: 'IM' },
      { label: 'IL', value: 'IL' },
      { label: 'IT', value: 'IT' },
      { label: 'JM', value: 'JM' },
      { label: 'JP', value: 'JP' },
      { label: 'JE', value: 'JE' },
      { label: 'JO', value: 'JO' },
      { label: 'KZ', value: 'KZ' },
      { label: 'KE', value: 'KE' },
      { label: 'KI', value: 'KI' },
      { label: 'KP', value: 'KP' },
      { label: 'KR', value: 'KR' },
      { label: 'XK', value: 'XK' },
      { label: 'KW', value: 'KW' },
      { label: 'KG', value: 'KG' },
      { label: 'LA', value: 'LA' },
      { label: 'LV', value: 'LV' },
      { label: 'LB', value: 'LB' },
      { label: 'LS', value: 'LS' },
      { label: 'LR', value: 'LR' },
      { label: 'LY', value: 'LY' },
      { label: 'LI', value: 'LI' },
      { label: 'LT', value: 'LT' },
      { label: 'LU', value: 'LU' },
      { label: 'MO', value: 'MO' },
      { label: 'MK', value: 'MK' },
      { label: 'MG', value: 'MG' },
      { label: 'MW', value: 'MW' },
      { label: 'MY', value: 'MY' },
      { label: 'MV', value: 'MV' },
      { label: 'ML', value: 'ML' },
      { label: 'MT', value: 'MT' },
      { label: 'MH', value: 'MH' },
      { label: 'MQ', value: 'MQ' },
      { label: 'MR', value: 'MR' },
      { label: 'MU', value: 'MU' },
      { label: 'YT', value: 'YT' },
      { label: 'MX', value: 'MX' },
      { label: 'FM', value: 'FM' },
      { label: 'MD', value: 'MD' },
      { label: 'MC', value: 'MC' },
      { label: 'MN', value: 'MN' },
      { label: 'ME', value: 'ME' },
      { label: 'MS', value: 'MS' },
      { label: 'MA', value: 'MA' },
      { label: 'MZ', value: 'MZ' },
      { label: 'MM', value: 'MM' },
      { label: 'NA', value: 'NA' },
      { label: 'NR', value: 'NR' },
      { label: 'NP', value: 'NP' },
      { label: 'NL', value: 'NL' },
      { label: 'NC', value: 'NC' },
      { label: 'NZ', value: 'NZ' },
      { label: 'NI', value: 'NI' },
      { label: 'NE', value: 'NE' },
      { label: 'NG', value: 'NG' },
      { label: 'NU', value: 'NU' },
      { label: 'NF', value: 'NF' },
      { label: 'MP', value: 'MP' },
      { label: 'NO', value: 'NO' },
      { label: 'OM', value: 'OM' },
      { label: 'PK', value: 'PK' },
      { label: 'PW', value: 'PW' },
      { label: 'PS', value: 'PS' },
      { label: 'PA', value: 'PA' },
      { label: 'PG', value: 'PG' },
      { label: 'PY', value: 'PY' },
      { label: 'PE', value: 'PE' },
      { label: 'PH', value: 'PH' },
      { label: 'PN', value: 'PN' },
      { label: 'PL', value: 'PL' },
      { label: 'PT', value: 'PT' },
      { label: 'PR', value: 'PR' },
      { label: 'QA', value: 'QA' },
      { label: 'RE', value: 'RE' },
      { label: 'RO', value: 'RO' },
      { label: 'RU', value: 'RU' },
      { label: 'RW', value: 'RW' },
      { label: 'BL', value: 'BL' },
      { label: 'SH', value: 'SH' },
      { label: 'KN', value: 'KN' },
      { label: 'LC', value: 'LC' },
      { label: 'MF', value: 'MF' },
      { label: 'PM', value: 'PM' },
      { label: 'VC', value: 'VC' },
      { label: 'WS', value: 'WS' },
      { label: 'SM', value: 'SM' },
      { label: 'ST', value: 'ST' },
      { label: 'SA', value: 'SA' },
      { label: 'SN', value: 'SN' },
      { label: 'RS', value: 'RS' },
      { label: 'SC', value: 'SC' },
      { label: 'SL', value: 'SL' },
      { label: 'SG', value: 'SG' },
      { label: 'SX', value: 'SX' },
      { label: 'SK', value: 'SK' },
      { label: 'SI', value: 'SI' },
      { label: 'SB', value: 'SB' },
      { label: 'SO', value: 'SO' },
      { label: 'ZA', value: 'ZA' },
      { label: 'GS', value: 'GS' },
      { label: 'SS', value: 'SS' },
      { label: 'ES', value: 'ES' },
      { label: 'LK', value: 'LK' },
      { label: 'SD', value: 'SD' },
      { label: 'SR', value: 'SR' },
      { label: 'SJ', value: 'SJ' },
      { label: 'SZ', value: 'SZ' },
      { label: 'SE', value: 'SE' },
      { label: 'CH', value: 'CH' },
      { label: 'SY', value: 'SY' },
      { label: 'TW', value: 'TW' },
      { label: 'TJ', value: 'TJ' },
      { label: 'TZ', value: 'TZ' },
      { label: 'TH', value: 'TH' },
      { label: 'TL', value: 'TL' },
      { label: 'TG', value: 'TG' },
      { label: 'TK', value: 'TK' },
      { label: 'TO', value: 'TO' },
      { label: 'TT', value: 'TT' },
      { label: 'TN', value: 'TN' },
      { label: 'TR', value: 'TR' },
      { label: 'TM', value: 'TM' },
      { label: 'TC', value: 'TC' },
      { label: 'TV', value: 'TV' },
      { label: 'UG', value: 'UG' },
      { label: 'UA', value: 'UA' },
      { label: 'AE', value: 'AE' },
      { label: 'GB', value: 'GB' },
      { label: 'US', value: 'US' },
      { label: 'UM', value: 'UM' },
      { label: 'UY', value: 'UY' },
      { label: 'UZ', value: 'UZ' },
      { label: 'VU', value: 'VU' },
      { label: 'VE', value: 'VE' },
      { label: 'VN', value: 'VN' },
      { label: 'VG', value: 'VG' },
      { label: 'VI', value: 'VI' },
      { label: 'WF', value: 'WF' },
      { label: 'EH', value: 'EH' },
      { label: 'YE', value: 'YE' },
      { label: 'ZM', value: 'ZM' },
      { label: 'ZW', value: 'ZW' }
      ],
    },
  }),

  allowance__excludedCountries: Property.StaticMultiSelectDropdown({
    displayName: 'Allowance - Excluded Countries',
    description: 'The allowance cannot be used on charge points in the countries in this list.',
    required: false,
    options: {
      options: [
      { label: 'AF', value: 'AF' },
      { label: 'AX', value: 'AX' },
      { label: 'AL', value: 'AL' },
      { label: 'DZ', value: 'DZ' },
      { label: 'AS', value: 'AS' },
      { label: 'AD', value: 'AD' },
      { label: 'AO', value: 'AO' },
      { label: 'AI', value: 'AI' },
      { label: 'AQ', value: 'AQ' },
      { label: 'AG', value: 'AG' },
      { label: 'AR', value: 'AR' },
      { label: 'AM', value: 'AM' },
      { label: 'AW', value: 'AW' },
      { label: 'AU', value: 'AU' },
      { label: 'AT', value: 'AT' },
      { label: 'AZ', value: 'AZ' },
      { label: 'BS', value: 'BS' },
      { label: 'BH', value: 'BH' },
      { label: 'BD', value: 'BD' },
      { label: 'BB', value: 'BB' },
      { label: 'BY', value: 'BY' },
      { label: 'BE', value: 'BE' },
      { label: 'BZ', value: 'BZ' },
      { label: 'BJ', value: 'BJ' },
      { label: 'BM', value: 'BM' },
      { label: 'BT', value: 'BT' },
      { label: 'BO', value: 'BO' },
      { label: 'BQ', value: 'BQ' },
      { label: 'BA', value: 'BA' },
      { label: 'BW', value: 'BW' },
      { label: 'BV', value: 'BV' },
      { label: 'BR', value: 'BR' },
      { label: 'IO', value: 'IO' },
      { label: 'BN', value: 'BN' },
      { label: 'BG', value: 'BG' },
      { label: 'BF', value: 'BF' },
      { label: 'BI', value: 'BI' },
      { label: 'KH', value: 'KH' },
      { label: 'CM', value: 'CM' },
      { label: 'CA', value: 'CA' },
      { label: 'CV', value: 'CV' },
      { label: 'KY', value: 'KY' },
      { label: 'CF', value: 'CF' },
      { label: 'TD', value: 'TD' },
      { label: 'CL', value: 'CL' },
      { label: 'CN', value: 'CN' },
      { label: 'CX', value: 'CX' },
      { label: 'CC', value: 'CC' },
      { label: 'CO', value: 'CO' },
      { label: 'KM', value: 'KM' },
      { label: 'CG', value: 'CG' },
      { label: 'CD', value: 'CD' },
      { label: 'CK', value: 'CK' },
      { label: 'CR', value: 'CR' },
      { label: 'CI', value: 'CI' },
      { label: 'HR', value: 'HR' },
      { label: 'CU', value: 'CU' },
      { label: 'CW', value: 'CW' },
      { label: 'CY', value: 'CY' },
      { label: 'CZ', value: 'CZ' },
      { label: 'DK', value: 'DK' },
      { label: 'DJ', value: 'DJ' },
      { label: 'DM', value: 'DM' },
      { label: 'DO', value: 'DO' },
      { label: 'EC', value: 'EC' },
      { label: 'EG', value: 'EG' },
      { label: 'SV', value: 'SV' },
      { label: 'GQ', value: 'GQ' },
      { label: 'ER', value: 'ER' },
      { label: 'EE', value: 'EE' },
      { label: 'ET', value: 'ET' },
      { label: 'FK', value: 'FK' },
      { label: 'FO', value: 'FO' },
      { label: 'FJ', value: 'FJ' },
      { label: 'FI', value: 'FI' },
      { label: 'FR', value: 'FR' },
      { label: 'GF', value: 'GF' },
      { label: 'PF', value: 'PF' },
      { label: 'TF', value: 'TF' },
      { label: 'GA', value: 'GA' },
      { label: 'GM', value: 'GM' },
      { label: 'GE', value: 'GE' },
      { label: 'DE', value: 'DE' },
      { label: 'GH', value: 'GH' },
      { label: 'GI', value: 'GI' },
      { label: 'GR', value: 'GR' },
      { label: 'GL', value: 'GL' },
      { label: 'GD', value: 'GD' },
      { label: 'GP', value: 'GP' },
      { label: 'GU', value: 'GU' },
      { label: 'GT', value: 'GT' },
      { label: 'GG', value: 'GG' },
      { label: 'GN', value: 'GN' },
      { label: 'GW', value: 'GW' },
      { label: 'GY', value: 'GY' },
      { label: 'HT', value: 'HT' },
      { label: 'HM', value: 'HM' },
      { label: 'VA', value: 'VA' },
      { label: 'HN', value: 'HN' },
      { label: 'HK', value: 'HK' },
      { label: 'HU', value: 'HU' },
      { label: 'IS', value: 'IS' },
      { label: 'IN', value: 'IN' },
      { label: 'ID', value: 'ID' },
      { label: 'IR', value: 'IR' },
      { label: 'IQ', value: 'IQ' },
      { label: 'IE', value: 'IE' },
      { label: 'IM', value: 'IM' },
      { label: 'IL', value: 'IL' },
      { label: 'IT', value: 'IT' },
      { label: 'JM', value: 'JM' },
      { label: 'JP', value: 'JP' },
      { label: 'JE', value: 'JE' },
      { label: 'JO', value: 'JO' },
      { label: 'KZ', value: 'KZ' },
      { label: 'KE', value: 'KE' },
      { label: 'KI', value: 'KI' },
      { label: 'KP', value: 'KP' },
      { label: 'KR', value: 'KR' },
      { label: 'XK', value: 'XK' },
      { label: 'KW', value: 'KW' },
      { label: 'KG', value: 'KG' },
      { label: 'LA', value: 'LA' },
      { label: 'LV', value: 'LV' },
      { label: 'LB', value: 'LB' },
      { label: 'LS', value: 'LS' },
      { label: 'LR', value: 'LR' },
      { label: 'LY', value: 'LY' },
      { label: 'LI', value: 'LI' },
      { label: 'LT', value: 'LT' },
      { label: 'LU', value: 'LU' },
      { label: 'MO', value: 'MO' },
      { label: 'MK', value: 'MK' },
      { label: 'MG', value: 'MG' },
      { label: 'MW', value: 'MW' },
      { label: 'MY', value: 'MY' },
      { label: 'MV', value: 'MV' },
      { label: 'ML', value: 'ML' },
      { label: 'MT', value: 'MT' },
      { label: 'MH', value: 'MH' },
      { label: 'MQ', value: 'MQ' },
      { label: 'MR', value: 'MR' },
      { label: 'MU', value: 'MU' },
      { label: 'YT', value: 'YT' },
      { label: 'MX', value: 'MX' },
      { label: 'FM', value: 'FM' },
      { label: 'MD', value: 'MD' },
      { label: 'MC', value: 'MC' },
      { label: 'MN', value: 'MN' },
      { label: 'ME', value: 'ME' },
      { label: 'MS', value: 'MS' },
      { label: 'MA', value: 'MA' },
      { label: 'MZ', value: 'MZ' },
      { label: 'MM', value: 'MM' },
      { label: 'NA', value: 'NA' },
      { label: 'NR', value: 'NR' },
      { label: 'NP', value: 'NP' },
      { label: 'NL', value: 'NL' },
      { label: 'NC', value: 'NC' },
      { label: 'NZ', value: 'NZ' },
      { label: 'NI', value: 'NI' },
      { label: 'NE', value: 'NE' },
      { label: 'NG', value: 'NG' },
      { label: 'NU', value: 'NU' },
      { label: 'NF', value: 'NF' },
      { label: 'MP', value: 'MP' },
      { label: 'NO', value: 'NO' },
      { label: 'OM', value: 'OM' },
      { label: 'PK', value: 'PK' },
      { label: 'PW', value: 'PW' },
      { label: 'PS', value: 'PS' },
      { label: 'PA', value: 'PA' },
      { label: 'PG', value: 'PG' },
      { label: 'PY', value: 'PY' },
      { label: 'PE', value: 'PE' },
      { label: 'PH', value: 'PH' },
      { label: 'PN', value: 'PN' },
      { label: 'PL', value: 'PL' },
      { label: 'PT', value: 'PT' },
      { label: 'PR', value: 'PR' },
      { label: 'QA', value: 'QA' },
      { label: 'RE', value: 'RE' },
      { label: 'RO', value: 'RO' },
      { label: 'RU', value: 'RU' },
      { label: 'RW', value: 'RW' },
      { label: 'BL', value: 'BL' },
      { label: 'SH', value: 'SH' },
      { label: 'KN', value: 'KN' },
      { label: 'LC', value: 'LC' },
      { label: 'MF', value: 'MF' },
      { label: 'PM', value: 'PM' },
      { label: 'VC', value: 'VC' },
      { label: 'WS', value: 'WS' },
      { label: 'SM', value: 'SM' },
      { label: 'ST', value: 'ST' },
      { label: 'SA', value: 'SA' },
      { label: 'SN', value: 'SN' },
      { label: 'RS', value: 'RS' },
      { label: 'SC', value: 'SC' },
      { label: 'SL', value: 'SL' },
      { label: 'SG', value: 'SG' },
      { label: 'SX', value: 'SX' },
      { label: 'SK', value: 'SK' },
      { label: 'SI', value: 'SI' },
      { label: 'SB', value: 'SB' },
      { label: 'SO', value: 'SO' },
      { label: 'ZA', value: 'ZA' },
      { label: 'GS', value: 'GS' },
      { label: 'SS', value: 'SS' },
      { label: 'ES', value: 'ES' },
      { label: 'LK', value: 'LK' },
      { label: 'SD', value: 'SD' },
      { label: 'SR', value: 'SR' },
      { label: 'SJ', value: 'SJ' },
      { label: 'SZ', value: 'SZ' },
      { label: 'SE', value: 'SE' },
      { label: 'CH', value: 'CH' },
      { label: 'SY', value: 'SY' },
      { label: 'TW', value: 'TW' },
      { label: 'TJ', value: 'TJ' },
      { label: 'TZ', value: 'TZ' },
      { label: 'TH', value: 'TH' },
      { label: 'TL', value: 'TL' },
      { label: 'TG', value: 'TG' },
      { label: 'TK', value: 'TK' },
      { label: 'TO', value: 'TO' },
      { label: 'TT', value: 'TT' },
      { label: 'TN', value: 'TN' },
      { label: 'TR', value: 'TR' },
      { label: 'TM', value: 'TM' },
      { label: 'TC', value: 'TC' },
      { label: 'TV', value: 'TV' },
      { label: 'UG', value: 'UG' },
      { label: 'UA', value: 'UA' },
      { label: 'AE', value: 'AE' },
      { label: 'GB', value: 'GB' },
      { label: 'US', value: 'US' },
      { label: 'UM', value: 'UM' },
      { label: 'UY', value: 'UY' },
      { label: 'UZ', value: 'UZ' },
      { label: 'VU', value: 'VU' },
      { label: 'VE', value: 'VE' },
      { label: 'VN', value: 'VN' },
      { label: 'VG', value: 'VG' },
      { label: 'VI', value: 'VI' },
      { label: 'WF', value: 'WF' },
      { label: 'EH', value: 'EH' },
      { label: 'YE', value: 'YE' },
      { label: 'ZM', value: 'ZM' },
      { label: 'ZW', value: 'ZW' }
      ],
    },
  }),

  allowance__excludeRoaming: Property.StaticDropdown({
    displayName: 'Allowance - Exclude Roaming',
    description: 'When true the allowance cannot be used on roaming charge points.',
    required: false,
    options: {
      options: [
      { label: 'true', value: 'true' },
      { label: 'false', value: 'false' }
      ],
    },
  }),

  allowance__includedPartnerChargePoints: Property.Array({
    displayName: 'Allowance - Included Partner Charge Points',
    description: 'An array of Partner IDs. The allowance can only be used on charge points of Partners in this list. When empty the allowance is valid for charge points of any Partner, except the ones explicitly listed in the excludedPartnerChargePoints.',
    required: false,
  }),

  allowance__excludedPartnerChargePoints: Property.Array({
    displayName: 'Allowance - Excluded Partner Charge Points',
    description: 'An array of Partner IDs. The allowance cannot be used on charge points of Partners in this list.',
    required: false,
  }),

  allowance__combined: Property.Number({
    displayName: 'Allowance - Combined',
    description: 'The amount of kWh included - combined for AC and DC, should be provided if the type is combined.',
    required: false,
  }),

  allowance__ac: Property.Number({
    displayName: 'Allowance - Ac',
    description: 'The amount of kWh included for AC, should be provided if the type is separate.',
    required: false,
  }),

  allowance__dc: Property.Number({
    displayName: 'Allowance - Dc',
    description: 'The amount of kWh included for DC, should be provided if the type is separate.',
    required: false,
  }),

  visibilityRestrictions__includedPartnerUsers: Property.Array({
    displayName: 'Visibility Restrictions - Included Partner Users',
    description: 'An array of Partner IDs. The Subscription plan is available only to users invited (and accepted) or created by one of the Partners in this list. When empty the plan is available to all users, except the ones of Partners listed in excludedPartnerUsers.',
    required: false,
  }),

  visibilityRestrictions__excludedPartnerUsers: Property.Array({
    displayName: 'Visibility Restrictions - Excluded Partner Users',
    description: 'An array of Partner IDs. The Subscription plan is not available to users of the Partners in this list.',
    required: false,
  }),

  visibilityRestrictions__includedUserGroups: Property.Array({
    displayName: 'Visibility Restrictions - Included User Groups',
    description: 'An array of User Group IDs. The Subscription plan is available only to users with a User Group that is in this list. When empty the plan is available to all users, except the ones with a User Group listed in excludedUserGroups.',
    required: false,
  }),

  visibilityRestrictions__excludedUserGroups: Property.Array({
    displayName: 'Visibility Restrictions - Excluded User Groups',
    description: 'An array of User Group IDs. The Subscription plan is not available to users with a User Group that is in this list.',
    required: false,
  }),
  },
  async run(context): Promise<SubscriptionPlanUpdateResponse> {
    try {
      const url = processPathParameters('/public-api/resources/subscription-plans/v2.0/{subscriptionPlan}', context.propsValue);
      
      const queryParams = prepareQueryParams(context.propsValue, []);
      
      const body = prepareRequestBody(context.propsValue,
        ['name', 'description', 'renewalCycle', 'freeRenewalPeriods', 'type', 'baseFee', 'feePerEachPersonalChargePoint', 'postPaidChargingSessionsAccumulation', 'billingUsageThreshold', 'billingType', 'status', 'allowance', 'visibilityRestrictions']
      );

      
      return await makeAmpecoApiCall(
        context.auth,
        url,
        HttpMethod.PATCH,
        body,
        queryParams
      ) as SubscriptionPlanUpdateResponse;

    } catch (error) {
      handleApiError(error);
    }
  },
});
