Skip to content

Commit 2a16c3a

Browse files
feat: sync SDK with API changes
1 parent 02cc06d commit 2a16c3a

7 files changed

Lines changed: 156 additions & 3 deletions

File tree

‎Sources/BlindPay/Core/BlindPay.swift‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,27 @@ public final class BlindPay: Sendable {
195195
method: .delete
196196
)
197197
}
198-
198+
199+
/// Migrates instance ownership to another user
200+
///
201+
/// This method transfers ownership of the instance to a specified user.
202+
///
203+
/// - Parameter data: The input data containing the user ID to transfer ownership to
204+
/// - Returns: An `APIResponse` containing the success status
205+
/// - Throws: `BlindPayError` if the request fails
206+
///
207+
/// Example:
208+
/// ```swift
209+
/// let input = MigrateInstanceOwnershipInput(userId: "user_123")
210+
/// let response = try await blindPay.migrateInstanceOwnership(data: input)
211+
/// if let result = response.data {
212+
/// print("Migration successful: \(result.success)")
213+
/// }
214+
/// ```
215+
public func migrateInstanceOwnership(data: MigrateInstanceOwnershipInput) async throws -> APIResponse<MigrateInstanceOwnershipResponse> {
216+
return try await instances.migrateOwnership(data: data)
217+
}
218+
199219
/// Deletes a member from the instance
200220
///
201221
/// This method permanently removes a member from the instance.

‎Sources/BlindPay/Models/BankAccount.swift‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ public struct BankAccount: Codable, Sendable, Equatable {
161161
/// SWIFT intermediary bank country
162162
public let swiftIntermediaryBankCountry: Country?
163163

164+
/// SEPA beneficiary BIC
165+
public let sepaBeneficiaryBic: String?
166+
164167
/// TED bank code
165168
public let tedBankCode: String?
166169

@@ -230,6 +233,7 @@ public struct BankAccount: Codable, Sendable, Equatable {
230233
swiftIntermediaryBankAccountNumberIban: String? = nil,
231234
swiftIntermediaryBankName: String? = nil,
232235
swiftIntermediaryBankCountry: Country? = nil,
236+
sepaBeneficiaryBic: String? = nil,
233237
tedBankCode: String? = nil,
234238
tedBranchCode: String? = nil,
235239
tedCpfCnpj: String? = nil,
@@ -287,6 +291,7 @@ public struct BankAccount: Codable, Sendable, Equatable {
287291
self.swiftIntermediaryBankAccountNumberIban = swiftIntermediaryBankAccountNumberIban
288292
self.swiftIntermediaryBankName = swiftIntermediaryBankName
289293
self.swiftIntermediaryBankCountry = swiftIntermediaryBankCountry
294+
self.sepaBeneficiaryBic = sepaBeneficiaryBic
290295
self.tedBankCode = tedBankCode
291296
self.tedBranchCode = tedBranchCode
292297
self.tedCpfCnpj = tedCpfCnpj
@@ -346,6 +351,7 @@ public struct BankAccount: Codable, Sendable, Equatable {
346351
case swiftIntermediaryBankAccountNumberIban = "swift_intermediary_bank_account_number_iban"
347352
case swiftIntermediaryBankName = "swift_intermediary_bank_name"
348353
case swiftIntermediaryBankCountry = "swift_intermediary_bank_country"
354+
case sepaBeneficiaryBic = "sepa_beneficiary_bic"
349355
case tedBankCode = "ted_bank_code"
350356
case tedBranchCode = "ted_branch_code"
351357
case tedCpfCnpj = "ted_cpf_cnpj"
@@ -517,6 +523,9 @@ public struct CreateBankAccountInput: Codable, Sendable {
517523
/// SWIFT intermediary bank SWIFT code BIC
518524
public let swiftIntermediaryBankSwiftCodeBic: String?
519525

526+
/// SEPA beneficiary BIC
527+
public let sepaBeneficiaryBic: String?
528+
520529
/// Transfers account
521530
public let transfersAccount: String?
522531

@@ -594,6 +603,7 @@ public struct CreateBankAccountInput: Codable, Sendable {
594603
swiftIntermediaryBankCountry: Country? = nil,
595604
swiftIntermediaryBankName: String? = nil,
596605
swiftIntermediaryBankSwiftCodeBic: String? = nil,
606+
sepaBeneficiaryBic: String? = nil,
597607
transfersAccount: String? = nil,
598608
transfersType: TransfersType? = nil,
599609
businessIndustry: String? = nil,
@@ -653,6 +663,7 @@ public struct CreateBankAccountInput: Codable, Sendable {
653663
self.swiftIntermediaryBankCountry = swiftIntermediaryBankCountry
654664
self.swiftIntermediaryBankName = swiftIntermediaryBankName
655665
self.swiftIntermediaryBankSwiftCodeBic = swiftIntermediaryBankSwiftCodeBic
666+
self.sepaBeneficiaryBic = sepaBeneficiaryBic
656667
self.transfersAccount = transfersAccount
657668
self.transfersType = transfersType
658669
self.businessIndustry = businessIndustry
@@ -714,6 +725,7 @@ public struct CreateBankAccountInput: Codable, Sendable {
714725
case swiftIntermediaryBankCountry = "swift_intermediary_bank_country"
715726
case swiftIntermediaryBankName = "swift_intermediary_bank_name"
716727
case swiftIntermediaryBankSwiftCodeBic = "swift_intermediary_bank_swift_code_bic"
728+
case sepaBeneficiaryBic = "sepa_beneficiary_bic"
717729
case transfersAccount = "transfers_account"
718730
case transfersType = "transfers_type"
719731
case businessIndustry = "business_industry"
@@ -870,6 +882,9 @@ public struct CreateBankAccountInput: Codable, Sendable {
870882
if let swiftIntermediaryBankSwiftCodeBic = swiftIntermediaryBankSwiftCodeBic {
871883
try container.encode(swiftIntermediaryBankSwiftCodeBic, forKey: .swiftIntermediaryBankSwiftCodeBic)
872884
}
885+
if let sepaBeneficiaryBic = sepaBeneficiaryBic {
886+
try container.encode(sepaBeneficiaryBic, forKey: .sepaBeneficiaryBic)
887+
}
873888
if let transfersAccount = transfersAccount {
874889
try container.encode(transfersAccount, forKey: .transfersAccount)
875890
}

‎Sources/BlindPay/Models/Instance.swift‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,27 @@ public struct VoidResponse: Codable, Sendable {
132132
public init() {}
133133
}
134134

135+
/// Input for migrating instance ownership
136+
public struct MigrateInstanceOwnershipInput: Codable, Sendable {
137+
/// User ID to transfer ownership to
138+
public let userId: String
139+
140+
public init(userId: String) {
141+
self.userId = userId
142+
}
143+
144+
enum CodingKeys: String, CodingKey {
145+
case userId = "user_id"
146+
}
147+
}
148+
149+
/// Response for migrating instance ownership
150+
public struct MigrateInstanceOwnershipResponse: Codable, Sendable, Equatable {
151+
/// Success status
152+
public let success: Bool
153+
154+
public init(success: Bool) {
155+
self.success = success
156+
}
157+
}
158+

‎Sources/BlindPay/Models/Payin.swift‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ public enum PayinType: String, Codable, Sendable {
3737
case business = "business"
3838
}
3939

40+
/// Manual execution status
41+
public enum ManualExecutionStatus: String, Codable, Sendable {
42+
case failed = "failed"
43+
}
44+
4045
// MARK: - Tracking Types
4146

4247
/// Transaction tracking information for payin

‎Sources/BlindPay/Models/Payout.swift‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,12 @@ public struct Payout: Codable, Sendable, Equatable {
540540
/// Has virtual account
541541
public let hasVirtualAccount: Bool?
542542

543+
/// Billing fee amount
544+
public let billingFeeAmount: Double?
545+
546+
/// CPN payment ID
547+
public let cpnPaymentId: String?
548+
543549
public init(
544550
id: String,
545551
receiverId: String,
@@ -610,7 +616,9 @@ public struct Payout: Codable, Sendable, Equatable {
610616
swiftAccountNumberIban: String? = nil,
611617
transfersAccount: String? = nil,
612618
transfersType: TransfersType? = nil,
613-
hasVirtualAccount: Bool? = nil
619+
hasVirtualAccount: Bool? = nil,
620+
billingFeeAmount: Double? = nil,
621+
cpnPaymentId: String? = nil
614622
) {
615623
self.id = id
616624
self.receiverId = receiverId
@@ -682,6 +690,8 @@ public struct Payout: Codable, Sendable, Equatable {
682690
self.transfersAccount = transfersAccount
683691
self.transfersType = transfersType
684692
self.hasVirtualAccount = hasVirtualAccount
693+
self.billingFeeAmount = billingFeeAmount
694+
self.cpnPaymentId = cpnPaymentId
685695
}
686696

687697
enum CodingKeys: String, CodingKey {
@@ -755,6 +765,8 @@ public struct Payout: Codable, Sendable, Equatable {
755765
case transfersAccount = "transfers_account"
756766
case transfersType = "transfers_type"
757767
case hasVirtualAccount = "has_virtual_account"
768+
case billingFeeAmount = "billing_fee_amount"
769+
case cpnPaymentId = "cpn_payment_id"
758770
}
759771
}
760772

‎Sources/BlindPay/Models/WebhookEndpoint.swift‎

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Foundation
1111
public enum WebhookEvent: String, Codable, Sendable {
1212
case receiverNew = "receiver.new"
1313
case receiverUpdate = "receiver.update"
14+
case receiverDelete = "receiver.delete"
1415
case bankAccountNew = "bankAccount.new"
1516
case payoutNew = "payout.new"
1617
case payoutUpdate = "payout.update"
@@ -136,9 +137,61 @@ public struct WebhookPortalAccess: Codable, Sendable {
136137
public struct DeleteWebhookEndpointResponse: Codable, Sendable {
137138
/// Indicates if the deletion was successful
138139
public let success: Bool
139-
140+
140141
public init(success: Bool) {
141142
self.success = success
142143
}
143144
}
144145

146+
/// Receiver delete webhook output
147+
public struct ReceiverDeleteWebhookOut: Codable, Sendable, Equatable {
148+
/// Receiver ID
149+
public let receiverId: String
150+
151+
/// Instance ID
152+
public let instanceId: String
153+
154+
/// Event type
155+
public let event: String
156+
157+
/// Timestamp
158+
public let timestamp: String
159+
160+
/// Webhook ID
161+
public let webhookId: String
162+
163+
/// Event ID
164+
public let eventId: String
165+
166+
/// Event data
167+
public let data: String?
168+
169+
public init(
170+
receiverId: String,
171+
instanceId: String,
172+
event: String,
173+
timestamp: String,
174+
webhookId: String,
175+
eventId: String,
176+
data: String? = nil
177+
) {
178+
self.receiverId = receiverId
179+
self.instanceId = instanceId
180+
self.event = event
181+
self.timestamp = timestamp
182+
self.webhookId = webhookId
183+
self.eventId = eventId
184+
self.data = data
185+
}
186+
187+
enum CodingKeys: String, CodingKey {
188+
case receiverId = "receiver_id"
189+
case instanceId = "instance_id"
190+
case event
191+
case timestamp
192+
case webhookId = "webhook_id"
193+
case eventId = "event_id"
194+
case data
195+
}
196+
}
197+

‎Sources/BlindPay/Services/InstancesService.swift‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,30 @@ public final class InstancesService: Sendable {
553553
)
554554
}
555555

556+
/// Migrates instance ownership to another user
557+
///
558+
/// This method transfers ownership of the instance to a specified user.
559+
///
560+
/// - Parameter data: The input data containing the user ID to transfer ownership to
561+
/// - Returns: An `APIResponse` containing the success status
562+
/// - Throws: `BlindPayError` if the request fails
563+
///
564+
/// Example:
565+
/// ```swift
566+
/// let input = MigrateInstanceOwnershipInput(userId: "user_123")
567+
/// let response = try await blindPay.instances.migrateOwnership(data: input)
568+
/// if let result = response.data {
569+
/// print("Migration successful: \(result.success)")
570+
/// }
571+
/// ```
572+
public func migrateOwnership(data: MigrateInstanceOwnershipInput) async throws -> APIResponse<MigrateInstanceOwnershipResponse> {
573+
return try await apiClient.request(
574+
endpoint: "/v1/instances/\(instanceId)/ownership",
575+
method: .post,
576+
body: data
577+
)
578+
}
579+
556580
/// Gets a receiver service for a specific receiver ID
557581
///
558582
/// This method returns a service instance for managing resources associated with a specific receiver,

0 commit comments

Comments
 (0)