Class: ProcessOut::DunningAction

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Initializes the DunningAction 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/dunning_action.rb', line 27

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

  self.action = data.fetch(:action, nil)
  self.delay_in_days = data.fetch(:delay_in_days, nil)
  
end

Instance Attribute Details

#actionObject

Returns the value of attribute action.



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

def action
  @action
end

#delay_in_daysObject

Returns the value of attribute delay_in_days.



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

def delay_in_days
  @delay_in_days
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/dunning_action.rb', line 43

def fill_with_data(data)
  if data.nil?
    return self
  end
  if data.include? "action"
    self.action = data["action"]
  end
  if data.include? "delay_in_days"
    self.delay_in_days = data["delay_in_days"]
  end
  
  self
end

#new(data = {}) ⇒ Object

Create a new DunningAction using the current client



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

def new(data = {})
  DunningAction.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/dunning_action.rb', line 60

def prefill(data)
  if data.nil?
    return self
  end
  self.action = data.fetch(:action, self.action)
  self.delay_in_days = data.fetch(:delay_in_days, self.delay_in_days)
  
  self
end