class ProcessOut::PayoutItem

Attributes

amount[R]
created_at[R]
fees[R]
gateway_resource_id[R]
id[R]
metadata[R]
payout[R]
payout_id[R]
project[R]
project_id[R]
transaction[R]
transaction_id[R]
type[R]

Public Class Methods

new(client, data = {}) click to toggle source

Initializes the PayoutItem object Params:

client

ProcessOut client instance

data

data that can be used to fill the object

# File lib/processout/payout_item.rb, line 119
def initialize(client, data = {})
  @client = client

  self.id = data.fetch(:id, nil)
  self.project = data.fetch(:project, nil)
  self.project_id = data.fetch(:project_id, nil)
  self.payout = data.fetch(:payout, nil)
  self.payout_id = data.fetch(:payout_id, nil)
  self.transaction = data.fetch(:transaction, nil)
  self.transaction_id = data.fetch(:transaction_id, nil)
  self.type = data.fetch(:type, nil)
  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)
  
end

Public Instance Methods

amount=(val) click to toggle source
# File lib/processout/payout_item.rb, line 98
def amount=(val)
  @amount = val
end
created_at=(val) click to toggle source
# File lib/processout/payout_item.rb, line 110
def created_at=(val)
  @created_at = val
end
fees=(val) click to toggle source
# File lib/processout/payout_item.rb, line 102
def fees=(val)
  @fees = val
end
fill_with_data(data) click to toggle source

Fills the object with data coming from the API Params:

data

Hash of data coming from the API

# File lib/processout/payout_item.rb, line 165
def fill_with_data(data)
  if data.nil?
    return self
  end
  if data.include? "id"
    self.id = data["id"]
  end
  if data.include? "project"
    self.project = data["project"]
  end
  if data.include? "project_id"
    self.project_id = data["project_id"]
  end
  if data.include? "payout"
    self.payout = data["payout"]
  end
  if data.include? "payout_id"
    self.payout_id = data["payout_id"]
  end
  if data.include? "transaction"
    self.transaction = data["transaction"]
  end
  if data.include? "transaction_id"
    self.transaction_id = data["transaction_id"]
  end
  if data.include? "type"
    self.type = data["type"]
  end
  if data.include? "gateway_resource_id"
    self.gateway_resource_id = data["gateway_resource_id"]
  end
  if data.include? "amount"
    self.amount = data["amount"]
  end
  if data.include? "fees"
    self.fees = data["fees"]
  end
  if data.include? "metadata"
    self.metadata = data["metadata"]
  end
  if data.include? "created_at"
    self.created_at = data["created_at"]
  end
  
  self
end
gateway_resource_id=(val) click to toggle source
# File lib/processout/payout_item.rb, line 94
def gateway_resource_id=(val)
  @gateway_resource_id = val
end
id=(val) click to toggle source
# File lib/processout/payout_item.rb, line 26
def id=(val)
  @id = val
end
metadata=(val) click to toggle source
# File lib/processout/payout_item.rb, line 106
def metadata=(val)
  @metadata = val
end
new(data = {}) click to toggle source

Create a new PayoutItem using the current client

# File lib/processout/payout_item.rb, line 139
def new(data = {})
  PayoutItem.new(@client, data)
end
payout=(val) click to toggle source
# File lib/processout/payout_item.rb, line 50
def payout=(val)
  if val.nil?
    @payout = val
    return
  end

  if val.instance_of? Payout
    @payout = val
  else
    obj = Payout.new(@client)
    obj.fill_with_data(val)
    @payout = obj
  end
  
end
payout_id=(val) click to toggle source
# File lib/processout/payout_item.rb, line 66
def payout_id=(val)
  @payout_id = val
end
prefill(data) click to toggle source

Prefills the object with the data passed as parameters Params:

data

Hash of data

# File lib/processout/payout_item.rb, line 215
def prefill(data)
  if data.nil?
    return self
  end
  self.id = data.fetch(:id, self.id)
  self.project = data.fetch(:project, self.project)
  self.project_id = data.fetch(:project_id, self.project_id)
  self.payout = data.fetch(:payout, self.payout)
  self.payout_id = data.fetch(:payout_id, self.payout_id)
  self.transaction = data.fetch(:transaction, self.transaction)
  self.transaction_id = data.fetch(:transaction_id, self.transaction_id)
  self.type = data.fetch(:type, self.type)
  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
end
project=(val) click to toggle source
# File lib/processout/payout_item.rb, line 30
def project=(val)
  if val.nil?
    @project = val
    return
  end

  if val.instance_of? Project
    @project = val
  else
    obj = Project.new(@client)
    obj.fill_with_data(val)
    @project = obj
  end
  
end
project_id=(val) click to toggle source
# File lib/processout/payout_item.rb, line 46
def project_id=(val)
  @project_id = val
end
to_json(options) click to toggle source

Overrides the JSON marshaller to only send the fields we want

# File lib/processout/payout_item.rb, line 144
def to_json(options)
  {
      "id": self.id,
      "project": self.project,
      "project_id": self.project_id,
      "payout": self.payout,
      "payout_id": self.payout_id,
      "transaction": self.transaction,
      "transaction_id": self.transaction_id,
      "type": self.type,
      "gateway_resource_id": self.gateway_resource_id,
      "amount": self.amount,
      "fees": self.fees,
      "metadata": self.metadata,
      "created_at": self.created_at,
  }.to_json
end
transaction=(val) click to toggle source
# File lib/processout/payout_item.rb, line 70
def transaction=(val)
  if val.nil?
    @transaction = val
    return
  end

  if val.instance_of? Transaction
    @transaction = val
  else
    obj = Transaction.new(@client)
    obj.fill_with_data(val)
    @transaction = obj
  end
  
end
transaction_id=(val) click to toggle source
# File lib/processout/payout_item.rb, line 86
def transaction_id=(val)
  @transaction_id = val
end
type=(val) click to toggle source
# File lib/processout/payout_item.rb, line 90
def type=(val)
  @type = val
end