> ## Documentation Index
> Fetch the complete documentation index at: https://docs.contactsmanager.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Social Event

> Events shared by users in the ContactsManager SDK

# Social Event

The `SocialEvent` model represents a social activity or event shared by users in the ContactsManager ecosystem. Events can represent various types of social interactions, from calendar events to posts, check-ins, and more.

## Properties

### Identifiers

* `id: String` - Unique identifier for the event
* `organizationId: String` - Organization the event belongs to
* `canonicalContactId: String` - Canonical contact ID of event creator
* `userId: String?` - External user ID of event creator

### Event Information

* `eventType: String` - Type of event (e.g., "post", "photo", "activity", "check-in")
* `title: String` - Event title or main content text
* `description: String?` - Optional detailed description or extended content
* `location: String?` - Optional location name or address

### Timing

* `startTime: Date?` - When the event occurred or should be displayed from
* `endTime: Date?` - Optional end time for events with duration

### Visibility

* `isPublic: Bool` - Whether the event is visible in public feeds

### Custom Data

* `metadata: [String: String]?` - Custom data specific to the event type

### Creator

* `createdBy: EventCreator?` - Information about who created the event

### Timestamps

* `createdAt: Date` - When the event was created
* `updatedAt: Date` - When the event was last updated

## Event Types and Metadata Examples

The `eventType` field combined with the `metadata` field allows for flexible event modeling:

### Social Post

```swift theme={null}
// Photo post
let photoMetadata: [String: String] = [
    "imageUrl": "https://example.com/images/beach.jpg",
    "filter": "sunset",
    "width": "1200",
    "height": "800",
    "caption": "Beautiful evening!"
]
```

### Activity Feed Item

```swift theme={null}
// Like activity
let likeMetadata: [String: String] = [
    "actionType": "like",
    "targetUserId": "user123",
    "targetContentId": "post456",
    "emoji": "❤️"
]
```

### Payment or Transaction

```swift theme={null}
// Payment activity
let paymentMetadata: [String: String] = [
    "amount": "25.50",
    "currency": "USD",
    "transactionId": "tx_12345",
    "merchantName": "Coffee Shop",
    "emoji": "☕"
]
```

### Location Check-in

```swift theme={null}
// Location check-in
let checkInMetadata: [String: String] = [
    "latitude": "37.7749",
    "longitude": "-122.4194",
    "venueName": "Golden Gate Park",
    "rating": "5",
    "emoji": "🌉"
]
```

## Usage Example

```swift theme={null}
// Getting event details
func displayEventDetails(eventId: String) async {
    do {
        let event = try await ContactsService.shared.socialService.getEvent(
            eventId: eventId
        )
        
        // Display basic event info
        print("Event: \(event.title)")
        print("Type: \(event.eventType)")
        print("Created by: \(event.createdBy?.name ?? "Unknown")")
        
        if let description = event.description {
            print("Description: \(description)")
        }
        
        if let location = event.location {
            print("Location: \(location)")
        }
        
        if let startTime = event.startTime {
            let formatter = DateFormatter()
            formatter.dateStyle = .medium
            formatter.timeStyle = .short
            print("When: \(formatter.string(from: startTime))")
        }
        
        // Process metadata based on event type
        if let metadata = event.metadata {
            switch event.eventType {
            case "photo", "post":
                if let imageUrl = metadata["imageUrl"] {
                    print("Image: \(imageUrl)")
                }
                
            case "activity":
                if let actionType = metadata["actionType"] {
                    print("Action: \(actionType)")
                }
                
            case "payment":
                if let amount = metadata["amount"], let currency = metadata["currency"] {
                    print("Payment: \(amount) \(currency)")
                }
                
            case "check-in":
                if let venueName = metadata["venueName"] {
                    print("Checked in at: \(venueName)")
                }
                
            default:
                // Display all metadata for other event types
                for (key, value) in metadata {
                    print("\(key): \(value)")
                }
            }
        }
    } catch {
        print("Error retrieving event: \(error.localizedDescription)")
    }
}
```

## Working with Event Feeds

The SDK provides several feed types for accessing events:

* **Following Feed**: Events from users the current user follows
* **"For You" Feed**: Public events from the wider network
* **Upcoming Events**: Events scheduled in the future
* **User Events**: Events created by a specific user

These feeds enable creation of rich social experiences within your app.

## Related Models

* [CanonicalContact](/models/canonical-contact) - Server-side user profile
* [FollowRelationship](/models/follow-relationship) - Connection between users
