Skip to content

Commit

Permalink
Merge pull request #239 from razorpay/subscription_entity_nmock
Browse files Browse the repository at this point in the history
Subscription entity nmock
  • Loading branch information
ankitdas13 authored Aug 24, 2022
2 parents 813484f + 9ff0927 commit 10596bc
Show file tree
Hide file tree
Showing 2 changed files with 178 additions and 102 deletions.
33 changes: 18 additions & 15 deletions src/main/java/com/razorpay/SubscriptionClient.java
Original file line number Diff line number Diff line change
@@ -1,64 +1,67 @@
package com.razorpay;

import java.io.IOException;
import java.net.URISyntaxException;
import java.util.List;

import org.json.JSONException;
import org.json.JSONObject;

public class SubscriptionClient extends ApiClient {

SubscriptionClient(String auth) {
super(auth);
SubscriptionClient(String auth, ApiUtils apiUtils) {
super(auth,apiUtils);
}

public Subscription create(JSONObject request) throws RazorpayException {
public Subscription create(JSONObject request) throws RazorpayException, JSONException, IOException, URISyntaxException {
return post(Constants.SUBSCRIPTION_CREATE, request);
}

public Subscription fetch(String id) throws RazorpayException {
public Subscription fetch(String id) throws RazorpayException, JSONException, IOException, URISyntaxException {
return get(String.format(Constants.SUBSCRIPTION, id), null);
}

public List<Subscription> fetchAll() throws RazorpayException {
public List<Subscription> fetchAll() throws RazorpayException, JSONException, IOException, URISyntaxException {
return fetchAll(null);
}

public List<Subscription> fetchAll(JSONObject request) throws RazorpayException {
public List<Subscription> fetchAll(JSONObject request) throws RazorpayException, JSONException, IOException, URISyntaxException {
return getCollection(Constants.SUBSCRIPTION_LIST, request);
}

public Subscription cancel(String id) throws RazorpayException {
public Subscription cancel(String id) throws RazorpayException, JSONException, IOException, URISyntaxException {
return cancel(id, null);
}

public Subscription cancel(String id, JSONObject request) throws RazorpayException {
public Subscription cancel(String id, JSONObject request) throws RazorpayException, JSONException, IOException, URISyntaxException {
return post(String.format(Constants.SUBSCRIPTION_CANCEL, id), request);
}

public Addon createAddon(String id, JSONObject request) throws RazorpayException {
public Addon createAddon(String id, JSONObject request) throws RazorpayException, JSONException, IOException, URISyntaxException {
return post(String.format(Constants.SUBSCRIPTION_ADDON_CREATE, id), request);
}

public Subscription update(String id, JSONObject request) throws RazorpayException {
public Subscription update(String id, JSONObject request) throws RazorpayException, JSONException, IOException, URISyntaxException {
return patch(String.format(Constants.SUBSCRIPTION, id), request);
}

public Subscription fetchPendingUpdate(String id) throws RazorpayException {
public Subscription fetchPendingUpdate(String id) throws RazorpayException, JSONException, IOException, URISyntaxException {
return get(String.format(Constants.SUBSCRIPTION_PENDING_UPDATE, id), null);
}

public Subscription cancelPendingUpdate(String id) throws RazorpayException {
public Subscription cancelPendingUpdate(String id) throws RazorpayException, JSONException, IOException, URISyntaxException {
return post(String.format(Constants.SUBSCRIPTION_CANCEL_SCHEDULED_UPDATE, id), null);
}

public Subscription pause(String id, JSONObject request) throws RazorpayException {
public Subscription pause(String id, JSONObject request) throws RazorpayException, JSONException, IOException, URISyntaxException {
return post(String.format(Constants.PAUSE_SUBSCRIPTION, id), request);
}

public Subscription resume(String id, JSONObject request) throws RazorpayException {
public Subscription resume(String id, JSONObject request) throws RazorpayException, JSONException, IOException, URISyntaxException {
return post(String.format(Constants.RESUME_SUBSCRIPTION, id), request);
}

public Subscription deleteSubscriptionOffer(String subId, String offerId) throws RazorpayException {
public Subscription deleteSubscriptionOffer(String subId, String offerId) throws RazorpayException, JSONException, IOException, URISyntaxException {
return delete(String.format(Constants.SUBSCRIPTION_OFFER, subId, offerId), null);
}
}
Loading

0 comments on commit 10596bc

Please sign in to comment.