class ProcessOut::CustomerAction

Attributes

type[R]
value[R]

Public Class Methods

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

Initializes the CustomerAction object Params:

client

ProcessOut client instance

data

data that can be used to fill the object

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

  self.type = data.fetch(:type, nil)
  self.value = data.fetch(:value, nil)
  
end

Public Instance Methods

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/customer_action.rb, line 52
def fill_with_data(data)
  if data.nil?
    return self
  end
  if data.include? "type"
    self.type = data["type"]
  end
  if data.include? "value"
    self.value = data["value"]
  end
  
  self
end
new(data = {}) click to toggle source

Create a new CustomerAction using the current client

# File lib/processout/customer_action.rb, line 37
def new(data = {})
  CustomerAction.new(@client, data)
end
prefill(data) click to toggle source

Prefills the object with the data passed as parameters Params:

data

Hash of data

# File lib/processout/customer_action.rb, line 69
def prefill(data)
  if data.nil?
    return self
  end
  self.type = data.fetch(:type, self.type)
  self.value = data.fetch(:value, self.value)
  
  self
end
to_json(options) click to toggle source

Overrides the JSON marshaller to only send the fields we want

# File lib/processout/customer_action.rb, line 42
def to_json(options)
  {
      "type": self.type,
      "value": self.value,
  }.to_json
end
type=(val) click to toggle source
# File lib/processout/customer_action.rb, line 15
def type=(val)
  @type = val
end
value=(val) click to toggle source
# File lib/processout/customer_action.rb, line 19
def value=(val)
  @value = val
end