Class: PayPal::SDK::REST::DataTypes::Webhook

Inherits:
Base show all
Includes:
RequestDataType
Defined in:
lib/paypal-sdk/rest/data_types.rb

Constant Summary

Constants inherited from Core::API::DataTypes::Base

Core::API::DataTypes::Base::ContentKey, Core::API::DataTypes::Base::HashOptions

Instance Attribute Summary

Attributes inherited from Base

#error, #header, #request_id

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RequestDataType

#api, api, #error=, included

Methods included from SetAPI

#client_id=, #client_secret=, #set_config, #token=

Methods inherited from Base

#http_header, #merge!, #raise_error!, raise_on_api_error, #success?

Methods inherited from Core::API::DataTypes::Base

add_attribute, add_member, array_of, #convert_array, #convert_object, define_alias_methods, #hash_key, #initialize, #member_names, members, #members, #merge!, object_of, #set, #skip_value?, snakecase, #to_hash, #value_to_hash

Methods included from Core::Logging

#log_event, #logger, logger, logger=

Constructor Details

This class inherits a constructor from PayPal::SDK::Core::API::DataTypes::Base

Class Method Details

.all(options = {}) ⇒ Object



1670
1671
1672
1673
# File 'lib/paypal-sdk/rest/data_types.rb', line 1670

def all(options={})
  path = "v1/notifications/webhooks"
  WebhookList.new(api.get(path))
end

.get(webhook_id) ⇒ Object

Raises:

  • (ArgumentError)


1658
1659
1660
1661
1662
# File 'lib/paypal-sdk/rest/data_types.rb', line 1658

def get(webhook_id)
  raise ArgumentError.new("webhook_id required") if webhook_id.to_s.strip.empty?
  path = "v1/notifications/webhooks/#{webhook_id}"
  Webhook.new(api.get(path))
end

.get_event_types(webhook_id) ⇒ Object

Raises:

  • (ArgumentError)


1664
1665
1666
1667
1668
# File 'lib/paypal-sdk/rest/data_types.rb', line 1664

def get_event_types(webhook_id)
  raise ArgumentError.new("webhook_id required") if webhook_id.to_s.strip.empty?
  path = "v1/notifications/webhooks/#{webhook_id}/event-types"
  EventTypeList.new(api.get(path))
end

.load_membersObject



1623
1624
1625
1626
1627
1628
# File 'lib/paypal-sdk/rest/data_types.rb', line 1623

def self.load_members
  object_of :id, String
  object_of :url, String
  array_of  :event_types, EventType
  array_of  :links, Links
end

.simulate_event(webhook_id, url, event_type) ⇒ Object



1675
1676
1677
1678
1679
1680
# File 'lib/paypal-sdk/rest/data_types.rb', line 1675

def simulate_event(webhook_id, url, event_type)
  path = "v1/notifications/simulate-event"
  options = { :webhook_id => webhook_id, :url => url, :event_type => event_type }
  response = api.post(path, options)
  WebhookEvent.new(response)
end

Instance Method Details

#createObject



1632
1633
1634
1635
1636
1637
# File 'lib/paypal-sdk/rest/data_types.rb', line 1632

def create()
  path = "v1/notifications/webhooks"
  response = api.post(path, self.to_hash, http_header)
  self.merge!(response)
  Webhook.new(response)
end

#deleteObject



1648
1649
1650
1651
1652
1653
# File 'lib/paypal-sdk/rest/data_types.rb', line 1648

def delete()
  path = "v1/notifications/webhooks/#{self.id}"
  response = api.delete(path, {})
  self.merge!(response)
  success?
end

#update(patch) ⇒ Object



1639
1640
1641
1642
1643
1644
1645
1646
# File 'lib/paypal-sdk/rest/data_types.rb', line 1639

def update(patch)
  patch = Patch.new(patch) unless patch.is_a? Patch
  patch_request = Array.new(1, patch.to_hash)
  path = "v1/notifications/webhooks/#{self.id}"
  response = api.patch(path, patch_request, http_header)
  self.merge!(response)
  success?
end