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 ⇒ DateTime
The identifier for the pricing scheme.
-
#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]
The identifier for the pricing scheme.
-
#pricing_scheme ⇒ PricingScheme
The identifier for the pricing scheme.
-
#segment_property_1_value ⇒ Object
The identifier for the pricing scheme.
-
#segment_property_2_value ⇒ Object
The identifier for the pricing scheme.
-
#segment_property_3_value ⇒ Object
The identifier for the pricing scheme.
-
#segment_property_4_value ⇒ Object
The identifier for the pricing scheme.
-
#updated_at ⇒ DateTime
The identifier for the pricing scheme.
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, additional_properties: {}) ⇒ Segment
constructor
A new instance of Segment.
- #to_custom_created_at ⇒ Object
- #to_custom_updated_at ⇒ Object
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, additional_properties: {}) ⇒ Segment
Returns a new instance of Segment.
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/advanced_billing/models/segment.rb', line 119 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, additional_properties: {}) @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 # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end end |
Instance Attribute Details
#component_id ⇒ Integer
TODO: Write general description for this method
19 20 21 |
# File 'lib/advanced_billing/models/segment.rb', line 19 def component_id @component_id end |
#created_at ⇒ DateTime
The identifier for the pricing scheme. See [Product Components](help.chargify.com/products/product-components.html) for an overview of pricing schemes.
63 64 65 |
# File 'lib/advanced_billing/models/segment.rb', line 63 def created_at @created_at end |
#event_based_billing_metric_id ⇒ Integer
TODO: Write general description for this method
27 28 29 |
# File 'lib/advanced_billing/models/segment.rb', line 27 def event_based_billing_metric_id @event_based_billing_metric_id end |
#id ⇒ Integer
TODO: Write general description for this method
15 16 17 |
# File 'lib/advanced_billing/models/segment.rb', line 15 def id @id end |
#price_point_id ⇒ Integer
TODO: Write general description for this method
23 24 25 |
# File 'lib/advanced_billing/models/segment.rb', line 23 def price_point_id @price_point_id end |
#prices ⇒ Array[SegmentPrice]
The identifier for the pricing scheme. See [Product Components](help.chargify.com/products/product-components.html) for an overview of pricing schemes.
75 76 77 |
# File 'lib/advanced_billing/models/segment.rb', line 75 def prices @prices end |
#pricing_scheme ⇒ PricingScheme
The identifier for the pricing scheme. See [Product Components](help.chargify.com/products/product-components.html) for an overview of pricing schemes.
33 34 35 |
# File 'lib/advanced_billing/models/segment.rb', line 33 def pricing_scheme @pricing_scheme end |
#segment_property_1_value ⇒ Object
The identifier for the pricing scheme. See [Product Components](help.chargify.com/products/product-components.html) for an overview of pricing schemes.
39 40 41 |
# File 'lib/advanced_billing/models/segment.rb', line 39 def segment_property_1_value @segment_property_1_value end |
#segment_property_2_value ⇒ Object
The identifier for the pricing scheme. See [Product Components](help.chargify.com/products/product-components.html) for an overview of pricing schemes.
45 46 47 |
# File 'lib/advanced_billing/models/segment.rb', line 45 def segment_property_2_value @segment_property_2_value end |
#segment_property_3_value ⇒ Object
The identifier for the pricing scheme. See [Product Components](help.chargify.com/products/product-components.html) for an overview of pricing schemes.
51 52 53 |
# File 'lib/advanced_billing/models/segment.rb', line 51 def segment_property_3_value @segment_property_3_value end |
#segment_property_4_value ⇒ Object
The identifier for the pricing scheme. See [Product Components](help.chargify.com/products/product-components.html) for an overview of pricing schemes.
57 58 59 |
# File 'lib/advanced_billing/models/segment.rb', line 57 def segment_property_4_value @segment_property_4_value end |
#updated_at ⇒ DateTime
The identifier for the pricing scheme. See [Product Components](help.chargify.com/products/product-components.html) for an overview of pricing schemes.
69 70 71 |
# File 'lib/advanced_billing/models/segment.rb', line 69 def updated_at @updated_at end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/advanced_billing/models/segment.rb', line 149 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 = if hash.key?('created_at') (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at']) else SKIP end updated_at = if hash.key?('updated_at') (DateTimeHelper.from_rfc3339(hash['updated_at']) if hash['updated_at']) else SKIP end # 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') # Clean out expected properties from Hash. names.each_value { |k| hash.delete(k) } # Create object from extracted values. Segment.new(id: id, component_id: component_id, price_point_id: price_point_id, event_based_billing_metric_id: event_based_billing_metric_id, pricing_scheme: pricing_scheme, segment_property_1_value: segment_property_1_value, segment_property_2_value: segment_property_2_value, segment_property_3_value: segment_property_3_value, segment_property_4_value: segment_property_4_value, created_at: created_at, updated_at: updated_at, prices: prices, additional_properties: hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/advanced_billing/models/segment.rb', line 78 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
115 116 117 |
# File 'lib/advanced_billing/models/segment.rb', line 115 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/advanced_billing/models/segment.rb', line 97 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.
223 224 225 226 227 228 229 |
# File 'lib/advanced_billing/models/segment.rb', line 223 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |
Instance Method Details
#to_custom_created_at ⇒ Object
213 214 215 |
# File 'lib/advanced_billing/models/segment.rb', line 213 def to_custom_created_at DateTimeHelper.to_rfc3339(created_at) end |
#to_custom_updated_at ⇒ Object
217 218 219 |
# File 'lib/advanced_billing/models/segment.rb', line 217 def to_custom_updated_at DateTimeHelper.to_rfc3339(updated_at) end |