From 422638795436fed193173dc72fdebf31a8d5b299 Mon Sep 17 00:00:00 2001 From: Krist Pregracke Date: Wed, 9 Jul 2025 22:57:09 -0500 Subject: [PATCH] Typing fixes, naming fixes --- src/managers/auth.ts | 4 +- src/managers/payment.ts | 4 +- src/managers/reader.ts | 6 +- src/models/errors.ts | 16 ++--- src/models/objects.ts | 127 ++++++++++++++++++++-------------------- 5 files changed, 79 insertions(+), 78 deletions(-) diff --git a/src/managers/auth.ts b/src/managers/auth.ts index 5cc9231..e2aff3a 100644 --- a/src/managers/auth.ts +++ b/src/managers/auth.ts @@ -9,8 +9,8 @@ export let authorizationObserver: EmitterSubscription; // Authorization: https://developer.squareup.com/docs/mobile-payments-sdk/ios/configure-authorize export const authorize = ( - accessToken: String, - locationId: String + accessToken: string, + locationId: string ): Promise => { return MobilePaymentsSdkReactNative.authorize(accessToken, locationId); }; diff --git a/src/managers/payment.ts b/src/managers/payment.ts index 1e9e016..0420066 100644 --- a/src/managers/payment.ts +++ b/src/managers/payment.ts @@ -1,7 +1,7 @@ import MobilePaymentsSdkReactNative from '../base_sdk'; import type { Money, - OffLinePayment, + OfflinePayment, Payment, PaymentParameters, PromptParameters, @@ -23,7 +23,7 @@ export const cancelPayment = (): Promise => { }; export namespace OfflinePaymentQueue { - export const getPayments = (): Promise => { + export const getPayments = (): Promise => { return MobilePaymentsSdkReactNative.getPayments(); }; diff --git a/src/managers/reader.ts b/src/managers/reader.ts index d8a79b3..42638f9 100644 --- a/src/managers/reader.ts +++ b/src/managers/reader.ts @@ -31,11 +31,11 @@ export const isPairingInProgress = (): Promise => { return MobilePaymentsSdkReactNative.isPairingInProgress(); }; -const addReaderChangedCallback = (refId: String): Promise => { +const addReaderChangedCallback = (refId: string): Promise => { return MobilePaymentsSdkReactNative.addReaderChangedCallback(refId); }; -const removeReaderChangedCallback = (refId: String): Promise => { +const removeReaderChangedCallback = (refId: string): Promise => { return MobilePaymentsSdkReactNative.removeReaderChangedCallback(refId); }; @@ -109,6 +109,6 @@ export namespace TapToPaySettings { }; } -const generateUUID = (): String => { +const generateUUID = (): string => { return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`; }; diff --git a/src/models/errors.ts b/src/models/errors.ts index cfca099..e4e1794 100644 --- a/src/models/errors.ts +++ b/src/models/errors.ts @@ -69,21 +69,21 @@ export enum ReaderPairingError { // Corresponds to the ErrorDetails inside the Failure object in the SDK // Android: https://square.github.io/mobile-payments-sdk-android/-mobile%20-payments%20-s-d-k%20-android%20-technical%20-reference/com.squareup.sdk.mobilepayments.core/-error-details/index.html export type ErrorDetails = { - category: String; - code: String; - detail: String; - field: String; + category: string; + code: string; + detail: string; + field: string; }; // Corresponds to the Failure object in the SDK // Android: https://square.github.io/mobile-payments-sdk-android/-mobile%20-payments%20-s-d-k%20-android%20-technical%20-reference/com.squareup.sdk.mobilepayments.core/-result/-failure/index.html // iOS: https://developer.apple.com/documentation/foundation/nserror export type Failure = { - debugMessage: String; - debugCode: String; + debugMessage: string; + debugCode: string; details: ErrorDetails[]; - errorMessage: String; - errorCode: String; + errorMessage: string; + errorCode: string; }; // Convenience function to map the error.userInfo object to a Failure object diff --git a/src/models/objects.ts b/src/models/objects.ts index 0aaa51c..e1420ca 100644 --- a/src/models/objects.ts +++ b/src/models/objects.ts @@ -10,6 +10,7 @@ import type { EntryMethod, OfflinePaymentStatus, PaymentStatus, + ProcessingMode, PromptMode, ReaderBatteryLevel, ReaderChange, @@ -24,14 +25,14 @@ import type { } from './enums'; export type Location = { - id: String; - currencyCode: String; - name: String; - mcc: String; + id: string; + currencyCode: string; + name: string; + mcc: string; }; export type Money = { - amount?: Number; + amount?: number; currencyCode: CurrencyCode; }; @@ -40,28 +41,28 @@ export type OnlinePayment = { appFeeMoney: Money; cardDetails: CardPaymentDetails; createdAt: Date; - customerId: String; - id: String; - locationId: String; - note: String; - orderId: String; - referenceId: String; + customerId: string; + id: string; + locationId: string; + note: string; + orderId: string; + referenceId: string; status: PaymentStatus; tipMoney: Money; totalMoney: Money; updatedAt: Date; }; -export type OffLinePayment = { +export type OfflinePayment = { amountMoney: Money; appFeeMoney: Money; cardDetails: OfflineCardPaymentDetails; createdAt: Date; - id: String; - localId: String; - locationId: String; - orderId: String; - referenceId: String; + id: string; + localId: string; + locationId: string; + orderId: string; + referenceId: string; status: OfflinePaymentStatus; sourceType: SourceType; tipMoney: Money; @@ -73,58 +74,58 @@ export type OffLinePayment = { export type PaymentParameters = { // Required amountMoney: Money; - processingMode: Number; + processingMode: ProcessingMode; // Optional. For defaults, check: // Android: https://square.github.io/mobile-payments-sdk-android/-mobile%20-payments%20-s-d-k%20-android%20-technical%20-reference/com.squareup.sdk.mobilepayments.payment/-payment-parameters/index.html // iOS: https://square.github.io/mobile-payments-sdk-ios/docs/documentation/mobilepaymentssdkapi/paymentparameters/ - acceptPartialAuthorization?: Boolean; + acceptPartialAuthorization?: boolean; appFeeMoney?: Money; - autocomplete?: Boolean; - customerId?: String; + autocomplete?: boolean; + customerId?: string; delayAction?: DelayAction; - delayDuration?: Number; - locationId?: String; - note?: String; - orderId?: String; - referenceId?: String; - statementDescriptionIdentifer?: String; - teamMemberId?: String; + delayDuration?: number; + locationId?: string; + note?: string; + orderId?: string; + referenceId?: string; + statementDescriptionIdentifer?: string; + teamMemberId?: string; tipMoney?: Money; totalMoney?: Money; - idempotencyKey?: String; - paymentAttemptId?: String; + idempotencyKey?: string; + paymentAttemptId?: string; }; export type Card = { brand: CardBrand; - cardholderName: String; + cardholderName: string; coBrand: CardCoBrand; - expirationMonth?: Number; - expirationYear?: Number; - id: String; - lastFourDigits: String; + expirationMonth?: number; + expirationYear?: number; + id: string; + lastFourDigits: string; }; export type CardPaymentDetails = { - applicationIdentifier: String; - applicationName: String; - authorizationCode: String; + applicationIdentifier: string; + applicationName: string; + authorizationCode: string; card: Card; entryMethod: EntryMethod; status: CardPaymentStatus; }; export type OfflineCardPaymentDetails = { - applicationIdentifier: String; - applicationName: String; + applicationIdentifier: string; + applicationName: string; card: Card; entryMethod: EntryMethod; }; export type CardInputMethods = { - chip: Boolean; - contactless: Boolean; - swipe: Boolean; + chip: boolean; + contactless: boolean; + swipe: boolean; }; export type PromptParameters = { @@ -136,10 +137,10 @@ export type Payment = { amountMoney: Money; appFeeMoney: Money; createdAt: Date; - id: String; - locationId: String; - orderId: String; - referenceId: String; + id: string; + locationId: string; + orderId: string; + referenceId: string; sourceType: SourceType; tipMoney: Money; totalMoney: Money; @@ -147,15 +148,15 @@ export type Payment = { }; export type ReaderBatteryStatus = { - isCharging: Boolean; + isCharging: boolean; level?: ReaderBatteryLevel; - percent: Number; + percent: number; }; export type ReaderConnectionFailureInfo = { failureReason: ReaderConnectionFailureReason; - localizedDescription: String; - localizedTitle: String; + localizedDescription: string; + localizedTitle: string; recoverySuggestion: ReaderConnectionFailureRecoverySuggestion; }; @@ -165,9 +166,9 @@ export type ReaderConnectionInfo = { }; export type ReaderFirmwareInfo = { - failureReason?: String; - updatePercentage: Number; - version: String; + failureReason?: string; + updatePercentage: number; + version: string; }; export type ReaderStatus = { @@ -176,28 +177,28 @@ export type ReaderStatus = { }; export type ReaderInfo = { - id: String; + id: string; model: ReaderModel; state: ReaderState; status: ReaderStatus; - serialNumber?: String; - name: String; + serialNumber?: string; + name: string; batteryStatus?: ReaderBatteryStatus; - firmwareVersion?: String; - firmwarePercent?: Number; + firmwareVersion?: string; + firmwarePercent?: number; supportedCardEntryMethods: CardEntryMethod[]; - isForgettable: Boolean; - isBlinkable: Boolean; + isForgettable: boolean; + isBlinkable: boolean; cardInsertionStatus?: CardInsertionStatus; connectionInfo?: ReaderConnectionInfo; firmwareInfo?: ReaderFirmwareInfo; - isConnectionRetryable?: Boolean; + isConnectionRetryable?: boolean; }; export type ReaderChangedEvent = { change: ReaderChange; reader: ReaderInfo; readerState: ReaderState; - readerSerialNumber?: String; + readerSerialNumber?: string; };