Class: AdvancedBilling::BatchJob

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

Overview

BatchJob Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(id: SKIP, finished_at: SKIP, row_count: SKIP, created_at: SKIP, completed: SKIP, additional_properties: {}) ⇒ BatchJob

Returns a new instance of BatchJob.



64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/advanced_billing/models/batch_job.rb', line 64

def initialize(id: SKIP, finished_at: SKIP, row_count: SKIP,
               created_at: SKIP, completed: SKIP, additional_properties: {})
  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end

  @id = id unless id == SKIP
  @finished_at = finished_at unless finished_at == SKIP
  @row_count = row_count unless row_count == SKIP
  @created_at = created_at unless created_at == SKIP
  @completed = completed unless completed == SKIP
end

Instance Attribute Details

#completedString

TODO: Write general description for this method

Returns:

  • (String)


31
32
33
# File 'lib/advanced_billing/models/batch_job.rb', line 31

def completed
  @completed
end

#created_atDateTime

TODO: Write general description for this method

Returns:

  • (DateTime)


27
28
29
# File 'lib/advanced_billing/models/batch_job.rb', line 27

def created_at
  @created_at
end

#finished_atDateTime

TODO: Write general description for this method

Returns:

  • (DateTime)


19
20
21
# File 'lib/advanced_billing/models/batch_job.rb', line 19

def finished_at
  @finished_at
end

#idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


15
16
17
# File 'lib/advanced_billing/models/batch_job.rb', line 15

def id
  @id
end

#row_countInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def row_count
  @row_count
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/advanced_billing/models/batch_job.rb', line 79

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : SKIP
  finished_at = if hash.key?('finished_at')
                  (DateTimeHelper.from_rfc3339(hash['finished_at']) if hash['finished_at'])
                else
                  SKIP
                end
  row_count = hash.key?('row_count') ? hash['row_count'] : SKIP
  created_at = if hash.key?('created_at')
                 (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at'])
               else
                 SKIP
               end
  completed = hash.key?('completed') ? hash['completed'] : SKIP

  # Clean out expected properties from Hash.
  additional_properties = hash.reject { |k, _| names.value?(k) }

  # Create object from extracted values.
  BatchJob.new(id: id,
               finished_at: finished_at,
               row_count: row_count,
               created_at: created_at,
               completed: completed,
               additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



34
35
36
37
38
39
40
41
42
# File 'lib/advanced_billing/models/batch_job.rb', line 34

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['finished_at'] = 'finished_at'
  @_hash['row_count'] = 'row_count'
  @_hash['created_at'] = 'created_at'
  @_hash['completed'] = 'completed'
  @_hash
end

.nullablesObject

An array for nullable fields



56
57
58
59
60
61
62
# File 'lib/advanced_billing/models/batch_job.rb', line 56

def self.nullables
  %w[
    finished_at
    row_count
    created_at
  ]
end

.optionalsObject

An array for optional fields



45
46
47
48
49
50
51
52
53
# File 'lib/advanced_billing/models/batch_job.rb', line 45

def self.optionals
  %w[
    id
    finished_at
    row_count
    created_at
    completed
  ]
end

Instance Method Details

#to_custom_created_atObject



113
114
115
# File 'lib/advanced_billing/models/batch_job.rb', line 113

def to_custom_created_at
  DateTimeHelper.to_rfc3339(created_at)
end

#to_custom_finished_atObject



109
110
111
# File 'lib/advanced_billing/models/batch_job.rb', line 109

def to_custom_finished_at
  DateTimeHelper.to_rfc3339(finished_at)
end