-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(models): convert models to be only types
This fixes an import bug but also simplifies the design alot. 1. Before this change the object literal created within an api client by JSON.parse(), was only type casted to a class instance. This meant that optional fields were actually undefined, as they're missing in the object literal. But typescript reported them to be null, as any class instance would initialize them null. Because the constructor was never called, this never happened. 2. The advantage of the new approach comes from the fact, that typescript will not emit an import, when a type is imported using 'type import ...'. The latter can be enforced by using setting verbatimModuleSyntax within the tsconfig file. Because no import is emitted, no code is loaded. This significantly improves load times, as the engine does not has to read and parse all the 100'ish files.
- Loading branch information
1 parent
42596f8
commit ec7fecf
Showing
139 changed files
with
1,798 additions
and
6,451 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,50 @@ | ||
/** | ||
* Commerce Platform API | ||
* RESTful API for the creation of Commerce Cases with Checkouts and the execution of Payments. | ||
* | ||
* OpenAPI spec version: 1.8.0 | ||
* | ||
* | ||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
* https://openapi-generator.tech | ||
* Do not edit the class manually. | ||
*/ | ||
|
||
/** | ||
* Contains detailed information on one single error. | ||
*/ | ||
export class APIError { | ||
/** @description Contains detailed information on one single error. */ | ||
export interface APIError { | ||
/** | ||
* Error code | ||
* @description Error code | ||
* @example 50001130 | ||
*/ | ||
'errorCode': string; | ||
errorCode: string; | ||
/** | ||
* Category the error belongs to. The category should give an indication of the type of error you are dealing with. Possible values: * DIRECT_PLATFORM_ERROR - indicating that a functional error has occurred in the platform. * PAYMENT_PLATFORM_ERROR - indicating that a functional error has occurred in the payment platform. * IO_ERROR - indicating that a technical error has occurred within the payment platform or between the payment platform and third party systems. * COMMERCE_PLATFORM_ERROR - indicating an error originating from the Commerce Platform. * COMMERCE_PORTAL_BACKEND_ERROR - indicating an error originating from the Commerce Portal Backend. | ||
* @description Category the error belongs to. The category should give an indication of the type of error you are dealing | ||
* with. Possible values: | ||
* * DIRECT_PLATFORM_ERROR - indicating that a functional error has occurred in the platform. | ||
* * PAYMENT_PLATFORM_ERROR - indicating that a functional error has occurred in the payment platform. | ||
* * IO_ERROR - indicating that a technical error has occurred within the payment platform or between the | ||
* payment platform and third party systems. | ||
* * COMMERCE_PLATFORM_ERROR - indicating an error originating from the Commerce Platform. | ||
* * COMMERCE_PORTAL_BACKEND_ERROR - indicating an error originating from the Commerce Portal Backend. | ||
* @example PAYMENT_PLATFORM_ERROR | ||
*/ | ||
'category'?: string; | ||
category?: string; | ||
/** | ||
* HTTP status code for this error that can be used to determine the type of error | ||
* Format: int32 | ||
* @description HTTP status code for this error that can be used to determine the type of error | ||
* @example 404 | ||
*/ | ||
'httpStatusCode'?: number; | ||
httpStatusCode?: number; | ||
/** | ||
* ID of the error. This is a short human-readable message that briefly describes the error. | ||
* @description ID of the error. This is a short human-readable message that briefly describes the error. | ||
* @example general-error-technical-fault-internal | ||
*/ | ||
'id'?: string; | ||
id?: string; | ||
/** | ||
* Human-readable error message that is not meant to be relayed to customer as it might tip off people who are trying to commit fraud | ||
* @description Human-readable error message that is not meant to be relayed to customer as it might tip off people who are | ||
* trying to commit fraud | ||
* @example Authorisation declined | ||
*/ | ||
'message'?: string; | ||
message?: string; | ||
/** | ||
* Returned only if the error relates to a value that was missing or incorrect. Contains a location path to the value as a JSonata query. Some common examples: * a.b selects the value of property b of root property a, * a[1] selects the first element of the array in root property a, * a[b=\'some value\'] selects all elements of the array in root property a that have a property b with value \'some value\'. | ||
* @description Returned only if the error relates to a value that was missing or incorrect. | ||
* | ||
* Contains a location path to the value as a JSonata query. | ||
* | ||
* Some common examples: | ||
* * a.b selects the value of property b of root property a, | ||
* * a[1] selects the first element of the array in root property a, | ||
* * a[b='some value'] selects all elements of the array in root property a that have a property b with value | ||
* 'some value'. | ||
* @example paymentId | ||
*/ | ||
'propertyName'?: string; | ||
|
||
static readonly discriminator: string | undefined = undefined; | ||
|
||
static readonly attributeTypeMap: Array<{ name: string; baseName: string; type: string; format: string }> = [ | ||
{ | ||
name: 'errorCode', | ||
baseName: 'errorCode', | ||
type: 'string', | ||
format: '', | ||
}, | ||
{ | ||
name: 'category', | ||
baseName: 'category', | ||
type: 'string', | ||
format: '', | ||
}, | ||
{ | ||
name: 'httpStatusCode', | ||
baseName: 'httpStatusCode', | ||
type: 'number', | ||
format: 'int32', | ||
}, | ||
{ | ||
name: 'id', | ||
baseName: 'id', | ||
type: 'string', | ||
format: '', | ||
}, | ||
{ | ||
name: 'message', | ||
baseName: 'message', | ||
type: 'string', | ||
format: '', | ||
}, | ||
{ | ||
name: 'propertyName', | ||
baseName: 'propertyName', | ||
type: 'string', | ||
format: '', | ||
}, | ||
]; | ||
|
||
static getAttributeTypeMap() { | ||
return APIError.attributeTypeMap; | ||
} | ||
|
||
public constructor() {} | ||
propertyName?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,39 @@ | ||
/** | ||
* Commerce Platform API | ||
* RESTful API for the creation of Commerce Cases with Checkouts and the execution of Payments. | ||
* | ||
* OpenAPI spec version: 1.8.0 | ||
* | ||
* | ||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
* https://openapi-generator.tech | ||
* Do not edit the class manually. | ||
*/ | ||
|
||
/** | ||
* Object containing billing address details | ||
*/ | ||
export class Address { | ||
/** @description Object containing billing address details */ | ||
export interface Address { | ||
/** | ||
* Second line of street or additional address information such as apartments and suits | ||
* @description Second line of street or additional address information such as apartments and suits | ||
* @example Apartment 203 | ||
*/ | ||
additionalInfo: string | null; | ||
additionalInfo?: string; | ||
/** | ||
* City | ||
* @description City | ||
* @example Kiel | ||
*/ | ||
city: string | null; | ||
city?: string; | ||
/** | ||
* ISO 3166-1 alpha-2 country code | ||
* @description ISO 3166-1 alpha-2 country code | ||
* @example DE | ||
*/ | ||
countryCode: string | null; | ||
countryCode?: string; | ||
/** | ||
* House number | ||
* @description House number | ||
* @example 3 | ||
*/ | ||
houseNumber: string | null; | ||
houseNumber?: string; | ||
/** | ||
* State (ISO 3166-2 subdivisions), only if country=US, CA, CN, JP, MX, BR, AR, ID, TH, IN. | ||
* @description State (ISO 3166-2 subdivisions), only if country=US, CA, CN, JP, MX, BR, AR, ID, TH, IN. | ||
* @example BR | ||
*/ | ||
state: string | null; | ||
state?: string; | ||
/** | ||
* Street name | ||
* @description Street name | ||
* @example Coral Avenue | ||
*/ | ||
street: string | null; | ||
street?: string; | ||
/** | ||
* Zip code | ||
* @description Zip code | ||
* @example 12345 | ||
*/ | ||
zip: string | null; | ||
|
||
public constructor() { | ||
this.additionalInfo = null; | ||
this.city = null; | ||
this.countryCode = null; | ||
this.houseNumber = null; | ||
this.state = null; | ||
this.street = null; | ||
this.zip = null; | ||
} | ||
zip?: string; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,41 @@ | ||
/** | ||
* Commerce Platform API | ||
* RESTful API for the creation of Commerce Cases with Checkouts and the execution of Payments. | ||
* | ||
* OpenAPI spec version: 1.8.0 | ||
* | ||
* | ||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
* https://openapi-generator.tech | ||
* Do not edit the class manually. | ||
*/ | ||
import type { PersonalName } from './PersonalName.js'; | ||
|
||
import { PersonalName } from './PersonalName.js'; | ||
|
||
/** | ||
* Object containing personal or shipping address information. | ||
*/ | ||
export class AddressPersonal { | ||
/** @description Object containing personal or shipping address information. */ | ||
export interface AddressPersonal { | ||
/** | ||
* Second line of street or additional address information such as apartments and suits | ||
* @description Second line of street or additional address information such as apartments and suits | ||
* @example Apartment 203 | ||
*/ | ||
additionalInfo: string | null; | ||
additionalInfo?: string; | ||
/** | ||
* City | ||
* @description City | ||
* @example Kiel | ||
*/ | ||
city: string | null; | ||
city?: string; | ||
/** | ||
* ISO 3166-1 alpha-2 country code | ||
* @description ISO 3166-1 alpha-2 country code | ||
* @example DE | ||
*/ | ||
countryCode: string | null; | ||
countryCode?: string; | ||
/** | ||
* House number | ||
* @description House number | ||
* @example 3 | ||
*/ | ||
houseNumber: string | null; | ||
houseNumber?: string; | ||
/** | ||
* State (ISO 3166-2 subdivisions), only if country=US, CA, CN, JP, MX, BR, AR, ID, TH, IN. | ||
* @description State (ISO 3166-2 subdivisions), only if country=US, CA, CN, JP, MX, BR, AR, ID, TH, IN. | ||
* @example MX | ||
*/ | ||
state: string | null; | ||
state?: string; | ||
/** | ||
* Street name | ||
* @description Street name | ||
* @example Coral Avenue | ||
*/ | ||
street: string | null; | ||
street?: string; | ||
/** | ||
* Zip code | ||
* @description Zip code | ||
* @example 1234 | ||
*/ | ||
zip: string | null; | ||
name: PersonalName | null; | ||
|
||
public constructor() { | ||
this.additionalInfo = null; | ||
this.city = null; | ||
this.countryCode = null; | ||
this.houseNumber = null; | ||
this.state = null; | ||
this.street = null; | ||
this.zip = null; | ||
this.name = null; | ||
} | ||
zip?: string; | ||
name?: PersonalName; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,15 @@ | ||
/** | ||
* Commerce Platform API | ||
* RESTful API for the creation of Commerce Cases with Checkouts and the execution of Payments. | ||
* | ||
* OpenAPI spec version: 1.8.0 | ||
* | ||
* | ||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
* https://openapi-generator.tech | ||
* Do not edit the class manually. | ||
*/ | ||
|
||
/** | ||
* Object containing amount and ISO currency code attributes | ||
*/ | ||
export class AmountOfMoney { | ||
/** @description Object containing amount and ISO currency code attributes */ | ||
export interface AmountOfMoney { | ||
/** | ||
* Amount in cents and always having 2 decimals | ||
* Format: int64 | ||
* @description Amount in cents and always having 2 decimals | ||
* @example 1000 | ||
*/ | ||
'amount': number; | ||
amount: number; | ||
/** | ||
* Three-letter ISO currency code representing the currency for the amount | ||
* @description Three-letter ISO currency code representing the currency for the amount | ||
* @example EUR | ||
*/ | ||
'currencyCode': string; | ||
|
||
static readonly discriminator: string | undefined = undefined; | ||
|
||
static readonly attributeTypeMap: Array<{ name: string; baseName: string; type: string; format: string }> = [ | ||
{ | ||
name: 'amount', | ||
baseName: 'amount', | ||
type: 'number', | ||
format: 'int64', | ||
}, | ||
{ | ||
name: 'currencyCode', | ||
baseName: 'currencyCode', | ||
type: 'string', | ||
format: '', | ||
}, | ||
]; | ||
|
||
static getAttributeTypeMap() { | ||
return AmountOfMoney.attributeTypeMap; | ||
} | ||
|
||
public constructor() {} | ||
currencyCode: string; | ||
} | ||
|
Oops, something went wrong.