Skip to content

Commit

Permalink
Rename CalendarNostrEvent to CalendarListEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
tyiu committed Dec 22, 2023
1 parent 200ddc7 commit 70a72b9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Sources/NostrSDK/EventCreating.swift
Original file line number Diff line number Diff line change
Expand Up @@ -469,17 +469,17 @@ public extension EventCreating {
return try TimeBasedCalendarEvent(content: description, tags: tags, signedBy: keypair)
}

/// Creates a ``CalendarNostrEvent`` (kind 31924), which is a collection of date-based and time-based calendar events.
/// Creates a ``CalendarListEvent`` (kind 31924), which is a collection of date-based and time-based calendar events.
/// - Parameters:
/// - identifier: A unique identifier for the calendar. Can be reused in the future for replacing the calendar. If an identifier is not provided, a ``UUID`` string is used.
/// - title: The title of the calendar.
/// - description: A detailed description of the calendar.
/// - calendarEventsCoordinates: The coordinates to date-based or time-based calendar events that belong to this calendar.
/// - keypair: The Keypair to sign with.
/// - Returns: The signed ``CalendarNostrEvent``.
/// - Returns: The signed ``CalendarListEvent``.
///
/// See [NIP-52](https://github.com/nostr-protocol/nips/blob/master/52.md).
func calendarNostrEvent(withIdentifier identifier: String = UUID().uuidString, title: String, description: String = "", calendarEventsCoordinates: [EventCoordinates], signedBy keypair: Keypair) throws -> CalendarListEvent {
func calendarListEvent(withIdentifier identifier: String = UUID().uuidString, title: String, description: String = "", calendarEventsCoordinates: [EventCoordinates], signedBy keypair: Keypair) throws -> CalendarListEvent {
guard calendarEventsCoordinates.allSatisfy({ $0.kind == .dateBasedCalendarEvent || $0.kind == .timeBasedCalendarEvent }) else {
throw EventCreatingError.invalidInput
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/NostrSDK/Events/Calendars/CalendarListEvent.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// CalendarNostrEvent.swift
// CalendarListEvent.swift
//
//
// Created by Terry Yiu on 12/1/23.
Expand Down
6 changes: 3 additions & 3 deletions Tests/NostrSDKTests/EventCreatingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ final class EventCreatingTests: XCTestCase, EventCreating, EventVerifying, Fixtu
let identifier = "family-calendar"
let title = "Family Calendar"
let description = "All family events."
let calendar = try calendarNostrEvent(withIdentifier: identifier, title: title, description: description, calendarEventsCoordinates: [dateBasedCalendarEventCoordinates, timeBasedCalendarEventCoordinates], signedBy: Keypair.test)
let calendar = try calendarListEvent(withIdentifier: identifier, title: title, description: description, calendarEventsCoordinates: [dateBasedCalendarEventCoordinates, timeBasedCalendarEventCoordinates], signedBy: Keypair.test)

XCTAssertEqual(calendar.identifier, identifier)
XCTAssertEqual(calendar.title, title)
Expand All @@ -584,7 +584,7 @@ final class EventCreatingTests: XCTestCase, EventCreating, EventVerifying, Fixtu
let identifier = "family-calendar"
let title = "Family Calendar"
let description = "All family events."
let calendar = try calendarNostrEvent(withIdentifier: identifier, title: title, description: description, calendarEventsCoordinates: [], signedBy: Keypair.test)
let calendar = try calendarListEvent(withIdentifier: identifier, title: title, description: description, calendarEventsCoordinates: [], signedBy: Keypair.test)

XCTAssertEqual(calendar.identifier, identifier)
XCTAssertEqual(calendar.title, title)
Expand All @@ -600,7 +600,7 @@ final class EventCreatingTests: XCTestCase, EventCreating, EventVerifying, Fixtu
let description = "All family events."
let eventCoordinates = try XCTUnwrap(EventCoordinates(kind: EventKind.textNote, pubkey: Keypair.test.publicKey, identifier: "abc"))

XCTAssertThrowsError(try calendarNostrEvent(withIdentifier: identifier, title: title, description: description, calendarEventsCoordinates: [eventCoordinates], signedBy: Keypair.test))
XCTAssertThrowsError(try calendarListEvent(withIdentifier: identifier, title: title, description: description, calendarEventsCoordinates: [eventCoordinates], signedBy: Keypair.test))
}

func testDateBasedCalendarEventRSVP() throws {
Expand Down

0 comments on commit 70a72b9

Please sign in to comment.