Class: Merge::Accounting::PaymentRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/merge_ruby_client/accounting/types/payment_request.rb

Overview

The Payment Object

Description

The Payment object represents general payments made towards a specific transaction.

Usage Example

Fetch from the GET Payment endpoint and view an invoice's payment.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(transaction_date: OMIT, contact: OMIT, account: OMIT, payment_method: OMIT, currency: OMIT, exchange_rate: OMIT, company: OMIT, total_amount: OMIT, type: OMIT, tracking_categories: OMIT, accounting_period: OMIT, applied_to_lines: OMIT, integration_params: OMIT, linked_account_params: OMIT, remote_fields: OMIT, additional_properties: nil) ⇒ Merge::Accounting::PaymentRequest



697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
# File 'lib/merge_ruby_client/accounting/types/payment_request.rb', line 697

def initialize(transaction_date: OMIT, contact: OMIT, account: OMIT, payment_method: OMIT, currency: OMIT,
               exchange_rate: OMIT, company: OMIT, total_amount: OMIT, type: OMIT, tracking_categories: OMIT, accounting_period: OMIT, applied_to_lines: OMIT, integration_params: OMIT, linked_account_params: OMIT, remote_fields: OMIT, additional_properties: nil)
  @transaction_date = transaction_date if transaction_date != OMIT
  @contact = contact if contact != OMIT
  @account =  if  != OMIT
  @payment_method = payment_method if payment_method != OMIT
  @currency = currency if currency != OMIT
  @exchange_rate = exchange_rate if exchange_rate != OMIT
  @company = company if company != OMIT
  @total_amount = total_amount if total_amount != OMIT
  @type = type if type != OMIT
  @tracking_categories = tracking_categories if tracking_categories != OMIT
  @accounting_period = accounting_period if accounting_period != OMIT
  @applied_to_lines = applied_to_lines if applied_to_lines != OMIT
  @integration_params = integration_params if integration_params != OMIT
   =  if  != OMIT
  @remote_fields = remote_fields if remote_fields != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "transaction_date": transaction_date,
    "contact": contact,
    "account": ,
    "payment_method": payment_method,
    "currency": currency,
    "exchange_rate": exchange_rate,
    "company": company,
    "total_amount": total_amount,
    "type": type,
    "tracking_categories": tracking_categories,
    "accounting_period": accounting_period,
    "applied_to_lines": applied_to_lines,
    "integration_params": integration_params,
    "linked_account_params": ,
    "remote_fields": remote_fields
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#accountMerge::Accounting::PaymentRequestAccount (readonly)



31
32
33
# File 'lib/merge_ruby_client/accounting/types/payment_request.rb', line 31

def 
  @account
end

#accounting_periodMerge::Accounting::PaymentRequestAccountingPeriod (readonly)



355
356
357
# File 'lib/merge_ruby_client/accounting/types/payment_request.rb', line 355

def accounting_period
  @accounting_period
end

#additional_propertiesOpenStruct (readonly)



365
366
367
# File 'lib/merge_ruby_client/accounting/types/payment_request.rb', line 365

def additional_properties
  @additional_properties
end

#applied_to_linesArray<Merge::Accounting::PaymentRequestAppliedToLinesItem> (readonly)



357
358
359
# File 'lib/merge_ruby_client/accounting/types/payment_request.rb', line 357

def applied_to_lines
  @applied_to_lines
end

#companyMerge::Accounting::PaymentRequestCompany (readonly)



345
346
347
# File 'lib/merge_ruby_client/accounting/types/payment_request.rb', line 345

def company
  @company
end

#contactMerge::Accounting::PaymentRequestContact (readonly)



29
30
31
# File 'lib/merge_ruby_client/accounting/types/payment_request.rb', line 29

def contact
  @contact
end

#currencyMerge::Accounting::TransactionCurrencyEnum (readonly)



341
342
343
# File 'lib/merge_ruby_client/accounting/types/payment_request.rb', line 341

def currency
  @currency
end

#exchange_rateString (readonly)



343
344
345
# File 'lib/merge_ruby_client/accounting/types/payment_request.rb', line 343

def exchange_rate
  @exchange_rate
end

#integration_paramsHash{String => Object} (readonly)



359
360
361
# File 'lib/merge_ruby_client/accounting/types/payment_request.rb', line 359

def integration_params
  @integration_params
end

#linked_account_paramsHash{String => Object} (readonly)



361
362
363
# File 'lib/merge_ruby_client/accounting/types/payment_request.rb', line 361

def 
  
end

#payment_methodMerge::Accounting::PaymentRequestPaymentMethod (readonly)



33
34
35
# File 'lib/merge_ruby_client/accounting/types/payment_request.rb', line 33

def payment_method
  @payment_method
end

#remote_fieldsArray<Merge::Accounting::RemoteFieldRequest> (readonly)



363
364
365
# File 'lib/merge_ruby_client/accounting/types/payment_request.rb', line 363

def remote_fields
  @remote_fields
end

#total_amountFloat (readonly)



347
348
349
# File 'lib/merge_ruby_client/accounting/types/payment_request.rb', line 347

def total_amount
  @total_amount
end

#tracking_categoriesArray<Merge::Accounting::PaymentRequestTrackingCategoriesItem> (readonly)



353
354
355
# File 'lib/merge_ruby_client/accounting/types/payment_request.rb', line 353

def tracking_categories
  @tracking_categories
end

#transaction_dateDateTime (readonly)



27
28
29
# File 'lib/merge_ruby_client/accounting/types/payment_request.rb', line 27

def transaction_date
  @transaction_date
end

#typeMerge::Accounting::PaymentTypeEnum (readonly)



351
352
353
# File 'lib/merge_ruby_client/accounting/types/payment_request.rb', line 351

def type
  @type
end

Class Method Details

.from_json(json_object:) ⇒ Merge::Accounting::PaymentRequest

Deserialize a JSON object to an instance of PaymentRequest



740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
# File 'lib/merge_ruby_client/accounting/types/payment_request.rb', line 740

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  transaction_date = (DateTime.parse(parsed_json["transaction_date"]) unless parsed_json["transaction_date"].nil?)
  if parsed_json["contact"].nil?
    contact = nil
  else
    contact = parsed_json["contact"].to_json
    contact = Merge::Accounting::PaymentRequestContact.from_json(json_object: contact)
  end
  if parsed_json["account"].nil?
     = nil
  else
     = parsed_json["account"].to_json
     = Merge::Accounting::PaymentRequestAccount.from_json(json_object: )
  end
  if parsed_json["payment_method"].nil?
    payment_method = nil
  else
    payment_method = parsed_json["payment_method"].to_json
    payment_method = Merge::Accounting::PaymentRequestPaymentMethod.from_json(json_object: payment_method)
  end
  currency = parsed_json["currency"]
  exchange_rate = parsed_json["exchange_rate"]
  if parsed_json["company"].nil?
    company = nil
  else
    company = parsed_json["company"].to_json
    company = Merge::Accounting::PaymentRequestCompany.from_json(json_object: company)
  end
  total_amount = parsed_json["total_amount"]
  type = parsed_json["type"]
  tracking_categories = parsed_json["tracking_categories"]&.map do |item|
    item = item.to_json
    Merge::Accounting::PaymentRequestTrackingCategoriesItem.from_json(json_object: item)
  end
  if parsed_json["accounting_period"].nil?
    accounting_period = nil
  else
    accounting_period = parsed_json["accounting_period"].to_json
    accounting_period = Merge::Accounting::PaymentRequestAccountingPeriod.from_json(json_object: accounting_period)
  end
  applied_to_lines = parsed_json["applied_to_lines"]&.map do |item|
    item = item.to_json
    Merge::Accounting::PaymentRequestAppliedToLinesItem.from_json(json_object: item)
  end
  integration_params = parsed_json["integration_params"]
   = parsed_json["linked_account_params"]
  remote_fields = parsed_json["remote_fields"]&.map do |item|
    item = item.to_json
    Merge::Accounting::RemoteFieldRequest.from_json(json_object: item)
  end
  new(
    transaction_date: transaction_date,
    contact: contact,
    account: ,
    payment_method: payment_method,
    currency: currency,
    exchange_rate: exchange_rate,
    company: company,
    total_amount: total_amount,
    type: type,
    tracking_categories: tracking_categories,
    accounting_period: accounting_period,
    applied_to_lines: applied_to_lines,
    integration_params: integration_params,
    linked_account_params: ,
    remote_fields: remote_fields,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object's property definitions.



825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
# File 'lib/merge_ruby_client/accounting/types/payment_request.rb', line 825

def self.validate_raw(obj:)
  obj.transaction_date&.is_a?(DateTime) != false || raise("Passed value for field obj.transaction_date is not the expected type, validation failed.")
  obj.contact.nil? || Merge::Accounting::PaymentRequestContact.validate_raw(obj: obj.contact)
  obj..nil? || Merge::Accounting::PaymentRequestAccount.validate_raw(obj: obj.)
  obj.payment_method.nil? || Merge::Accounting::PaymentRequestPaymentMethod.validate_raw(obj: obj.payment_method)
  obj.currency&.is_a?(Merge::Accounting::TransactionCurrencyEnum) != false || raise("Passed value for field obj.currency is not the expected type, validation failed.")
  obj.exchange_rate&.is_a?(String) != false || raise("Passed value for field obj.exchange_rate is not the expected type, validation failed.")
  obj.company.nil? || Merge::Accounting::PaymentRequestCompany.validate_raw(obj: obj.company)
  obj.total_amount&.is_a?(Float) != false || raise("Passed value for field obj.total_amount is not the expected type, validation failed.")
  obj.type&.is_a?(Merge::Accounting::PaymentTypeEnum) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
  obj.tracking_categories&.is_a?(Array) != false || raise("Passed value for field obj.tracking_categories is not the expected type, validation failed.")
  obj.accounting_period.nil? || Merge::Accounting::PaymentRequestAccountingPeriod.validate_raw(obj: obj.accounting_period)
  obj.applied_to_lines&.is_a?(Array) != false || raise("Passed value for field obj.applied_to_lines is not the expected type, validation failed.")
  obj.integration_params&.is_a?(Hash) != false || raise("Passed value for field obj.integration_params is not the expected type, validation failed.")
  obj.&.is_a?(Hash) != false || raise("Passed value for field obj.linked_account_params is not the expected type, validation failed.")
  obj.remote_fields&.is_a?(Array) != false || raise("Passed value for field obj.remote_fields is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of PaymentRequest to a JSON object



815
816
817
# File 'lib/merge_ruby_client/accounting/types/payment_request.rb', line 815

def to_json(*_args)
  @_field_set&.to_json
end