@armoyu/core 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/api/ApiClient.d.ts +49 -11
  2. package/dist/api/ApiClient.js +137 -33
  3. package/dist/api/ArmoyuApi.d.ts +38 -0
  4. package/dist/api/ArmoyuApi.js +66 -0
  5. package/dist/armoyu-core.bundle.js +1 -0
  6. package/dist/index.d.ts +11 -1
  7. package/dist/index.js +9 -2
  8. package/dist/models/auth/User.js +17 -22
  9. package/dist/models/core/Rule.d.ts +23 -0
  10. package/dist/models/core/Rule.js +39 -0
  11. package/dist/models/index.d.ts +1 -0
  12. package/dist/models/index.js +1 -0
  13. package/dist/models/social/Post.js +15 -15
  14. package/dist/services/AuthService.d.ts +11 -10
  15. package/dist/services/AuthService.js +56 -27
  16. package/dist/services/BaseService.d.ts +10 -0
  17. package/dist/services/BaseService.js +27 -0
  18. package/dist/services/BlogService.d.ts +16 -0
  19. package/dist/services/BlogService.js +54 -0
  20. package/dist/services/BotService.d.ts +28 -0
  21. package/dist/services/BotService.js +92 -0
  22. package/dist/services/ForumService.d.ts +19 -0
  23. package/dist/services/ForumService.js +64 -0
  24. package/dist/services/RuleService.d.ts +28 -0
  25. package/dist/services/RuleService.js +90 -0
  26. package/dist/services/ShopService.d.ts +20 -0
  27. package/dist/services/ShopService.js +53 -0
  28. package/dist/services/SocialService.d.ts +8 -7
  29. package/dist/services/SocialService.js +26 -21
  30. package/dist/services/SupportService.d.ts +16 -0
  31. package/dist/services/SupportService.js +54 -0
  32. package/dist/services/UserService.d.ts +12 -7
  33. package/dist/services/UserService.js +35 -18
  34. package/package.json +27 -21
  35. package/src/api/ApiClient.ts +0 -57
  36. package/src/index.ts +0 -24
  37. package/src/models/auth/Role.ts +0 -26
  38. package/src/models/auth/Session.ts +0 -50
  39. package/src/models/auth/User.ts +0 -111
  40. package/src/models/community/Classroom.ts +0 -34
  41. package/src/models/community/Event.ts +0 -32
  42. package/src/models/community/Faculty.ts +0 -30
  43. package/src/models/community/Forum.ts +0 -42
  44. package/src/models/community/Giveaway.ts +0 -39
  45. package/src/models/community/Group.ts +0 -78
  46. package/src/models/community/School.ts +0 -51
  47. package/src/models/community/SchoolTeam.ts +0 -49
  48. package/src/models/community/Station.ts +0 -145
  49. package/src/models/community/Survey.ts +0 -53
  50. package/src/models/community/SurveyAnswer.ts +0 -26
  51. package/src/models/community/Team.ts +0 -24
  52. package/src/models/community/Workplace.ts +0 -32
  53. package/src/models/content/Game.ts +0 -39
  54. package/src/models/content/Media.ts +0 -30
  55. package/src/models/content/Mod.ts +0 -38
  56. package/src/models/content/News.ts +0 -43
  57. package/src/models/content/Project.ts +0 -49
  58. package/src/models/core/PlatformStats.ts +0 -74
  59. package/src/models/core/SystemSettings.ts +0 -59
  60. package/src/models/index.ts +0 -37
  61. package/src/models/shop/CartItem.ts +0 -31
  62. package/src/models/shop/Order.ts +0 -48
  63. package/src/models/shop/Product.ts +0 -61
  64. package/src/models/social/Chat.ts +0 -47
  65. package/src/models/social/ChatMessage.ts +0 -30
  66. package/src/models/social/Comment.ts +0 -38
  67. package/src/models/social/Group.ts +0 -63
  68. package/src/models/social/Leaderboard.ts +0 -57
  69. package/src/models/social/Note.ts +0 -28
  70. package/src/models/social/Notification.ts +0 -99
  71. package/src/models/social/NotificationSender.ts +0 -36
  72. package/src/models/social/Post.ts +0 -75
  73. package/src/models/social/Story.ts +0 -30
  74. package/src/models/social/SupportTicket.ts +0 -38
  75. package/src/models/store/StoreItem.ts +0 -32
  76. package/src/services/AuthService.ts +0 -91
  77. package/src/services/SocialService.ts +0 -92
  78. package/src/services/SocketService.ts +0 -112
  79. package/src/services/UserService.ts +0 -69
  80. package/src/types/stats.ts +0 -17
  81. package/tsconfig.json +0 -16
@@ -1,48 +0,0 @@
1
- import { CartItem } from './CartItem';
2
-
3
- export type OrderStatus = 'pending' | 'completed' | 'canceled' | 'shipped';
4
-
5
- export class Order {
6
- id: string;
7
- items: CartItem[];
8
- total: number;
9
- status: OrderStatus;
10
- createdAt: number;
11
- paymentMethod: 'credit_card' | 'armoyu_coin' | 'paypal';
12
-
13
- constructor(data: Partial<Order>) {
14
- this.id = data.id || '';
15
- this.items = data.items || [];
16
- this.total = data.total || 0;
17
- this.status = data.status || 'pending';
18
- this.createdAt = data.createdAt || Date.now();
19
- this.paymentMethod = data.paymentMethod || 'credit_card';
20
- }
21
-
22
- /**
23
- * Static factory to create an Order instance from JSON.
24
- */
25
- static fromJSON(json: any): Order {
26
- return new Order({
27
- id: json.id || '',
28
- items: Array.isArray(json.items) ? json.items.map((i: any) => CartItem.fromJSON(i)) : [],
29
- total: json.total || json.total_amount || 0,
30
- status: (json.status || 'pending') as OrderStatus,
31
- createdAt: json.createdAt || json.created_at || Date.now(),
32
- paymentMethod: (json.paymentMethod || json.payment_method || 'credit_card') as 'credit_card' | 'armoyu_coin' | 'paypal'
33
- });
34
- }
35
-
36
- /**
37
- * Returns a user-friendly status name in Turkish.
38
- */
39
- getStatusLabel(): string {
40
- switch (this.status) {
41
- case 'pending': return 'Hazırlanıyor';
42
- case 'completed': return 'Tamamlandı';
43
- case 'shipped': return 'Kargoya Verildi';
44
- case 'canceled': return 'İptal Edildi';
45
- default: return this.status;
46
- }
47
- }
48
- }
@@ -1,61 +0,0 @@
1
- export class Product {
2
- id: string;
3
- name: string;
4
- description: string;
5
- price: number;
6
- discountPrice?: number;
7
- image: string;
8
- category: string;
9
- stock: number;
10
- tags?: string[];
11
- isFeatured: boolean = false;
12
- badge?: string;
13
-
14
- constructor(data: Partial<Product>) {
15
- this.id = data.id || '';
16
- this.name = data.name || '';
17
- this.description = data.description || '';
18
- this.price = data.price || 0;
19
- this.discountPrice = data.discountPrice;
20
- this.image = data.image || '';
21
- this.category = data.category || '';
22
- this.stock = data.stock || 0;
23
- this.tags = data.tags || [];
24
- this.isFeatured = data.isFeatured || false;
25
- this.badge = data.badge;
26
- }
27
-
28
- /**
29
- * Helper to get the display price (discounted if available)
30
- */
31
- getDisplayPrice(): number {
32
- return this.discountPrice && this.discountPrice < this.price
33
- ? this.discountPrice
34
- : this.price;
35
- }
36
-
37
- static fromJSON(json: any): Product {
38
- const parsePrice = (p: any): number => {
39
- if (typeof p === 'number') return p;
40
- if (typeof p === 'string') {
41
- const cleaned = p.replace(/[₺,]/g, '').replace(' ', '');
42
- return parseFloat(cleaned) || 0;
43
- }
44
- return 0;
45
- };
46
-
47
- return new Product({
48
- id: json.id || '',
49
- name: json.name || json.product_name || '',
50
- description: json.description || json.desc || '',
51
- price: parsePrice(json.price),
52
- discountPrice: json.discountPrice !== undefined ? parsePrice(json.discountPrice) : undefined,
53
- image: json.image || json.img_url || '',
54
- category: json.category || 'Genel',
55
- stock: json.stock || 0,
56
- tags: json.tags || [],
57
- isFeatured: json.isFeatured || json.is_featured || false,
58
- badge: json.badge
59
- });
60
- }
61
- }
@@ -1,47 +0,0 @@
1
- import { User } from '../auth/User';
2
- import { ChatMessage } from './ChatMessage';
3
-
4
- /**
5
- * Represents a Chat conversation or summary.
6
- */
7
- export class Chat {
8
- id: string = '';
9
- participants: User[] = [];
10
- name: string = '';
11
- avatar: string = '';
12
- lastMessage: ChatMessage | null = null;
13
- time: string = '';
14
- unreadCount: number = 0;
15
- isOnline: boolean = false;
16
- lastSeen: string = '';
17
- updatedAt: number = 0;
18
- isGroup: boolean = false;
19
- isFavorite: boolean = false;
20
- messages: ChatMessage[] = [];
21
-
22
- constructor(data: Partial<Chat>) {
23
- Object.assign(this, data);
24
- }
25
-
26
- /**
27
- * Instantiates a Chat object from a JSON object.
28
- */
29
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
- static fromJSON(json: Record<string, any>): Chat {
31
- return new Chat({
32
- id: json.id || '',
33
- participants: Array.isArray(json.participants) ? json.participants.map((p: Record<string, any>) => User.fromJSON(p)) : [],
34
- name: json.name || '',
35
- avatar: json.avatar || '',
36
- lastMessage: json.lastMessage ? ChatMessage.fromJSON(json.lastMessage) : (json.last_message ? ChatMessage.fromJSON(json.last_message) : null),
37
- time: json.time || '',
38
- unreadCount: json.unreadCount || json.unread_count || 0,
39
- isOnline: json.isOnline || json.is_online || false,
40
- lastSeen: json.lastSeen || json.last_seen || '',
41
- updatedAt: json.updatedAt || json.updated_at || 0,
42
- isGroup: json.isGroup || json.is_group || false,
43
- isFavorite: json.isFavorite || json.is_favorite || false,
44
- messages: Array.isArray(json.messages) ? json.messages.map((m: any) => ChatMessage.fromJSON(m)) : [],
45
- });
46
- }
47
- }
@@ -1,30 +0,0 @@
1
- import { User } from '../auth/User';
2
-
3
- /**
4
- * Represents a single message in a Chat.
5
- */
6
- export class ChatMessage {
7
- id: string = '';
8
- sender: User | null = null;
9
- content: string = '';
10
- timestamp: string = '';
11
- isSystem: boolean = false;
12
-
13
- constructor(data: Partial<ChatMessage>) {
14
- Object.assign(this, data);
15
- }
16
-
17
- /**
18
- * Instantiates a ChatMessage object from a JSON object.
19
- */
20
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
- static fromJSON(json: Record<string, any>): ChatMessage {
22
- return new ChatMessage({
23
- id: json.id || '',
24
- sender: json.sender ? User.fromJSON(json.sender) : (json.sender_name ? new User({ displayName: json.sender_name }) : null),
25
- content: json.content || json.text || '',
26
- timestamp: json.timestamp || json.time || '',
27
- isSystem: json.isSystem || json.is_system || false,
28
- });
29
- }
30
- }
@@ -1,38 +0,0 @@
1
- import { User } from '../auth/User';
2
-
3
- /**
4
- * Represents a Comment (Yorum) in the aramizdakioyuncu.com platform.
5
- */
6
- export class Comment {
7
- id: string = '';
8
- author: User | null = null;
9
- text: string = '';
10
- date: string = '';
11
- replies: Comment[] = [];
12
-
13
- constructor(data: Partial<Comment>) {
14
- Object.assign(this, data);
15
- }
16
-
17
- /**
18
- * Adds a reply to the comment.
19
- */
20
- addReply(reply: Comment): void {
21
- this.replies.push(reply);
22
- }
23
-
24
- /**
25
- * Instantiates a Comment object from a JSON object.
26
- */
27
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
- static fromJSON(json: Record<string, any>): Comment {
29
- return new Comment({
30
- id: json.id || '',
31
- author: json.user ? User.fromJSON(json.user) : (json.author_name ? new User({ displayName: json.author_name }) : null),
32
- text: json.text || json.comment || '',
33
- date: json.date || json.created_at || '',
34
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
35
- replies: Array.isArray(json.replies) ? json.replies.map((r: any) => Comment.fromJSON(r)) : [],
36
- });
37
- }
38
- }
@@ -1,63 +0,0 @@
1
- import { User } from '../auth/User';
2
-
3
- /**
4
- * Represents a Group/Community/Guild in the aramizdakioyuncu.com platform.
5
- */
6
- export class Group {
7
- id: string = '';
8
- name: string = '';
9
- shortName: string = '';
10
- slug: string = '';
11
- description: string = '';
12
- avatar: string = ''; // Keep for backward compatibility
13
- logo: string = '';
14
- banner: string = '';
15
- coverImage: string = ''; // Keep for backward compatibility
16
- memberCount: number = 0;
17
- isPrivate: boolean = false;
18
- category: string = '';
19
- tag: string = '';
20
- recruitment: string = 'Açık';
21
- date: string = '';
22
- owner: User | null = null;
23
- moderators: User[] = [];
24
- members: User[] = [];
25
- permissions: string[] = [];
26
-
27
- constructor(data: Partial<Group>) {
28
- Object.assign(this, data);
29
- if (!this.slug && this.name) {
30
- this.slug = this.name.toLowerCase().replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, '');
31
- }
32
- if (!this.logo && this.avatar) this.logo = this.avatar;
33
- if (!this.banner && this.coverImage) this.banner = this.coverImage;
34
- }
35
-
36
- /**
37
- * Instantiates a Group object from a JSON object.
38
- */
39
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
40
- static fromJSON(json: Record<string, any>): Group {
41
- return new Group({
42
- id: json.id || '',
43
- name: json.name || '',
44
- shortName: json.shortName || json.tag || '',
45
- slug: json.slug || '',
46
- description: json.description || '',
47
- avatar: json.avatar || '',
48
- logo: json.logo || json.avatar || '',
49
- banner: json.banner || json.coverImage || json.cover_image || '',
50
- coverImage: json.coverImage || json.cover_image || '',
51
- memberCount: json.memberCount || json.member_count || 0,
52
- isPrivate: json.isPrivate || json.is_private || false,
53
- category: json.category || '',
54
- tag: json.tag || '',
55
- recruitment: json.recruitment || 'Açık',
56
- date: json.date || '',
57
- owner: json.owner ? User.fromJSON(json.owner) : null,
58
- moderators: Array.isArray(json.moderators) ? json.moderators.map((m: any) => User.fromJSON(m)) : [],
59
- members: Array.isArray(json.members) ? json.members.map((m: any) => User.fromJSON(m)) : [],
60
- permissions: Array.isArray(json.permissions) ? json.permissions : [],
61
- });
62
- }
63
- }
@@ -1,57 +0,0 @@
1
- import { User } from '../auth/User';
2
-
3
- /**
4
- * Represents an entry in a leaderboard/ranking list.
5
- */
6
- export class LeaderboardEntry {
7
- displayName: string = '';
8
- username: string = '';
9
- score: string = '';
10
- avatar: string = '';
11
-
12
- constructor(data: Partial<LeaderboardEntry>) {
13
- Object.assign(this, data);
14
- }
15
- }
16
-
17
- /**
18
- * Utility class to manage and generate various leaderboards across the platform.
19
- */
20
- export class Leaderboard {
21
- /**
22
- * Generates a level-based ranking from a list of users.
23
- */
24
- static getLevelRankings(users: User[], limit: number = 5): LeaderboardEntry[] {
25
- return [...users]
26
- .sort((a, b) => (b.level || 0) - (a.level || 0) || (b.xp || 0) - (a.xp || 0))
27
- .slice(0, limit)
28
- .map(user => new LeaderboardEntry({
29
- displayName: user.displayName || user.username,
30
- username: user.username,
31
- score: `LVL ${user.level || 1}`,
32
- avatar: user.avatar
33
- }));
34
- }
35
-
36
- /**
37
- * Generates a popularity-based ranking from a list of users.
38
- */
39
- static getPopularityRankings(users: User[], limit: number = 5): LeaderboardEntry[] {
40
- return [...users]
41
- .sort((a, b) => (b.popScore || 0) - (a.popScore || 0))
42
- .slice(0, limit)
43
- .map(user => {
44
- const score = user.popScore || 0;
45
- const formattedScore = score >= 1000
46
- ? (score / 1000).toFixed(1) + 'k'
47
- : score.toString();
48
-
49
- return new LeaderboardEntry({
50
- displayName: user.displayName || user.username,
51
- username: user.username,
52
- score: formattedScore,
53
- avatar: user.avatar
54
- });
55
- });
56
- }
57
- }
@@ -1,28 +0,0 @@
1
- import { User } from '../auth/User';
2
-
3
- /**
4
- * Represents a "Note" (Instagram-style status bubble) in the aramizdakioyuncu.com platform.
5
- */
6
- export class Note {
7
- id: string = '';
8
- user: User | null = null;
9
- note: string = '';
10
- isMe: boolean = false;
11
-
12
- constructor(data: Partial<Note>) {
13
- Object.assign(this, data);
14
- }
15
-
16
- /**
17
- * Instantiates a Note object from a JSON object.
18
- */
19
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
- static fromJSON(json: Record<string, any>): Note {
21
- return new Note({
22
- id: json.id || '',
23
- user: json.user ? User.fromJSON(json.user) : null,
24
- note: json.note || '',
25
- isMe: json.isMe || false,
26
- });
27
- }
28
- }
@@ -1,99 +0,0 @@
1
- import { User } from '../auth/User';
2
- import { Group } from '../community/Group';
3
- import { Post } from './Post';
4
- import { NotificationSender, NotificationType, NotificationCategory } from './NotificationSender';
5
-
6
- /**
7
- * Represents a Notification in the aramizdakioyuncu.com platform.
8
- */
9
- export class Notification {
10
- id: string = '';
11
- type: NotificationType = 'SYSTEM_ALERT';
12
- category: NotificationCategory = 'SYSTEM';
13
- title: string = '';
14
- message: string = '';
15
- context: string = ''; // Detailed context (snippet of comment, etc)
16
- sender?: NotificationSender;
17
- link: string = '';
18
- isRead: boolean = false;
19
- isClickable: boolean = true; // New property
20
- createdAt: string = '';
21
-
22
- // Direct Associated IDs (Legacy supporting)
23
- postId?: string;
24
- commentId?: string;
25
- eventId?: string;
26
- groupId?: string;
27
-
28
- // Rich Objects (OO approach)
29
- group?: Group;
30
- post?: Post;
31
- // event?: Event; // Add when Event is ready
32
-
33
- constructor(data: Partial<Notification>) {
34
- Object.assign(this, data);
35
-
36
- // 1. Sync from Post object if exists
37
- if (this.post) {
38
- this.postId = this.post.id;
39
- if (!this.context) {
40
- // Create context snippet from post content
41
- this.context = this.post.content.length > 50
42
- ? this.post.content.substring(0, 47) + '...'
43
- : this.post.content;
44
- }
45
- }
46
-
47
- // 2. Auto-generate link from objects (OO)
48
- if (!this.link) {
49
- if (this.group) {
50
- this.link = this.group.getGroupUrl();
51
- } else if (this.groupId) {
52
- // Fallback for ID strings
53
- const targetSlug = this.groupId.toLowerCase().replace(/\s+/g, '-');
54
- this.link = `/gruplar/${targetSlug}`;
55
- } else if (this.postId) {
56
- this.link = `/?post=${this.postId}`;
57
- } else if (this.sender?.url) {
58
- this.link = this.sender.url;
59
- }
60
- }
61
-
62
- // 3. Sync title/metadata if missing but object exists
63
- if (!this.title && this.group && this.type === 'GROUP_INVITE') {
64
- this.title = 'Grup Daveti';
65
- this.message = `${this.group.name} grubuna davet edildin.`;
66
- }
67
-
68
- // Default to system sender if not provided for system notifications
69
- if (this.category === 'SYSTEM') {
70
- if (!this.sender) this.sender = NotificationSender.system();
71
- this.isClickable = false;
72
- this.link = ''; // System messages shouldn't have links usually
73
- }
74
- }
75
-
76
- /**
77
- * Instantiates a Notification object from a JSON object.
78
- */
79
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
80
- static fromJSON(json: Record<string, any>): Notification {
81
- return new Notification({
82
- id: json.id || '',
83
- type: json.type || 'SYSTEM_ALERT',
84
- category: json.category || 'SYSTEM',
85
- title: json.title || '',
86
- message: json.message || '',
87
- context: json.context || '',
88
- sender: json.sender ? new NotificationSender(json.sender) : undefined,
89
- link: json.link || '',
90
- isRead: json.isRead || false,
91
- createdAt: json.createdAt || json.created_at || '',
92
- postId: json.postId || json.post_id,
93
- commentId: json.commentId || json.comment_id,
94
- eventId: json.eventId || json.event_id,
95
- groupId: json.groupId || json.group_id,
96
- group: json.group ? Group.fromJSON(json.group) : undefined,
97
- });
98
- }
99
- }
@@ -1,36 +0,0 @@
1
- export type NotificationType =
2
- | 'POST_LIKE' | 'POST_COMMENT' | 'POST_MENTION'
3
- | 'GROUP_INVITE' | 'GROUP_JOIN_REQUEST' | 'GROUP_ANNOUNCEMENT'
4
- | 'EVENT_INVITE' | 'EVENT_REMINDER'
5
- | 'FRIEND_REQUEST' | 'FRIEND_ACCEPT'
6
- | 'SYSTEM_ALERT' | 'SYSTEM_UPDATE';
7
-
8
- export type NotificationCategory = 'SOCIAL' | 'GROUP' | 'EVENT' | 'SYSTEM';
9
- export type SenderType = 'USER' | 'GROUP' | 'SYSTEM';
10
-
11
- /**
12
- * Interface representing a standardized sender for notifications.
13
- */
14
- export class NotificationSender {
15
- id: string = '';
16
- name: string = '';
17
- avatar: string = '';
18
- type: SenderType = 'SYSTEM';
19
- url?: string;
20
-
21
- constructor(data: Partial<NotificationSender>) {
22
- Object.assign(this, data);
23
- }
24
-
25
- /**
26
- * Helper to create a system sender.
27
- */
28
- static system(): NotificationSender {
29
- return new NotificationSender({
30
- id: 'system',
31
- name: 'ARMOYU',
32
- avatar: 'https://armoyu.com/assets/img/armoyu_logo.png',
33
- type: 'SYSTEM'
34
- });
35
- }
36
- }
@@ -1,75 +0,0 @@
1
- import { User } from '../auth/User';
2
-
3
- export interface PostMedia {
4
- type: 'image' | 'video';
5
- url: string;
6
- }
7
-
8
- export interface PostStats {
9
- likes: number;
10
- comments: number;
11
- reposts: number;
12
- shares: number;
13
- }
14
-
15
- export interface PostComment {
16
- id: string;
17
- author: User;
18
- content: string;
19
- createdAt: string;
20
- likes?: number;
21
- replies?: PostComment[];
22
- }
23
-
24
- /**
25
- * Represents a Post (Gönderi/Paylaşım) in the aramizdakioyuncu.com platform.
26
- */
27
- export class Post {
28
- id: string = '';
29
- author: User | null = null;
30
- content: string = '';
31
- media: PostMedia[] = [];
32
- createdAt: string = '';
33
- stats: PostStats = { likes: 0, comments: 0, reposts: 0, shares: 0 };
34
- hashtags: string[] = [];
35
- isPending: boolean = false;
36
- repostOf?: Post; // Original post if this is a repost
37
-
38
- // Real-time Lists
39
- likeList: User[] = [];
40
- repostList: User[] = [];
41
- commentList: PostComment[] = [];
42
-
43
- constructor(data: Partial<Post>) {
44
- Object.assign(this, data);
45
- }
46
-
47
- /**
48
- * Instantiates a Post object from a JSON object.
49
- */
50
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
51
- static fromJSON(json: Record<string, any>): Post {
52
- return new Post({
53
- id: json.id || '',
54
- author: json.author ? User.fromJSON(json.author) : null,
55
- content: json.content || '',
56
- media: Array.isArray(json.media) ? json.media : (json.imageUrl ? [{ type: 'image', url: json.imageUrl }] : []),
57
- createdAt: json.createdAt || json.created_at || '',
58
- stats: json.stats || {
59
- likes: json.likeCount || 0,
60
- comments: json.commentCount || 0,
61
- reposts: json.repostCount || 0,
62
- shares: json.shareCount || 0,
63
- },
64
- hashtags: json.hashtags || [],
65
- likeList: Array.isArray(json.likeList) ? json.likeList.map(User.fromJSON) : [],
66
- repostList: Array.isArray(json.repostList) ? json.repostList.map(User.fromJSON) : [],
67
- commentList: Array.isArray(json.commentList) ? json.commentList.map((c: any) => ({
68
- ...c,
69
- author: User.fromJSON(c.author),
70
- replies: Array.isArray(c.replies) ? c.replies.map((r: any) => ({ ...r, author: User.fromJSON(r.author) })) : []
71
- })) : [],
72
- repostOf: json.repostOf ? Post.fromJSON(json.repostOf) : undefined
73
- });
74
- }
75
- }
@@ -1,30 +0,0 @@
1
- import { User } from '../auth/User';
2
-
3
- /**
4
- * Represents a Story in the aramizdakioyuncu.com platform.
5
- */
6
- export class Story {
7
- id: string = '';
8
- user: User | null = null;
9
- media: string = '';
10
- hasUnseen: boolean = false;
11
- isMe: boolean = false;
12
-
13
- constructor(data: Partial<Story>) {
14
- Object.assign(this, data);
15
- }
16
-
17
- /**
18
- * Instantiates a Story object from a JSON object.
19
- */
20
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
- static fromJSON(json: Record<string, any>): Story {
22
- return new Story({
23
- id: json.id || '',
24
- user: json.user ? User.fromJSON(json.user) : (json.username ? new User({ username: json.username, avatar: json.avatar }) : null),
25
- media: json.media || '',
26
- hasUnseen: json.hasUnseen || false,
27
- isMe: json.isMe || false,
28
- });
29
- }
30
- }
@@ -1,38 +0,0 @@
1
- import { User } from '../auth/User';
2
-
3
- /**
4
- * Represents a Support Ticket in the armoyu platform.
5
- */
6
- export class SupportTicket {
7
- id: string = '';
8
- subject: string = '';
9
- category: string = 'Genel'; // Şikayet, Öneri, Bildiri
10
- status: string = 'Açık'; // Açık, Cevaplandı, Kapandı
11
- priority: string = 'Normal'; // Düşük, Normal, Yüksek
12
- createdAt: string = '';
13
- updatedAt: string = '';
14
- lastMessage: string = '';
15
- author?: User;
16
-
17
- constructor(data: Partial<SupportTicket>) {
18
- Object.assign(this, data);
19
- }
20
-
21
- /**
22
- * Instantiates a SupportTicket object from a JSON object.
23
- */
24
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
- static fromJSON(json: Record<string, any>): SupportTicket {
26
- return new SupportTicket({
27
- id: json.id || '',
28
- subject: json.subject || '',
29
- category: json.category || 'Genel',
30
- status: json.status || 'Açık',
31
- priority: json.priority || 'Normal',
32
- createdAt: json.createdAt || json.created_at || '',
33
- updatedAt: json.updatedAt || json.updated_at || '',
34
- lastMessage: json.lastMessage || json.last_message || '',
35
- author: json.author ? User.fromJSON(json.author) : undefined,
36
- });
37
- }
38
- }