From 0cfda0a986086c0c92cf224532e7e3f62bd99094 Mon Sep 17 00:00:00 2001 From: yanyin1986 Date: Sun, 28 Aug 2022 21:48:45 +0900 Subject: [PATCH 1/4] Add delete account API for PlutoSDK --- Pluto/Classes/Core/Pluto+Login.swift | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Pluto/Classes/Core/Pluto+Login.swift b/Pluto/Classes/Core/Pluto+Login.swift index 29842bb..ec63a02 100644 --- a/Pluto/Classes/Core/Pluto+Login.swift +++ b/Pluto/Classes/Core/Pluto+Login.swift @@ -192,6 +192,29 @@ extension Pluto { state = .notSignIn completion?() } + + public func deleteAccount(success: @escaping (() -> Void), error: ErrorCompletion? = nil) { + let requestUrl = url(from: "/v1/user/delete") + getHeaders { + AF.request( + requestUrl, + method: .post, + parameters: nil, + encoding: JSONEncoding.default, + headers: $0 + ).responseJSON { + let response = PlutoResponse($0) + if response.statusOK() { + DefaultsManager.shared.clear() + self.state = .notSignIn + + success() + } else { + error?(response.getError()) + } + } + } + } private func handleLogin(response: PlutoResponse, success: (() -> Void)?, error: ErrorCompletion?) { if response.statusOK() { From 7ab98d2218debc76cbe98f0cc4677bae5a07e70a Mon Sep 17 00:00:00 2001 From: yanyin1986 Date: Sun, 28 Aug 2022 21:50:17 +0900 Subject: [PATCH 2/4] Add delete account button in UserViewController --- .../Pluto-Example/Base.lproj/Main.storyboard | 76 ++++++++++--------- .../Pluto-Example/UserViewController.swift | 27 ++++--- Example/Podfile.lock | 2 +- 3 files changed, 60 insertions(+), 45 deletions(-) diff --git a/Example/Pluto-Example/Base.lproj/Main.storyboard b/Example/Pluto-Example/Base.lproj/Main.storyboard index 058ae09..ebcd821 100644 --- a/Example/Pluto-Example/Base.lproj/Main.storyboard +++ b/Example/Pluto-Example/Base.lproj/Main.storyboard @@ -1,9 +1,9 @@ - + - + @@ -45,14 +45,14 @@ - - - - - + + + + + + + + +