Skip to content

Commit

Permalink
Initial commit .
Browse files Browse the repository at this point in the history
  • Loading branch information
William Alvelos committed Apr 29, 2018
0 parents commit 1b6e598
Show file tree
Hide file tree
Showing 552 changed files with 67,708 additions and 0 deletions.
894 changes: 894 additions & 0 deletions Marvel.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions Marvel.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0920"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3D0D6F1420857AA100A1EDC4"
BuildableName = "Marvel.app"
BlueprintName = "Marvel"
ReferencedContainer = "container:Marvel.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3D0D6F2820857AA100A1EDC4"
BuildableName = "MarvelTests.xctest"
BlueprintName = "MarvelTests"
ReferencedContainer = "container:Marvel.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3D0D6F3320857AA100A1EDC4"
BuildableName = "MarvelUITests.xctest"
BlueprintName = "MarvelUITests"
ReferencedContainer = "container:Marvel.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3D0D6F1420857AA100A1EDC4"
BuildableName = "Marvel.app"
BlueprintName = "Marvel"
ReferencedContainer = "container:Marvel.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3D0D6F1420857AA100A1EDC4"
BuildableName = "Marvel.app"
BlueprintName = "Marvel"
ReferencedContainer = "container:Marvel.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3D0D6F1420857AA100A1EDC4"
BuildableName = "Marvel.app"
BlueprintName = "Marvel"
ReferencedContainer = "container:Marvel.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
10 changes: 10 additions & 0 deletions Marvel.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

108 changes: 108 additions & 0 deletions Marvel/API/APIManager.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
//
// APIManager.swift
// Animations
//
// Created by William Alvelos on 2/8/18.
// Copyright © 2018 William Alvelos. All rights reserved.
//

import Foundation
import Alamofire
import RxSwift
import RxCocoa
import RxAlamofire


////
//// APIManager.swift
//// Animations
////
//// Created by William Alvelos on 2/8/18.
//// Copyright © 2018 William Alvelos. All rights reserved.
////
//
//import Foundation
//import RxSwift
//import RxAlamofire
//import ObjectMapper
//
//
//extension ObservableType {
// public func mapObject<T: Mappable>(type: T.Type) -> Observable<T> {
// return flatMap { JSON -> Observable<T> in
// guard let object = Mapper<T>().map(JSONObject: JSON) else {
// throw NSError(
// domain: "",
// code: -1,
// userInfo: [NSLocalizedDescriptionKey: "ObjectMapper can't mapping"]
// )
// }
//
// return Observable.just(object)
// }
// }
//
// public func mapArray<T: Mappable>(type: T.Type) -> Observable<[T]> {
// return flatMap { JSON -> Observable<[T]> in
// guard let objects = Mapper<T>().mapArray(JSONObject: JSON) else {
// throw NSError(
// domain: "",
// code: -1,
// userInfo: [NSLocalizedDescriptionKey: "ObjectMapper can't mapping"]
// )
// }
//
// return Observable.just(objects)
// }
// }
//}
//
//class APIManager: NSObject {
//
// //MARK:- Vars and Lets
// private let marvel = "http://gateway.marvel.com/v1/public/"
//
// private var parameters : [String: Any] = Marvel.defaultParams
//
// //MARK:- Methods
// func getFrom(_ method: String, params: [String: Any]? = nil) -> Observable {
// return RxAlamofire
// .request(.get, marvel + method, parameters: params, headers: nil)
// .validate()
// .responseJSON()
// }
//
//}


class APIManager: NSObject {

//MARK:- Vars and Lets
private let marvel = "http://gateway.marvel.com/v1/public/"

private var parameters : [String: Any] = Marvel.defaultParams

//MARK:- Methods
func getFrom(_ method: String, params: [[String: Any]]? = nil, completion: @escaping(Any?) -> Void) {

Alamofire.request(marvel + method, method: .get, parameters: parameters)
.validate()
.responseJSON { (response) in
print("GET: \(response.request?.url?.absoluteString ?? "")")

switch response.result
{
case .success:
do {
completion(try JSONSerialization.jsonObject(with: response.data!, options: []) as? [String : Any])
} catch {
completion(NSError(domain: "", code: -1, userInfo: nil))
}
break
case .failure(let error):
completion(error)
break
}
}
}
}
38 changes: 38 additions & 0 deletions Marvel/API/Marvel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// marvel.swift
// Animations
//
// Created by William Alvelos on 2/8/18.
// Copyright © 2018 William Alvelos. All rights reserved.
//

import Foundation
import CryptoSwift

struct ParamKeys {
static let apikey = "apikey"
static let hash = "hash"
static let timeStamp = "ts"
static let limit = "limit"
static let offset = "offset"
static let searchName = "nameStartsWith"
}

struct Marvel {

private enum Keys : String {
case privatKey = "252003dafe243b67ac7b4d4f8f3fd16abc4b4214"
case publicKey = "8a13919f4c92b10f75223805677c8d37"
}

static var defaultParams: [String: Any] {
let timeStamp = Int(Date().timeIntervalSince1970)
let hash = "\(timeStamp)\(Keys.privatKey.rawValue)\(Keys.publicKey.rawValue)"

return [
ParamKeys.apikey : Keys.publicKey.rawValue,
ParamKeys.timeStamp : timeStamp,
ParamKeys.hash : hash.md5()
]
}
}
22 changes: 22 additions & 0 deletions Marvel/App/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// AppDelegate.swift
// Marvel
//
// Created by William Alvelos on 16/04/18.
// Copyright © 2018 WilliamAlvelos. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}

}

Loading

0 comments on commit 1b6e598

Please sign in to comment.