diff --git a/Sources/Swiftagram/Endpoints/Archive/Endpoint+Archive.swift b/Sources/Swiftagram/Endpoints/Archive/Endpoint+Archive.swift index 2cd80e9b..a48d2228 100644 --- a/Sources/Swiftagram/Endpoints/Archive/Endpoint+Archive.swift +++ b/Sources/Swiftagram/Endpoints/Archive/Endpoint+Archive.swift @@ -8,8 +8,8 @@ import Foundation public extension Endpoint.Group { - /// A `struct` defining `archive` endpoints. - struct Archive { } + /// A `class` defining `archive` endpoints. + final class Archive { } } public extension Endpoint { diff --git a/Sources/Swiftagram/Endpoints/Direct/Endpoint+Conversation.swift b/Sources/Swiftagram/Endpoints/Direct/Endpoint+Conversation.swift index af3b6d27..03528d57 100644 --- a/Sources/Swiftagram/Endpoints/Direct/Endpoint+Conversation.swift +++ b/Sources/Swiftagram/Endpoints/Direct/Endpoint+Conversation.swift @@ -8,10 +8,17 @@ import Foundation public extension Endpoint.Group.Direct { - /// A `struct` defining a wrapper for a specific conversation. - struct Conversation { + /// A `class` defining a wrapper for a specific conversation. + final class Conversation { /// The identifier. public let identifier: String + + /// Init. + /// + /// - parameter identifier: A valid `String`. + init(identifier: String) { + self.identifier = identifier + } } /// A wrapper for conversation endpoints. diff --git a/Sources/Swiftagram/Endpoints/Direct/Endpoint+ConversationRequest.swift b/Sources/Swiftagram/Endpoints/Direct/Endpoint+ConversationRequest.swift index f0411a82..8c2372ce 100644 --- a/Sources/Swiftagram/Endpoints/Direct/Endpoint+ConversationRequest.swift +++ b/Sources/Swiftagram/Endpoints/Direct/Endpoint+ConversationRequest.swift @@ -8,10 +8,17 @@ import Foundation public extension Endpoint.Group.Direct.Conversation { - /// A `struct` defining a wrapper for a conversation request. - struct Request { + /// A `class` defining a wrapper for a conversation request. + final class Request { /// The conversation. public let conversation: Endpoint.Group.Direct.Conversation + + /// Init. + /// + /// - parameter conversation: A valid `Endpoint.Group.Direct.Conversation`. + init(conversation: Endpoint.Group.Direct.Conversation) { + self.conversation = conversation + } } /// A wrapper for request endpoints. diff --git a/Sources/Swiftagram/Endpoints/Direct/Endpoint+Direct.swift b/Sources/Swiftagram/Endpoints/Direct/Endpoint+Direct.swift index 568cae50..e8f3377d 100644 --- a/Sources/Swiftagram/Endpoints/Direct/Endpoint+Direct.swift +++ b/Sources/Swiftagram/Endpoints/Direct/Endpoint+Direct.swift @@ -8,8 +8,8 @@ import Foundation public extension Endpoint.Group { - /// A `struct` defining `direct_v2` endpoints. - struct Direct { } + /// A `class` defining `direct_v2` endpoints. + final class Direct { } } public extension Endpoint { diff --git a/Sources/Swiftagram/Endpoints/Direct/Endpoint+Message.swift b/Sources/Swiftagram/Endpoints/Direct/Endpoint+Message.swift index a6d6385a..fb38377c 100644 --- a/Sources/Swiftagram/Endpoints/Direct/Endpoint+Message.swift +++ b/Sources/Swiftagram/Endpoints/Direct/Endpoint+Message.swift @@ -8,12 +8,23 @@ import Foundation public extension Endpoint.Group.Direct.Conversation { - /// A `struct` defining a wrapper for a specific message. - struct Message { + /// A `class` defining a wrapper for a specific message. + final class Message { /// The conversation. public let conversation: Endpoint.Group.Direct.Conversation /// The identifier. public let identifier: String + + /// Init. + /// + /// - parameters: + /// - conversation: A valid `Endpoint.Group.Direct.Conversation`. + /// - identifier: A valid `String`. + init(conversation: Endpoint.Group.Direct.Conversation, + identifier: String) { + self.conversation = conversation + self.identifier = identifier + } } /// A wrapper for message endpoints. diff --git a/Sources/Swiftagram/Endpoints/EndpointMedia.swift b/Sources/Swiftagram/Endpoints/EndpointMedia.swift deleted file mode 100644 index 5d10bd8b..00000000 --- a/Sources/Swiftagram/Endpoints/EndpointMedia.swift +++ /dev/null @@ -1,18 +0,0 @@ -// -// EndpointMedia.swift -// Swiftagram -// -// Created by Stefano Bertagno on 14/03/2020. -// - -import Foundation - -public extension Endpoint { - /// A module-like `enum` holding reference to `media` `Endpoint`s. Requires authentication. - enum Media { - /// The base endpoint. - static let base = Request.version1.media.appendingDefaultHeader() - - public enum Posts { } - } -} diff --git a/Sources/Swiftagram/Endpoints/Explore/Endpoint+Explore.swift b/Sources/Swiftagram/Endpoints/Explore/Endpoint+Explore.swift index 1f57b045..03eb510a 100644 --- a/Sources/Swiftagram/Endpoints/Explore/Endpoint+Explore.swift +++ b/Sources/Swiftagram/Endpoints/Explore/Endpoint+Explore.swift @@ -9,7 +9,7 @@ import Foundation public extension Endpoint.Group { /// A `struct` defining `explore` endpoints. - struct Explore { } + final class Explore { } } public extension Endpoint { diff --git a/Sources/Swiftagram/Endpoints/Location/Endpoint+Location.swift b/Sources/Swiftagram/Endpoints/Location/Endpoint+Location.swift index d3834de7..eb9f995e 100644 --- a/Sources/Swiftagram/Endpoints/Location/Endpoint+Location.swift +++ b/Sources/Swiftagram/Endpoints/Location/Endpoint+Location.swift @@ -8,10 +8,17 @@ import Foundation public extension Endpoint.Group { - /// A `struct` defining location endpoints. - struct Location { + /// A `class` defining location endpoints. + final class Location { /// The location identifier. public let identifier: String + + /// Init. + /// + /// - parameter identifier: A valid `String`. + init(identifier: String) { + self.identifier = identifier + } } } diff --git a/Sources/Swiftagram/Endpoints/Media/Endpoint+Comment.swift b/Sources/Swiftagram/Endpoints/Media/Endpoint+Comment.swift index d9ac4330..ec4f35ce 100644 --- a/Sources/Swiftagram/Endpoints/Media/Endpoint+Comment.swift +++ b/Sources/Swiftagram/Endpoints/Media/Endpoint+Comment.swift @@ -8,12 +8,23 @@ import Foundation public extension Endpoint.Group.Media { - /// A `struct` defining comment endpoints. - struct Comment { + /// A `class` defining comment endpoints. + final class Comment { /// The media. public let media: Endpoint.Group.Media /// The comment identifier. public let identifier: String + + /// Init. + /// + /// - parameters: + /// - media: A valid `Endpoint.Group.Media`. + /// - identifier: A valid `String`. + init(media: Endpoint.Group.Media, + identifier: String) { + self.media = media + self.identifier = identifier + } } /// A wrapper for comments endpoints. diff --git a/Sources/Swiftagram/Endpoints/Media/Endpoint+ManyComments.swift b/Sources/Swiftagram/Endpoints/Media/Endpoint+ManyComments.swift index a175a214..7d205b34 100644 --- a/Sources/Swiftagram/Endpoints/Media/Endpoint+ManyComments.swift +++ b/Sources/Swiftagram/Endpoints/Media/Endpoint+ManyComments.swift @@ -8,12 +8,23 @@ import Foundation public extension Endpoint.Group.Media { - /// A `struct` defining multiple comments endpoints. - struct ManyComments { + /// A `class` defining multiple comments endpoints. + final class ManyComments { /// The media. public let media: Endpoint.Group.Media /// A list of comment identifiers. public let identifiers: [String] + + /// Init. + /// + /// - parameters: + /// - media: A valid `Endpoint.Group.Media`. + /// - identifiers: An array of `String`s. + init(media: Endpoint.Group.Media, + identifiers: [String]) { + self.media = media + self.identifiers = identifiers + } } /// A wrapper for comments-specific endpoints. diff --git a/Sources/Swiftagram/Endpoints/Media/Endpoint+Media.swift b/Sources/Swiftagram/Endpoints/Media/Endpoint+Media.swift index 8257828a..ba2dce59 100644 --- a/Sources/Swiftagram/Endpoints/Media/Endpoint+Media.swift +++ b/Sources/Swiftagram/Endpoints/Media/Endpoint+Media.swift @@ -8,10 +8,17 @@ import Foundation public extension Endpoint.Group { - /// A `struct` defining media endpoints. - struct Media { + /// A `class` defining media endpoints. + final class Media { /// The media identifier. public let identifier: String + + /// Init. + /// + /// - parameter identifier: A valid `String`. + init(identifier: String) { + self.identifier = identifier + } } } diff --git a/Sources/Swiftagram/Endpoints/Posts/Endpoint+Posts.swift b/Sources/Swiftagram/Endpoints/Posts/Endpoint+Posts.swift index 78ee35f2..146ca84d 100644 --- a/Sources/Swiftagram/Endpoints/Posts/Endpoint+Posts.swift +++ b/Sources/Swiftagram/Endpoints/Posts/Endpoint+Posts.swift @@ -8,8 +8,8 @@ import Foundation public extension Endpoint.Group { - /// A `struct` defining posts-related endpoints. - struct Posts { } + /// A `class` defining posts-related endpoints. + final class Posts { } } public extension Endpoint { diff --git a/Sources/Swiftagram/Endpoints/Recent/Endpoint+Recent.swift b/Sources/Swiftagram/Endpoints/Recent/Endpoint+Recent.swift index fdcf83e9..0834ae5c 100644 --- a/Sources/Swiftagram/Endpoints/Recent/Endpoint+Recent.swift +++ b/Sources/Swiftagram/Endpoints/Recent/Endpoint+Recent.swift @@ -8,8 +8,8 @@ import Foundation public extension Endpoint.Group { - /// A `struct` defining a recent wrapper. - struct Recent { } + /// A `class` defining a recent wrapper. + final class Recent { } } public extension Endpoint { diff --git a/Sources/Swiftagram/Endpoints/Stories/Endpoint+Stories.swift b/Sources/Swiftagram/Endpoints/Stories/Endpoint+Stories.swift index ef8e8bf8..87359d95 100644 --- a/Sources/Swiftagram/Endpoints/Stories/Endpoint+Stories.swift +++ b/Sources/Swiftagram/Endpoints/Stories/Endpoint+Stories.swift @@ -8,8 +8,8 @@ import Foundation public extension Endpoint.Group { - /// A `struct` defining stories-related endpoints. - struct Stories { } + /// A `class` defining stories-related endpoints. + final class Stories { } } public extension Endpoint { diff --git a/Sources/Swiftagram/Endpoints/Tag/Endpoint+Tag.swift b/Sources/Swiftagram/Endpoints/Tag/Endpoint+Tag.swift index 7bd0a141..0458e09b 100644 --- a/Sources/Swiftagram/Endpoints/Tag/Endpoint+Tag.swift +++ b/Sources/Swiftagram/Endpoints/Tag/Endpoint+Tag.swift @@ -8,10 +8,17 @@ import Foundation public extension Endpoint.Group { - /// A `struct` defining tag endpoints. - struct Tag { + /// A `class` defining tag endpoints. + final class Tag { /// The tag name. public let name: String + + /// Init. + /// + /// - parameter name: A valid `String`. + init(name: String) { + self.name = name + } } } diff --git a/Sources/Swiftagram/Endpoints/User/Endpoint+ManyUsers.swift b/Sources/Swiftagram/Endpoints/User/Endpoint+ManyUsers.swift index 50c7d827..333f6df1 100644 --- a/Sources/Swiftagram/Endpoints/User/Endpoint+ManyUsers.swift +++ b/Sources/Swiftagram/Endpoints/User/Endpoint+ManyUsers.swift @@ -8,10 +8,17 @@ import Foundation public extension Endpoint.Group { - /// A `struct` defining users-related endpoints. - struct ManyUsers { + /// A `class` defining users-related endpoints. + final class ManyUsers { /// The user identifiers. public let identifiers: [String] + + /// Init. + /// + /// - parameter identifiers: An array of `String`s. + init(identifiers: [String]) { + self.identifiers = identifiers + } } } diff --git a/Sources/Swiftagram/Endpoints/User/Endpoint+User.swift b/Sources/Swiftagram/Endpoints/User/Endpoint+User.swift index f775b458..f433bf5e 100644 --- a/Sources/Swiftagram/Endpoints/User/Endpoint+User.swift +++ b/Sources/Swiftagram/Endpoints/User/Endpoint+User.swift @@ -8,10 +8,17 @@ import Foundation public extension Endpoint.Group { - /// A `struct` defining user-related endpoints. - struct User { + /// A `class` defining user-related endpoints. + final class User { /// The user identifier. public let identifier: String + + /// Init. + /// + /// - parameter identifier: A valid `String`. + init(identifier: String) { + self.identifier = identifier + } } } diff --git a/Sources/Swiftagram/Endpoints/User/Endpoint+Users.swift b/Sources/Swiftagram/Endpoints/User/Endpoint+Users.swift index 60fd19ab..d7d30cd4 100644 --- a/Sources/Swiftagram/Endpoints/User/Endpoint+Users.swift +++ b/Sources/Swiftagram/Endpoints/User/Endpoint+Users.swift @@ -8,8 +8,8 @@ import Foundation public extension Endpoint.Group { - /// A `struct` defining users-related endpoints. - struct Users { } + /// A `class` defining users-related endpoints. + final class Users { } } public extension Endpoint { diff --git a/Sources/Swiftagram/Models/Errors/IdentifierError.swift b/Sources/Swiftagram/Models/Errors/IdentifierError.swift deleted file mode 100644 index ba0fbfb3..00000000 --- a/Sources/Swiftagram/Models/Errors/IdentifierError.swift +++ /dev/null @@ -1,19 +0,0 @@ -// -// IdentifierError.swift -// Swiftagram -// -// Created by Stefano Bertagno on 24/02/21. -// - -import Foundation - -public extension Endpoint.Media.Posts { - /// An `enum` listing all identifier-related errors. - enum IdentifierError: Error { - /// The `URL` either does not contain a `p` directory, - /// or it's in last position. - case invalidURL(URL) - /// The shortcode contains invalid characters. - case invalidShortcode(String) - } -} diff --git a/Sources/SwiftagramCrypto/Endpoints/Endpoint+Media.swift b/Sources/SwiftagramCrypto/Endpoints/Endpoint+Media.swift index 841ae894..31b2bb68 100644 --- a/Sources/SwiftagramCrypto/Endpoints/Endpoint+Media.swift +++ b/Sources/SwiftagramCrypto/Endpoints/Endpoint+Media.swift @@ -77,7 +77,7 @@ public extension Endpoint.Group.Media { .header(appending: secret.header) .signing(body: [ "igtv_feed_preview": false.wrapped, - "media_id": identifier.wrapped, + "media_id": self.identifier.wrapped, "_csrftoken": secret["csrftoken"]!.wrapped, "_uid": secret.identifier.wrapped, "_uuid": secret.client.device.identifier.uuidString.wrapped @@ -131,7 +131,7 @@ extension Endpoint.Group.Media { "_uid": secret.identifier, "device_id": secret.client.device.instagramIdentifier, "_uuid": secret.client.device.identifier.uuidString, - "media_id": identifier]) + "media_id": self.identifier]) .publish(with: session) .map(\.data) .wrap()