Sha256: 314da26688704936790626c376f9329939dec6271a8e965bf673960e728fd7c6

Contents?: true

Size: 945 Bytes

Versions: 1

Compression:

Stored size: 945 Bytes

Contents

module Nurego
  class Entitlement < APIResource
    include Nurego::APIOperations::List
    include Nurego::APIOperations::Create

    def set_usage(feature_id, amount)
      payload = {
          feature_id: feature_id,
          amount: amount,
      }
      response, api_key = Nurego.request(:put, "/v1/organizations/#{id}/entitlements/usage", nil, payload)
    end

    def self.all(organization_id, filters={}, api_key=nil)
      response, api_key = Nurego.request(:get, "/v1/organizations/#{organization_id}/entitlements", api_key, filters)
      Util.convert_to_nurego_object(response, api_key)
    end

private
      def structure_sensitive_mimic_to_query(array, key)
        prefix = "#{key}[]"
        array.collect do | feature |
          feature.collect do |key, value|
            nk = "#{prefix}[#{key}]"
            "#{CGI.escape(nk)}=#{CGI.escape(value.to_s)}"
          end.sort * '&'
        end.join '&'
      end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nurego-1.1.18 lib/nurego/entitlement.rb