lib/fastly.rb in fastly-0.98 vs lib/fastly.rb in fastly-0.99

- old
+ new

@@ -3,11 +3,11 @@ # License:: Distributes under the same terms as Ruby # A client library for interacting with the Fastly web acceleration service class Fastly # The current version of the library - VERSION = "0.98" + VERSION = "0.99" require 'fastly/fetcher' require 'fastly/client' require 'fastly/base' @@ -63,9 +63,18 @@ # Return a User object representing the current logged in user. # NOTE: requires you to be fully authed - will not work with only an API key def current_user raise Fastly::FullAuthRequired unless self.fully_authed? @current_user ||= get(User) + end + + # Set the current customer to act as. + # NOTE: this will only work if you're an admin + def set_customer(id) + raise Fastly::FullAuthRequired "You must be fully authed to set the customer" unless self.fully_authed?; + raise Fastly::AdminRequired "You must be an admin to set the customer" unless self.current_user.can_do?(:admin); + @current_customer = nil + client.set_customer(id); end # Return a hash representing all commands available. # # Useful for information.