Skip to content

Commit

Permalink
fix(calls): snake_case parameters and time serialization (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
genaris authored Dec 2, 2024
1 parent f9ef5ff commit ff96e56
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 10 additions & 1 deletion packages/calls/src/messages/CallOfferMessage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { AgentMessage, IsValidMessageType, parseMessageType } from '@credo-ts/core'
import { IsString } from 'class-validator'
import { DateTransformer } from '@credo-ts/core/build/utils/transformers'
import { Expose } from 'class-transformer'
import { IsDate, IsString } from 'class-validator'

export type DidCommCallType = 'audio' | 'video' | 'service'

Expand Down Expand Up @@ -27,10 +29,17 @@ export class CallOfferMessage extends AgentMessage {
}

@IsString()
@Expose({ name: 'call_type' })
public callType!: string

@IsDate()
@Expose({ name: 'offer_expiration_time' })
@DateTransformer()
public offerExpirationTime?: Date | null

@IsDate()
@DateTransformer()
@Expose({ name: 'offer_start_time' })
public offerStartTime?: Date | null

public description?: string
Expand Down
7 changes: 6 additions & 1 deletion packages/calls/tests/DidCommCallsService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ describe('Didcomm Calls', () => {
const message = didcommCallsService.createOffer({
callType: 'video',
description: 'new Call Offer',
offerStartTime: new Date('2024-12-02T01:26:02Z'),
offerExpirationTime: new Date('2024-12-02T01:26:03.070Z'),
parameters: { param: 'value' },
})

Expand All @@ -36,7 +38,10 @@ describe('Didcomm Calls', () => {
expect.objectContaining({
'@id': expect.any(String),
'@type': 'https://didcomm.org/calls/1.0/call-offer',
callType: 'video',
description: 'new Call Offer',
call_type: 'video',
offer_start_time: '2024-12-02T01:26:02.000Z',
offer_expiration_time: '2024-12-02T01:26:03.070Z',
parameters: { param: 'value' },
}),
)
Expand Down

0 comments on commit ff96e56

Please sign in to comment.