Skip to content

Commit

Permalink
Improve on memory usage
Browse files Browse the repository at this point in the history
  • Loading branch information
sbertix committed Apr 8, 2021
1 parent a126bd1 commit d83f992
Show file tree
Hide file tree
Showing 20 changed files with 117 additions and 72 deletions.
4 changes: 2 additions & 2 deletions Sources/Swiftagram/Endpoints/Archive/Endpoint+Archive.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 9 additions & 2 deletions Sources/Swiftagram/Endpoints/Direct/Endpoint+Conversation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions Sources/Swiftagram/Endpoints/Direct/Endpoint+Direct.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
15 changes: 13 additions & 2 deletions Sources/Swiftagram/Endpoints/Direct/Endpoint+Message.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 0 additions & 18 deletions Sources/Swiftagram/Endpoints/EndpointMedia.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation

public extension Endpoint.Group {
/// A `struct` defining `explore` endpoints.
struct Explore { }
final class Explore { }
}

public extension Endpoint {
Expand Down
11 changes: 9 additions & 2 deletions Sources/Swiftagram/Endpoints/Location/Endpoint+Location.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

Expand Down
15 changes: 13 additions & 2 deletions Sources/Swiftagram/Endpoints/Media/Endpoint+Comment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 13 additions & 2 deletions Sources/Swiftagram/Endpoints/Media/Endpoint+ManyComments.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 9 additions & 2 deletions Sources/Swiftagram/Endpoints/Media/Endpoint+Media.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/Swiftagram/Endpoints/Posts/Endpoint+Posts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions Sources/Swiftagram/Endpoints/Recent/Endpoint+Recent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions Sources/Swiftagram/Endpoints/Stories/Endpoint+Stories.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 9 additions & 2 deletions Sources/Swiftagram/Endpoints/Tag/Endpoint+Tag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

Expand Down
11 changes: 9 additions & 2 deletions Sources/Swiftagram/Endpoints/User/Endpoint+ManyUsers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

Expand Down
11 changes: 9 additions & 2 deletions Sources/Swiftagram/Endpoints/User/Endpoint+User.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/Swiftagram/Endpoints/User/Endpoint+Users.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
19 changes: 0 additions & 19 deletions Sources/Swiftagram/Models/Errors/IdentifierError.swift

This file was deleted.

4 changes: 2 additions & 2 deletions Sources/SwiftagramCrypto/Endpoints/Endpoint+Media.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit d83f992

Please sign in to comment.