Class: PayPal::SDK::REST::DataTypes::Base

Inherits:
Core::API::DataTypes::Base show all
Defined in:
lib/paypal-sdk/rest/data_types.rb

Direct Known Subclasses

Agreement, AgreementDetails, AgreementStateDescriptor, AgreementTransaction, AgreementTransactions, AllOf, AlternatePayment, Amount, AnyOf, Authorization, BankAccount, BankAccountsList, BankToken, BaseAddress, Billing, BillingAgreementToken, BillingInfo, Buyer, CancelNotification, Capture, CarrierAccountToken, CartBase, ChargeModels, Cost, CountryCode, Credit, CreditCard, CreditCardList, CreditCardToken, CreditFinancingOffered, Currency, CurrencyConversion, CustomAmount, Details, Dispute, DisputeOutcome, Error, ErrorDetails, EventType, EventTypeList, ExternalFunding, FileAttachment, FlowConfig, FmfDetails, FundingDetail, FundingInstrument, FundingOption, FundingSource, Incentive, InputFields, InstallmentInfo, InstallmentOption, Invoice, InvoiceAmountWrapper, InvoiceItem, Invoices, InvoicingMetaData, InvoicingNotification, InvoicingPaymentDetail, InvoicingRefundDetail, InvoicingSearch, Item, ItemInfo, ItemList, Links, Measurement, MerchantInfo, MerchantPreferences, Messages, Metadata, Money, NameValuePair, Notification, Offer, OneOf, Order, OverrideChargeModel, Participant, Patch, PatchRequest, Payee, Payer, PayerInfo, Payment, PaymentCard, PaymentDefinition, PaymentDetail, PaymentExecution, PaymentHistory, PaymentInstruction, PaymentOptions, PaymentSummary, PaymentTerm, Payout, PayoutBatch, PayoutBatchHeader, PayoutItem, PayoutItemDetails, PayoutSenderBatchHeader, Percentage, Phone, Plan, PlanList, PotentialPayerInfo, Presentation, PrivateLabelCard, ProcessorResponse, RecipientBankingInstruction, RedirectUrls, Refund, RefundDetail, RefundRequest, RelatedResources, Sale, Schema, Search, Seller, ShippingAddress, ShippingCost, ShippingInfo, Tax, Template, TemplateData, TemplateSettings, TemplateSettingsMetadata, Templates, Terms, Transaction, TransactionInfo, WebProfile, WebProfileList, Webhook, WebhookEvent, WebhookEventList, WebhookList, WebhooksEventType

Defined Under Namespace

Classes: Number

Constant Summary

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

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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, 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

Instance Attribute Details

#errorObject

Returns the value of attribute error.



12
13
14
# File 'lib/paypal-sdk/rest/data_types.rb', line 12

def error
  @error
end

#headerObject



15
16
17
# File 'lib/paypal-sdk/rest/data_types.rb', line 15

def header
  @header ||= {}
end

#request_idObject



19
20
21
# File 'lib/paypal-sdk/rest/data_types.rb', line 19

def request_id
  @request_id ||= SecureRandom.uuid
end

Class Method Details

.load_membersObject



40
41
# File 'lib/paypal-sdk/rest/data_types.rb', line 40

def self.load_members
end

.raise_on_api_error(*methods) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/paypal-sdk/rest/data_types.rb', line 43

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



23
24
25
# File 'lib/paypal-sdk/rest/data_types.rb', line 23

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

#merge!(values) ⇒ Object



31
32
33
34
# File 'lib/paypal-sdk/rest/data_types.rb', line 31

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

#raise_error!Object



36
37
38
# File 'lib/paypal-sdk/rest/data_types.rb', line 36

def raise_error!
  raise Core::Exceptions::UnsuccessfulApiCall, error if error
end

#success?Boolean

Returns:



27
28
29
# File 'lib/paypal-sdk/rest/data_types.rb', line 27

def success?
  @error.nil?
end