Class: ProcessOut::InvoiceRisk

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Initializes the InvoiceRisk object Params:

client

ProcessOut client instance

data

data that can be used to fill the object



33
34
35
36
37
38
39
40
# File 'lib/processout/invoice_risk.rb', line 33

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

  self.score = data.fetch(:score, nil)
  self.is_legit = data.fetch(:is_legit, nil)
  self.skip_gateway_rules = data.fetch(:skip_gateway_rules, nil)
  
end

Instance Attribute Details

#is_legitObject

Returns the value of attribute is_legit.



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

def is_legit
  @is_legit
end

#scoreObject

Returns the value of attribute score.



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

def score
  @score
end

#skip_gateway_rulesObject

Returns the value of attribute skip_gateway_rules.



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

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



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/processout/invoice_risk.rb', line 59

def fill_with_data(data)
  if data.nil?
    return self
  end
  if data.include? "score"
    self.score = data["score"]
  end
  if data.include? "is_legit"
    self.is_legit = data["is_legit"]
  end
  if data.include? "skip_gateway_rules"
    self.skip_gateway_rules = data["skip_gateway_rules"]
  end
  
  self
end

#new(data = {}) ⇒ Object

Create a new InvoiceRisk using the current client



43
44
45
# File 'lib/processout/invoice_risk.rb', line 43

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

#prefill(data) ⇒ Object

Prefills the object with the data passed as parameters Params:

data

Hash of data



79
80
81
82
83
84
85
86
87
88
# File 'lib/processout/invoice_risk.rb', line 79

def prefill(data)
  if data.nil?
    return self
  end
  self.score = data.fetch(:score, self.score)
  self.is_legit = data.fetch(:is_legit, self.is_legit)
  self.skip_gateway_rules = data.fetch(:skip_gateway_rules, self.skip_gateway_rules)
  
  self
end

#to_json(options) ⇒ Object

Overrides the JSON marshaller to only send the fields we want



48
49
50
51
52
53
54
# File 'lib/processout/invoice_risk.rb', line 48

def to_json(options)
  {
      "score": self.score,
      "is_legit": self.is_legit,
      "skip_gateway_rules": self.skip_gateway_rules,
  }.to_json
end