Class: Nurego::Entitlement

Inherits:
APIResource show all
Includes:
APIOperations::Create, APIOperations::List
Defined in:
lib/nurego/entitlement.rb

Instance Attribute Summary

Attributes inherited from NuregoObject

#api_key

Instance Method Summary collapse

Methods included from APIOperations::Create

included

Methods included from APIOperations::List

included

Methods inherited from APIResource

class_name, #refresh, retrieve, url, #url

Methods inherited from NuregoObject

#[], #[]=, #as_json, construct_from, #each, #initialize, #inspect, #keys, #refresh_from, #to_hash, #to_json, #to_s, #values

Constructor Details

This class inherits a constructor from Nurego::NuregoObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Nurego::NuregoObject

Instance Method Details

#is_allowed(features, provider_name = nil) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/nurego/entitlement.rb', line 16

def is_allowed(features, provider_name = nil)
  payload =  {
      :organization => id,
  }
  payload[:provider_name] = provider_name if provider_name

  features = features.is_a?(Array) ? features : [features]
  features_url = structure_sensitive_mimic_to_query(features, 'features')
  response, api_key = Nurego.request(:get, "/v1/entitlements/allowed?#{features_url}",
                                     nil, payload)
  Util.convert_to_nurego_object(response, api_key)
end

#set_usage(feature_id, amount, provider_name = nil) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/nurego/entitlement.rb', line 6

def set_usage(feature_id, amount, provider_name = nil)
  payload = {
      feature_id: feature_id,
      organization: id,
      amount: amount,
  }
  payload[:provider_name] = provider_name if provider_name
  response, api_key = Nurego.request(:put, "/v1/entitlements/usage", nil, payload)
end