Class: PayPal::SDK::Subscriptions::RequestBase

Inherits:
RequestAPIBase
  • Object
show all
Defined in:
lib/paypal-sdk/subscriptions/request_base.rb

Instance Attribute Summary

Attributes inherited from RequestAPIBase

#error, #header, #request_id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RequestAPIBase

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

Methods included from RequestDataType

#api, api, #error=, included

Class Method Details

.create!(attrs) ⇒ Object



79
80
81
# File 'lib/paypal-sdk/subscriptions/request_base.rb', line 79

def self.create!(attrs)
  new(attrs).tap(&:create!)
end

.find(resource_id) ⇒ Object

Raises:

  • (ArgumentError)


88
89
90
91
# File 'lib/paypal-sdk/subscriptions/request_base.rb', line 88

def self.find(resource_id)
  raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
  new api.get(path resource_id)
end

Instance Method Details

#commit(path, data = {}, method = :post) ⇒ Object



74
75
76
77
# File 'lib/paypal-sdk/subscriptions/request_base.rb', line 74

def commit(path, data = {}, method = :post)
  merge! api.send(method, path, data, http_header)
  success?
end

#createObject



83
84
85
# File 'lib/paypal-sdk/subscriptions/request_base.rb', line 83

def create
  commit(path, to_hash)
end

#path(id = nil) ⇒ Object



70
71
72
# File 'lib/paypal-sdk/subscriptions/request_base.rb', line 70

def path(id = nil)
  self.class.path(id)
end

#update(patch) ⇒ Object

patch [Hash] { op: ‘replace’, path: , value: }



94
95
96
97
# File 'lib/paypal-sdk/subscriptions/request_base.rb', line 94

def update(patch)
  patch = Patch.new(patch) unless patch.is_a? Patch
  commit(path(id), [patch.to_hash], :patch)
end