Class: PayPal::SDK::Subscriptions::RequestAPIBase

Inherits:
Core::API::DataTypes::Base
  • Object
show all
Includes:
RequestDataType
Defined in:
lib/paypal-sdk/subscriptions/request_base.rb

Direct Known Subclasses

RequestBase

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RequestDataType

#api, api, included

Instance Attribute Details

#errorObject

Returns the value of attribute error.



25
26
27
# File 'lib/paypal-sdk/subscriptions/request_base.rb', line 25

def error
  @error
end

#headerObject



28
29
30
# File 'lib/paypal-sdk/subscriptions/request_base.rb', line 28

def header
  @header ||= {}
end

#request_idObject



32
33
34
# File 'lib/paypal-sdk/subscriptions/request_base.rb', line 32

def request_id
  @request_id ||= SecureRandom.uuid
end

Class Method Details

.raise_on_api_error(*methods) ⇒ Object



53
54
55
56
57
58
59
# File 'lib/paypal-sdk/subscriptions/request_base.rb', line 53

def self.raise_on_api_error(*methods)
  methods.each do |symbol|
    define_method("#{symbol}!") {|*arg|
      raise_error! unless send(symbol, *arg)
    }
  end
end

Instance Method Details

#http_headerObject



36
37
38
# File 'lib/paypal-sdk/subscriptions/request_base.rb', line 36

def http_header
  { "PayPal-Request-Id" => request_id.to_s }.merge(header)
end

#merge!(values) ⇒ Object



44
45
46
47
# File 'lib/paypal-sdk/subscriptions/request_base.rb', line 44

def merge!(values)
  @error = nil
  super
end

#raise_error!Object



49
50
51
# File 'lib/paypal-sdk/subscriptions/request_base.rb', line 49

def raise_error!
  raise UnsuccessfulApiCall, error if error
end

#success?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/paypal-sdk/subscriptions/request_base.rb', line 40

def success?
  @error.nil?
end