lib/3scale/authorize_response.rb in 3scale_client-2.8.1 vs lib/3scale/authorize_response.rb in 3scale_client-2.8.2

- old
+ new

@@ -1,19 +1,9 @@ require 'time' module ThreeScale class AuthorizeResponse < Response - def initialize - super - @usage_reports = [] - end - - attr_accessor :plan - attr_accessor :app_key - attr_accessor :redirect_url - attr_accessor :service_id - class UsageReport attr_reader :metric attr_reader :period attr_reader :current_value attr_reader :max_value @@ -35,12 +25,31 @@ def exceeded? current_value > max_value end end + attr_accessor :plan + attr_accessor :app_key + attr_accessor :redirect_url + attr_accessor :service_id attr_reader :usage_reports + attr_reader :hierarchy # Not part of the stable API + def initialize + super + @usage_reports = [] + + # hierarchy is a hash where the keys are metric names, and the values + # their children (array of metric names). + # Only metrics that have at least one child appear as keys. + @hierarchy = {} + end + def add_usage_report(options) @usage_reports << UsageReport.new(options) end + + def add_metric_to_hierarchy(metric_name, children) + @hierarchy[metric_name] = children + end end -end \ No newline at end of file +end