Class: ThreeScale::AuthorizeResponse

Inherits:
Response
  • Object
show all
Defined in:
lib/3scale/authorize_response.rb

Defined Under Namespace

Classes: UsageReport

Instance Attribute Summary collapse

Attributes inherited from Response

#error_code, #error_message

Instance Method Summary collapse

Methods inherited from Response

#error!, #success!, #success?

Constructor Details

#initializeAuthorizeResponse

Returns a new instance of AuthorizeResponse.



44
45
46
47
48
49
50
51
52
# File 'lib/3scale/authorize_response.rb', line 44

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

Instance Attribute Details

#app_keyObject

Returns the value of attribute app_key.



38
39
40
# File 'lib/3scale/authorize_response.rb', line 38

def app_key
  @app_key
end

#hierarchyObject (readonly)

Not part of the stable API



42
43
44
# File 'lib/3scale/authorize_response.rb', line 42

def hierarchy
  @hierarchy
end

#planObject

Returns the value of attribute plan.



37
38
39
# File 'lib/3scale/authorize_response.rb', line 37

def plan
  @plan
end

#redirect_urlObject

Returns the value of attribute redirect_url.



39
40
41
# File 'lib/3scale/authorize_response.rb', line 39

def redirect_url
  @redirect_url
end

#service_idObject

Returns the value of attribute service_id.



40
41
42
# File 'lib/3scale/authorize_response.rb', line 40

def service_id
  @service_id
end

#usage_reportsObject (readonly)

Returns the value of attribute usage_reports.



41
42
43
# File 'lib/3scale/authorize_response.rb', line 41

def usage_reports
  @usage_reports
end

Instance Method Details

#add_metric_to_hierarchy(metric_name, children) ⇒ Object



58
59
60
# File 'lib/3scale/authorize_response.rb', line 58

def add_metric_to_hierarchy(metric_name, children)
  @hierarchy[metric_name] = children
end

#add_usage_report(options) ⇒ Object



54
55
56
# File 'lib/3scale/authorize_response.rb', line 54

def add_usage_report(options)
  @usage_reports << UsageReport.new(options)
end

#limits_exceeded?Boolean

The response already specifies whether any usage report (if present) is over the limits, so use that instead of scanning the reports.

Returns:

  • (Boolean)


64
65
66
# File 'lib/3scale/authorize_response.rb', line 64

def limits_exceeded?
  error_code == LIMITS_EXCEEDED || error_message == LIMITS_EXCEEDED_MSG
end