Skip to content

Commit 73ff6de

Browse files
feat: sync CLI with API changes
1 parent dbce8bb commit 73ff6de

4 files changed

Lines changed: 1 addition & 101 deletions

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.3.1",
4+
"version": "0.4.0",
55
"description": "Blindpay CLI - manage receivers, bank accounts, payouts, payins, and more from the terminal",
66
"license": "MIT",
77
"author": "Blindpay <alves@blindpay.com> (https://blindpay.com/)",

src/__tests__/resources.test.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -555,32 +555,6 @@ describe('Partner Fees', () => {
555555
})
556556
})
557557

558-
describe('API Keys', () => {
559-
beforeEach(setupTestEnv)
560-
afterEach(teardownTestEnv)
561-
562-
test('lists API keys', async () => {
563-
mockResponse.body = []
564-
await resources.listApiKeys({ json: true })
565-
expect(lastCall().url).toBe(`${BASE}/api-keys`)
566-
})
567-
568-
test('creates an API key', async () => {
569-
mockResponse.body = { id: 'ak_new', key: 'sk_...' }
570-
await resources.createApiKey({ name: 'test', permission: 'read', json: true })
571-
expect(lastCall().method).toBe('POST')
572-
expect(lastCall().url).toBe(`${BASE}/api-keys`)
573-
expect(lastCall().body).toEqual({ name: 'test', permission: 'read' })
574-
})
575-
576-
test('deletes an API key', async () => {
577-
mockResponse.body = { success: true }
578-
await resources.deleteApiKey('ak_1', { json: true })
579-
expect(lastCall().method).toBe('DELETE')
580-
expect(lastCall().url).toBe(`${BASE}/api-keys/ak_1`)
581-
})
582-
})
583-
584558
describe('Virtual Accounts', () => {
585559
beforeEach(setupTestEnv)
586560
afterEach(teardownTestEnv)

src/commands/resources.ts

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -645,49 +645,6 @@ export async function deletePartnerFee(id: string, options: { json?: boolean } =
645645
}
646646
}
647647

648-
// API Keys
649-
export async function listApiKeys(options: { json: boolean }) {
650-
try {
651-
const ctx = resolveContext()
652-
const res = await apiGet<unknown>(ctx, `${instancePath(ctx)}/api-keys`)
653-
const list = extractList(res)
654-
const maskKey = (s: string | null) => (!s ? '-' : s.length > 8 ? `${s.slice(0, 4)}...${s.slice(-4)}` : '***')
655-
const display = list.map((k: any) => ({ id: k.id, name: k.name, key: maskKey(k.key), permission: k.permission }))
656-
printResult(options.json ? list : display, options.json, ['id', 'name', 'key', 'permission'])
657-
}
658-
catch (e) {
659-
handleApiError(e, options.json)
660-
}
661-
}
662-
663-
export async function createApiKey(options: { name?: string, permission?: string, json: boolean }) {
664-
try {
665-
const ctx = resolveContext()
666-
const body: Record<string, string> = { name: options.name || 'CLI API Key' }
667-
if (options.permission) body.permission = options.permission
668-
const key = await apiPost<{ id: string, key: string }>(ctx, `${instancePath(ctx)}/api-keys`, body)
669-
clack.log.success(`Created API key ${key.id}`)
670-
clack.log.warning(`Secret: ${key.key}`)
671-
clack.log.message('Save this key now — it will not be shown again.')
672-
if (options.json)
673-
console.log(formatOutput(key, true))
674-
}
675-
catch (e) {
676-
handleApiError(e, options.json)
677-
}
678-
}
679-
680-
export async function deleteApiKey(id: string, options: { json?: boolean } = {}) {
681-
try {
682-
const ctx = resolveContext()
683-
await apiDelete(ctx, `${instancePath(ctx)}/api-keys/${id}`)
684-
clack.log.success(`Deleted API key ${id}`)
685-
}
686-
catch (e) {
687-
handleApiError(e, options.json)
688-
}
689-
}
690-
691648
// Virtual Accounts
692649
export async function listVirtualAccounts(options: { customerId: string, json: boolean }) {
693650
try {

src/index.ts

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ import {
3636
listPartnerFees,
3737
createPartnerFee,
3838
deletePartnerFee,
39-
listApiKeys,
40-
createApiKey,
41-
deleteApiKey,
4239
listVirtualAccounts,
4340
createVirtualAccount,
4441
getVirtualAccount,
@@ -517,34 +514,6 @@ partnerFees
517514
.option('--json', 'Output as JSON', false)
518515
.action((id, opts) => deletePartnerFee(id, opts))
519516

520-
// ── API Keys ────────────────────────────────────────────────────────────
521-
const apiKeys = program.command('api_keys').description('Manage API keys')
522-
.addHelpText('after', `
523-
Examples:
524-
$ blindpay api_keys list
525-
$ blindpay api_keys create --name "Production Key"
526-
$ blindpay api_keys delete <id>`)
527-
528-
apiKeys
529-
.command('list')
530-
.description('List API keys')
531-
.option('--json', 'Output as JSON', false)
532-
.action(opts => listApiKeys(opts))
533-
534-
apiKeys
535-
.command('create')
536-
.description('Create an API key')
537-
.option('--name <name>', 'Key name', 'CLI API Key')
538-
.option('--permission <permission>', 'Permission level')
539-
.option('--json', 'Output as JSON', false)
540-
.action(opts => createApiKey(opts))
541-
542-
apiKeys
543-
.command('delete <id>')
544-
.description('Delete an API key')
545-
.option('--json', 'Output as JSON', false)
546-
.action((id, opts) => deleteApiKey(id, opts))
547-
548517
// ── Virtual Accounts ────────────────────────────────────────────────────
549518
const virtualAccounts = program.command('virtual_accounts').description('Manage virtual accounts')
550519
.addHelpText('after', `

0 commit comments

Comments
 (0)