lib/processout/payout_item.rb in processout-2.28.0 vs lib/processout/payout_item.rb in processout-2.29.0
- old
+ new
@@ -19,10 +19,11 @@
attr_reader :gateway_resource_id
attr_reader :amount
attr_reader :fees
attr_reader :metadata
attr_reader :created_at
+ attr_reader :breakdown
def id=(val)
@id = val
end
@@ -109,11 +110,27 @@
def created_at=(val)
@created_at = val
end
+ def breakdown=(val)
+ if val.nil?
+ @breakdown = val
+ return
+ end
+ if val.instance_of? PayoutItemAmountBreakdowns
+ @breakdown = val
+ else
+ obj = PayoutItemAmountBreakdowns.new(@client)
+ obj.fill_with_data(val)
+ @breakdown = obj
+ end
+
+ end
+
+
# Initializes the PayoutItem object
# Params:
# +client+:: +ProcessOut+ client instance
# +data+:: data that can be used to fill the object
def initialize(client, data = {})
@@ -130,10 +147,11 @@
self.gateway_resource_id = data.fetch(:gateway_resource_id, nil)
self.amount = data.fetch(:amount, nil)
self.fees = data.fetch(:fees, nil)
self.metadata = data.fetch(:metadata, nil)
self.created_at = data.fetch(:created_at, nil)
+ self.breakdown = data.fetch(:breakdown, nil)
end
# Create a new PayoutItem using the current client
def new(data = {})
@@ -154,10 +172,11 @@
"gateway_resource_id": self.gateway_resource_id,
"amount": self.amount,
"fees": self.fees,
"metadata": self.metadata,
"created_at": self.created_at,
+ "breakdown": self.breakdown,
}.to_json
end
# Fills the object with data coming from the API
# Params:
@@ -203,10 +222,13 @@
self.metadata = data["metadata"]
end
if data.include? "created_at"
self.created_at = data["created_at"]
end
+ if data.include? "breakdown"
+ self.breakdown = data["breakdown"]
+ end
self
end
# Prefills the object with the data passed as parameters
@@ -227,9 +249,10 @@
self.gateway_resource_id = data.fetch(:gateway_resource_id, self.gateway_resource_id)
self.amount = data.fetch(:amount, self.amount)
self.fees = data.fetch(:fees, self.fees)
self.metadata = data.fetch(:metadata, self.metadata)
self.created_at = data.fetch(:created_at, self.created_at)
+ self.breakdown = data.fetch(:breakdown, self.breakdown)
self
end