Class: ApiReference::UngroupedSubscriptionUsageRecord
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- ApiReference::UngroupedSubscriptionUsageRecord
- Defined in:
- lib/api_reference/models/ungrouped_subscription_usage_record.rb
Overview
UngroupedSubscriptionUsageRecord Model.
Instance Attribute Summary collapse
-
#billable_metric ⇒ BillableMetricSimple
TODO: Write general description for this method.
-
#usage ⇒ Array[Usage]
TODO: Write general description for this method.
-
#view_mode ⇒ ViewMode
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(usage:, billable_metric:, view_mode:, additional_properties: nil) ⇒ UngroupedSubscriptionUsageRecord
constructor
A new instance of UngroupedSubscriptionUsageRecord.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(usage:, billable_metric:, view_mode:, additional_properties: nil) ⇒ UngroupedSubscriptionUsageRecord
Returns a new instance of UngroupedSubscriptionUsageRecord.
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/api_reference/models/ungrouped_subscription_usage_record.rb', line 43 def initialize(usage:, billable_metric:, view_mode:, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @usage = usage @billable_metric = billable_metric @view_mode = view_mode @additional_properties = additional_properties end |
Instance Attribute Details
#billable_metric ⇒ BillableMetricSimple
TODO: Write general description for this method
18 19 20 |
# File 'lib/api_reference/models/ungrouped_subscription_usage_record.rb', line 18 def billable_metric @billable_metric end |
#usage ⇒ Array[Usage]
TODO: Write general description for this method
14 15 16 |
# File 'lib/api_reference/models/ungrouped_subscription_usage_record.rb', line 14 def usage @usage end |
#view_mode ⇒ ViewMode
TODO: Write general description for this method
22 23 24 |
# File 'lib/api_reference/models/ungrouped_subscription_usage_record.rb', line 22 def view_mode @view_mode end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/api_reference/models/ungrouped_subscription_usage_record.rb', line 55 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 usage = nil unless hash['usage'].nil? usage = [] hash['usage'].each do |structure| usage << (Usage.from_hash(structure) if structure) end end usage = nil unless hash.key?('usage') billable_metric = BillableMetricSimple.from_hash(hash['billable_metric']) if hash['billable_metric'] view_mode = hash.key?('view_mode') ? hash['view_mode'] : nil # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. UngroupedSubscriptionUsageRecord.new(usage: usage, billable_metric: billable_metric, view_mode: view_mode, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
25 26 27 28 29 30 31 |
# File 'lib/api_reference/models/ungrouped_subscription_usage_record.rb', line 25 def self.names @_hash = {} if @_hash.nil? @_hash['usage'] = 'usage' @_hash['billable_metric'] = 'billable_metric' @_hash['view_mode'] = 'view_mode' @_hash end |
.nullables ⇒ Object
An array for nullable fields
39 40 41 |
# File 'lib/api_reference/models/ungrouped_subscription_usage_record.rb', line 39 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
34 35 36 |
# File 'lib/api_reference/models/ungrouped_subscription_usage_record.rb', line 34 def self.optionals [] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/api_reference/models/ungrouped_subscription_usage_record.rb', line 89 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.usage, ->(val) { Usage.validate(val) }, is_model_hash: true, is_inner_model_hash: true) and APIHelper.valid_type?(value.billable_metric, ->(val) { BillableMetricSimple.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value.view_mode, ->(val) { ViewMode.validate(val) }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['usage'], ->(val) { Usage.validate(val) }, is_model_hash: true, is_inner_model_hash: true) and APIHelper.valid_type?(value['billable_metric'], ->(val) { BillableMetricSimple.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value['view_mode'], ->(val) { ViewMode.validate(val) }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
127 128 129 130 131 |
# File 'lib/api_reference/models/ungrouped_subscription_usage_record.rb', line 127 def inspect class_name = self.class.name.split('::').last "<#{class_name} usage: #{@usage.inspect}, billable_metric: #{@billable_metric.inspect},"\ " view_mode: #{@view_mode.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
120 121 122 123 124 |
# File 'lib/api_reference/models/ungrouped_subscription_usage_record.rb', line 120 def to_s class_name = self.class.name.split('::').last "<#{class_name} usage: #{@usage}, billable_metric: #{@billable_metric}, view_mode:"\ " #{@view_mode}, additional_properties: #{@additional_properties}>" end |