Skip to content

Commit

Permalink
Issue.516 removing SwiftyJSON (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew-Lees11 authored and tunniclm committed Jan 27, 2018
1 parent bf3f399 commit 1c71fd7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
*.xcodeproj/
.build
build
Package.resolved
Package.resolved
Packages/
.DS_Store
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ let package = Package(
)
],
dependencies: [
.package(url: "https://github.com/IBM-Swift/Kitura-Credentials.git", .upToNextMinor(from: "2.0.0")),
.package(url: "https://github.com/IBM-Swift/Kitura-Credentials.git", .upToNextMinor(from: "2.1.0")),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand Down
16 changes: 5 additions & 11 deletions Sources/CredentialsGitHub/CredentialsGitHub.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ import Kitura
import KituraNet
import LoggerAPI
import Credentials

import SwiftyJSON

import Foundation

// MARK CredentialsGitHub
Expand Down Expand Up @@ -106,8 +103,8 @@ public class CredentialsGitHub: CredentialsPluginProtocol {
do {
var body = Data()
try fbResponse.readAllData(into: &body)
var jsonBody = JSON(data: body)
if let token = jsonBody["access_token"].string {
if var jsonBody = try JSONSerialization.jsonObject(with: body, options: []) as? [String : Any],
let token = jsonBody["access_token"] as? String {
requestOptions = []
requestOptions.append(.schema("https://"))
requestOptions.append(.hostname("api.github.com"))
Expand All @@ -124,13 +121,10 @@ public class CredentialsGitHub: CredentialsPluginProtocol {
do {
body = Data()
try profileResponse.readAllData(into: &body)
jsonBody = JSON(data: body)

if let userDictionary = jsonBody.dictionaryObject,
let userProfile = self.createUserProfile(from: userDictionary) {

if let userDictionary = try JSONSerialization.jsonObject(with: body, options: []) as? [String : Any],
let userProfile = self.createUserProfile(from: userDictionary) {
if let delegate = self.userProfileDelegate {
delegate.update(userProfile: userProfile, from: jsonBody.dictionaryValue)
delegate.update(userProfile: userProfile, from: userDictionary)
}

onSuccess(userProfile)
Expand Down

0 comments on commit 1c71fd7

Please sign in to comment.