Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.paypal.api.payments;
  
  import  com.paypal.core.Constants;
  import  com.paypal.core.rest.APIContext;
  import  com.paypal.core.rest.HttpMethod;
  import  com.paypal.core.rest.JSONFormatter;
  import  com.paypal.core.rest.PayPalRESTException;
  import  com.paypal.core.rest.PayPalResource;
  import  com.paypal.core.rest.RESTUtil;
 
 import java.util.List;
 
 
 public class Webhook  {

Identifier of the webhook resource.
 
 	private String id;

Webhook notification endpoint url.
 
 	private String url;

List of Webhooks event-types.
 
 	private List<EventTypeeventTypes;

Hateoas Links.
 
 	private List<Linkslinks;

Default Constructor
 
 	public Webhook() {
 	}

Parameterized Constructor
 
 	public Webhook(String urlList<EventTypeeventTypes) {
 		this. = url;
 		this. = eventTypes;
 	}


Setter for id
 
 	public Webhook setId(String id) {
 		this. = id;
 		return this;
 	}

Getter for id
 
 	public String getId() {
 		return this.;
 	}


Setter for url
 
 	public Webhook setUrl(String url) {
 		this. = url;
 		return this;
 	}

Getter for url
 
 	public String getUrl() {
 		return this.;
 	}


Setter for eventTypes
 
 	public Webhook setEventTypes(List<EventTypeeventTypes) {
 		this. = eventTypes;
 		return this;
 	}

Getter for eventTypes
 
 	public List<EventTypegetEventTypes() {
 		return this.;
 	}


Setter for links
	public Webhook setLinks(List<Linkslinks) {
		this. = links;
		return this;
	}

Getter for links
	public List<LinksgetLinks() {
		return this.;
	}

Creates the Webhook for the application associated with the access token.

Parameters:
accessToken Access Token used for the API call.
webhook Webhook Request
Returns:
Webhook
Throws:
PayPalRESTException
	public Webhook create(String accessTokenWebhook webhookthrows PayPalRESTException {
		APIContext apiContext = new APIContext(accessToken);
		return create(apiContextwebhook);
	}

Creates the Webhook for the application associated with the access token.

Parameters:
apiContext APIContext used for the API call.
webhook Webhook Request
Returns:
Webhook
Throws:
PayPalRESTException
	public Webhook create(APIContext apiContextWebhook webhookthrows PayPalRESTException {
		if (apiContext == null) {
			throw new IllegalArgumentException("APIContext cannot be null");
		}
		if (apiContext.getAccessToken() == null || apiContext.getAccessToken().trim().length() <= 0) {
			throw new IllegalArgumentException("AccessToken cannot be null or empty");
		}
		if (apiContext.getHTTPHeaders() == null) {
			apiContext.setHTTPHeaders(new HashMap<StringString>());
		}
		if (webhook == null) {
			throw new IllegalArgumentException("webhook cannot be null");
		}
		apiContext.getHTTPHeaders().put(Constants.HTTP_CONTENT_TYPE_HEADER, Constants.HTTP_CONTENT_TYPE_JSON);
		apiContext.setSdkVersion(new SDKVersionImpl());
		Object[] parameters = new Object[] {};
		String pattern = "v1/notifications/webhooks";
		String resourcePath = RESTUtil.formatURIPath(patternparameters);
		String payLoad = webhook.toJSON();
		return PayPalResource.configureAndExecute(apiContext, HttpMethod.POST, resourcePathpayLoadWebhook.class);
	}

Retrieves the Webhook identified by webhook_id for the application associated with access token.

Parameters:
accessToken Access Token used for the API call.
webhookId Identifier of the webhook
Returns:
Webhook
Throws:
PayPalRESTException
	public Webhook get(String accessTokenString webhookIdthrows PayPalRESTException {
		APIContext apiContext = new APIContext(accessToken);
		return get(apiContextwebhookId);
	}

Retrieves the Webhook identified by webhook_id for the application associated with access token.

Parameters:
apiContext APIContext used for the API call.
webhookId Identifier of the webhook
patchRequest patchRequest
Returns:
Webhook
Throws:
PayPalRESTException
	public Webhook get(APIContext apiContextString webhookIdthrows PayPalRESTException {
		if (apiContext == null) {
			throw new IllegalArgumentException("APIContext cannot be null");
		}
		if (apiContext.getAccessToken() == null || apiContext.getAccessToken().trim().length() <= 0) {
			throw new IllegalArgumentException("AccessToken cannot be null or empty");
		}
		if (apiContext.getHTTPHeaders() == null) {
			apiContext.setHTTPHeaders(new HashMap<StringString>());
		}
		if (webhookId == null) {
			throw new IllegalArgumentException("webhookId cannot be null");
		}
		apiContext.getHTTPHeaders().put(Constants.HTTP_CONTENT_TYPE_HEADER, Constants.HTTP_CONTENT_TYPE_JSON);
		apiContext.setSdkVersion(new SDKVersionImpl());
		Object[] parameters = new Object[] {webhookId};
		String pattern = "v1/notifications/webhooks/{0}";
		String resourcePath = RESTUtil.formatURIPath(patternparameters);
		String payLoad = "";
		return PayPalResource.configureAndExecute(apiContext, HttpMethod.GET, resourcePathpayLoadWebhook.class);
	}

Updates the Webhook identified by webhook_id for the application associated with access token.

Parameters:
accessToken Access Token used for the API call.
webhookId Identifier of the webhook
patchRequest patchRequest
Returns:
Webhook
Throws:
PayPalRESTException
	public Webhook update(String accessTokenString webhookIdString patchRequestthrows PayPalRESTException {
		APIContext apiContext = new APIContext(accessToken);
		return update(apiContextwebhookIdpatchRequest);
	}

Updates the Webhook identified by webhook_id for the application associated with access token.

Parameters:
apiContext APIContext used for the API call.
webhookId Identifier of the webhook
Returns:
Webhook
Throws:
PayPalRESTException
	public Webhook update(APIContext apiContextString webhookIdString patchRequestthrows PayPalRESTException {
		if (apiContext == null) {
			throw new IllegalArgumentException("APIContext cannot be null");
		}
		if (apiContext.getAccessToken() == null || apiContext.getAccessToken().trim().length() <= 0) {
			throw new IllegalArgumentException("AccessToken cannot be null or empty");
		}
		if (apiContext.getHTTPHeaders() == null) {
			apiContext.setHTTPHeaders(new HashMap<StringString>());
		}
		if (webhookId == null) {
			throw new IllegalArgumentException("webhookId cannot be null");
		}
		if (patchRequest == null) {
			throw new IllegalArgumentException("patchRequest cannot be null");
		}
		apiContext.getHTTPHeaders().put(Constants.HTTP_CONTENT_TYPE_HEADER, Constants.HTTP_CONTENT_TYPE_JSON);
		apiContext.setSdkVersion(new SDKVersionImpl());
		Object[] parameters = new Object[] {webhookId};
		String pattern = "v1/notifications/webhooks/{0}";
		String resourcePath = RESTUtil.formatURIPath(patternparameters);
		String payLoad = patchRequest;
		return PayPalResource.configureAndExecute(apiContext, HttpMethod.PATCH, resourcePathpayLoadWebhook.class);
	}

Deletes the Webhook identified by webhook_id for the application associated with access token.

Parameters:
accessToken Access Token used for the API call.
webhookId Identifier of the webhook
Throws:
PayPalRESTException
	public void delete(String accessTokenString webhookIdthrows PayPalRESTException {
		APIContext apiContext = new APIContext(accessToken);
		delete(apiContextwebhookId);
	}

Deletes the Webhook identified by webhook_id for the application associated with access token.

Parameters:
apiContext APIContext used for the API call.
webhookId Identifier of the webhook
Throws:
PayPalRESTException
	public void delete(APIContext apiContextString webhookIdthrows PayPalRESTException {
		if (apiContext == null) {
			throw new IllegalArgumentException("APIContext cannot be null");
		}
		if (apiContext.getAccessToken() == null || apiContext.getAccessToken().trim().length() <= 0) {
			throw new IllegalArgumentException("AccessToken cannot be null or empty");
		}
		if (apiContext.getHTTPHeaders() == null) {
			apiContext.setHTTPHeaders(new HashMap<StringString>());
		}
		if (webhookId == null) {
			throw new IllegalArgumentException("webhookId cannot be null");
		}
		apiContext.getHTTPHeaders().put(Constants.HTTP_CONTENT_TYPE_HEADER, Constants.HTTP_CONTENT_TYPE_JSON);
		apiContext.setSdkVersion(new SDKVersionImpl());
		Object[] parameters = new Object[] {webhookId};
		String pattern = "v1/notifications/webhooks/{0}";
		String resourcePath = RESTUtil.formatURIPath(patternparameters);
		String payLoad = "";
		PayPalResource.configureAndExecute(apiContext, HttpMethod.DELETE, resourcePathpayLoadnull);
	}

Returns a JSON string corresponding to object state

Returns:
JSON representation
	public String toJSON() {
		return JSONFormatter.toJSON(this);
	}
	public String toString() {
		return toJSON();
	}
New to GrepCode? Check out our FAQ X