Class: ApiReference::GroupedSubscriptionUsageRecord
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- ApiReference::GroupedSubscriptionUsageRecord
- Defined in:
- lib/api_reference/models/grouped_subscription_usage_record.rb
Overview
GroupedSubscriptionUsageRecord Model.
Instance Attribute Summary collapse
-
#billable_metric ⇒ BillableMetricSimple
TODO: Write general description for this method.
-
#metric_group ⇒ MetricGroup
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:, metric_group:, view_mode:, additional_properties: nil) ⇒ GroupedSubscriptionUsageRecord
constructor
A new instance of GroupedSubscriptionUsageRecord.
-
#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:, metric_group:, view_mode:, additional_properties: nil) ⇒ GroupedSubscriptionUsageRecord
Returns a new instance of GroupedSubscriptionUsageRecord.
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/api_reference/models/grouped_subscription_usage_record.rb', line 48 def initialize(usage:, billable_metric:, metric_group:, view_mode:, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @usage = usage @billable_metric = billable_metric @metric_group = metric_group @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/grouped_subscription_usage_record.rb', line 18 def billable_metric @billable_metric end |
#metric_group ⇒ MetricGroup
TODO: Write general description for this method
22 23 24 |
# File 'lib/api_reference/models/grouped_subscription_usage_record.rb', line 22 def metric_group @metric_group end |
#usage ⇒ Array[Usage]
TODO: Write general description for this method
14 15 16 |
# File 'lib/api_reference/models/grouped_subscription_usage_record.rb', line 14 def usage @usage end |
#view_mode ⇒ ViewMode
TODO: Write general description for this method
26 27 28 |
# File 'lib/api_reference/models/grouped_subscription_usage_record.rb', line 26 def view_mode @view_mode end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 86 87 88 89 90 91 92 93 |
# File 'lib/api_reference/models/grouped_subscription_usage_record.rb', line 61 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'] metric_group = MetricGroup.from_hash(hash['metric_group']) if hash['metric_group'] 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. GroupedSubscriptionUsageRecord.new(usage: usage, billable_metric: billable_metric, metric_group: metric_group, view_mode: view_mode, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
29 30 31 32 33 34 35 36 |
# File 'lib/api_reference/models/grouped_subscription_usage_record.rb', line 29 def self.names @_hash = {} if @_hash.nil? @_hash['usage'] = 'usage' @_hash['billable_metric'] = 'billable_metric' @_hash['metric_group'] = 'metric_group' @_hash['view_mode'] = 'view_mode' @_hash end |
.nullables ⇒ Object
An array for nullable fields
44 45 46 |
# File 'lib/api_reference/models/grouped_subscription_usage_record.rb', line 44 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
39 40 41 |
# File 'lib/api_reference/models/grouped_subscription_usage_record.rb', line 39 def self.optionals [] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
97 98 99 100 101 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 |
# File 'lib/api_reference/models/grouped_subscription_usage_record.rb', line 97 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.metric_group, ->(val) { MetricGroup.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['metric_group'], ->(val) { MetricGroup.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.
142 143 144 145 146 147 |
# File 'lib/api_reference/models/grouped_subscription_usage_record.rb', line 142 def inspect class_name = self.class.name.split('::').last "<#{class_name} usage: #{@usage.inspect}, billable_metric: #{@billable_metric.inspect},"\ " metric_group: #{@metric_group.inspect}, view_mode: #{@view_mode.inspect},"\ " additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
134 135 136 137 138 139 |
# File 'lib/api_reference/models/grouped_subscription_usage_record.rb', line 134 def to_s class_name = self.class.name.split('::').last "<#{class_name} usage: #{@usage}, billable_metric: #{@billable_metric}, metric_group:"\ " #{@metric_group}, view_mode: #{@view_mode}, additional_properties:"\ " #{@additional_properties}>" end |