Class: ProcessOut::InvoiceDetail

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Initializes the InvoiceDetail object Params:

client

ProcessOut client instance

data

data that can be used to fill the object



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

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

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

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



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

def amount
  @amount
end

#metadataObject

Returns the value of attribute metadata.



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

def 
  
end

#typeObject

Returns the value of attribute type.



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

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



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/processout/invoice_detail.rb', line 49

def fill_with_data(data)
  if data.nil?
    return self
  end
  if data.include? "type"
    self.type = data["type"]
  end
  if data.include? "amount"
    self.amount = data["amount"]
  end
  if data.include? "metadata"
    self. = data["metadata"]
  end
  
  self
end

#new(data = {}) ⇒ Object

Create a new InvoiceDetail using the current client



42
43
44
# File 'lib/processout/invoice_detail.rb', line 42

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

#prefill(data) ⇒ Object

Prefills the object with the data passed as parameters Params:

data

Hash of data



69
70
71
72
73
74
75
76
77
78
# File 'lib/processout/invoice_detail.rb', line 69

def prefill(data)
  if data.nil?
    return self
  end
  self.type = data.fetch(:type, self.type)
  self.amount = data.fetch(:amount, self.amount)
  self. = data.fetch(:metadata, self.)
  
  self
end