Skip to content

Commit 2649db7

Browse files
committed
GlobantPlus example App and Lambdas
1 parent 3b72f6a commit 2649db7

File tree

197 files changed

+5878
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

197 files changed

+5878
-0
lines changed

Examples/GlobantPlus/App/GlobantPlus.xcodeproj/project.pbxproj

Lines changed: 966 additions & 0 deletions
Large diffs are not rendered by default.

Examples/GlobantPlus/App/GlobantPlus.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1420"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "91334796299FC5CA00F2ECF4"
18+
BuildableName = "GlobantPlus.app"
19+
BlueprintName = "GlobantPlus"
20+
ReferencedContainer = "container:GlobantPlus.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<Testables>
31+
</Testables>
32+
</TestAction>
33+
<LaunchAction
34+
buildConfiguration = "Debug"
35+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
36+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
37+
launchStyle = "0"
38+
useCustomWorkingDirectory = "NO"
39+
ignoresPersistentStateOnLaunch = "NO"
40+
debugDocumentVersioning = "YES"
41+
debugServiceExtension = "internal"
42+
allowLocationSimulation = "YES">
43+
<BuildableProductRunnable
44+
runnableDebuggingMode = "0">
45+
<BuildableReference
46+
BuildableIdentifier = "primary"
47+
BlueprintIdentifier = "91334796299FC5CA00F2ECF4"
48+
BuildableName = "GlobantPlus.app"
49+
BlueprintName = "GlobantPlus"
50+
ReferencedContainer = "container:GlobantPlus.xcodeproj">
51+
</BuildableReference>
52+
</BuildableProductRunnable>
53+
</LaunchAction>
54+
<ProfileAction
55+
buildConfiguration = "Debug"
56+
shouldUseLaunchSchemeArgsEnv = "YES"
57+
savedToolIdentifier = ""
58+
useCustomWorkingDirectory = "NO"
59+
debugDocumentVersioning = "YES">
60+
<BuildableProductRunnable
61+
runnableDebuggingMode = "0">
62+
<BuildableReference
63+
BuildableIdentifier = "primary"
64+
BlueprintIdentifier = "91334796299FC5CA00F2ECF4"
65+
BuildableName = "GlobantPlus.app"
66+
BlueprintName = "GlobantPlus"
67+
ReferencedContainer = "container:GlobantPlus.xcodeproj">
68+
</BuildableReference>
69+
</BuildableProductRunnable>
70+
</ProfileAction>
71+
<AnalyzeAction
72+
buildConfiguration = "Debug">
73+
</AnalyzeAction>
74+
<ArchiveAction
75+
buildConfiguration = "Debug"
76+
revealArchiveInOrganizer = "YES">
77+
</ArchiveAction>
78+
</Scheme>
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
//
2+
// Environment.swift
3+
// Premiere
4+
//
5+
// Created by Adolfo Vera Blasco on 3/1/23.
6+
//
7+
8+
import Foundation
9+
10+
final class ApplicationEnvironment {
11+
enum Keys: String {
12+
case apiURL = "API_KEY"
13+
case apiToken = "API_AUTH_KEY"
14+
case awsAccessKey = "AWS_ACCESS_KEY_ID"
15+
case awsSecretAccessKey = "AWS_SECRET_ACCESS_KEY"
16+
case awsSQSQueueURL = "SQS_QUEUE_URL"
17+
case awsAPIGatewayURL = "API_GATEWAY_URL"
18+
}
19+
20+
static let shared = ApplicationEnvironment()
21+
22+
let dictionary: [String : Any]?
23+
24+
private init() {
25+
self.dictionary = Bundle.main.infoDictionary
26+
}
27+
}
28+
29+
extension ApplicationEnvironment {
30+
var apiKey: String {
31+
guard let dictionary = self.dictionary,
32+
let value = dictionary[Keys.apiURL.rawValue] as? String
33+
else {
34+
fatalError("Non value for API_KEY key")
35+
}
36+
37+
return value
38+
}
39+
40+
var apiToken: String {
41+
guard let dictionary = self.dictionary,
42+
let token = dictionary[Keys.apiToken.rawValue] as? String
43+
else {
44+
fatalError("Non value for API_AUTH_KEY key")
45+
}
46+
47+
return token
48+
}
49+
50+
var awsAccessKey: String {
51+
guard let dictionary = self.dictionary,
52+
let token = dictionary[Keys.awsAccessKey.rawValue] as? String
53+
else {
54+
fatalError("Non value for MY_AWS_ACCESS_KEY_ID key")
55+
}
56+
57+
return token
58+
}
59+
60+
var awsSecretAccessKey: String {
61+
guard let dictionary = self.dictionary,
62+
let token = dictionary[Keys.awsSecretAccessKey.rawValue] as? String
63+
else {
64+
fatalError("Non value for MY_AWS_SECRET_ACCESS_KEY key")
65+
}
66+
67+
return token
68+
}
69+
70+
var awsAPIGatewayURL: String {
71+
guard let dictionary = self.dictionary,
72+
let token = dictionary[Keys.awsAPIGatewayURL.rawValue] as? String
73+
else {
74+
fatalError("Non value for API_GATEWAY_URL key")
75+
}
76+
77+
return token
78+
}
79+
80+
var awsSQSQueueURL: String {
81+
guard let dictionary = self.dictionary,
82+
let token = dictionary[Keys.awsSQSQueueURL.rawValue] as? String
83+
else {
84+
fatalError("Non value for AWS_SQS_QUEUE_URL key")
85+
}
86+
87+
return token
88+
}
89+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//
2+
// AppConfig.xcconfig
3+
// Premiere
4+
//
5+
// Created by Adolfo Vera Blasco on 3/1/23.
6+
//
7+
8+
// Configuration settings file format documentation can be found at:
9+
// https://help.apple.com/xcode/#/dev745c5c974
10+
11+
TMDB_API_KEY = ae18023495231d6c234fd8f8ba1e2eb0
12+
TMDB_API_AUTH_KEY = eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJhZTE4MDIzNDk1MjMxZDZjMjM0ZmQ4ZjhiYTFlMmViMCIsInN1YiI6IjUyNzBlNjRlMTljMjk1MmFjMDAzNWI1MyIsInNjb3BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIjoxfQ.WFrdV7VnZQAhgFzhc-O9jIvpWEL2-JMxCC6rMhwE4l8
13+
14+
AWS_ACCESS_KEY_ID = AKIATDXGUYITWP7KXS4S
15+
AWS_SECRET_ACCESS_KEY = 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
16+
17+
AWS_SQS_QUEUE_URL = https:/$()/sqs.us-east-1.amazonaws.com/214158328359/user_activity
18+
AWS_API_GATEWAY_URL = https:/$()/fhlymaqeol.execute-api.us-east-1.amazonaws.com
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//
2+
// PremiereApp.swift
3+
// Premiere
4+
//
5+
// Created by Adolfo Vera Blasco on 3/1/23.
6+
//
7+
8+
import SwiftUI
9+
10+
@main
11+
struct GlobantPlusApp: App {
12+
var body: some Scene {
13+
WindowGroup {
14+
TabView {
15+
NavigationStack {
16+
DashboardView()
17+
.edgesIgnoringSafeArea([ .horizontal ])
18+
}
19+
.tabItem {
20+
Image(systemName: "flame")
21+
}
22+
23+
Text("Search")
24+
.tabItem {
25+
Image(systemName: "magnifyingglass")
26+
}
27+
}
28+
.padding(0)
29+
}
30+
}
31+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// Int+Runtime.swift
3+
// Premiere
4+
//
5+
// Created by Adolfo Vera Blasco on 10/3/23.
6+
//
7+
8+
import Foundation
9+
10+
extension Array where Element == Int {
11+
func average() -> Int {
12+
let amount = self.reduce(0) { $0 + $1 }
13+
return (self.count == 0 ? 0 : amount / self.count)
14+
}
15+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import Foundation
2+
import Resty
3+
4+
class AmazonFavoriteTrainingBaseRepository {
5+
func process(mediaID: Int, forUser userID: String, httpMethod verb: NetworkRequest.HttpMethod) async throws {
6+
let resty = Resty()
7+
8+
let amazonFavorite = AmazonFavorite(media: mediaID, user: userID)
9+
10+
let favoriteRequest = NetworkRequest(
11+
httpHeaders: [ "Content-Type" : "application/json" ],
12+
body: amazonFavorite.encoded(),
13+
httpMethod: verb)
14+
15+
let favoriteResponse = try await resty.fetch(endpoint: AmazonFavoriteEndpoint.favorite, withParameters: favoriteRequest)
16+
17+
if favoriteResponse.httpCodeResponse != 200 {
18+
throw GlobantPlusError.dataSourceFailure
19+
}
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// AmazonFavoriteTrainningDELETERepository.swift
3+
// GlobantPlus
4+
//
5+
// Created by Adolfo Vera Blasco on 15/3/23.
6+
//
7+
8+
import Foundation
9+
import Resty
10+
11+
final class AmazonFavoriteTrainingDELETERepository: AmazonFavoriteTrainingBaseRepository, FavoriteTrainingDELETERepository {
12+
func delete(mediaID: Int, forUser userID: String) async throws {
13+
try await super.process(mediaID: mediaID, forUser: userID, httpMethod: .delete)
14+
}
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// AmazonFavoriteTrainningRepository.swift
3+
// GlobantPlus
4+
//
5+
// Created by Adolfo Vera Blasco on 15/3/23.
6+
//
7+
8+
import Foundation
9+
import Resty
10+
11+
final class AmazonFavoriteTrainingPOSTRepository: AmazonFavoriteTrainingBaseRepository, FavoriteTrainingPOSTRepository {
12+
func post(mediaID: Int, forUser userID: String) async throws {
13+
try await super.process(mediaID: mediaID, forUser: userID, httpMethod: .post)
14+
}
15+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// AmazonFavorite.swift
3+
// GlobantPlus
4+
//
5+
// Created by Adolfo Vera Blasco on 15/3/23.
6+
//
7+
8+
import Foundation
9+
10+
struct AmazonFavorite: Encodable {
11+
let userID: String
12+
let showID: Int
13+
let recordID: String
14+
15+
init(media: Int, user: String) {
16+
self.userID = user
17+
self.showID = media
18+
self.recordID = "\(user.description)-\(media)"
19+
}
20+
21+
func encoded() -> Data? {
22+
let jsonEncoder = JSONEncoder()
23+
24+
let meEncoded = try? jsonEncoder.encode(self)
25+
26+
return meEncoded
27+
}
28+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// AmazonFavoriteEndpoint.swift
3+
// GlobantPlus
4+
//
5+
// Created by Adolfo Vera Blasco on 15/3/23.
6+
//
7+
8+
import Foundation
9+
import Resty
10+
11+
enum AmazonFavoriteEndpoint {
12+
case favorite
13+
}
14+
15+
extension AmazonFavoriteEndpoint {
16+
var baseURL: String {
17+
return ApplicationEnvironment.shared.awsAPIGatewayURL
18+
}
19+
}
20+
21+
extension AmazonFavoriteEndpoint: Endpoint {
22+
var path: String {
23+
switch self {
24+
case .favorite:
25+
return "\(baseURL)/favorites"
26+
}
27+
}
28+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// SQSActivity.swift
3+
// Premiere
4+
//
5+
// Created by Adolfo Vera Blasco on 13/3/23.
6+
//
7+
8+
import Foundation
9+
10+
struct SQSActivity: Codable {
11+
let createdAt: Date
12+
let activity: String
13+
let mediaId: Int
14+
let userId: String
15+
}

0 commit comments

Comments
 (0)