File tree Expand file tree Collapse file tree 8 files changed +85
-43
lines changed Expand file tree Collapse file tree 8 files changed +85
-43
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import * as notifications from './notifications'
7
7
import * as comments from './comments'
8
8
import * as upload from './upload'
9
9
import * as stories from './stories'
10
+ import * as mediaMeta from './media-meta'
10
11
11
12
/**
12
13
* API
@@ -30,6 +31,7 @@ export const api = {
30
31
comments,
31
32
upload,
32
33
stories,
34
+ mediaMeta,
33
35
}
34
36
/**
35
37
* API 集合
Original file line number Diff line number Diff line change
1
+ import { request , toResponse } from '../request'
2
+ import type { LiteralUnion } from '../utils/typings'
3
+ import type { InteractiveResponse } from '../types/api-responses'
4
+
5
+ /**
6
+ * 获取视频地址
7
+ * @param id 视频id
8
+ * @param type 类型 如:STORY
9
+ * @param trigger 触发 如:user
10
+ */
11
+ export const interactive = async < T = InteractiveResponse > (
12
+ id : string ,
13
+ type : LiteralUnion < 'STORY' > ,
14
+ trigger : LiteralUnion < 'user' > = 'user'
15
+ ) =>
16
+ toResponse < T > (
17
+ request . post ( '1.0/mediaMeta/interactive' , {
18
+ searchParams : {
19
+ id,
20
+ type,
21
+ trigger,
22
+ } ,
23
+ } )
24
+ )
Original file line number Diff line number Diff line change @@ -194,3 +194,7 @@ export namespace Stories {
194
194
data : Story [ ]
195
195
}
196
196
}
197
+
198
+ export interface InteractiveResponse {
199
+ url : string
200
+ }
Original file line number Diff line number Diff line change @@ -5,3 +5,4 @@ export * from './post'
5
5
export * from './profile'
6
6
export * from './topic'
7
7
export * from './user'
8
+ export * from './story'
Original file line number Diff line number Diff line change 1
- import type { CommonImage } from './common'
2
1
import type { Topic } from './topic'
3
2
import type {
4
3
Picture ,
@@ -8,7 +7,6 @@ import type {
8
7
UrlsInText ,
9
8
} from './post'
10
9
import type { User } from './user'
11
- import type { LiteralUnion } from '../../utils/typings'
12
10
13
11
export type PostTypeRaw = 'ORIGINAL_POST' | 'REPOST'
14
12
export type TargetType = PostTypeRaw | 'STORY'
@@ -162,43 +160,3 @@ export interface RecommendPost {
162
160
createdAt : Date
163
161
type : string
164
162
}
165
-
166
- export interface StoryPicture extends CommonImage {
167
- key : string
168
- cropperPosX : number
169
- cropperPosY : number
170
- width : number
171
- height : number
172
- }
173
-
174
- export interface StoryVideo {
175
- duration : number
176
- height : number
177
- type : string
178
- width : number
179
- image : {
180
- format : string
181
- picUrl : string
182
- thumbnailUrl : string
183
- }
184
- }
185
-
186
- export interface Story {
187
- type : 'STORY'
188
- id : string
189
- storyType : LiteralUnion < 'PICTURE' | 'VIDEO' >
190
- status : LiteralUnion < 'PUBLIC' >
191
- user : User
192
- emoji ?: string
193
- video ?: StoryVideo
194
- thumbnailVideo ?: StoryVideo
195
- picture ?: StoryPicture
196
- liked : boolean
197
- likeCount : number
198
- commentCount : number
199
- viewerCount : number
200
- createdAt : string
201
- likedUsers : User [ ]
202
- enablePictureComments : boolean
203
- isFeatured : boolean
204
- }
Original file line number Diff line number Diff line change
1
+ import type { CommonImage } from './common'
2
+ import type { LiteralUnion } from '../../utils/typings'
3
+ import type { User } from './user'
4
+
5
+ export interface StoryPicture extends CommonImage {
6
+ key : string
7
+ cropperPosX : number
8
+ cropperPosY : number
9
+ width : number
10
+ height : number
11
+ }
12
+
13
+ export interface StoryVideo {
14
+ duration : number
15
+ height : number
16
+ type : string
17
+ width : number
18
+ image : {
19
+ format : string
20
+ picUrl : string
21
+ thumbnailUrl : string
22
+ }
23
+ }
24
+
25
+ export interface Story {
26
+ type : 'STORY'
27
+ id : string
28
+ storyType : LiteralUnion < 'PICTURE' | 'VIDEO' >
29
+ status : LiteralUnion < 'PUBLIC' >
30
+ user : User
31
+ emoji ?: string
32
+ video ?: StoryVideo
33
+ thumbnailVideo ?: StoryVideo
34
+ picture : StoryPicture
35
+ liked : boolean
36
+ likeCount : number
37
+ commentCount : number
38
+ viewerCount : number
39
+ createdAt : string
40
+ likedUsers : User [ ]
41
+ enablePictureComments : boolean
42
+ isFeatured : boolean
43
+ }
Original file line number Diff line number Diff line change @@ -16,4 +16,13 @@ describe('stories should work', () => {
16
16
)
17
17
expect ( isSuccess ( result ) ) . toBe ( true )
18
18
} )
19
+
20
+ it ( 'getVideo should word' , async ( ) => {
21
+ const result = await api . mediaMeta . interactive (
22
+ '627fcab1d505530011e9c7c4' ,
23
+ 'STORY' ,
24
+ 'user'
25
+ )
26
+ expect ( isSuccess ( result ) ) . toBe ( true )
27
+ } )
19
28
} )
Original file line number Diff line number Diff line change 9
9
" src/api/users.ts" ,
10
10
" src/api/comments.ts" ,
11
11
" src/api/upload.ts" ,
12
- " src/api/stories.ts"
12
+ " src/api/stories.ts" ,
13
+ " src/api/media-meta.ts"
13
14
],
14
15
"out" : " docs" ,
15
16
"name" : " Ⓙ Jike SDK" ,
You can’t perform that action at this time.
0 commit comments