forked from SeunAdelekan/PaystackJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSubscriptions.java
More file actions
96 lines (77 loc) · 3.42 KB
/
Subscriptions.java
File metadata and controls
96 lines (77 loc) · 3.42 KB
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
91
92
93
94
95
96
import org.json.JSONObject;
import java.util.HashMap;
/**
* Created by Iyanu on 17/07/2016.
*/
public class Subscriptions {
public Subscriptions(){
}
private ApiConnection apiConnection = null;
private ApiQuery apiQuery = null;
/*
The following set of methods aids the sending of API
requests for the CREATION of subscriptions
*/
public JSONObject createSubscription(HashMap<String, Object> queryMap) {
apiConnection = new ApiConnection(Definitions.PAYSTACK_SUBSCRIPTIONS_CREATE_SUBSCRIPTION);
return apiConnection.connectAndQuery(queryMap);
}
public JSONObject createSubscription(ApiQuery query) {
apiConnection = new ApiConnection(Definitions.PAYSTACK_SUBSCRIPTIONS_CREATE_SUBSCRIPTION);
return apiConnection.connectAndQuery(query);
}
public JSONObject createSubscription(String customer, String plan, String authorization) {
apiConnection = new ApiConnection(Definitions.PAYSTACK_SUBSCRIPTIONS_CREATE_SUBSCRIPTION);
apiQuery = new ApiQuery();
apiQuery.putParams("customer", customer);
apiQuery.putParams("plan", plan);
apiQuery.putParams("authorization", authorization);
return apiConnection.connectAndQuery(apiQuery);
}
/*
The following set of methods aids the sending of API
requests for the DISABLING of subscriptions
*/
public JSONObject disableSubscription(HashMap<String, Object> queryMap) {
apiConnection = new ApiConnection(Definitions.PAYSTACK_SUBSCRIPTIONS_DISABLE_SUBSCRIPTION);
return apiConnection.connectAndQuery(queryMap);
}
public JSONObject disableSubscription(ApiQuery query) {
apiConnection = new ApiConnection(Definitions.PAYSTACK_SUBSCRIPTIONS_DISABLE_SUBSCRIPTION);
return apiConnection.connectAndQuery(query);
}
public JSONObject disableSubscription(String code, String token) {
apiConnection = new ApiConnection(Definitions.PAYSTACK_SUBSCRIPTIONS_DISABLE_SUBSCRIPTION);
apiQuery = new ApiQuery();
apiQuery.putParams("code", code);
apiQuery.putParams("token", token);
return apiConnection.connectAndQuery(apiQuery);
}
/*
The following set of methods aids the sending of API
requests for the ENABLING of subscriptions
*/
public JSONObject enableSubscription(HashMap<String, Object> queryMap) {
apiConnection = new ApiConnection(Definitions.PAYSTACK_SUBSCRIPTIONS_ENABLE_SUBSCRIPTION);
return apiConnection.connectAndQuery(queryMap);
}
public JSONObject enableSubscription(ApiQuery query) {
apiConnection = new ApiConnection(Definitions.PAYSTACK_SUBSCRIPTIONS_ENABLE_SUBSCRIPTION);
return apiConnection.connectAndQuery(query);
}
public JSONObject enableSubscription(String code, String token) {
apiConnection = new ApiConnection(Definitions.PAYSTACK_SUBSCRIPTIONS_ENABLE_SUBSCRIPTION);
apiQuery = new ApiQuery();
apiQuery.putParams("code", code);
apiQuery.putParams("token", token);
return apiConnection.connectAndQuery(apiQuery);
}
/*
The following set of methods aids the sending of API
requests for the FETCHING of subscriptions
*/
public JSONObject fetchSubscription(String idOrSubscriptionCode) {
apiConnection = new ApiConnection(Definitions.PAYSTACK_SUBSCRIPTIONS_FETCH_SUBSCRIPTION);
return apiConnection.connectAndQueryWithGet();
}
}