Skip to content

Commit

Permalink
updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
lukepistrol committed May 13, 2022
1 parent 89607fc commit ef6180e
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Sources/PexelsSwift/Documentation.docc/Documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ let results = await pexels.getCuratedPhotos()
### Structures

- ``PexelsSwift/PSPhoto``
- ``PexelsSwift/CollectionCategory``
- ``PexelsSwift/PSCollectionCategory``
15 changes: 14 additions & 1 deletion Sources/PexelsSwift/PSCollectionCategory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation

/// A structure representing a Collection Category and its metadata.
public struct CollectionCategory: Identifiable, Codable, Equatable {
public struct PSCollectionCategory: Identifiable, Codable, Equatable {

enum CodingKeys: String, CodingKey {
case id, title, description
Expand All @@ -18,12 +18,25 @@ public struct CollectionCategory: Identifiable, Codable, Equatable {
case videosCount = "videos_count"
}

/// The ID of the collection.
public var id: String

/// The name of the collection.
public var title: String

/// The description of the collection.
public var description: String

/// A flag indicating whether or not the collection is marked as private.
public var isPrivate: Bool

/// The total number of media included in this collection.
public var mediaCount: Int

/// The total number of photos included in this collection.
public var photosCount: Int

/// The total number of videos included in this collection.
public var videosCount: Int

}
45 changes: 44 additions & 1 deletion Sources/PexelsSwift/PSPhoto.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,62 @@ public struct PSPhoto: Identifiable, Codable, Equatable {
case averageColor = "avg_color"
}

/// The id of the photo.
public var id: Int

/// The real width of the photo in pixels.
public var width: Int

/// The real height of the photo in pixels
public var height: Int

/// The Pexels URL where the photo is located.
public var url: String

/// The name of the photographer who took the photo.
public var photographer: String

/// The URL of the photographer's Pexels profile.
public var photographerURL: String

/// The ID of the photographer.
public var photographerID: Int

/// The average color of the photo. Useful for a placeholder while the image loads.
public var averageColor: String

/// A collection of URLs of different image sizes that can be used to display this ``PSPhoto``.
public var source: Dictionary<Size.RawValue,String>

/// Text description of the photo for use in the `alt` attribute (HTML).
public var alternateDescription: String

/// Keys for different image sizes that can be used to display this ``PSPhoto``
public enum Size: String {
case original, large2x, large, medium, small, portrait, landscape, tiny

/// The image without any size changes. It will be the same as the ``PSPhoto/width`` and ``PSPhoto/height`` attributes.
case original

/// the image resized to `940px X 650px @2x`
case large2x

/// the image resized to `940px X 650px`
case large

/// The image scaled proportionally so that it's new height is `350px`
case medium

/// The image scaled proportionally so that it's new height is `130px`
case small

/// The image cropped to `800px X 1200px`
case portrait

/// The image cropped to `1200px X 627px`
case landscape

/// The image cropped to `280px X 200px`
case tiny
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extension PexelsSwift {
case nextPage = "next_page"
}

var collections: Array<CollectionCategory>
var collections: Array<PSCollectionCategory>
var page: Int
var perPage: Int
var totalResults: Int
Expand Down
2 changes: 1 addition & 1 deletion Sources/PexelsSwift/PexelsSwift.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class PexelsSwift {
public func getCategories(
page: Int = 1,
count results: Int = 10
) async -> Array<CollectionCategory> {
) async -> Array<PSCollectionCategory> {
var req = URLRequest(url: URL(string: "https://api.pexels.com/v1/collections/featured?page=\(page)&per_page=\(results)")!)
req.setValue(apiKey, forHTTPHeaderField: apiHeader)

Expand Down

0 comments on commit ef6180e

Please sign in to comment.