Skip to content

Commit

Permalink
Merge pull request #123 from Sopt-Mongle/feature/#115
Browse files Browse the repository at this point in the history
Feature/#115
  • Loading branch information
qodhrkawk committed Nov 12, 2020
2 parents 706e66e + abc80c3 commit bbf89fe
Show file tree
Hide file tree
Showing 82 changed files with 2,136 additions and 128 deletions.
52 changes: 50 additions & 2 deletions Mongle/Mongle.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Mongle/Mongle/Resource/APIService/APIConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,6 @@ struct APIConstants {
static let myThemeURL = baseURL + "/my/theme"
static let mySentenceURL = baseURL + "/my/sentence"
static let myCuratorURL = baseURL + "/my/subscribe"
static let signupEmailURL = baseURL + "/users/auth"
static let signupDuplicateURL = baseURL + "/users/duplicate"
}
85 changes: 85 additions & 0 deletions Mongle/Mongle/Resource/APIService/SignUpDuplicateService.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
//
// SignUpDuplicateService.swift
// Mongle
//
// Created by Yunjae Kim on 2020/11/12.
// Copyright © 2020 이주혁. All rights reserved.
//

import Foundation
import Alamofire


struct SignUpDuplicateService {
static let shared = SignUpDuplicateService()

private func makeParameter(_ email : String,_ name : String)-> Parameters{
return ["email" : email, "name" : name]
}

func checkDuplicate(email : String, name : String, completion : @escaping (NetworkResult<Any>) -> Void){
let header : HTTPHeaders = ["Content-Type" : "application/json"]

let dataRequest = Alamofire.request(APIConstants.signupDuplicateURL,
method: .post,
parameters: makeParameter(email,name),
encoding: JSONEncoding.default,
headers: header)


dataRequest.responseData { dataResponse in
switch dataResponse.result {
case .success :
print("succccceeesss")
guard let statusCode = dataResponse.response?.statusCode else {return}
guard let data = dataResponse.value else {return}
let networkResult = self.judge(by: statusCode, data)
completion(networkResult)

case .failure :

completion(.networkFail)


}
}





}

private func judge(by statusCode : Int , _ data : Data) -> NetworkResult<Any> {
switch statusCode{
case 200 :
return succeed(by: data)
case 400 :
print("400__")
return .pathErr
case 600 :
print("600__")
return .serverErr
default :
print("other__")
return .networkFail

}

}

private func succeed(by data : Data) -> NetworkResult<Any> {
let decoder = JSONDecoder()
guard let decodedData = try? decoder.decode(GenericResponse<DataClass>.self, from: data) else { return .serverErr }
guard let tokenData = decodedData.data else { return .requestErr(decodedData.message) }
return .success(tokenData.duplicate)

}







}
70 changes: 70 additions & 0 deletions Mongle/Mongle/Resource/APIService/SignUpEmailService.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
//
// SignUpEmail.swift
// Mongle
//
// Created by Yunjae Kim on 2020/11/11.
// Copyright © 2020 이주혁. All rights reserved.
//

import Foundation
import Alamofire

struct SignUpEmailService{
static let shared = SignUpEmailService()
private func makeParameter(_ email : String)-> Parameters{
return ["email" : email]
}

func signup(email : String , completion : @escaping (NetworkResult<Any>) -> Void){
let header : HTTPHeaders = ["Content-Type" : "application/json"]

let dataRequest = Alamofire.request(APIConstants.signupEmailURL,
method: .post,
parameters: makeParameter(email),
encoding: JSONEncoding.default,
headers: header)


dataRequest.responseData { dataResponse in
switch dataResponse.result {
case .success :
guard let statusCode = dataResponse.response?.statusCode else {return}
guard let data = dataResponse.value else {return}
let networkResult = self.judge(by: statusCode, data)
completion(networkResult)

case .failure :
completion(.networkFail)


}
}
}

private func judge(by statusCode : Int , _ data : Data) -> NetworkResult<Any> {
switch statusCode{
case 200 :
return isSignUp(by: data)
case 400 :
return .pathErr
case 600 :
return .serverErr
default :
return .networkFail

}

}

private func isSignUp(by data : Data) -> NetworkResult<Any> {
let decoder = JSONDecoder()
guard let decodedData = try? decoder.decode(GenericResponse<SignUpEmailData>.self, from: data) else { return .serverErr }
guard let tokenData = decodedData.data else { return .requestErr(decodedData.message) }
return .success(tokenData.authNum)



}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "onboarding1Bg.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "[email protected]"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "onboarding1ImgBook.png",
"scale" : "1x"
},
{
"scale" : "2x",
"filename" : "[email protected]",
"idiom" : "universal"
},
{
"scale" : "3x",
"idiom" : "universal",
"filename" : "[email protected]"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "onboarding1ImgMongle.png",
"scale" : "1x",
"idiom" : "universal"
},
{
"filename" : "[email protected]",
"scale" : "2x",
"idiom" : "universal"
},
{
"filename" : "[email protected]",
"scale" : "3x",
"idiom" : "universal"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"scale" : "1x",
"idiom" : "universal",
"filename" : "onboarding1Text.png"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "[email protected]"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"scale" : "1x",
"filename" : "onboarding2Bg.png",
"idiom" : "universal"
},
{
"scale" : "2x",
"idiom" : "universal",
"filename" : "[email protected]"
},
{
"filename" : "[email protected]",
"scale" : "3x",
"idiom" : "universal"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "onboarding2ImgList.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "onboarding2ImgMongle.png"
},
{
"scale" : "2x",
"filename" : "[email protected]",
"idiom" : "universal"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"scale" : "1x",
"idiom" : "universal",
"filename" : "onboarding2Text.png"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"scale" : "3x",
"idiom" : "universal"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"scale" : "1x",
"idiom" : "universal",
"filename" : "onboarding3Bg.png"
},
{
"scale" : "2x",
"idiom" : "universal",
"filename" : "[email protected]"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit bbf89fe

Please sign in to comment.