-
-
Notifications
You must be signed in to change notification settings - Fork 69
/
ParseGoogle+combine.swift
90 lines (84 loc) · 3.44 KB
/
ParseGoogle+combine.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//
// ParseGoogle+combine.swift
// ParseSwift
//
// Created by Corey Baker on 1/1/22.
// Copyright © 2022 Parse Community. All rights reserved.
//
#if canImport(Combine)
import Foundation
import Combine
public extension ParseGoogle {
// MARK: Combine
/**
Login a `ParseUser` *asynchronously* using Google authentication for graph API login. Publishes when complete.
- parameter id: The **id** from **Google**.
- parameter idToken: Optional **id_token** from **Google**.
- parameter accessToken: Optional **access_token** from **Google**.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: A publisher that eventually produces a single value and then finishes or fails.
*/
func loginPublisher(id: String,
idToken: String? = nil,
accessToken: String? = nil,
options: API.Options = []) -> Future<AuthenticatedUser, ParseError> {
Future { promise in
self.login(id: id,
idToken: idToken,
accessToken: accessToken,
options: options,
completion: promise)
}
}
/**
Login a `ParseUser` *asynchronously* using Google authentication for graph API login. Publishes when complete.
- parameter authData: Dictionary containing key/values.
- returns: A publisher that eventually produces a single value and then finishes or fails.
*/
func loginPublisher(authData: [String: String],
options: API.Options = []) -> Future<AuthenticatedUser, ParseError> {
Future { promise in
self.login(authData: authData,
options: options,
completion: promise)
}
}
}
public extension ParseGoogle {
/**
Link the *current* `ParseUser` *asynchronously* using Google authentication for graph API login.
Publishes when complete.
- parameter id: The **id** from **Google**.
- parameter idToken: Optional **id_token** from **Google**.
- parameter accessToken: Optional **access_token** from **Google**.
- parameter options: A set of header options sent to the server. Defaults to an empty set.
- returns: A publisher that eventually produces a single value and then finishes or fails.
*/
func linkPublisher(id: String,
idToken: String? = nil,
accessToken: String? = nil,
options: API.Options = []) -> Future<AuthenticatedUser, ParseError> {
Future { promise in
self.link(id: id,
idToken: idToken,
accessToken: accessToken,
options: options,
completion: promise)
}
}
/**
Link the *current* `ParseUser` *asynchronously* using Google authentication for graph API login.
Publishes when complete.
- parameter authData: Dictionary containing key/values.
- returns: A publisher that eventually produces a single value and then finishes or fails.
*/
func linkPublisher(authData: [String: String],
options: API.Options = []) -> Future<AuthenticatedUser, ParseError> {
Future { promise in
self.link(authData: authData,
options: options,
completion: promise)
}
}
}
#endif