Skip to content

Commit

Permalink
feat: Add /acs/credentials/read_card (#1109)
Browse files Browse the repository at this point in the history
  • Loading branch information
seambot authored Sep 26, 2024
1 parent c7aa3e7 commit 103c53b
Show file tree
Hide file tree
Showing 4 changed files with 1,317 additions and 55 deletions.
2 changes: 2 additions & 0 deletions src/lib/seam/connect/models/action-attempts/action-attempt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { z } from 'zod'
import { activate_climate_preset_action_attempt } from './activate-climate-preset.js'
import { deprecated_action_attempts } from './deprecated.js'
import { lock_door_action_attempt } from './lock-door.js'
import { read_card_action_attempt } from './read-card.js'
import { reset_sandbox_workspace_action_attempt } from './reset-sandbox-workspace.js'
import { set_cool_action_attempt } from './set-cool.js'
import { set_fan_mode_action_attempt } from './set-fan-mode.js'
Expand All @@ -14,6 +15,7 @@ import { unlock_door_action_attempt } from './unlock-door.js'
export const action_attempt = z.union([
...lock_door_action_attempt.options,
...unlock_door_action_attempt.options,
...read_card_action_attempt.options,
...reset_sandbox_workspace_action_attempt.options,
...set_cool_action_attempt.options,
...set_heat_action_attempt.options,
Expand Down
46 changes: 46 additions & 0 deletions src/lib/seam/connect/models/action-attempts/read-card.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { z } from 'zod'

import {
common_failed_action_attempt,
common_pending_action_attempt,
common_succeeded_action_attempt,
} from './common.js'

const action_type = z.literal('READ_CARD')

const error = z.object({
type: z.string(), // TODO This should be typed properly with the possible errors
message: z.string(),
})

const result = z.object({
acs_credential_id: z
.string()
.uuid()
.nullable()
.describe('Matching acs_credential currently encoded on this card.'),
card_number: z
.string()
.nullable()
.describe('A number or sting that physically identifies this card.'),
// TODO visionline_metadata: visionline_credential_metadata,
})

export const read_card_action_attempt = z.discriminatedUnion('status', [
common_pending_action_attempt
.extend({
action_type,
})
.describe('Reading card data from physical encoder.'),
common_succeeded_action_attempt
.extend({
action_type,
result,
})
.describe('Reading card data from physical encoder succeeded.'),
common_failed_action_attempt
.extend({ action_type, error })
.describe('Reading card data from physical encoder failed.'),
])

export type ReadCardActionAttempt = z.infer<typeof read_card_action_attempt>
156 changes: 156 additions & 0 deletions src/lib/seam/connect/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,100 @@ export default {
],
type: 'object',
},
{
description: 'Reading card data from physical encoder.',
properties: {
action_attempt_id: {
description: 'The ID of the action attempt.',
format: 'uuid',
type: 'string',
'x-title': 'Action Attempt ID',
},
action_type: { enum: ['READ_CARD'], type: 'string' },
error: { nullable: true },
result: { nullable: true },
status: { enum: ['pending'], type: 'string' },
},
required: [
'action_attempt_id',
'status',
'result',
'error',
'action_type',
],
type: 'object',
},
{
description: 'Reading card data from physical encoder succeeded.',
properties: {
action_attempt_id: {
description: 'The ID of the action attempt.',
format: 'uuid',
type: 'string',
'x-title': 'Action Attempt ID',
},
action_type: { enum: ['READ_CARD'], type: 'string' },
error: { nullable: true },
result: {
properties: {
acs_credential_id: {
description:
'Matching acs_credential currently encoded on this card.',
format: 'uuid',
nullable: true,
type: 'string',
},
card_number: {
description:
'A number or sting that physically identifies this card.',
nullable: true,
type: 'string',
},
},
required: ['acs_credential_id', 'card_number'],
type: 'object',
},
status: { enum: ['success'], type: 'string' },
},
required: [
'action_attempt_id',
'status',
'error',
'action_type',
'result',
],
type: 'object',
},
{
description: 'Reading card data from physical encoder failed.',
properties: {
action_attempt_id: {
description: 'The ID of the action attempt.',
format: 'uuid',
type: 'string',
'x-title': 'Action Attempt ID',
},
action_type: { enum: ['READ_CARD'], type: 'string' },
error: {
properties: {
message: { type: 'string' },
type: { type: 'string' },
},
required: ['type', 'message'],
type: 'object',
},
result: { nullable: true },
status: { enum: ['error'], type: 'string' },
},
required: [
'action_attempt_id',
'status',
'result',
'action_type',
'error',
],
type: 'object',
},
{
description: 'Resetting sandbox workspace.',
properties: {
Expand Down Expand Up @@ -6716,6 +6810,68 @@ export default {
'x-fern-sdk-return-value': 'acs_entrances',
},
},
'/acs/credentials/read_card': {
post: {
operationId: 'acsCredentialsReadCardPost',
requestBody: {
content: {
'application/json': {
schema: {
oneOf: [
{
properties: {
acs_system_id: { format: 'uuid', type: 'string' },
device_name: { type: 'string' },
},
required: ['acs_system_id', 'device_name'],
type: 'object',
},
{
properties: {
device_id: { format: 'uuid', type: 'string' },
},
required: ['device_id'],
type: 'object',
},
],
},
},
},
},
responses: {
200: {
content: {
'application/json': {
schema: {
properties: {
action_attempt: {
$ref: '#/components/schemas/action_attempt',
},
ok: { type: 'boolean' },
},
required: ['action_attempt', 'ok'],
type: 'object',
},
},
},
description: 'OK',
},
400: { description: 'Bad Request' },
401: { description: 'Unauthorized' },
},
security: [
{ pat_with_workspace: [] },
{ console_session: [] },
{ api_key: [] },
],
summary: '/acs/credentials/read_card',
tags: ['/acs'],
'x-fern-sdk-group-name': ['acs', 'credentials'],
'x-fern-sdk-method-name': 'read_card',
'x-fern-sdk-return-value': 'action_attempt',
'x-undocumented': 'Reading a card is currently unimplemented.',
},
},
'/acs/credentials/unassign': {
patch: {
operationId: 'acsCredentialsUnassignPatch',
Expand Down
Loading

0 comments on commit 103c53b

Please sign in to comment.