Sha256: ecb1278d67fdecbc91bd1dda82d9a00f619a3378125c72eb7c9e3f522b5ec8b1

Contents?: true

Size: 751 Bytes

Versions: 6

Compression:

Stored size: 751 Bytes

Contents

module Masheri
  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

6 entries across 6 versions & 1 rubygems

Version Path
masheri-0.3.5 lib/masheri/key.rb
masheri-0.3.4 lib/masheri/key.rb
masheri-0.3.1 lib/masheri/key.rb
masheri-0.2.0 lib/masheri/key.rb
masheri-0.1.1 lib/masheri/key.rb
masheri-0.1.0 lib/masheri/key.rb