Class: Zernio::UsageStats
- Inherits:
-
ApiModelBase
- Object
- ApiModelBase
- Zernio::UsageStats
- Defined in:
- lib/zernio-sdk/models/usage_stats.rb
Overview
Plan and usage stats. The response shape depends on billingSystem: * Stripe users (default): per-period counters like usage.uploads and usage.profiles are returned, scoped by the plan's limits. * Metronome users (usage-based): limits are unlimited (-1). The usage block carries connected-account and per-X-operation counts, and the spend block carries current-period costs plus the X cap.
Defined Under Namespace
Classes: EnumAttributeValidator
Instance Attribute Summary collapse
-
#auto_upgrade_enabled ⇒ Object
Stripe-only.
-
#billing_anchor_day ⇒ Object
Day of month (1-31) when the billing cycle resets.
-
#billing_period ⇒ Object
Returns the value of attribute billing_period.
-
#billing_system ⇒ Object
Which billing system the account is on.
-
#customer_id ⇒ Object
Stripe customer ID, when present.
-
#has_access ⇒ Object
True if the account is in good standing.
-
#is_invited_user ⇒ Object
True if this is a team member; limits/usage reflect the account owner.
-
#limits ⇒ Object
Returns the value of attribute limits.
-
#plan_name ⇒ Object
Returns the value of attribute plan_name.
-
#signup_date ⇒ Object
Returns the value of attribute signup_date.
-
#spend ⇒ Object
Returns the value of attribute spend.
-
#usage ⇒ Object
Returns the value of attribute usage.
Class Method Summary collapse
-
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about.
-
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about.
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.build_from_hash(attributes) ⇒ Object
Builds the object from hash.
-
.openapi_nullable ⇒ Object
List of attributes with nullable: true.
-
.openapi_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ UsageStats
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Methods inherited from ApiModelBase
_deserialize, #_to_hash, #to_body, #to_s
Constructor Details
#initialize(attributes = {}) ⇒ UsageStats
Initializes the object
126 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 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/zernio-sdk/models/usage_stats.rb', line 126 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `Zernio::UsageStats` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key acceptable_attribute_map = self.class.acceptable_attribute_map attributes = attributes.each_with_object({}) { |(k, v), h| if (!acceptable_attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `Zernio::UsageStats`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'billing_system') self.billing_system = attributes[:'billing_system'] end if attributes.key?(:'plan_name') self.plan_name = attributes[:'plan_name'] end if attributes.key?(:'billing_period') self.billing_period = attributes[:'billing_period'] end if attributes.key?(:'signup_date') self.signup_date = attributes[:'signup_date'] end if attributes.key?(:'billing_anchor_day') self.billing_anchor_day = attributes[:'billing_anchor_day'] end if attributes.key?(:'has_access') self.has_access = attributes[:'has_access'] end if attributes.key?(:'customer_id') self.customer_id = attributes[:'customer_id'] end if attributes.key?(:'is_invited_user') self.is_invited_user = attributes[:'is_invited_user'] end if attributes.key?(:'auto_upgrade_enabled') self.auto_upgrade_enabled = attributes[:'auto_upgrade_enabled'] end if attributes.key?(:'limits') self.limits = attributes[:'limits'] end if attributes.key?(:'usage') self.usage = attributes[:'usage'] end if attributes.key?(:'spend') self.spend = attributes[:'spend'] end end |
Instance Attribute Details
#auto_upgrade_enabled ⇒ Object
Stripe-only. Always false for Metronome users.
41 42 43 |
# File 'lib/zernio-sdk/models/usage_stats.rb', line 41 def auto_upgrade_enabled @auto_upgrade_enabled end |
#billing_anchor_day ⇒ Object
Day of month (1-31) when the billing cycle resets
29 30 31 |
# File 'lib/zernio-sdk/models/usage_stats.rb', line 29 def billing_anchor_day @billing_anchor_day end |
#billing_period ⇒ Object
Returns the value of attribute billing_period.
24 25 26 |
# File 'lib/zernio-sdk/models/usage_stats.rb', line 24 def billing_period @billing_period end |
#billing_system ⇒ Object
Which billing system the account is on. Shape of usage/spend differs.
20 21 22 |
# File 'lib/zernio-sdk/models/usage_stats.rb', line 20 def billing_system @billing_system end |
#customer_id ⇒ Object
Stripe customer ID, when present.
35 36 37 |
# File 'lib/zernio-sdk/models/usage_stats.rb', line 35 def customer_id @customer_id end |
#has_access ⇒ Object
True if the account is in good standing. False for past-due/unpaid/paused subscriptions.
32 33 34 |
# File 'lib/zernio-sdk/models/usage_stats.rb', line 32 def has_access @has_access end |
#is_invited_user ⇒ Object
True if this is a team member; limits/usage reflect the account owner.
38 39 40 |
# File 'lib/zernio-sdk/models/usage_stats.rb', line 38 def is_invited_user @is_invited_user end |
#limits ⇒ Object
Returns the value of attribute limits.
43 44 45 |
# File 'lib/zernio-sdk/models/usage_stats.rb', line 43 def limits @limits end |
#plan_name ⇒ Object
Returns the value of attribute plan_name.
22 23 24 |
# File 'lib/zernio-sdk/models/usage_stats.rb', line 22 def plan_name @plan_name end |
#signup_date ⇒ Object
Returns the value of attribute signup_date.
26 27 28 |
# File 'lib/zernio-sdk/models/usage_stats.rb', line 26 def signup_date @signup_date end |
#spend ⇒ Object
Returns the value of attribute spend.
47 48 49 |
# File 'lib/zernio-sdk/models/usage_stats.rb', line 47 def spend @spend end |
#usage ⇒ Object
Returns the value of attribute usage.
45 46 47 |
# File 'lib/zernio-sdk/models/usage_stats.rb', line 45 def usage @usage end |
Class Method Details
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about
90 91 92 |
# File 'lib/zernio-sdk/models/usage_stats.rb', line 90 def self.acceptable_attribute_map attribute_map end |
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
95 96 97 |
# File 'lib/zernio-sdk/models/usage_stats.rb', line 95 def self.acceptable_attributes acceptable_attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/zernio-sdk/models/usage_stats.rb', line 72 def self.attribute_map { :'billing_system' => :'billingSystem', :'plan_name' => :'planName', :'billing_period' => :'billingPeriod', :'signup_date' => :'signupDate', :'billing_anchor_day' => :'billingAnchorDay', :'has_access' => :'hasAccess', :'customer_id' => :'customerId', :'is_invited_user' => :'isInvitedUser', :'auto_upgrade_enabled' => :'autoUpgradeEnabled', :'limits' => :'limits', :'usage' => :'usage', :'spend' => :'spend' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
# File 'lib/zernio-sdk/models/usage_stats.rb', line 262 def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) transformed_hash = {} openapi_types.each_pair do |key, type| if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[attribute_map[key]].is_a?(Array) transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } end elsif !attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) end end new(transformed_hash) end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
118 119 120 121 122 |
# File 'lib/zernio-sdk/models/usage_stats.rb', line 118 def self.openapi_nullable Set.new([ :'customer_id', ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/zernio-sdk/models/usage_stats.rb', line 100 def self.openapi_types { :'billing_system' => :'String', :'plan_name' => :'String', :'billing_period' => :'String', :'signup_date' => :'Time', :'billing_anchor_day' => :'Integer', :'has_access' => :'Boolean', :'customer_id' => :'String', :'is_invited_user' => :'Boolean', :'auto_upgrade_enabled' => :'Boolean', :'limits' => :'UsageStatsLimits', :'usage' => :'UsageStatsUsage', :'spend' => :'UsageStatsSpend' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/zernio-sdk/models/usage_stats.rb', line 230 def ==(o) return true if self.equal?(o) self.class == o.class && billing_system == o.billing_system && plan_name == o.plan_name && billing_period == o.billing_period && signup_date == o.signup_date && billing_anchor_day == o.billing_anchor_day && has_access == o.has_access && customer_id == o.customer_id && is_invited_user == o.is_invited_user && auto_upgrade_enabled == o.auto_upgrade_enabled && limits == o.limits && usage == o.usage && spend == o.spend end |
#eql?(o) ⇒ Boolean
249 250 251 |
# File 'lib/zernio-sdk/models/usage_stats.rb', line 249 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
255 256 257 |
# File 'lib/zernio-sdk/models/usage_stats.rb', line 255 def hash [billing_system, plan_name, billing_period, signup_date, billing_anchor_day, has_access, customer_id, is_invited_user, auto_upgrade_enabled, limits, usage, spend].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
191 192 193 194 195 |
# File 'lib/zernio-sdk/models/usage_stats.rb', line 191 def list_invalid_properties warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' invalid_properties = Array.new invalid_properties end |
#to_hash ⇒ Hash
Returns the object in the form of hash
284 285 286 287 288 289 290 291 292 293 294 295 296 |
# File 'lib/zernio-sdk/models/usage_stats.rb', line 284 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end hash[param] = _to_hash(value) end hash end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
199 200 201 202 203 204 205 206 |
# File 'lib/zernio-sdk/models/usage_stats.rb', line 199 def valid? warn '[DEPRECATED] the `valid?` method is obsolete' billing_system_validator = EnumAttributeValidator.new('String', ["stripe", "metronome"]) return false unless billing_system_validator.valid?(@billing_system) billing_period_validator = EnumAttributeValidator.new('String', ["monthly", "yearly"]) return false unless billing_period_validator.valid?(@billing_period) true end |