Class: AdvancedBilling::InvoiceEvent

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/advanced_billing/models/invoice_event.rb

Overview

InvoiceEvent Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(id = SKIP, event_type = SKIP, event_data = SKIP, timestamp = SKIP, invoice = SKIP) ⇒ InvoiceEvent

Returns a new instance of InvoiceEvent.



62
63
64
65
66
67
68
69
# File 'lib/advanced_billing/models/invoice_event.rb', line 62

def initialize(id = SKIP, event_type = SKIP, event_data = SKIP,
               timestamp = SKIP, invoice = SKIP)
  @id = id unless id == SKIP
  @event_type = event_type unless event_type == SKIP
  @event_data = event_data unless event_data == SKIP
  @timestamp = timestamp unless timestamp == SKIP
  @invoice = invoice unless invoice == SKIP
end

Instance Attribute Details

#event_dataInvoiceEvent1

The event data is the data that, when combined with the command, results in the output invoice found in the invoice field.

Returns:



23
24
25
# File 'lib/advanced_billing/models/invoice_event.rb', line 23

def event_data
  @event_data
end

#event_typeInvoiceEventType

Invoice Event Type

Returns:



18
19
20
# File 'lib/advanced_billing/models/invoice_event.rb', line 18

def event_type
  @event_type
end

#idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


14
15
16
# File 'lib/advanced_billing/models/invoice_event.rb', line 14

def id
  @id
end

#invoiceInvoice

The event data is the data that, when combined with the command, results in the output invoice found in the invoice field.

Returns:



33
34
35
# File 'lib/advanced_billing/models/invoice_event.rb', line 33

def invoice
  @invoice
end

#timestampString

The event data is the data that, when combined with the command, results in the output invoice found in the invoice field.

Returns:

  • (String)


28
29
30
# File 'lib/advanced_billing/models/invoice_event.rb', line 28

def timestamp
  @timestamp
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/advanced_billing/models/invoice_event.rb', line 72

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : SKIP
  event_type = hash.key?('event_type') ? hash['event_type'] : SKIP
  event_data = hash.key?('event_data') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:InvoiceEventEventData), hash['event_data']
  ) : SKIP
  timestamp = hash.key?('timestamp') ? hash['timestamp'] : SKIP
  invoice = Invoice.from_hash(hash['invoice']) if hash['invoice']

  # Create object from extracted values.
  InvoiceEvent.new(id,
                   event_type,
                   event_data,
                   timestamp,
                   invoice)
end

.namesObject

A mapping from model property names to API property names.



36
37
38
39
40
41
42
43
44
# File 'lib/advanced_billing/models/invoice_event.rb', line 36

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['event_type'] = 'event_type'
  @_hash['event_data'] = 'event_data'
  @_hash['timestamp'] = 'timestamp'
  @_hash['invoice'] = 'invoice'
  @_hash
end

.nullablesObject

An array for nullable fields



58
59
60
# File 'lib/advanced_billing/models/invoice_event.rb', line 58

def self.nullables
  []
end

.optionalsObject

An array for optional fields



47
48
49
50
51
52
53
54
55
# File 'lib/advanced_billing/models/invoice_event.rb', line 47

def self.optionals
  %w[
    id
    event_type
    event_data
    timestamp
    invoice
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (InvoiceEvent | Hash)

    value against the validation is performed.



94
95
96
97
98
99
100
# File 'lib/advanced_billing/models/invoice_event.rb', line 94

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end