Sha256: e6ad25ee5d223f98591be1d635ca4ce8637f36f2343311905d3ac9509a551a64

Contents?: true

Size: 789 Bytes

Versions: 4

Compression:

Stored size: 789 Bytes

Contents

# frozen_string_literal: true

# Token object
class Fastly
  class Token < Base
    attr_accessor :id, :access_token, :user_id, :services, :name,  :scope, :created_at, :last_used_at, :expires_at, :ip, :user_agent
    
    private

    def self.get_path(*_args)
      '/tokens'
    end

    def self.post_path(*_args)
      '/tokens'
    end
    
    def self.delete_path(opts)
      "/tokens/#{opts.id}"
    end
  end

  def new_token(opts)
    opts[:username] = client.user
    opts[:password] = client.password
    opts[:include_auth] = false
    
    token = create(Token, opts)
    token.nil? ? nil : token
  end

  def customer_tokens(opts)
    hash = client.get("/customer/#{opts[:customer_id]}/tokens")
    hash.map { |token_hash| Token.new(token_hash, Fastly::Fetcher) }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fastly-2.5.3 lib/fastly/token.rb
fastly-2.5.2 lib/fastly/token.rb
fastly-2.5.1 lib/fastly/token.rb
fastly-2.5.0 lib/fastly/token.rb