lib/fastly/token.rb in fastly-2.5.3 vs lib/fastly/token.rb in fastly-3.0.0

- old
+ new

@@ -19,15 +19,19 @@ "/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 + if client.fully_authed? + opts[:username] = client.user + opts[:password] = client.password + opts[:include_auth] = false + + token = create(Token, opts) + token.nil? ? nil : token + else + raise ArgumentError, "Required options missing. Please pass :api_key, :user and :password." + end end def customer_tokens(opts) hash = client.get("/customer/#{opts[:customer_id]}/tokens") hash.map { |token_hash| Token.new(token_hash, Fastly::Fetcher) }