Class: AdvancedBilling::Segment
- Defined in:
- lib/advanced_billing/models/segment.rb
Overview
Segment Model.
Instance Attribute Summary collapse
-
#component_id ⇒ Integer
TODO: Write general description for this method.
-
#created_at ⇒ String
TODO: Write general description for this method.
-
#event_based_billing_metric_id ⇒ Integer
TODO: Write general description for this method.
-
#id ⇒ Integer
TODO: Write general description for this method.
-
#price_point_id ⇒ Integer
TODO: Write general description for this method.
-
#prices ⇒ Array[SegmentPrice]
TODO: Write general description for this method.
-
#pricing_scheme ⇒ String
TODO: Write general description for this method.
-
#segment_property_1_value ⇒ Object
TODO: Write general description for this method.
-
#segment_property_2_value ⇒ Object
TODO: Write general description for this method.
-
#segment_property_3_value ⇒ Object
TODO: Write general description for this method.
-
#segment_property_4_value ⇒ Object
TODO: Write general description for this method.
-
#updated_at ⇒ String
TODO: Write general description for this method.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(id = SKIP, component_id = SKIP, price_point_id = SKIP, event_based_billing_metric_id = SKIP, pricing_scheme = SKIP, segment_property_1_value = SKIP, segment_property_2_value = SKIP, segment_property_3_value = SKIP, segment_property_4_value = SKIP, created_at = SKIP, updated_at = SKIP, prices = SKIP) ⇒ Segment
constructor
A new instance of Segment.
Methods inherited from BaseModel
Constructor Details
#initialize(id = SKIP, component_id = SKIP, price_point_id = SKIP, event_based_billing_metric_id = SKIP, pricing_scheme = SKIP, segment_property_1_value = SKIP, segment_property_2_value = SKIP, segment_property_3_value = SKIP, segment_property_4_value = SKIP, created_at = SKIP, updated_at = SKIP, prices = SKIP) ⇒ Segment
Returns a new instance of Segment.
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/advanced_billing/models/segment.rb', line 102 def initialize(id = SKIP, component_id = SKIP, price_point_id = SKIP, event_based_billing_metric_id = SKIP, pricing_scheme = SKIP, segment_property_1_value = SKIP, segment_property_2_value = SKIP, segment_property_3_value = SKIP, segment_property_4_value = SKIP, created_at = SKIP, updated_at = SKIP, prices = SKIP) @id = id unless id == SKIP @component_id = component_id unless component_id == SKIP @price_point_id = price_point_id unless price_point_id == SKIP unless event_based_billing_metric_id == SKIP @event_based_billing_metric_id = event_based_billing_metric_id end @pricing_scheme = pricing_scheme unless pricing_scheme == SKIP @segment_property_1_value = segment_property_1_value unless segment_property_1_value == SKIP @segment_property_2_value = segment_property_2_value unless segment_property_2_value == SKIP @segment_property_3_value = segment_property_3_value unless segment_property_3_value == SKIP @segment_property_4_value = segment_property_4_value unless segment_property_4_value == SKIP @created_at = created_at unless created_at == SKIP @updated_at = updated_at unless updated_at == SKIP @prices = prices unless prices == SKIP end |
Instance Attribute Details
#component_id ⇒ Integer
TODO: Write general description for this method
18 19 20 |
# File 'lib/advanced_billing/models/segment.rb', line 18 def component_id @component_id end |
#created_at ⇒ String
TODO: Write general description for this method
50 51 52 |
# File 'lib/advanced_billing/models/segment.rb', line 50 def created_at @created_at end |
#event_based_billing_metric_id ⇒ Integer
TODO: Write general description for this method
26 27 28 |
# File 'lib/advanced_billing/models/segment.rb', line 26 def event_based_billing_metric_id @event_based_billing_metric_id end |
#id ⇒ Integer
TODO: Write general description for this method
14 15 16 |
# File 'lib/advanced_billing/models/segment.rb', line 14 def id @id end |
#price_point_id ⇒ Integer
TODO: Write general description for this method
22 23 24 |
# File 'lib/advanced_billing/models/segment.rb', line 22 def price_point_id @price_point_id end |
#prices ⇒ Array[SegmentPrice]
TODO: Write general description for this method
58 59 60 |
# File 'lib/advanced_billing/models/segment.rb', line 58 def prices @prices end |
#pricing_scheme ⇒ String
TODO: Write general description for this method
30 31 32 |
# File 'lib/advanced_billing/models/segment.rb', line 30 def pricing_scheme @pricing_scheme end |
#segment_property_1_value ⇒ Object
TODO: Write general description for this method
34 35 36 |
# File 'lib/advanced_billing/models/segment.rb', line 34 def segment_property_1_value @segment_property_1_value end |
#segment_property_2_value ⇒ Object
TODO: Write general description for this method
38 39 40 |
# File 'lib/advanced_billing/models/segment.rb', line 38 def segment_property_2_value @segment_property_2_value end |
#segment_property_3_value ⇒ Object
TODO: Write general description for this method
42 43 44 |
# File 'lib/advanced_billing/models/segment.rb', line 42 def segment_property_3_value @segment_property_3_value end |
#segment_property_4_value ⇒ Object
TODO: Write general description for this method
46 47 48 |
# File 'lib/advanced_billing/models/segment.rb', line 46 def segment_property_4_value @segment_property_4_value end |
#updated_at ⇒ String
TODO: Write general description for this method
54 55 56 |
# File 'lib/advanced_billing/models/segment.rb', line 54 def updated_at @updated_at end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/advanced_billing/models/segment.rb', line 127 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : SKIP component_id = hash.key?('component_id') ? hash['component_id'] : SKIP price_point_id = hash.key?('price_point_id') ? hash['price_point_id'] : SKIP event_based_billing_metric_id = hash.key?('event_based_billing_metric_id') ? hash['event_based_billing_metric_id'] : SKIP pricing_scheme = hash.key?('pricing_scheme') ? hash['pricing_scheme'] : SKIP segment_property_1_value = hash.key?('segment_property_1_value') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:SegmentSegmentProperty1Value), hash['segment_property_1_value'] ) : SKIP segment_property_2_value = hash.key?('segment_property_2_value') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:SegmentSegmentProperty2Value), hash['segment_property_2_value'] ) : SKIP segment_property_3_value = hash.key?('segment_property_3_value') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:SegmentSegmentProperty3Value), hash['segment_property_3_value'] ) : SKIP segment_property_4_value = hash.key?('segment_property_4_value') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:SegmentSegmentProperty4Value), hash['segment_property_4_value'] ) : SKIP created_at = hash.key?('created_at') ? hash['created_at'] : SKIP updated_at = hash.key?('updated_at') ? hash['updated_at'] : SKIP # Parameter is an array, so we need to iterate through it prices = nil unless hash['prices'].nil? prices = [] hash['prices'].each do |structure| prices << (SegmentPrice.from_hash(structure) if structure) end end prices = SKIP unless hash.key?('prices') # Create object from extracted values. Segment.new(id, component_id, price_point_id, event_based_billing_metric_id, pricing_scheme, segment_property_1_value, segment_property_2_value, segment_property_3_value, segment_property_4_value, created_at, updated_at, prices) end |
.names ⇒ Object
A mapping from model property names to API property names.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/advanced_billing/models/segment.rb', line 61 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['component_id'] = 'component_id' @_hash['price_point_id'] = 'price_point_id' @_hash['event_based_billing_metric_id'] = 'event_based_billing_metric_id' @_hash['pricing_scheme'] = 'pricing_scheme' @_hash['segment_property_1_value'] = 'segment_property_1_value' @_hash['segment_property_2_value'] = 'segment_property_2_value' @_hash['segment_property_3_value'] = 'segment_property_3_value' @_hash['segment_property_4_value'] = 'segment_property_4_value' @_hash['created_at'] = 'created_at' @_hash['updated_at'] = 'updated_at' @_hash['prices'] = 'prices' @_hash end |
.nullables ⇒ Object
An array for nullable fields
98 99 100 |
# File 'lib/advanced_billing/models/segment.rb', line 98 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/advanced_billing/models/segment.rb', line 80 def self.optionals %w[ id component_id price_point_id event_based_billing_metric_id pricing_scheme segment_property_1_value segment_property_2_value segment_property_3_value segment_property_4_value created_at updated_at prices ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
181 182 183 184 185 186 187 |
# File 'lib/advanced_billing/models/segment.rb', line 181 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |