Sha256: f06163043aa505ffb2fc72598bc9616ebc7e1f625bf3def19d15268b97f8f6af

Contents?: true

Size: 738 Bytes

Versions: 5

Compression:

Stored size: 738 Bytes

Contents

module Mashery
  class Key < ApiObjectBase
    attr_reader :id, :created, :updated, :service_key, :username, :limits
    attr_accessor :apikey, :status, :rate_limit_ceiling, :qps_limit_ceiling, :rate_limit_exempt, :qps_limit_exempt,
      :required_referer, :secret

    def self.create(service_key, username, fields = {})
      fields ||= {}
      our_fields = fields.merge('service' => {'service_key' => service_key}, 'member' => {'username' => username})
      super(our_fields)
    end

    def initialize(data)
      limits = data.delete('limits')
      @limits = limits.map {|l| Limit.new(l['period'], l['source'], l['ceiling'])} if limits
      super
    end
  end

  class Limit < Struct.new(:period, :source, :ceiling)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mashery-0.1.1 lib/mashery/key.rb
mashery-0.1.0 lib/mashery/key.rb
mashery-0.0.11 lib/mashery/key.rb
mashery-0.0.10 lib/mashery/key.rb
mashery-0.0.9 lib/mashery/key.rb