-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathRestifizerManager.cs
57 lines (45 loc) · 1.34 KB
/
RestifizerManager.cs
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
using UnityEngine;
using System.Collections;
namespace Restifizer {
public class RestifizerManager: MonoBehaviour, RestifizerParams {
public string baseUrl;
public MonoBehaviour errorHandler;
public static RestifizerManager Instance;
private string clientId;
private string clientSecret;
private string accessToken;
void Start () {
Instance = this;
}
void Awake() {
if (errorHandler != null && !(errorHandler is IErrorHandler)) {
Debug.LogError("Wrong ErrorHandler, it should implement IErrorHandler");
}
}
public RestifizerManager ConfigClientAuth(string clientId, string clientSecret) {
this.clientId = clientId;
this.clientSecret = clientSecret;
return this;
}
public RestifizerManager ConfigBearerAuth(string accessToken) {
this.accessToken = accessToken;
return this;
}
public RestifizerRequest ResourceAt(string resourceName) {
RestifizerRequest restifizerRequest = new RestifizerRequest(this, (IErrorHandler)errorHandler);
restifizerRequest.FetchList = true;
restifizerRequest.Path += baseUrl + "/" + resourceName;
return restifizerRequest;
}
/* RestifizerParams */
public string GetClientId() {
return clientId;
}
public string GetClientSecret() {
return clientSecret;
}
public string GetAccessToken() {
return accessToken;
}
}
}