Skip to content

Commit ff2a61a

Browse files
committed
Add ObjectMapper, Himotoki, Argo
1 parent d1d03d4 commit ff2a61a

File tree

81 files changed

+5587
-1206
lines changed

Some content is hidden

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

81 files changed

+5587
-1206
lines changed

APIKitExt.podspec

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@ APIKitExt is a set of useful extension to work with APIKit and libraries such as
2727
ss.dependency "ObjectMapper", '2.2.2'
2828
end
2929

30+
s.subspec "Himotoki" do |ss|
31+
ss.source_files = "Sources/Classes/Himotoki/*.swift"
32+
ss.dependency "APIKitExt/Core"
33+
ss.dependency "Himotoki", '3.0.0'
34+
end
35+
36+
s.subspec "Argo" do |ss|
37+
ss.source_files = "Sources/Classes/Argo/*.swift"
38+
ss.dependency "APIKitExt/Core"
39+
ss.dependency "Argo", '4.1.1'
40+
end
41+
3042
s.subspec "RxSwift" do |ss|
3143
ss.source_files = "Sources/Classes/RxSwift/*.swift"
3244
ss.dependency "APIKitExt/Core"

Example/APIKitExt.xcodeproj/project.pbxproj

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; };
1414
607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; };
1515
97BA591F6D0710A806541BEE /* Pods_APIKitExt_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2A75DCD734D3B06DAC6668A /* Pods_APIKitExt_Example.framework */; };
16+
B401BABD1E0D2C6100F93BC4 /* RepoRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B401BABC1E0D2C6100F93BC4 /* RepoRequest.swift */; };
17+
B401BABF1E0D2C9500F93BC4 /* Repo.swift in Sources */ = {isa = PBXBuildFile; fileRef = B401BABE1E0D2C9500F93BC4 /* Repo.swift */; };
18+
B401BAC11E0D677E00F93BC4 /* GithubAPIService.swift in Sources */ = {isa = PBXBuildFile; fileRef = B401BAC01E0D677E00F93BC4 /* GithubAPIService.swift */; };
19+
B401BAC31E0D6DFA00F93BC4 /* SchedulerService.swift in Sources */ = {isa = PBXBuildFile; fileRef = B401BAC21E0D6DFA00F93BC4 /* SchedulerService.swift */; };
1620
/* End PBXBuildFile section */
1721

1822
/* Begin PBXFileReference section */
@@ -27,6 +31,10 @@
2731
607FACDF1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = "<group>"; };
2832
81D83B10964604D9E4BAB7C4 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
2933
A5EF206D927F04BE6F7BDB0D /* APIKitExt.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = APIKitExt.podspec; path = ../APIKitExt.podspec; sourceTree = "<group>"; };
34+
B401BABC1E0D2C6100F93BC4 /* RepoRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RepoRequest.swift; sourceTree = "<group>"; };
35+
B401BABE1E0D2C9500F93BC4 /* Repo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Repo.swift; sourceTree = "<group>"; };
36+
B401BAC01E0D677E00F93BC4 /* GithubAPIService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GithubAPIService.swift; sourceTree = "<group>"; };
37+
B401BAC21E0D6DFA00F93BC4 /* SchedulerService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SchedulerService.swift; sourceTree = "<group>"; };
3038
C2A75DCD734D3B06DAC6668A /* Pods_APIKitExt_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_APIKitExt_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
3139
E8CD31ACDF6C49A1F5EF399C /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
3240
/* End PBXFileReference section */
@@ -65,6 +73,7 @@
6573
607FACD21AFB9204008FA782 /* Example for APIKitExt */ = {
6674
isa = PBXGroup;
6775
children = (
76+
B401BABB1E0D2BDE00F93BC4 /* Model */,
6877
607FACD51AFB9204008FA782 /* AppDelegate.swift */,
6978
607FACD71AFB9204008FA782 /* ViewController.swift */,
7079
607FACD91AFB9204008FA782 /* Main.storyboard */,
@@ -94,6 +103,17 @@
94103
name = "Podspec Metadata";
95104
sourceTree = "<group>";
96105
};
106+
B401BABB1E0D2BDE00F93BC4 /* Model */ = {
107+
isa = PBXGroup;
108+
children = (
109+
B401BABC1E0D2C6100F93BC4 /* RepoRequest.swift */,
110+
B401BABE1E0D2C9500F93BC4 /* Repo.swift */,
111+
B401BAC01E0D677E00F93BC4 /* GithubAPIService.swift */,
112+
B401BAC21E0D6DFA00F93BC4 /* SchedulerService.swift */,
113+
);
114+
name = Model;
115+
sourceTree = "<group>";
116+
};
97117
E00343CF68F09F5E0B254AEC /* Pods */ = {
98118
isa = PBXGroup;
99119
children = (
@@ -235,8 +255,12 @@
235255
isa = PBXSourcesBuildPhase;
236256
buildActionMask = 2147483647;
237257
files = (
258+
B401BABD1E0D2C6100F93BC4 /* RepoRequest.swift in Sources */,
259+
B401BAC31E0D6DFA00F93BC4 /* SchedulerService.swift in Sources */,
238260
607FACD81AFB9204008FA782 /* ViewController.swift in Sources */,
261+
B401BAC11E0D677E00F93BC4 /* GithubAPIService.swift in Sources */,
239262
607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */,
263+
B401BABF1E0D2C9500F93BC4 /* Repo.swift in Sources */,
240264
);
241265
runOnlyForDeploymentPostprocessing = 0;
242266
};

Example/APIKitExt/Base.lproj/LaunchScreen.xib

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6214" systemVersion="14A314h" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16B2555" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES">
3+
<device id="retina4_7" orientation="portrait">
4+
<adaptation id="fullscreen"/>
5+
</device>
36
<dependencies>
4-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6207"/>
7+
<deployment identifier="iOS"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
59
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
10+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
611
</dependencies>
712
<objects>
813
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
@@ -24,7 +29,7 @@
2429
<nil key="highlightedColor"/>
2530
</label>
2631
</subviews>
27-
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
32+
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
2833
<constraints>
2934
<constraint firstItem="kId-c2-rCX" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="bottom" multiplier="1/3" constant="1" id="5cJ-9S-tgC"/>
3035
<constraint firstAttribute="centerX" secondItem="kId-c2-rCX" secondAttribute="centerX" id="Koa-jz-hwk"/>

Example/APIKitExt/Base.lproj/Main.storyboard

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
1-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6211" systemVersion="14A298i" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="vXZ-lx-hvc">
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16B2555" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="vXZ-lx-hvc">
3+
<device id="retina4_7" orientation="portrait">
4+
<adaptation id="fullscreen"/>
5+
</device>
36
<dependencies>
4-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6204"/>
7+
<deployment identifier="iOS"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
9+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
510
</dependencies>
611
<scenes>
712
<!--View Controller-->
813
<scene sceneID="ufC-wZ-h7g">
914
<objects>
10-
<viewController id="vXZ-lx-hvc" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
15+
<viewController id="vXZ-lx-hvc" customClass="ViewController" customModule="APIKitExt_Example" customModuleProvider="target" sceneMemberID="viewController">
1116
<layoutGuides>
1217
<viewControllerLayoutGuide type="top" id="jyV-Pf-zRb"/>
1318
<viewControllerLayoutGuide type="bottom" id="2fi-mo-0CV"/>
1419
</layoutGuides>
1520
<view key="view" contentMode="scaleToFill" id="kh9-bI-dsS">
16-
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
21+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
1722
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
18-
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
23+
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
1924
</view>
2025
</viewController>
2126
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//
2+
// GithubAPIService.swift
3+
// APIKitExt
4+
//
5+
// Created by DTVD on 12/23/16.
6+
// Copyright © 2016 CocoaPods. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import APIKit
11+
import APIKitExt
12+
import RxSwift
13+
14+
class GithubApiService {
15+
let schedulers = SchedulerService.sharedInstance
16+
17+
// Normal
18+
func getRepoList(query: String, successHandler: @escaping ([Repo]) -> Void) {
19+
let request = RepoRequest(query: query)
20+
Session.send(request) { result in
21+
switch result {
22+
case .success(let response):
23+
successHandler(response)
24+
case .failure(let error):
25+
print(error.localizedDescription)
26+
}
27+
}
28+
}
29+
30+
// RxSwift
31+
func getRepoList(query: String) -> Observable<[Repo]>{
32+
let request = RepoRequest(query: query)
33+
return Session.send(request: request)
34+
}
35+
}

Example/APIKitExt/Images.xcassets/AppIcon.appiconset/Contents.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
{
22
"images" : [
3+
{
4+
"idiom" : "iphone",
5+
"size" : "20x20",
6+
"scale" : "2x"
7+
},
8+
{
9+
"idiom" : "iphone",
10+
"size" : "20x20",
11+
"scale" : "3x"
12+
},
313
{
414
"idiom" : "iphone",
515
"size" : "29x29",
@@ -35,4 +45,4 @@
3545
"version" : 1,
3646
"author" : "xcode"
3747
}
38-
}
48+
}

Example/APIKitExt/Repo.swift

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
// Repo.swift
3+
// APIKitExt
4+
//
5+
// Created by DTVD on 12/23/16.
6+
// Copyright © 2016 CocoaPods. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import ObjectMapper
11+
12+
struct Repo: Mappable {
13+
var id: Int?
14+
var fullName: String?
15+
var avatar: String?
16+
var stargazersCount: Int?
17+
18+
init?(map: Map) {}
19+
20+
mutating func mapping(map: Map) {
21+
id <- map["id"]
22+
fullName <- map["full_name"]
23+
avatar <- map["owner.avatar_url"]
24+
stargazersCount <- map["stargazers_count"]
25+
}
26+
}
27+
28+
extension Repo: Equatable {
29+
static public func ==(lhs: Repo, rhs: Repo) -> Bool {
30+
return lhs.id == rhs.id &&
31+
lhs.fullName == rhs.fullName
32+
}
33+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//
2+
// RepoRequest.swift
3+
// APIKitExt
4+
//
5+
// Created by DTVD on 12/23/16.
6+
// Copyright © 2016 CocoaPods. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import APIKit
11+
import APIKitExt
12+
13+
struct RepoRequest: Request {
14+
typealias Response = [Repo]
15+
var query: String
16+
17+
init(query: String) {
18+
self.query = query
19+
}
20+
21+
var baseURL: URL {
22+
return URL(string: "https://api.github.com")!
23+
}
24+
25+
var method: HTTPMethod {
26+
return .get
27+
}
28+
29+
var queryParameters: [String : Any]? {
30+
return [
31+
"q": query
32+
]
33+
}
34+
35+
var path: String {
36+
return "/search/repositories"
37+
}
38+
}
39+
40+
extension RepoRequest {
41+
42+
func response(from object: Any, urlResponse: HTTPURLResponse) -> Response {
43+
guard
44+
let tree = object as? [String: Any],
45+
let items = tree["items"],
46+
let repos = try? Repo.mapArray(items)
47+
else {
48+
return []
49+
}
50+
return repos
51+
}
52+
53+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//
2+
// SchedulerService.swift
3+
// APIKitExt
4+
//
5+
// Created by DTVD on 12/23/16.
6+
// Copyright © 2016 CocoaPods. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import RxSwift
11+
12+
class SchedulerService {
13+
static let sharedInstance = SchedulerService()
14+
15+
let backgroundWorkScheduler: ImmediateSchedulerType
16+
let mainScheduler: SerialDispatchQueueScheduler
17+
18+
private init() {
19+
let operationQueue = OperationQueue()
20+
operationQueue.maxConcurrentOperationCount = 10
21+
backgroundWorkScheduler = OperationQueueScheduler(operationQueue: operationQueue)
22+
mainScheduler = MainScheduler.instance
23+
}
24+
}

Example/Podfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@ use_frameworks!
22

33
target 'APIKitExt_Example' do
44
pod 'APIKitExt/ObjectMapper', :path => '../'
5+
pod 'APIKitExt/Himotoki', :path => '../'
6+
pod 'APIKitExt/Argo', :path => '../'
57
pod 'APIKitExt/RxSwift', :path => '../'
68
end

0 commit comments

Comments
 (0)