Skip to content

Commit

Permalink
Implement encode(to:) method of Event (fixes #252) (#255)
Browse files Browse the repository at this point in the history
  • Loading branch information
Frizlab authored May 8, 2024
1 parent b654208 commit 223594d
Showing 1 changed file with 108 additions and 1 deletion.
109 changes: 108 additions & 1 deletion Sources/StripeKit/Core Resources/Events/Event.swift
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,114 @@ public enum EventObject: Codable {
}
}

public func encode(to encoder: Encoder) throws { }
public func encode(to encoder: Encoder) throws {
switch self {
case .account(let connectAccount):
try connectAccount.encode(to: encoder)
case .application(let connectApplication):
try connectApplication.encode(to: encoder)
case .card(let card):
try card.encode(to: encoder)
case .cashBalance(let cashBalance):
try cashBalance.encode(to: encoder)
case .bankAccount(let bankAccount):
try bankAccount.encode(to: encoder)
case .applicationFee(let applicationFee):
try applicationFee.encode(to: encoder)
case .applicationFeeRefund(let applicationFeeRefund):
try applicationFeeRefund.encode(to: encoder)
case .balance(let balance):
try balance.encode(to: encoder)
case .capability(let capability):
try capability.encode(to: encoder)
case .charge(let charge):
try charge.encode(to: encoder)
case .dispute(let dispute):
try dispute.encode(to: encoder)
case .refund(let refund):
try refund.encode(to: encoder)
case .checkoutSession(let session):
try session.encode(to: encoder)
case .configuration(let portalConfiguration):
try portalConfiguration.encode(to: encoder)
case .coupon(let coupon):
try coupon.encode(to: encoder)
case .creditNote(let creditNote):
try creditNote.encode(to: encoder)
case .customer(let customer):
try customer.encode(to: encoder)
case .discount(let discount):
try discount.encode(to: encoder)
case .subscription(let subscription):
try subscription.encode(to: encoder)
case .taxId(let taxID):
try taxID.encode(to: encoder)
case .file(let file):
try file.encode(to: encoder)
case .invoice(let invoice):
try invoice.encode(to: encoder)
case .invoiceItem(let invoiceItem):
try invoiceItem.encode(to: encoder)
case .issuingAuthorization(let authorization):
try authorization.encode(to: encoder)
case .issuingCard(let issuingCard):
try issuingCard.encode(to: encoder)
case .issuingCardHolder(let cardholder):
try cardholder.encode(to: encoder)
case .issuingDispute(let issuingDispute):
try issuingDispute.encode(to: encoder)
case .issuingTransaction(let transaction):
try transaction.encode(to: encoder)
case .mandate(let mandate):
try mandate.encode(to: encoder)
case .paymentIntent(let paymentIntent):
try paymentIntent.encode(to: encoder)
case .paymentLink(let paymentLink):
try paymentLink.encode(to: encoder)
case .paymentMethod(let paymentMethod):
try paymentMethod.encode(to: encoder)
case .payout(let payout):
try payout.encode(to: encoder)
case .person(let person):
try person.encode(to: encoder)
case .plan(let plan):
try plan.encode(to: encoder)
case .price(let price):
try price.encode(to: encoder)
case .product(let product):
try product.encode(to: encoder)
case .promotionCode(let promotionCode):
try promotionCode.encode(to: encoder)
case .earlyFraudWarniing(let earlyFraudWarning):
try earlyFraudWarning.encode(to: encoder)
case .quote(let quote):
try quote.encode(to: encoder)
case .reportRun(let reportRun):
try reportRun.encode(to: encoder)
case .reportType(let reportType):
try reportType.encode(to: encoder)
case .review(let review):
try review.encode(to: encoder)
case .setupIntent(let setupIntent):
try setupIntent.encode(to: encoder)
case .scheduledQueryRun(let scheduledQueryRun):
try scheduledQueryRun.encode(to: encoder)
case .subscriptionSchedule(let subscriptionSchedule):
try subscriptionSchedule.encode(to: encoder)
case .taxRate(let taxRate):
try taxRate.encode(to: encoder)
case .topup(let topUp):
try topUp.encode(to: encoder)
case .transfer(let transfer):
try transfer.encode(to: encoder)
case .testClock(let testClock):
try testClock.encode(to: encoder)
case .reader(let terminalReader):
try terminalReader.encode(to: encoder)
case .verificationSession(let verificationSession):
try verificationSession.encode(to: encoder)
}
}

private enum CodingKeys: String, CodingKey {
case object
Expand Down

0 comments on commit 223594d

Please sign in to comment.