-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(SubscriptionNotification): create separate class for subscri…
…ption created
- Loading branch information
1 parent
0fb1cbf
commit d5f3ad7
Showing
15 changed files
with
134 additions
and
16 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
76 changes: 76 additions & 0 deletions
76
src/notifications/entities/subscription/subscription-created-notification.ts
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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/** | ||
* ! Autogenerated code ! | ||
* Do not make changes to this file. | ||
* Changes may be overwritten as part of auto-generation. | ||
*/ | ||
|
||
import { | ||
BillingDetailsNotification, | ||
ImportMetaNotification, | ||
SubscriptionDiscountNotification, | ||
SubscriptionItemNotification, | ||
SubscriptionScheduledChangeNotification, | ||
SubscriptionTimePeriodNotification, | ||
TimePeriodNotification, | ||
} from '../index'; | ||
import { type CollectionMode, type CurrencyCode, type SubscriptionStatus } from '../../../enums'; | ||
import { type ISubscriptionCreatedNotificationResponse } from '../../types'; | ||
import { type CustomData } from '../../../entities'; | ||
|
||
export class SubscriptionCreatedNotification { | ||
public readonly id: string; | ||
public readonly status: SubscriptionStatus; | ||
public readonly transactionId: string; | ||
public readonly customerId: string; | ||
public readonly addressId: string; | ||
public readonly businessId: string | null; | ||
public readonly currencyCode: CurrencyCode; | ||
public readonly createdAt: string; | ||
public readonly updatedAt: string; | ||
public readonly startedAt: string | null; | ||
public readonly firstBilledAt: string | null; | ||
public readonly nextBilledAt: string | null; | ||
public readonly pausedAt: string | null; | ||
public readonly canceledAt: string | null; | ||
public readonly discount: SubscriptionDiscountNotification | null; | ||
public readonly collectionMode: CollectionMode; | ||
public readonly billingDetails: BillingDetailsNotification | null; | ||
public readonly currentBillingPeriod: SubscriptionTimePeriodNotification | null; | ||
public readonly billingCycle: TimePeriodNotification; | ||
public readonly scheduledChange: SubscriptionScheduledChangeNotification | null; | ||
public readonly items: SubscriptionItemNotification[]; | ||
public readonly customData: CustomData | null; | ||
public readonly importMeta: ImportMetaNotification | null; | ||
|
||
constructor(subscription: ISubscriptionCreatedNotificationResponse) { | ||
this.id = subscription.id; | ||
this.status = subscription.status; | ||
this.transactionId = subscription.transaction_id; | ||
this.customerId = subscription.customer_id; | ||
this.addressId = subscription.address_id; | ||
this.businessId = subscription.business_id ? subscription.business_id : null; | ||
this.currencyCode = subscription.currency_code; | ||
this.createdAt = subscription.created_at; | ||
this.updatedAt = subscription.updated_at; | ||
this.startedAt = subscription.started_at ? subscription.started_at : null; | ||
this.firstBilledAt = subscription.first_billed_at ? subscription.first_billed_at : null; | ||
this.nextBilledAt = subscription.next_billed_at ? subscription.next_billed_at : null; | ||
this.pausedAt = subscription.paused_at ? subscription.paused_at : null; | ||
this.canceledAt = subscription.canceled_at ? subscription.canceled_at : null; | ||
this.discount = subscription.discount ? new SubscriptionDiscountNotification(subscription.discount) : null; | ||
this.collectionMode = subscription.collection_mode; | ||
this.billingDetails = subscription.billing_details | ||
? new BillingDetailsNotification(subscription.billing_details) | ||
: null; | ||
this.currentBillingPeriod = subscription.current_billing_period | ||
? new SubscriptionTimePeriodNotification(subscription.current_billing_period) | ||
: null; | ||
this.billingCycle = new TimePeriodNotification(subscription.billing_cycle); | ||
this.scheduledChange = subscription.scheduled_change | ||
? new SubscriptionScheduledChangeNotification(subscription.scheduled_change) | ||
: null; | ||
this.items = subscription.items.map((item) => new SubscriptionItemNotification(item)); | ||
this.customData = subscription.custom_data ? subscription.custom_data : null; | ||
this.importMeta = subscription.import_meta ? new ImportMetaNotification(subscription.import_meta) : null; | ||
} | ||
} |
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
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
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
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
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
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
43 changes: 43 additions & 0 deletions
43
src/notifications/types/subscription/subscription-created-notification-response.ts
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* ! Autogenerated code ! | ||
* Do not make changes to this file. | ||
* Changes may be overwritten as part of auto-generation. | ||
*/ | ||
|
||
import { | ||
type IBillingDetailsNotificationResponse, | ||
type IImportMetaNotificationResponse, | ||
type ISubscriptionDiscountNotificationResponse, | ||
type ISubscriptionItemNotificationResponse, | ||
type ISubscriptionScheduledChangeNotificationResponse, | ||
type ISubscriptionTimePeriodNotificationResponse, | ||
type ITimePeriodNotification, | ||
} from '../index'; | ||
import { type CollectionMode, type CurrencyCode, type SubscriptionStatus } from '../../../enums'; | ||
import { type ICustomData } from '../../../types'; | ||
|
||
export interface ISubscriptionCreatedNotificationResponse { | ||
id: string; | ||
status: SubscriptionStatus; | ||
transaction_id: string; | ||
customer_id: string; | ||
address_id: string; | ||
business_id?: string | null; | ||
currency_code: CurrencyCode; | ||
created_at: string; | ||
updated_at: string; | ||
started_at?: string | null; | ||
first_billed_at?: string | null; | ||
next_billed_at?: string | null; | ||
paused_at?: string | null; | ||
canceled_at?: string | null; | ||
discount?: ISubscriptionDiscountNotificationResponse | null; | ||
collection_mode: CollectionMode; | ||
billing_details?: IBillingDetailsNotificationResponse | null; | ||
current_billing_period?: ISubscriptionTimePeriodNotificationResponse | null; | ||
billing_cycle: ITimePeriodNotification; | ||
scheduled_change?: ISubscriptionScheduledChangeNotificationResponse | null; | ||
items: ISubscriptionItemNotificationResponse[]; | ||
custom_data?: ICustomData | null; | ||
import_meta?: IImportMetaNotificationResponse | null; | ||
} |
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