Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checkout session #688

Open
wants to merge 2 commits into
base: develop_debrecated
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion maas-schemas-ts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "maas-schemas-ts",
"version": "15.16.0",
"version": "15.17.0",
"description": "TypeScript types and io-ts validators for maas-schemas",
"main": "index.js",
"files": [
Expand Down
108 changes: 108 additions & 0 deletions maas-schemas-ts/src/_types/core/components/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1408,6 +1408,114 @@ export interface VerificationStateABANDONEDBrand {
/** require('io-ts-validator').validator(VerificationStateABANDONED).decodeSync(defaultVerificationStateABANDONED) // => defaultVerificationStateABANDONED */
export const defaultVerificationStateABANDONED: VerificationStateABANDONED = ('ABANDONED' as unknown) as VerificationStateABANDONED;

// CheckoutSessionState
// The life-cycle state of a verification
export type CheckoutSessionState = t.Branded<
string & ('PENDING' | 'FINISHED' | 'REFUNDED'),
CheckoutSessionStateBrand
>;
export type CheckoutSessionStateC = t.BrandC<
t.IntersectionC<
[
t.StringC,
t.UnionC<[t.LiteralC<'PENDING'>, t.LiteralC<'FINISHED'>, t.LiteralC<'REFUNDED'>]>,
]
>,
CheckoutSessionStateBrand
>;
export const CheckoutSessionState: CheckoutSessionStateC = t.brand(
t.intersection([
t.string,
t.union([t.literal('PENDING'), t.literal('FINISHED'), t.literal('REFUNDED')]),
]),
(
x,
): x is t.Branded<
string & ('PENDING' | 'FINISHED' | 'REFUNDED'),
CheckoutSessionStateBrand
> => true,
'CheckoutSessionState',
);
export interface CheckoutSessionStateBrand {
readonly CheckoutSessionState: unique symbol;
}

// CheckoutSessionStatePENDING
// The purpose of this remains a mystery
export type CheckoutSessionStatePENDING = t.Branded<
CheckoutSessionState & 'PENDING',
CheckoutSessionStatePENDINGBrand
>;
export type CheckoutSessionStatePENDINGC = t.BrandC<
t.IntersectionC<[typeof CheckoutSessionState, t.LiteralC<'PENDING'>]>,
CheckoutSessionStatePENDINGBrand
>;
export const CheckoutSessionStatePENDING: CheckoutSessionStatePENDINGC = t.brand(
t.intersection([CheckoutSessionState, t.literal('PENDING')]),
(
x,
): x is t.Branded<CheckoutSessionState & 'PENDING', CheckoutSessionStatePENDINGBrand> =>
true,
'CheckoutSessionStatePENDING',
);
export interface CheckoutSessionStatePENDINGBrand {
readonly CheckoutSessionStatePENDING: unique symbol;
}
/** require('io-ts-validator').validator(CheckoutSessionStatePENDING).decodeSync(defaultCheckoutSessionStatePENDING) // => defaultCheckoutSessionStatePENDING */
export const defaultCheckoutSessionStatePENDING: CheckoutSessionStatePENDING = ('PENDING' as unknown) as CheckoutSessionStatePENDING;

// CheckoutSessionStateFINISHED
// The purpose of this remains a mystery
export type CheckoutSessionStateFINISHED = t.Branded<
CheckoutSessionState & 'FINISHED',
CheckoutSessionStateFINISHEDBrand
>;
export type CheckoutSessionStateFINISHEDC = t.BrandC<
t.IntersectionC<[typeof CheckoutSessionState, t.LiteralC<'FINISHED'>]>,
CheckoutSessionStateFINISHEDBrand
>;
export const CheckoutSessionStateFINISHED: CheckoutSessionStateFINISHEDC = t.brand(
t.intersection([CheckoutSessionState, t.literal('FINISHED')]),
(
x,
): x is t.Branded<
CheckoutSessionState & 'FINISHED',
CheckoutSessionStateFINISHEDBrand
> => true,
'CheckoutSessionStateFINISHED',
);
export interface CheckoutSessionStateFINISHEDBrand {
readonly CheckoutSessionStateFINISHED: unique symbol;
}
/** require('io-ts-validator').validator(CheckoutSessionStateFINISHED).decodeSync(defaultCheckoutSessionStateFINISHED) // => defaultCheckoutSessionStateFINISHED */
export const defaultCheckoutSessionStateFINISHED: CheckoutSessionStateFINISHED = ('FINISHED' as unknown) as CheckoutSessionStateFINISHED;

// CheckoutSessionStateREFUNDED
// The purpose of this remains a mystery
export type CheckoutSessionStateREFUNDED = t.Branded<
CheckoutSessionState & 'REFUNDED',
CheckoutSessionStateREFUNDEDBrand
>;
export type CheckoutSessionStateREFUNDEDC = t.BrandC<
t.IntersectionC<[typeof CheckoutSessionState, t.LiteralC<'REFUNDED'>]>,
CheckoutSessionStateREFUNDEDBrand
>;
export const CheckoutSessionStateREFUNDED: CheckoutSessionStateREFUNDEDC = t.brand(
t.intersection([CheckoutSessionState, t.literal('REFUNDED')]),
(
x,
): x is t.Branded<
CheckoutSessionState & 'REFUNDED',
CheckoutSessionStateREFUNDEDBrand
> => true,
'CheckoutSessionStateREFUNDED',
);
export interface CheckoutSessionStateREFUNDEDBrand {
readonly CheckoutSessionStateREFUNDED: unique symbol;
}
/** require('io-ts-validator').validator(CheckoutSessionStateREFUNDED).decodeSync(defaultCheckoutSessionStateREFUNDED) // => defaultCheckoutSessionStateREFUNDED */
export const defaultCheckoutSessionStateREFUNDED: CheckoutSessionStateREFUNDED = ('REFUNDED' as unknown) as CheckoutSessionStateREFUNDED;

// State
// The default export. More information at the top.
export type State = t.Branded<unknown, StateBrand>;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
/*

undefined
MaaS customer benefits initiate

!!! AUTO GENERATED BY IOTSFJS REFRAIN FROM MANUAL EDITING !!!
See https://www.npmjs.com/package/io-ts-from-json-schema

*/

import * as t from 'io-ts';
import * as Units_ from '../../../core/components/units';
import * as State_ from '../../../core/components/state';
import * as BenefitProvider_ from '../../../core/components/benefit-provider';

export type Defined = {} | null;
export class DefinedType extends t.Type<Defined> {
readonly _tag: 'DefinedType' = 'DefinedType';
constructor() {
super(
'defined',
(u): u is Defined => typeof u !== 'undefined',
(u, c) => (this.is(u) ? t.success(u) : t.failure(u, c)),
t.identity,
);
}
}
export interface DefinedC extends DefinedType {}
export const Defined: DefinedC = new DefinedType();

export const schemaId =
'https://schemas.maas.global/maas-backend/checkouts/session-retrieve/request.json';

// Response
// The default export. More information at the top.
export type Response = t.Branded<
{
id?: Units_.Url;
state?: State_.CheckoutSessionState;
identityId?: Units_.IdentityId;
checkoutProviderId?: BenefitProvider_.BenefitsProviderId;
amount?: number;
currency?: Units_.Currency;
productType?: string & ('product' | 'subscription' | 'package');
productId?: string;
} & {
id: Defined;
state: Defined;
identityId: Defined;
checkoutProviderId: Defined;
amount: Defined;
currency: Defined;
productType: Defined;
productId: Defined;
},
ResponseBrand
>;
export type ResponseC = t.BrandC<
t.IntersectionC<
[
t.PartialC<{
id: typeof Units_.Url;
state: typeof State_.CheckoutSessionState;
identityId: typeof Units_.IdentityId;
checkoutProviderId: typeof BenefitProvider_.BenefitsProviderId;
amount: t.NumberC;
currency: typeof Units_.Currency;
productType: t.IntersectionC<
[
t.StringC,
t.UnionC<
[t.LiteralC<'product'>, t.LiteralC<'subscription'>, t.LiteralC<'package'>]
>,
]
>;
productId: t.StringC;
}>,
t.TypeC<{
id: typeof Defined;
state: typeof Defined;
identityId: typeof Defined;
checkoutProviderId: typeof Defined;
amount: typeof Defined;
currency: typeof Defined;
productType: typeof Defined;
productId: typeof Defined;
}>,
]
>,
ResponseBrand
>;
export const Response: ResponseC = t.brand(
t.intersection([
t.partial({
id: Units_.Url,
state: State_.CheckoutSessionState,
identityId: Units_.IdentityId,
checkoutProviderId: BenefitProvider_.BenefitsProviderId,
amount: t.number,
currency: Units_.Currency,
productType: t.intersection([
t.string,
t.union([t.literal('product'), t.literal('subscription'), t.literal('package')]),
]),
productId: t.string,
}),
t.type({
id: Defined,
state: Defined,
identityId: Defined,
checkoutProviderId: Defined,
amount: Defined,
currency: Defined,
productType: Defined,
productId: Defined,
}),
]),
(
x,
): x is t.Branded<
{
id?: Units_.Url;
state?: State_.CheckoutSessionState;
identityId?: Units_.IdentityId;
checkoutProviderId?: BenefitProvider_.BenefitsProviderId;
amount?: number;
currency?: Units_.Currency;
productType?: string & ('product' | 'subscription' | 'package');
productId?: string;
} & {
id: Defined;
state: Defined;
identityId: Defined;
checkoutProviderId: Defined;
amount: Defined;
currency: Defined;
productType: Defined;
productId: Defined;
},
ResponseBrand
> => true,
'Response',
);
export interface ResponseBrand {
readonly Response: unique symbol;
}

export default Response;

// Success
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const schemaId =
export type Response = t.Branded<
{
checkoutUrl?: Units_.Url;
checkoutSessionId?: Units_.Uuid;
} & {
checkoutUrl: Defined;
},
Expand All @@ -44,6 +45,7 @@ export type ResponseC = t.BrandC<
[
t.PartialC<{
checkoutUrl: typeof Units_.Url;
checkoutSessionId: typeof Units_.Uuid;
}>,
t.TypeC<{
checkoutUrl: typeof Defined;
Expand All @@ -56,6 +58,7 @@ export const Response: ResponseC = t.brand(
t.intersection([
t.partial({
checkoutUrl: Units_.Url,
checkoutSessionId: Units_.Uuid,
}),
t.type({
checkoutUrl: Defined,
Expand All @@ -66,6 +69,7 @@ export const Response: ResponseC = t.brand(
): x is t.Branded<
{
checkoutUrl?: Units_.Url;
checkoutSessionId?: Units_.Uuid;
} & {
checkoutUrl: Defined;
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Generated by update-index.ts Do not edit!

export * from '../../../_types/maas-backend/checkouts/session-retrieve/request';
18 changes: 18 additions & 0 deletions maas-schemas-ts/translation.log
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,12 @@ INFO: missing description
in ../maas-schemas/schemas/core/components/state.json
INFO: missing description
in ../maas-schemas/schemas/core/components/state.json
INFO: missing description
in ../maas-schemas/schemas/core/components/state.json
INFO: missing description
in ../maas-schemas/schemas/core/components/state.json
INFO: missing description
in ../maas-schemas/schemas/core/components/state.json
INFO: primitive type "string" used outside top-level definitions
in ../maas-schemas/schemas/core/components/station.json
INFO: primitive type "string" used outside top-level definitions
Expand Down Expand Up @@ -1552,6 +1558,18 @@ WARNING: missing $schema declaration
in ../maas-schemas/schemas/maas-backend/bookings/v2/bookings-create/request.json
WARNING: missing $schema declaration
in ../maas-schemas/schemas/maas-backend/bookings/v2/bookings-create/response.json
WARNING: missing $schema declaration
in ../maas-schemas/schemas/maas-backend/checkouts/session-retrieve/request.json
WARNING: missing $schema declaration
in ../maas-schemas/schemas/maas-backend/checkouts/session-retrieve/response.json
INFO: primitive type "number" used outside top-level definitions
in ../maas-schemas/schemas/maas-backend/checkouts/session-retrieve/response.json
WARNING: minimum field not supported outside top-level definitions
in ../maas-schemas/schemas/maas-backend/checkouts/session-retrieve/response.json
INFO: primitive type "string" used outside top-level definitions
in ../maas-schemas/schemas/maas-backend/checkouts/session-retrieve/response.json
INFO: primitive type "string" used outside top-level definitions
in ../maas-schemas/schemas/maas-backend/checkouts/session-retrieve/response.json
WARNING: naming clash, ignoring default export
in ../maas-schemas/schemas/maas-backend/coupons/code.json
WARNING: missing $schema declaration
Expand Down
2 changes: 1 addition & 1 deletion maas-schemas/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "maas-schemas",
"version": "15.16.0",
"version": "15.17.0",
"description": "Schemas for MaaS infrastructure",
"main": "index.js",
"engine": {
Expand Down
17 changes: 17 additions & 0 deletions maas-schemas/schemas/core/components/state.json
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,23 @@
"verificationStateABANDONED": {
"default": "ABANDONED",
"allOf": [{ "$ref": "#/definitions/verificationState" }, { "const": "ABANDONED" }]
},
"checkoutSessionState": {
"description": "The life-cycle state of a verification",
"type": "string",
"enum": ["PENDING", "FINISHED", "REFUNDED"]
},
"checkoutSessionStatePENDING": {
"default": "PENDING",
"allOf": [{ "$ref": "#/definitions/checkoutSessionState" }, { "const": "PENDING" }]
},
"checkoutSessionStateFINISHED": {
"default": "FINISHED",
"allOf": [{ "$ref": "#/definitions/checkoutSessionState" }, { "const": "FINISHED" }]
},
"checkoutSessionStateREFUNDED": {
"default": "REFUNDED",
"allOf": [{ "$ref": "#/definitions/checkoutSessionState" }, { "const": "REFUNDED" }]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"$id": "https://schemas.maas.global/maas-backend/checkouts/session-retrieve/request.json",
"additionalProperties": false,
"description": "MaaS customer benefits initiate",
"type": "object",
"properties": {
"identityId": {
"$ref": "https://schemas.maas.global/core/components/units.json#/definitions/identityId"
},
"headers": {
"$ref": "https://schemas.maas.global/core/components/api-common.json#/definitions/headers"
},
"payload": {
"type": "object",
"properties": {
"checkoutSessionId": {
"$ref": "https://schemas.maas.global/core/components/units.json#/definitions/uuid"
}
},
"additionalProperties": false,
"required": ["checkoutSessionId"]
}
},
"required": ["identityId", "payload", "headers"]
}
Loading