Class: AdvancedBilling::BillingManifest

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

Overview

BillingManifest Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(line_items = SKIP, total_in_cents = SKIP, total_discount_in_cents = SKIP, total_tax_in_cents = SKIP, subtotal_in_cents = SKIP, start_date = SKIP, end_date = SKIP, period_type = SKIP, existing_balance_in_cents = SKIP) ⇒ BillingManifest

Returns a new instance of BillingManifest.



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/advanced_billing/models/billing_manifest.rb', line 83

def initialize(line_items = SKIP, total_in_cents = SKIP,
               total_discount_in_cents = SKIP, total_tax_in_cents = SKIP,
               subtotal_in_cents = SKIP, start_date = SKIP, end_date = SKIP,
               period_type = SKIP, existing_balance_in_cents = SKIP)
  @line_items = line_items unless line_items == SKIP
  @total_in_cents = total_in_cents unless total_in_cents == SKIP
  @total_discount_in_cents = total_discount_in_cents unless total_discount_in_cents == SKIP
  @total_tax_in_cents = total_tax_in_cents unless total_tax_in_cents == SKIP
  @subtotal_in_cents = subtotal_in_cents unless subtotal_in_cents == SKIP
  @start_date = start_date unless start_date == SKIP
  @end_date = end_date unless end_date == SKIP
  @period_type = period_type unless period_type == SKIP
  unless existing_balance_in_cents == SKIP
    @existing_balance_in_cents =
      existing_balance_in_cents
  end
end

Instance Attribute Details

#end_dateString

TODO: Write general description for this method

Returns:

  • (String)


38
39
40
# File 'lib/advanced_billing/models/billing_manifest.rb', line 38

def end_date
  @end_date
end

#existing_balance_in_centsInteger

TODO: Write general description for this method

Returns:

  • (Integer)


46
47
48
# File 'lib/advanced_billing/models/billing_manifest.rb', line 46

def existing_balance_in_cents
  @existing_balance_in_cents
end

#line_itemsArray[BillingManifestItem]

TODO: Write general description for this method

Returns:



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

def line_items
  @line_items
end

#period_typeString

TODO: Write general description for this method

Returns:

  • (String)


42
43
44
# File 'lib/advanced_billing/models/billing_manifest.rb', line 42

def period_type
  @period_type
end

#start_dateString

TODO: Write general description for this method

Returns:

  • (String)


34
35
36
# File 'lib/advanced_billing/models/billing_manifest.rb', line 34

def start_date
  @start_date
end

#subtotal_in_centsInteger

TODO: Write general description for this method

Returns:

  • (Integer)


30
31
32
# File 'lib/advanced_billing/models/billing_manifest.rb', line 30

def subtotal_in_cents
  @subtotal_in_cents
end

#total_discount_in_centsInteger

TODO: Write general description for this method

Returns:

  • (Integer)


22
23
24
# File 'lib/advanced_billing/models/billing_manifest.rb', line 22

def total_discount_in_cents
  @total_discount_in_cents
end

#total_in_centsInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def total_in_cents
  @total_in_cents
end

#total_tax_in_centsInteger

TODO: Write general description for this method

Returns:

  • (Integer)


26
27
28
# File 'lib/advanced_billing/models/billing_manifest.rb', line 26

def total_tax_in_cents
  @total_tax_in_cents
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/advanced_billing/models/billing_manifest.rb', line 102

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.

  # Parameter is an array, so we need to iterate through it

  line_items = nil
  unless hash['line_items'].nil?
    line_items = []
    hash['line_items'].each do |structure|
      line_items << (BillingManifestItem.from_hash(structure) if structure)
    end
  end

  line_items = SKIP unless hash.key?('line_items')
  total_in_cents =
    hash.key?('total_in_cents') ? hash['total_in_cents'] : SKIP
  total_discount_in_cents =
    hash.key?('total_discount_in_cents') ? hash['total_discount_in_cents'] : SKIP
  total_tax_in_cents =
    hash.key?('total_tax_in_cents') ? hash['total_tax_in_cents'] : SKIP
  subtotal_in_cents =
    hash.key?('subtotal_in_cents') ? hash['subtotal_in_cents'] : SKIP
  start_date = hash.key?('start_date') ? hash['start_date'] : SKIP
  end_date = hash.key?('end_date') ? hash['end_date'] : SKIP
  period_type = hash.key?('period_type') ? hash['period_type'] : SKIP
  existing_balance_in_cents =
    hash.key?('existing_balance_in_cents') ? hash['existing_balance_in_cents'] : SKIP

  # Create object from extracted values.

  BillingManifest.new(line_items,
                      total_in_cents,
                      total_discount_in_cents,
                      total_tax_in_cents,
                      subtotal_in_cents,
                      start_date,
                      end_date,
                      period_type,
                      existing_balance_in_cents)
end

.namesObject

A mapping from model property names to API property names.



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/advanced_billing/models/billing_manifest.rb', line 49

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['line_items'] = 'line_items'
  @_hash['total_in_cents'] = 'total_in_cents'
  @_hash['total_discount_in_cents'] = 'total_discount_in_cents'
  @_hash['total_tax_in_cents'] = 'total_tax_in_cents'
  @_hash['subtotal_in_cents'] = 'subtotal_in_cents'
  @_hash['start_date'] = 'start_date'
  @_hash['end_date'] = 'end_date'
  @_hash['period_type'] = 'period_type'
  @_hash['existing_balance_in_cents'] = 'existing_balance_in_cents'
  @_hash
end

.nullablesObject

An array for nullable fields



79
80
81
# File 'lib/advanced_billing/models/billing_manifest.rb', line 79

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    line_items
    total_in_cents
    total_discount_in_cents
    total_tax_in_cents
    subtotal_in_cents
    start_date
    end_date
    period_type
    existing_balance_in_cents
  ]
end