Class: ProcessOut::CustomerAction

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Initializes the CustomerAction object Params:

client

ProcessOut client instance

data

data that can be used to fill the object



27
28
29
30
31
32
33
# File 'lib/processout/customer_action.rb', line 27

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

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

Instance Attribute Details

#typeObject

Returns the value of attribute type.



10
11
12
# File 'lib/processout/customer_action.rb', line 10

def type
  @type
end

#valueObject

Returns the value of attribute value.



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

def value
  @value
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



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/processout/customer_action.rb', line 43

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 = {}) ⇒ Object

Create a new CustomerAction using the current client



36
37
38
# File 'lib/processout/customer_action.rb', line 36

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

#prefill(data) ⇒ Object

Prefills the object with the data passed as parameters Params:

data

Hash of data



60
61
62
63
64
65
66
67
68
# File 'lib/processout/customer_action.rb', line 60

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