Class: ProcessOut::ExportLayoutConfiguration

Inherits:
Object
  • Object
show all
Defined in:
lib/processout/export_layout_configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, data = {}) ⇒ ExportLayoutConfiguration

Initializes the ExportLayoutConfiguration object Params:

client

ProcessOut client instance

data

data that can be used to fill the object



73
74
75
76
77
78
79
80
# File 'lib/processout/export_layout_configuration.rb', line 73

def initialize(client, data = {})
  @client = client

  self.columns = data.fetch(:columns, nil)
  self.time = data.fetch(:time, nil)
  self.amount = data.fetch(:amount, nil)
  
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



13
14
15
# File 'lib/processout/export_layout_configuration.rb', line 13

def amount
  @amount
end

#columnsObject

Returns the value of attribute columns.



11
12
13
# File 'lib/processout/export_layout_configuration.rb', line 11

def columns
  @columns
end

#timeObject

Returns the value of attribute time.



12
13
14
# File 'lib/processout/export_layout_configuration.rb', line 12

def time
  @time
end

Instance Method Details

#fill_with_data(data) ⇒ Object

Fills the object with data coming from the API Params:

data

Hash of data coming from the API



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/processout/export_layout_configuration.rb', line 99

def fill_with_data(data)
  if data.nil?
    return self
  end
  if data.include? "columns"
    self.columns = data["columns"]
  end
  if data.include? "time"
    self.time = data["time"]
  end
  if data.include? "amount"
    self.amount = data["amount"]
  end
  
  self
end

#new(data = {}) ⇒ Object

Create a new ExportLayoutConfiguration using the current client



83
84
85
# File 'lib/processout/export_layout_configuration.rb', line 83

def new(data = {})
  ExportLayoutConfiguration.new(@client, data)
end

#prefill(data) ⇒ Object

Prefills the object with the data passed as parameters Params:

data

Hash of data



119
120
121
122
123
124
125
126
127
128
# File 'lib/processout/export_layout_configuration.rb', line 119

def prefill(data)
  if data.nil?
    return self
  end
  self.columns = data.fetch(:columns, self.columns)
  self.time = data.fetch(:time, self.time)
  self.amount = data.fetch(:amount, self.amount)
  
  self
end

#to_json(options) ⇒ Object

Overrides the JSON marshaller to only send the fields we want



88
89
90
91
92
93
94
# File 'lib/processout/export_layout_configuration.rb', line 88

def to_json(options)
  {
      "columns": self.columns,
      "time": self.time,
      "amount": self.amount,
  }.to_json
end