Skip to content

Commit

Permalink
Updated CustomerReviewService
Browse files Browse the repository at this point in the history
  • Loading branch information
aromanov91 committed Nov 24, 2024
1 parent bedfb7a commit c246212
Show file tree
Hide file tree
Showing 24 changed files with 969 additions and 314 deletions.
3 changes: 3 additions & 0 deletions .swiftformat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--swiftversion 6.0
--disable preferKeyPath
--ifdef no-indent
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public struct NetworkEnvironment {
public var description: String {
switch self {
case let .unreadableEntry(context):
return """
"""
\(context.url.relativePath):\(context.line): Unreadable entry in "\(context.content)"
"""
}
Expand Down Expand Up @@ -72,7 +72,7 @@ public struct NetworkEnvironment {
loadedEnvironment[name] ?? processInfo.environment[name]
}
set {
guard let newValue = newValue else { return }
guard let newValue else { return }
loadedEnvironment[name] = newValue
}
}
Expand Down
220 changes: 110 additions & 110 deletions Sources/OversizeAppStoreServices/Models/AppCategory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,121 +53,121 @@ public struct AppCategory: Identifiable, Sendable {
public extension AppCategory {
var displayName: String {
switch id {
case "STICKERS_EMOJI_AND_EXPRESSIONS": return "Emoji & Expressions"
case "GAMES_ACTION": return "Action Games"
case "BUSINESS": return "Business"
case "SOCIAL_NETWORKING": return "Social Networking"
case "GAMES_STRATEGY": return "Strategy Games"
case "GAMES_SPORTS": return "Sports Games"
case "STICKERS_CELEBRATIONS": return "Celebrations"
case "STICKERS": return "Stickers"
case "GAMES": return "Games"
case "GAMES_CASUAL": return "Casual Games"
case "STICKERS_SPORTS_AND_ACTIVITIES": return "Sports & Activities"
case "GAMES_TRIVIA": return "Trivia Games"
case "STICKERS_EATING_AND_DRINKING": return "Eating & Drinking"
case "STICKERS_CHARACTERS": return "Characters"
case "MEDICAL": return "Medical"
case "GAMES_PUZZLE": return "Puzzle Games"
case "GAMES_CASINO": return "Casino Games"
case "GAMES_FAMILY": return "Family Games"
case "STICKERS_PLACES_AND_OBJECTS": return "Places & Objects"
case "FOOD_AND_DRINK": return "Food & Drink"
case "GAMES_ADVENTURE": return "Adventure Games"
case "GAMES_BOARD": return "Board Games"
case "EDUCATION": return "Education"
case "BOOKS": return "Books"
case "SPORTS": return "Sports"
case "FINANCE": return "Finance"
case "REFERENCE": return "Reference"
case "GAMES_RACING": return "Racing Games"
case "DEVELOPER_TOOLS": return "Developer Tools"
case "GRAPHICS_AND_DESIGN": return "Graphics & Design"
case "HEALTH_AND_FITNESS": return "Health & Fitness"
case "MUSIC": return "Music"
case "ENTERTAINMENT": return "Entertainment"
case "TRAVEL": return "Travel"
case "WEATHER": return "Weather"
case "GAMES_WORD": return "Word Games"
case "STICKERS_CELEBRITIES": return "Celebrities"
case "LIFESTYLE": return "Lifestyle"
case "GAMES_MUSIC": return "Music Games"
case "GAMES_ROLE_PLAYING": return "Role Playing Games"
case "STICKERS_MOVIES_AND_TV": return "Movies & TV"
case "GAMES_CARD": return "Card Games"
case "STICKERS_ANIMALS": return "Animals"
case "MAGAZINES_AND_NEWSPAPERS": return "Magazines & Newspapers"
case "STICKERS_ART": return "Art"
case "STICKERS_FASHION": return "Fashion"
case "UTILITIES": return "Utilities"
case "STICKERS_GAMING": return "Gaming"
case "SHOPPING": return "Shopping"
case "NEWS": return "News"
case "PRODUCTIVITY": return "Productivity"
case "GAMES_SIMULATION": return "Simulation Games"
case "NAVIGATION": return "Navigation"
case "PHOTO_AND_VIDEO": return "Photo & Video"
default: return "Other"
case "STICKERS_EMOJI_AND_EXPRESSIONS": "Emoji & Expressions"
case "GAMES_ACTION": "Action Games"
case "BUSINESS": "Business"
case "SOCIAL_NETWORKING": "Social Networking"
case "GAMES_STRATEGY": "Strategy Games"
case "GAMES_SPORTS": "Sports Games"
case "STICKERS_CELEBRATIONS": "Celebrations"
case "STICKERS": "Stickers"
case "GAMES": "Games"
case "GAMES_CASUAL": "Casual Games"
case "STICKERS_SPORTS_AND_ACTIVITIES": "Sports & Activities"
case "GAMES_TRIVIA": "Trivia Games"
case "STICKERS_EATING_AND_DRINKING": "Eating & Drinking"
case "STICKERS_CHARACTERS": "Characters"
case "MEDICAL": "Medical"
case "GAMES_PUZZLE": "Puzzle Games"
case "GAMES_CASINO": "Casino Games"
case "GAMES_FAMILY": "Family Games"
case "STICKERS_PLACES_AND_OBJECTS": "Places & Objects"
case "FOOD_AND_DRINK": "Food & Drink"
case "GAMES_ADVENTURE": "Adventure Games"
case "GAMES_BOARD": "Board Games"
case "EDUCATION": "Education"
case "BOOKS": "Books"
case "SPORTS": "Sports"
case "FINANCE": "Finance"
case "REFERENCE": "Reference"
case "GAMES_RACING": "Racing Games"
case "DEVELOPER_TOOLS": "Developer Tools"
case "GRAPHICS_AND_DESIGN": "Graphics & Design"
case "HEALTH_AND_FITNESS": "Health & Fitness"
case "MUSIC": "Music"
case "ENTERTAINMENT": "Entertainment"
case "TRAVEL": "Travel"
case "WEATHER": "Weather"
case "GAMES_WORD": "Word Games"
case "STICKERS_CELEBRITIES": "Celebrities"
case "LIFESTYLE": "Lifestyle"
case "GAMES_MUSIC": "Music Games"
case "GAMES_ROLE_PLAYING": "Role Playing Games"
case "STICKERS_MOVIES_AND_TV": "Movies & TV"
case "GAMES_CARD": "Card Games"
case "STICKERS_ANIMALS": "Animals"
case "MAGAZINES_AND_NEWSPAPERS": "Magazines & Newspapers"
case "STICKERS_ART": "Art"
case "STICKERS_FASHION": "Fashion"
case "UTILITIES": "Utilities"
case "STICKERS_GAMING": "Gaming"
case "SHOPPING": "Shopping"
case "NEWS": "News"
case "PRODUCTIVITY": "Productivity"
case "GAMES_SIMULATION": "Simulation Games"
case "NAVIGATION": "Navigation"
case "PHOTO_AND_VIDEO": "Photo & Video"
default: "Other"
}
}

var image: Image {
switch id {
case "STICKERS_EMOJI_AND_EXPRESSIONS": return Image(systemName: "face.smiling.fill")
case "GAMES_ACTION": return Image(systemName: "gamecontroller.fill")
case "BUSINESS": return Image(systemName: "briefcase.fill")
case "SOCIAL_NETWORKING": return Image(systemName: "person.2.fill")
case "GAMES_STRATEGY": return Image(systemName: "puzzlepiece.fill")
case "GAMES_SPORTS": return Image(systemName: "sportscourt.fill")
case "STICKERS_CELEBRATIONS": return Image(systemName: "party.popper.fill")
case "STICKERS": return Image(systemName: "face.smiling.fill")
case "GAMES": return Image(systemName: "gamecontroller.fill")
case "GAMES_CASUAL": return Image(systemName: "die.face.4.fill")
case "STICKERS_SPORTS_AND_ACTIVITIES": return Image(systemName: "bicycle.circle.fill")
case "GAMES_TRIVIA": return Image(systemName: "questionmark.circle.fill")
case "STICKERS_EATING_AND_DRINKING": return Image(systemName: "fork.knife.circle.fill")
case "STICKERS_CHARACTERS": return Image(systemName: "person.crop.circle.fill")
case "MEDICAL": return Image(systemName: "cross.case.fill")
case "GAMES_PUZZLE": return Image(systemName: "puzzlepiece.extension.fill")
case "GAMES_CASINO": return Image(systemName: "suit.club.fill")
case "GAMES_FAMILY": return Image(systemName: "person.3.fill")
case "STICKERS_PLACES_AND_OBJECTS": return Image(systemName: "location.circle.fill")
case "FOOD_AND_DRINK": return Image(systemName: "fork.knife")
case "GAMES_ADVENTURE": return Image(systemName: "star.circle.fill")
case "GAMES_BOARD": return Image(systemName: "checkerboard.rectangle")
case "EDUCATION": return Image(systemName: "book.fill")
case "BOOKS": return Image(systemName: "books.vertical.fill")
case "SPORTS": return Image(systemName: "sportscourt.fill")
case "FINANCE": return Image(systemName: "banknote.fill")
case "REFERENCE": return Image(systemName: "magnifyingglass.circle.fill")
case "GAMES_RACING": return Image(systemName: "car.fill")
case "DEVELOPER_TOOLS": return Image(systemName: "hammer.fill")
case "GRAPHICS_AND_DESIGN": return Image(systemName: "paintpalette.fill")
case "HEALTH_AND_FITNESS": return Image(systemName: "heart.fill")
case "MUSIC": return Image(systemName: "music.note")
case "ENTERTAINMENT": return Image(systemName: "tv.fill")
case "TRAVEL": return Image(systemName: "airplane")
case "WEATHER": return Image(systemName: "cloud.sun.fill")
case "GAMES_WORD": return Image(systemName: "textformat.abc")
case "STICKERS_CELEBRITIES": return Image(systemName: "person.crop.circle.badge.checkmark")
case "LIFESTYLE": return Image(systemName: "leaf.fill")
case "GAMES_MUSIC": return Image(systemName: "guitars.fill")
case "GAMES_ROLE_PLAYING": return Image(systemName: "shield.fill")
case "STICKERS_MOVIES_AND_TV": return Image(systemName: "film.fill")
case "GAMES_CARD": return Image(systemName: "suit.heart.fill")
case "STICKERS_ANIMALS": return Image(systemName: "pawprint.fill")
case "MAGAZINES_AND_NEWSPAPERS": return Image(systemName: "newspaper.fill")
case "STICKERS_ART": return Image(systemName: "paintbrush.fill")
case "STICKERS_FASHION": return Image(systemName: "tshirt.fill")
case "UTILITIES": return Image(systemName: "gearshape.fill")
case "STICKERS_GAMING": return Image(systemName: "gamecontroller.fill")
case "SHOPPING": return Image(systemName: "cart.fill")
case "NEWS": return Image(systemName: "newspaper.fill")
case "PRODUCTIVITY": return Image(systemName: "calendar")
case "GAMES_SIMULATION": return Image(systemName: "simcard.fill")
case "NAVIGATION": return Image(systemName: "location.north.line.fill")
case "PHOTO_AND_VIDEO": return Image(systemName: "camera.fill")
default: return Image(systemName: "questionmark.circle.fill")
case "STICKERS_EMOJI_AND_EXPRESSIONS": Image(systemName: "face.smiling.fill")
case "GAMES_ACTION": Image(systemName: "gamecontroller.fill")
case "BUSINESS": Image(systemName: "briefcase.fill")
case "SOCIAL_NETWORKING": Image(systemName: "person.2.fill")
case "GAMES_STRATEGY": Image(systemName: "puzzlepiece.fill")
case "GAMES_SPORTS": Image(systemName: "sportscourt.fill")
case "STICKERS_CELEBRATIONS": Image(systemName: "party.popper.fill")
case "STICKERS": Image(systemName: "face.smiling.fill")
case "GAMES": Image(systemName: "gamecontroller.fill")
case "GAMES_CASUAL": Image(systemName: "die.face.4.fill")
case "STICKERS_SPORTS_AND_ACTIVITIES": Image(systemName: "bicycle.circle.fill")
case "GAMES_TRIVIA": Image(systemName: "questionmark.circle.fill")
case "STICKERS_EATING_AND_DRINKING": Image(systemName: "fork.knife.circle.fill")
case "STICKERS_CHARACTERS": Image(systemName: "person.crop.circle.fill")
case "MEDICAL": Image(systemName: "cross.case.fill")
case "GAMES_PUZZLE": Image(systemName: "puzzlepiece.extension.fill")
case "GAMES_CASINO": Image(systemName: "suit.club.fill")
case "GAMES_FAMILY": Image(systemName: "person.3.fill")
case "STICKERS_PLACES_AND_OBJECTS": Image(systemName: "location.circle.fill")
case "FOOD_AND_DRINK": Image(systemName: "fork.knife")
case "GAMES_ADVENTURE": Image(systemName: "star.circle.fill")
case "GAMES_BOARD": Image(systemName: "checkerboard.rectangle")
case "EDUCATION": Image(systemName: "book.fill")
case "BOOKS": Image(systemName: "books.vertical.fill")
case "SPORTS": Image(systemName: "sportscourt.fill")
case "FINANCE": Image(systemName: "banknote.fill")
case "REFERENCE": Image(systemName: "magnifyingglass.circle.fill")
case "GAMES_RACING": Image(systemName: "car.fill")
case "DEVELOPER_TOOLS": Image(systemName: "hammer.fill")
case "GRAPHICS_AND_DESIGN": Image(systemName: "paintpalette.fill")
case "HEALTH_AND_FITNESS": Image(systemName: "heart.fill")
case "MUSIC": Image(systemName: "music.note")
case "ENTERTAINMENT": Image(systemName: "tv.fill")
case "TRAVEL": Image(systemName: "airplane")
case "WEATHER": Image(systemName: "cloud.sun.fill")
case "GAMES_WORD": Image(systemName: "textformat.abc")
case "STICKERS_CELEBRITIES": Image(systemName: "person.crop.circle.badge.checkmark")
case "LIFESTYLE": Image(systemName: "leaf.fill")
case "GAMES_MUSIC": Image(systemName: "guitars.fill")
case "GAMES_ROLE_PLAYING": Image(systemName: "shield.fill")
case "STICKERS_MOVIES_AND_TV": Image(systemName: "film.fill")
case "GAMES_CARD": Image(systemName: "suit.heart.fill")
case "STICKERS_ANIMALS": Image(systemName: "pawprint.fill")
case "MAGAZINES_AND_NEWSPAPERS": Image(systemName: "newspaper.fill")
case "STICKERS_ART": Image(systemName: "paintbrush.fill")
case "STICKERS_FASHION": Image(systemName: "tshirt.fill")
case "UTILITIES": Image(systemName: "gearshape.fill")
case "STICKERS_GAMING": Image(systemName: "gamecontroller.fill")
case "SHOPPING": Image(systemName: "cart.fill")
case "NEWS": Image(systemName: "newspaper.fill")
case "PRODUCTIVITY": Image(systemName: "calendar")
case "GAMES_SIMULATION": Image(systemName: "simcard.fill")
case "NAVIGATION": Image(systemName: "location.north.line.fill")
case "PHOTO_AND_VIDEO": Image(systemName: "camera.fill")
default: Image(systemName: "questionmark.circle.fill")
}
}
}
2 changes: 1 addition & 1 deletion Sources/OversizeAppStoreServices/Models/Build.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public struct Build: Sendable, Identifiable, Equatable {
func parseURL(from urlString: String) -> URL? {
if let url = URL(string: urlString), let components = URLComponents(url: url, resolvingAgainstBaseURL: true) {
if let scheme = components.scheme, let host = components.host {
if !scheme.isEmpty && !host.isEmpty {
if !scheme.isEmpty, !host.isEmpty {
return url
}
}
Expand Down
34 changes: 31 additions & 3 deletions Sources/OversizeAppStoreServices/Models/CustomerReview.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,39 @@

import AppStoreAPI
import AppStoreConnect
import Foundation

public struct CustomerReview: Sendable {
public struct CustomerReview: Sendable, Identifiable {
public let id: String
public let title: String?
public let rating: Int
init?(schema: AppStoreAPI.CustomerReview) {
guard let rating = schema.attributes?.rating else { return nil }
public let body: String?
public let reviewerNickname: String?
public let createdDate: Date?
public let territory: TerritoryCode?

public let included: Included?

init?(schema: AppStoreAPI.CustomerReview, included: [AppStoreAPI.CustomerReviewResponseV1]? = nil) {
guard let rating = schema.attributes?.rating,
let territory = schema.attributes?.territory?.rawValue
else { return nil }
id = schema.id
self.rating = rating
title = schema.attributes?.title
body = schema.attributes?.body
reviewerNickname = schema.attributes?.reviewerNickname
createdDate = schema.attributes?.createdDate
self.territory = .init(rawValue: territory)

if let customerReviewResponseV1 = included?.first(where: { $0.id == schema.relationships?.response?.data?.id }) {
self.included = .init(customerReviewResponse: .init(schema: customerReviewResponseV1))
} else {
self.included = nil
}
}

public struct Included: Sendable {
public let customerReviewResponse: CustomerReviewResponseV1?
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// Copyright © 2024 Alexander Romanov
// CustomerReviewResponseV1.swift, created on 22.11.2024
//

import AppStoreAPI
import AppStoreConnect
import Foundation

public struct CustomerReviewResponseV1: Sendable, Identifiable {
public enum State: String, CaseIterable, Codable, Sendable {
case published = "PUBLISHED"
case pendingPublish = "PENDING_PUBLISH"
}

public let id: String
public let responseBody: String
public let lastModifiedDate: Date
public let state: State

init?(schema: AppStoreAPI.CustomerReviewResponseV1) {
guard let attributes = schema.attributes,
let responseBody = attributes.responseBody,
let lastModifiedDate = attributes.lastModifiedDate,
let stateRawValue = attributes.state?.rawValue,
let state: State = .init(rawValue: stateRawValue)
else { return nil }
id = schema.id
self.responseBody = responseBody
self.lastModifiedDate = lastModifiedDate
self.state = state
}
}
Loading

0 comments on commit c246212

Please sign in to comment.