-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFeedItem.ts
186 lines (181 loc) · 4.46 KB
/
FeedItem.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
import { CountryCode, LanguageCode } from './Feed'
export interface CisionMediaResponse {
CreatedDate: string
FileName: string
Title: string
Description: string
IsMain: boolean
MediaType: string
Keywords: []
}
export interface CisionFileResponse extends CisionMediaResponse {
Url: string
}
export interface CisionImageResponse extends CisionMediaResponse {
DownloadUrl: string
Photographer: string
UrlTo100x100ArResized: string
UrlTo100x100Thumbnail: string
UrlTo200x200ArResized: string
UrlTo200x200Thumbnail: string
UrlTo400x400ArResized: string
UrlTo800x800ArResized: string
}
export interface CisionCategoryResponse {
Code: string
Name: string
}
export interface CisionQuoteResponse {
Author: string
Text: string
}
export interface CisionLanguageVersionResponse {
Code: string
ReleaseId: string
}
export interface CisionServiceCategoryResponse {
ServiceName: string
Name: string
Value: string
}
export interface CisionTickerResponse {
Symbol: string
ISIN: string
PrimaryListing: boolean
IsShare: boolean
MarketPlaceSymbol: string
MarketPlaceName: string
MarketPlaceIsRegulated: boolean
MarketPlaceCountryCode: CountryCode
}
export interface CisionExternalLinkResponse {
Title: string
Url: string
}
export interface CisionFeedItemResponse {
SyndicatedUrl: string
CompanyInformation: string
Title: string
Intro: string
Body: string
Id: number
IptcCode: string
EncryptedId: string
LanguageCode: LanguageCode
CountryCode: CountryCode
LanguageVersions: CisionLanguageVersionResponse[]
Categories: CisionCategoryResponse[]
Keywords: string[]
Images: CisionImageResponse[]
InformationType: string
PublishDate: string
LastChangeDate: string
LogoUrl: string
MainJobId: number
IsRegulatory: boolean
CanonicalUrl: string
CisionWireUrl: string
Complete: string
Contact: string
EmbeddedItems: []
ExternalLinks: CisionExternalLinkResponse[]
QuickFacts: string[]
Quotes: CisionQuoteResponse[]
Files: CisionFileResponse[]
Header: string
HtmlTitle: string
HtmlIntro: string
HtmlBody: string
HtmlHeader: string
HtmlCompanyInformation: string
SocialMediaPitch: string
HtmlContact: string
RawHtmlUrl: string
ServiceCategories: CisionServiceCategoryResponse[]
SourceId: number
SourceIsListed: boolean
SourceName: string
SuppressImageOnCisionWire: boolean
Videos: []
Tickers: CisionTickerResponse[]
}
export class CisionFeedItem {
title: string
body: string
htmlBody: string
intro: string
htmlIntro: string
image: string
files: {
url: string
fileName: string
title: string
description: string
isMain: boolean
type: string
}[]
date: string
categories: string[]
keywords: string[]
languageCode: LanguageCode
countryCode: CountryCode
type: string
isRegulatory: boolean
encryptedId: string
id: number
constructor(rawItem: CisionFeedItemResponse) {
this.title = rawItem.Title
this.body = rawItem.Body
this.htmlBody = rawItem.HtmlBody
this.intro = rawItem.Intro
this.htmlIntro = rawItem.HtmlIntro
this.image = rawItem.Images?.[0]?.DownloadUrl
this.files = (rawItem.Files || []).map((it: CisionFileResponse) => ({
url: it.Url,
fileName: it.FileName,
title: it.Title,
description: it.Description,
isMain: it.IsMain,
type: it.MediaType,
}))
this.date = new Date(rawItem.PublishDate).toDateString()
this.categories = (rawItem.Categories || []).map(
(it: CisionCategoryResponse) => it.Name.toLowerCase()
)
this.keywords = (rawItem.Keywords || []).map((it) => it.toLowerCase())
this.languageCode = rawItem.LanguageCode.toLowerCase()
this.countryCode = rawItem.CountryCode.toLowerCase()
this.type = rawItem.InformationType.toUpperCase()
this.isRegulatory = rawItem.IsRegulatory
this.encryptedId = rawItem.EncryptedId
this.id = rawItem.Id
}
hasCategory(categories: string[]): boolean {
for (const category of categories) {
if (this.categories.includes(category.toLowerCase())) {
return true
}
}
return false
}
hasKeyword(keywords: string[]): boolean {
for (const keyword of keywords) {
if (this.keywords.includes(keyword.toLowerCase())) {
return true
}
}
return false
}
toJSON() {
return { ...this }
}
}
export interface CisionPressReleaseResponse {
Release: CisionFeedItemResponse
DatePackaged: string
Title: string
Author: string
}
export default {
CisionFeedItem,
}