Class: ProcessOut::ExportLayoutConfigurationOptions

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Initializes the ExportLayoutConfigurationOptions object Params:

client

ProcessOut client instance

data

data that can be used to fill the object



57
58
59
60
61
62
63
64
# File 'lib/processout/export_layout_configuration_options.rb', line 57

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_options.rb', line 13

def amount
  @amount
end

#columnsObject

Returns the value of attribute columns.



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

def columns
  @columns
end

#timeObject

Returns the value of attribute time.



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

def time
  @time
end

Instance Method Details

#fetch(export_type, options = {}) ⇒ Object

Fetch export layout configuration options. Params:

export_type

Export type

options

Hash of options



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/processout/export_layout_configuration_options.rb', line 118

def fetch(export_type, options = {})
  self.prefill(options)

  request = Request.new(@client)
  path    = "/exports/layouts/options/" + CGI.escape(export_type) + ""
  data    = {

  }

  response = Response.new(request.get(path, data, options))
  return_values = Array.new
  
  body = response.body
  body = body["export_layout_configuration_options"]
  
  
  obj = ExportLayoutConfigurationOptions.new(@client)
  return_values.push(obj.fill_with_data(body))
  

  
  return_values[0]
end

#fill_with_data(data) ⇒ Object

Fills the object with data coming from the API Params:

data

Hash of data coming from the API



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/processout/export_layout_configuration_options.rb', line 83

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 ExportLayoutConfigurationOptions using the current client



67
68
69
# File 'lib/processout/export_layout_configuration_options.rb', line 67

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

#prefill(data) ⇒ Object

Prefills the object with the data passed as parameters Params:

data

Hash of data



103
104
105
106
107
108
109
110
111
112
# File 'lib/processout/export_layout_configuration_options.rb', line 103

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



72
73
74
75
76
77
78
# File 'lib/processout/export_layout_configuration_options.rb', line 72

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