Skip to content

Commit 2947349

Browse files
feat: sync CLI with API changes
1 parent 5b17b4f commit 2947349

4 files changed

Lines changed: 33 additions & 1 deletion

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@blindpay/cli",
33
"type": "module",
4-
"version": "0.1.1",
4+
"version": "0.1.2",
55
"description": "Blindpay CLI - manage receivers, bank accounts, payouts, payins, and more from the terminal",
66
"license": "MIT",
77
"author": "Blindpay <gabriel@blindpay.com> (https://blindpay.com/)",

src/__tests__/resources.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ describe('Bank Accounts', () => {
237237
account_class: null,
238238
country: null,
239239
swift_ifsc_branch_code: null,
240+
sepa_beneficiary_bic: null,
240241
})
241242
})
242243

@@ -564,6 +565,14 @@ describe('Instances', () => {
564565
expect(lastCall().url).toBe(`${BASE}`)
565566
expect(lastCall().body).toEqual({ name: 'New' })
566567
})
568+
569+
test('migrates instance ownership to another user', async () => {
570+
mockResponse.body = { success: true }
571+
await resources.migrateInstanceOwnership({ userId: 'usr_abc', json: true })
572+
expect(lastCall().method).toBe('POST')
573+
expect(lastCall().url).toBe(`${BASE}/ownership`)
574+
expect(lastCall().body).toEqual({ user_id: 'usr_abc' })
575+
})
567576
})
568577

569578
describe('Available', () => {

src/commands/resources.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ export async function createBankAccount(options: {
254254
accountClass?: string
255255
country?: string
256256
swiftIfscBranchCode?: string
257+
sepaBeneficiaryBic?: string
257258
json: boolean
258259
}) {
259260
try {
@@ -270,6 +271,7 @@ export async function createBankAccount(options: {
270271
account_class: options.accountClass ?? null,
271272
country: options.country ?? null,
272273
swift_ifsc_branch_code: options.swiftIfscBranchCode ?? null,
274+
sepa_beneficiary_bic: options.sepaBeneficiaryBic ?? null,
273275
}
274276
const ba = await apiPost<{ id: string, type: string }>(ctx, `${instancePath(ctx)}/receivers/${options.receiverId}/bank-accounts`, body)
275277
clack.log.success(`Created bank account ${ba.id} (${ba.type})`)
@@ -748,6 +750,18 @@ export async function updateInstance(options: {
748750
}
749751
}
750752

753+
export async function migrateInstanceOwnership(options: { userId: string, json: boolean }) {
754+
try {
755+
const ctx = resolveContext()
756+
const res = await apiPost<{ success: boolean }>(ctx, `${instancePath(ctx)}/ownership`, { user_id: options.userId })
757+
clack.log.success('Instance ownership migrated')
758+
if (options.json) console.log(formatOutput(res, true))
759+
}
760+
catch (e) {
761+
handleApiError(e, options.json)
762+
}
763+
}
764+
751765
// Receiver Limits
752766
export async function getReceiverLimits(receiverId: string, options: { json: boolean }) {
753767
try {

src/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import {
4242
getInstance,
4343
listInstanceMembers,
4444
updateInstance,
45+
migrateInstanceOwnership,
4546
listAvailableRails,
4647
getAvailableBankDetails,
4748
createReceiverLimitIncrease,
@@ -256,6 +257,7 @@ bankAccounts
256257
.option('--recipient-relationship <rel>', 'Recipient relationship')
257258
.option('--country <country>', 'Country code')
258259
.option('--swift-ifsc-branch-code <code>', 'SWIFT/IFSC branch code (international_swift accounts)')
260+
.option('--sepa-beneficiary-bic <bic>', 'SEPA beneficiary BIC code (sepa accounts)')
259261
.option('--json', 'Output as JSON', false)
260262
.action(opts => createBankAccount(opts))
261263

@@ -562,6 +564,13 @@ instances
562564
.option('--json', 'Output as JSON', false)
563565
.action(opts => updateInstance(opts))
564566

567+
instances
568+
.command('migrate_ownership')
569+
.description('Migrate instance ownership to another user')
570+
.requiredOption('--user-id <id>', 'User ID to transfer ownership to')
571+
.option('--json', 'Output as JSON', false)
572+
.action(opts => migrateInstanceOwnership(opts))
573+
565574
const instanceMembers = instances.command('members').description('Manage instance members')
566575

567576
instanceMembers

0 commit comments

Comments
 (0)