From 3c6f8df124e515f9ce09f5380339e613b95a4d2d Mon Sep 17 00:00:00 2001 From: Igor de Paula Date: Mon, 15 Jan 2024 11:59:41 +0000 Subject: [PATCH 1/2] feat: adds idenity types --- src/types/Identity.ts | 141 ++++++++++++++++++++++++++++++++++++++++++ src/types/index.ts | 11 ++-- 2 files changed, 147 insertions(+), 5 deletions(-) create mode 100644 src/types/Identity.ts diff --git a/src/types/Identity.ts b/src/types/Identity.ts new file mode 100644 index 00000000..f0d1bcac --- /dev/null +++ b/src/types/Identity.ts @@ -0,0 +1,141 @@ +export type AcceptedCurrencies = 'AUD' | 'CAD' | 'EUR' | 'GBP' | 'USD' + +export type LegalEntityType = + | 'corporation' + | 'non_profit' + | 'other' + | 'partnership' + | 'sole_proprietorship' + +export type PersonalAccessTokenRole = 'roles/user/personal' + +export type SourceOfFunds = 'capital_invested' | 'debt' | 'other' | 'revenue' + +export type TokenRole = 'roles/api/read_write' | 'roles/api/read_only' + +export type UserRole = + | 'roles/duffel/travel_ops' + | 'roles/user/admin' + | 'roles/user/agent' + | 'roles/user/developer' + | 'roles/user/owner' + | 'roles/user/viewer' + | PersonalAccessTokenRole + +export type VerificationFlow = 'duffel_2020' | 'stripe_connect' + +export interface AccessToken { + created_at: string + expires_at: string + id: string + last_used_at: string | null + last_version_used: string | null + live_mode: boolean | null + name: string | null + scope: TokenRole | UserRole + token: string +} + +export interface Invitation { + accepted_at: string | null + created_at: string + expires_at: string | null + id: string + organisation: Organisation + organisation_id: string + recipient: User | null + recipient_email: string + recipient_id: string | null + revoked_at: string | null + scope: UserRole + sender: User + sender_id: string + sent_at: string + token: string +} + +export interface Organisation { + access_tokens: AccessToken[] | null + avatar_url: string | null + created_at: string + id: string + name: string + settlement_currency: AcceptedCurrencies + slug: string + verified: boolean | null + legal_entity: LegalEntity | null + stripe_customer_id: string | null + stripe_payment_method_id: string | null + verification_flow: VerificationFlow + contact_emails: string[] | null + schedule_change_emails: string[] | null + is_duffel_links_enabled: boolean + stays_access_status: 'disabled' | 'live' | 'test' + password_expiry_timeout_days: number | null + session_expiry_timeout: number +} + +export interface OrganisationMembership { + avatar_url: string | null + id: string + created_at: string + disabled_at: string | null + organisation_id: string + owner: boolean | null + scope: UserRole + user_id: string + user: User +} + +export interface User { + avatar_url: string | null + created_at: string + duffel_admin: boolean | null + email: string + email_confirmed_at: string | null + full_name: string + id: string + organisation_invitations: Invitation[] | null + organisation_memberships: UserOrganisationMembership[] | null + unconfirmed_email: string | null + temporary_personal_access_tokens: PersonalAccessToken[] | null + send_marketing_emails: boolean +} + +export interface PersonalAccessToken { + created_at: string + expires_at: string + id: string + last_used_at: null | string + last_version_used: null | string + live_mode: true + name: null + scope: PersonalAccessTokenRole + token: string +} + +export interface UserOrganisationMembership extends OrganisationMembership { + organisation: Organisation +} + +export interface LegalEntity { + name: string + type: LegalEntityType + type_extra: string | null + trading_name: string | null + registered_business_address_line1: string + registered_business_address_line2: string | null + registered_business_address_city: string + registered_business_address_region: string | null + registered_business_address_postal_code: string + registered_business_address_country_code: string + registration_number: string + registration_country_code: string + tax_identification_number: string + key_contact_first_name: string + key_contact_last_name: string + key_contact_job_title: string + key_contact_email: string + initial_top_up_source_of_funds: SourceOfFunds + initial_top_up_source_of_funds_description: string | null +} diff --git a/src/types/index.ts b/src/types/index.ts index 0aeb151f..335f638d 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,3 +1,6 @@ +export * from '../DuffelPayments/PaymentIntents/PaymentIntentsType' +export * from '../Places/Suggestions/SuggestionsType' +export * from '../Stays/StaysTypes' export * from '../booking/AirlineInitiatedChanges/AirlineInitiatedChangesTypes' export * from '../booking/OfferRequests/OfferRequestsTypes' export * from '../booking/Offers/OfferTypes' @@ -8,12 +11,10 @@ export * from '../booking/OrderChanges/OrderChangesTypes' export * from '../booking/Orders/OrdersTypes' export * from '../booking/Payments/PaymentsTypes' export * from '../booking/SeatMaps/SeatMapTypes' +export * from '../notifications/Webhooks/WebhooksType' export * from '../supportingResources/Aircraft/AircraftTypes' export * from '../supportingResources/Airlines/AirlinesTypes' export * from '../supportingResources/Airports/AirportsTypes' -export * from '../DuffelPayments/PaymentIntents/PaymentIntentsType' -export * from '../Places/Suggestions/SuggestionsType' -export * from './shared' export * from './ClientType' -export * from '../notifications/Webhooks/WebhooksType' -export * from '../Stays/StaysTypes' +export * from './Identity' +export * from './shared' From 8c5f48bb5b053ad9e630ad51213e9e4f8980ba2e Mon Sep 17 00:00:00 2001 From: Igor de Paula Date: Mon, 15 Jan 2024 12:01:10 +0000 Subject: [PATCH 2/2] fix: bonus exposes the different passenger types --- src/booking/OfferRequests/OfferRequestsTypes.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/booking/OfferRequests/OfferRequestsTypes.ts b/src/booking/OfferRequests/OfferRequestsTypes.ts index df073250..33c3708c 100644 --- a/src/booking/OfferRequests/OfferRequestsTypes.ts +++ b/src/booking/OfferRequests/OfferRequestsTypes.ts @@ -65,7 +65,7 @@ interface CreateOfferRequestPassengerCommon { loyalty_programme_accounts?: LoyaltyProgrammeAccount[] } -interface CreateOfferRequestAdultPassenger +export interface CreateOfferRequestAdultPassenger extends CreateOfferRequestPassengerCommon { age?: never fare_type?: never @@ -78,7 +78,7 @@ interface CreateOfferRequestAdultPassenger type: Extract } -interface CreateOfferRequestNonAdultPassenger +export interface CreateOfferRequestNonAdultPassenger extends CreateOfferRequestPassengerCommon { /** * The age of the passenger on the `departure_date` of the final slice. e.g.