Class: VisaAcceptanceMergedSpec::BaseModel

Inherits:
CoreLibrary::BaseModel
  • Object
show all
Defined in:
lib/visa_acceptance_merged_spec/models/base_model.rb

Overview

Base model. rubocop:disable all

Direct Known Subclasses

Account, Account1, Account12, Account14, Account15, Account2, Account3, Account6, Account8, Account9, AccountFeatures, AccountFeatures1, AccountFeatures2, AccountHistory, AchVerification, AcquirerInformation, ActualFinalDestination, Agency, Agency5, AggregatorInformation, AggregatorInformation1, AggregatorInformation5, AgreementInformation, AgreementInformation1, AgreementInformation10, AgreementInformation5, AgreementInformation6, AgreementInformation7, AgreementInformation8, AgreementInformation9, Airline, AmexAdditionalAmount, AmountDetails, AmountDetails1, AmountDetails10, AmountDetails12, AmountDetails2, AmountDetails22, AmountDetails26, AmountDetails27, AmountDetails28, AmountDetails29, AmountDetails3, AmountDetails32, AmountDetails35, AmountDetails36, AmountDetails5, AmountDetails6, AmountDetails9, AncillaryInformation, ApCapture, Application, ApplicationInformation, AuthReversalRequest, AuthorizationInformation, AuthorizationOptions, AuthorizationOptions1, AuthorizationOptions2, AuthorizationOptions3, AuthorizationOptions4, AuthorizationOptions5, AuthorizationOptions6, AutoRental, AutoRental5, AuxiliaryDatum, Avs, Avs1, Balance, Bank, Bank1, Bank11, Bank13, Bank2, Bank6, Bank7, Bank9, BankAccount, BankAccount1, BankAccountValidation, BankTransferOptions, BankTransferOptions1, BankTransferOptions2, BankTransferOptions21, BankTransferOptions3, BankTransferOptions4, BillTo, BillTo1, BillTo11, BillTo12, BillTo14, BillTo15, BillTo16, BillTo2, BillTo3, BillTo56, BillTo57, BillTo6, BillTo7, BillTo9, BinLookup, Bonuse, Brand, Brand24, BrandLogoAsset, BrandLogoAsset2, BuyerHistory, BuyerInformation, BuyerInformation1, BuyerInformation11, BuyerInformation12, BuyerInformation13, BuyerInformation2, BuyerInformation34, BuyerInformation6, BuyerInformation7, BuyerInformation8, BuyerInformation9, Capture, Capture1, CaptureMandate, CaptureOptions, CaptureOptions1, CaptureOptions2, CaptureOptions3, CapturePaymentRequest, Card, Card1, Card10, Card105, Card12, Card13, Card14, Card15, Card2, Card3, Card4, Card5, Card7, CardArt, CardVerification, CardVerification1, ClientReferenceInformation, ClientReferenceInformation1, ClientReferenceInformation10, ClientReferenceInformation11, ClientReferenceInformation2, ClientReferenceInformation26, ClientReferenceInformation28, ClientReferenceInformation29, ClientReferenceInformation3, ClientReferenceInformation39, ClientReferenceInformation4, ClientReferenceInformation42, ClientReferenceInformation47, Color, CombinedAsset, CombinedAsset2, Company, Company5, CompleteMandate, CompleteMandate2, ConsumerAuthenticationInformation, ConsumerAuthenticationInformation1, ConsumerAuthenticationInformation2, ConsumerAuthenticationInformation4, ConsumerAuthenticationResponse, Consumerauthentication, Content, CreateBillingAgreement, CreateCreditRequest, CreateOrderRequest, CreatePaymentRequest, CreateSessionReq, CreateSessionRequest, CreditAmountDetails, CurrencyConversion, Customer, Customer1, Customer10, Customer14, Customer15, Customer2, Customer4, Customer42, CustomerAccount, Decision, DefaultPaymentInstrument, DefaultPaymentInstrument1, DefaultShippingAddress, DefaultShippingAddress1, Detail, Detail15, Detail27, Detail40, Detail66, DeviceInformation, DeviceInformation1, DeviceInformation5, DeviceInformation7, DeviceInformation9, DirectDebit, DirectDebitSepa, EWallet, EWallet1, EWallet10, EWallet13, EWallet2, EWallet5, EWallet6, EWallet7, EWallet8, EWallet9, ElectronicBenefitsTransfer, ElectronicBenefitsTransfer1, ElectronicVerificationResults, ElectronicVerificationResults1, Embedded, Embedded1, Embedded12, Embedded15, Embedded2, Embedded20, Embedded4, Embedded8, Embedded9, EmbeddedActions, EmbeddedActions1, EmbeddedActions2, Emv, Emv1, Emv2, Emv6, Error, Error1, Error15, Error2, Error3, Error4, Error8, ErrorInformation, ErrorInformation1, ErrorInformation17, ErrorInformation2, ErrorInformation20, ErrorInformation6, EventInformation, Features, Features24, First, FirstDeparture, FirstDestination, FluidData, FluidData4, FraudMarkingInformation, GenerateUnifiedCheckoutCaptureContextException, GenerateUnifiedCheckoutCaptureContextRequest, GetCardArtAssetResponse, GetCustomerPaymentInstrumentResponse, GetCustomerResponse, GetCustomerShippingAddressResponse, GetInstrumentIdentifierResponse, GetPaymentInstrumentResponse, GetTokenizedCardResponse, HealthCareInformation, HostedPaymentInformation, IconAsset, IconAsset2, IncrementAuthRequest, InfoCodes, Initiator, Initiator1, Initiator2, Initiator26, InstallmentInformation, InstallmentInformation1, InstallmentInformation10, InstallmentInformation2, InstallmentInformation3, InstallmentInformation4, InstallmentInformation5, InstrumentIdentifier, InstrumentIdentifier1, InstrumentIdentifier10, InstrumentIdentifier2, InstrumentIdentifier27, InstrumentIdentifier3, IntimateBillingAgreement, Invoice, InvoiceDetails, InvoiceDetails1, InvoiceDetails12, InvoiceDetails13, InvoiceDetails14, InvoiceDetails16, InvoiceDetails2, InvoiceDetails3, InvoiceDetails4, InvoiceDetails5, IpAddress, IpAddress2, IssuedBy, Issuer, Issuer1, Issuer3, Issuer4, IssuerInformation, IssuerInformation1, IssuerInformation2, IssuerInformation3, IssuerInformation30, IssuerInformation5, IssuerInformation6, IssuerLogoAsset, IssuerLogoAsset2, Ivr, JapanPaymentOptions, JapanPaymentOptions1, JapanPaymentOptions2, Last, LastDestination, Leg, LegacyToken, LineItem, LineItem1, LineItem11, LineItem3, LineItem4, LineItem7, LineItem9, Links, Links1, Links13, Links14, Links15, Links16, Links19, Links20, Links21, Links219, Links22, Links23, Links24, Links25, Links26, Links27, Links4, Links5, Links66, LoanOptions, Lodging, Mandate, Mandate1, Match, MerchantAdvice, MerchantDefinedInformation, MerchantDefinedInformation7, MerchantDefinedSecureInformation, MerchantDefinedSecureInformation2, MerchantDescriptor, MerchantDescriptor1, MerchantDescriptor11, MerchantDescriptor13, MerchantDescriptor30, MerchantDescriptor6, MerchantInformation, MerchantInformation1, MerchantInformation11, MerchantInformation14, MerchantInformation16, MerchantInformation17, MerchantInformation18, MerchantInformation2, MerchantInformation3, MerchantInformation35, MerchantInformation4, MerchantInformation7, MerchantInitiatedTransaction, MerchantInitiatedTransaction1, MerchantInitiatedTransactionObject, Metadata, Metadata1, Metadata2, Metadata3, Metadata36, Metadata4, Method, Method1, Method12, Method13, Method19, Method2, MitReversalRequest, MitVoidRequest, ModifyBillingAgreement, Morphing, MultiProcessorRouting, Network, Network24, Next, ObjectInformation, OctSurcharge, Options, Options1, Orchestration, Order, OrderInformation, OrderInformation1, OrderInformation14, OrderInformation19, OrderInformation2, OrderInformation20, OrderInformation22, OrderInformation24, OrderInformation25, OrderInformation26, OrderInformation27, OrderInformation3, OrderInformation30, OrderInformation31, OrderInformation32, OrderInformation33, OrderInformation34, OrderInformation4, OrderInformation6, OrderInformation7, OrderInformation8, OrderInformation9, OrderPaymentRequest, Partner, Partner1, Partner16, Partner2, Passcode, Passcode2, Passenger, Passenger2, PassiveProfile, PassiveRule, PatchCustomerPaymentInstrumentRequest, PatchCustomerRequest, PatchCustomerResponse, PatchCustomerShippingAddressRequest, PatchCustomersPaymentInstrumentResponse, PatchCustomersShippingAddressResponse, PatchInstrumentIdentifierRequest, PatchInstrumentIdentifierResponse, PatchPaymentInstrumentRequest, PatchPaymentInstrumentResponse, PaymentAccountInformation, PaymentAccountInformation1, PaymentAccountReference, PaymentInformation, PaymentInformation1, PaymentInformation14, PaymentInformation15, PaymentInformation16, PaymentInformation18, PaymentInformation2, PaymentInformation20, PaymentInformation21, PaymentInformation22, PaymentInformation23, PaymentInformation26, PaymentInformation28, PaymentInformation29, PaymentInformation3, PaymentInformation30, PaymentInformation31, PaymentInformation4, PaymentInformation5, PaymentInformation8, PaymentInformation9, PaymentInsightsInformation, PaymentInstrument, PaymentInstrument1, PaymentInstrument2, PaymentInstrument4, PaymentInstrumentList, PaymentInstruments, PaymentInstruments1, PaymentInstruments12, PaymentType, PaymentType1, PaymentType11, PaymentType12, PaymentType13, PaymentType19, PaymentType2, PaymentType22, PaymentType3, PaymentsStrongAuthIssuerInformation, PayoutOptions, PersonalIdentification, PersonalIdentification2, PersonalIdentification6, PersonalIdentification9, PointOfSaleInformation, PointOfSaleInformation1, PointOfSaleInformation14, PointOfSaleInformation2, PointOfSaleInformation6, PointOfSaleInformation7, PointOfSaleInformation8, PostCustomerPaymentInstrumentRequest, PostCustomerPaymentInstrumentResponse, PostCustomerRequest, PostCustomerShippingAddressRequest, PostCustomerShippingAddressResponse, PostInstrumentIdentifierEnrollmentRequest, PostInstrumentIdentifierRequest, PostInstrumentIdentifierResponse, PostPaymentCredentialsRequest, PostPaymentInstrumentRequest, PostPaymentInstrumentResponse, PostTokenizedCardResponse, Prev, ProcessingInformation, ProcessingInformation1, ProcessingInformation11, ProcessingInformation12, ProcessingInformation13, ProcessingInformation17, ProcessingInformation18, ProcessingInformation19, ProcessingInformation2, ProcessingInformation20, ProcessingInformation21, ProcessingInformation22, ProcessingInformation23, ProcessingInformation25, ProcessingInformation26, ProcessingInformation27, ProcessingInformation28, ProcessingInformation3, ProcessingInformation5, ProcessingInformation52, ProcessingInformation6, ProcessingInformation7, Processor, ProcessorInformation, ProcessorInformation1, ProcessorInformation10, ProcessorInformation15, ProcessorInformation16, ProcessorInformation18, ProcessorInformation19, ProcessorInformation2, ProcessorInformation20, ProcessorInformation22, ProcessorInformation24, ProcessorInformation3, ProcessorInformation4, ProcessorInformation5, ProcessorInformation6, ProcessorInformation7, ProcessorResults, ProcessorResults1, Profile, Profile1, Profile2, Profile3, PromotionInformation, PtsV1TransactionBatchesGet200Response, PtsV1TransactionBatchesIdGet200Response, PtsV2CapturesRefundsPost201Response, PtsV2CapturesVoidsPost201Response, PtsV2CreateBillingAgreementPost201Response, PtsV2CreateOrderPost201Response, PtsV2CreditsPost201Response, PtsV2CreditsPost201Response1, PtsV2CreditsVoidsPost201Response, PtsV2IncrementalAuthorizationPatch201Response, PtsV2ModifyBillingAgreementPost201Response, PtsV2PaymentsCapturesPost201Response, PtsV2PaymentsOrderPost201Response, PtsV2PaymentsPost201Response, PtsV2PaymentsPost201Response1, PtsV2PaymentsPost201Response2, PtsV2PaymentsRefundPost201Response, PtsV2PaymentsReversalsPost201Response, PtsV2PaymentsVoidsPost201Response, PtsV2RefundsVoidsPost201Response, PtsV2ReversalsPost201Response, PtsV2UpdateOrderPatch201Response, PtsV2VoidsPost200Response, PurchaseOptions, PurchaseOptions1, PurchaseOptions2, RawDatum, RecipientInformation, RecipientInformation1, RecipientInformation2, RecurringOptions, RecurringOptions1, RecurringPaymentInformation, RecurringPaymentInformation1, RecurringPaymentInformation2, RefreshPaymentStatusRequest, Refund, RefundAmountDetails, RefundCaptureRequest, RefundOptions, RefundOptions2, RefundPaymentRequest, RelatedTransaction, RentalAddress, Request, ResponseInsights, RetrieveOrDeletePaymentTokenResponse, ReturnAddress, Reversal, Reversal1, ReversalAmountDetails, ReversalInformation, RevokeAgreement, RewardPointsDetails, RiskInformation, RiskInformation1, RiskInformation2, RiskInformation22, RiskInformation3, RiskInformation4, RiskInformation5, Room, Routing, Rule, Rule1, Score, Score1, Self, Self13, Self18, Self19, Self20, Self21, Self22, Self23, Self24, Self25, Self26, Self65, SellerProtection, SellerProtection3, SenderInformation, SenderInformation1, SenderInformation2, SenderInformation3, Sepa, Service, ServiceFeeDescriptor, ServiceLocation, ShipTo, ShipTo1, ShipTo11, ShipTo13, ShipTo14, ShipTo2, ShipTo25, ShipTo26, ShipTo6, ShipTo7, ShipTo8, ShipTo9, ShippingAddress, ShippingAddress1, ShippingAddress11, ShippingAddress16, ShippingAddress2, ShippingAddress4, ShippingAddressListForCustomer, ShippingDetails, ShippingDetails1, ShippingDetails2, ShippingDetails5, ShippingDetails8, Status, StrongAuthentication, StrongAuthentication1, StrongAuthentication2, SubMerchant, SubMerchant1, Surcharge, Surcharge1, TaxDetail, TaxDetails, TaxDetails1, TicketIssuer, TmsAuthorizationOptions, TmsBinLookup, TmsCardArt, TmsEmbeddedInstrumentIdentifier, TmsPaymentInstrumentProcessingInfo, TmsV2CustomersResponse, Tmsv2TokenizedCard, TokenInformation, TokenInformation1, TokenInformation2, TokenProvisioningInformation, Tokencreate, TokenizedCard, TokenizedCard1, TokenizedCard5, TokenizedInformation, TokenizedPaymentMethod, TokenizedPaymentMethod1, TokenizedPaymentMethod2, TokenizedPaymentMethod4, TokenizedcardRequest, Tokenupdate, Transaction, TransactionAdviceAddendum, TransactionBatch, TransientTokenResponseOptions, Transit, Travel, TravelInformation, TravelInformation1, TravelInformation6, TravelInformation8, TssV2TransactionsGet200Response, UnscheduledPaymentInformation, UpdateAgreement, UpdateOrderRequest, UserAgent, UserAgent2, UserInterface, Validateconsumerauthentication, VehicleData, Velocity, Void, VoidAmountDetails, VoidCaptureRequest, VoidCreditRequest, VoidPaymentRequest, VoidRefundRequest, WatchList, WatchlistScreeningInformation, WatchlistScreeningInformation1, Watchlistscreening, Weights

Instance Method Summary collapse

Instance Method Details

#check_for_conflict(name, existing_prop_names) ⇒ Object

Checks if an additional property conflicts with a model's existing property.

Raises:

  • (ArgumentError)


80
81
82
83
84
# File 'lib/visa_acceptance_merged_spec/models/base_model.rb', line 80

def check_for_conflict(name, existing_prop_names)
  return unless existing_prop_names.key?(name)

  raise ArgumentError, "An additional property key, '#{name}' conflicts with one of the model's properties"
end

#process_additional_properties(additional_properties, existing_prop_names) ⇒ Object

Processes additional properties, ensuring no conflicts with existing properties.



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/visa_acceptance_merged_spec/models/base_model.rb', line 63

def process_additional_properties(additional_properties, existing_prop_names)
  hash = {}
  additional_properties.each do |name, value|
    check_for_conflict(name, existing_prop_names)

    hash[name] = if value.is_a?(Array)
                   process_array(value)
                 elsif value.is_a?(Hash)
                   process_hash(value)
                 else
                   process_basic_value(value)
                 end
  end
  hash
end

#process_array(value) ⇒ Object

Processes an array of values, recursively calling to_hash on BaseModel objects.



87
88
89
# File 'lib/visa_acceptance_merged_spec/models/base_model.rb', line 87

def process_array(value)
  value.map { |v| v.is_a?(BaseModel) ? v.to_hash : v }
end

#process_basic_value(value) ⇒ Object

Processes a basic value (non-array, non-hash).



99
100
101
# File 'lib/visa_acceptance_merged_spec/models/base_model.rb', line 99

def process_basic_value(value)
  value.is_a?(BaseModel) ? value.to_hash : value
end

#process_hash(value) ⇒ Object

Processes a hash of values, recursively calling to_hash on BaseModel objects.



92
93
94
95
96
# File 'lib/visa_acceptance_merged_spec/models/base_model.rb', line 92

def process_hash(value)
  value.transform_values do |v|
    v.is_a?(BaseModel) ? v.to_hash : v
  end
end

#to_hashObject

Returns a Hash representation of the current object.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/visa_acceptance_merged_spec/models/base_model.rb', line 11

def to_hash
  # validating the model being serialized
  self.class.validate(self) if self.class.respond_to?(:validate)

  hash = {}
  instance_variables.each do |name|
    value = instance_variable_get(name)
    name = name[1..]
    if name == 'additional_properties'
      additional_properties = process_additional_properties(value, self.class.names)
      hash.merge!(additional_properties)
    else
      key = self.class.names.key?(name) ? self.class.names[name] : name
      optional_fields = self.class.optionals
      nullable_fields = self.class.nullables
      if value.nil?
        next unless nullable_fields.include?(name)

        if !optional_fields.include?(name) && !nullable_fields.include?(name)
          raise ArgumentError,
                "`#{name}` cannot be nil in `#{self.class}`. Please specify a valid value."
        end
      end

      hash[key] = nil
      unless value.nil?
        if respond_to?("to_custom_#{name}")
          if (value.instance_of? Array) || (value.instance_of? Hash)
            params = [hash, key]
            hash[key] = send("to_custom_#{name}", *params)
          else
            hash[key] = send("to_custom_#{name}")
          end
        elsif respond_to?("to_union_type_#{name}")
          hash[key] = send("to_union_type_#{name}")
        elsif value.instance_of? Array
          hash[key] = value.map { |v| v.is_a?(BaseModel) ? v.to_hash : v }
        elsif value.instance_of? Hash
          hash[key] = {}
          value.each do |k, v|
            hash[key][k] = v.is_a?(BaseModel) ? v.to_hash : v
          end
        else
          hash[key] = value.is_a?(BaseModel) ? value.to_hash : value
        end
      end
    end
  end
  hash
end

#to_json(options = {}) ⇒ Object

Returns a JSON representation of the curent object.



104
105
106
107
# File 'lib/visa_acceptance_merged_spec/models/base_model.rb', line 104

def to_json(options = {})
  hash = to_hash
  hash.to_json(options)
end