lib/nimbu-api/endpoints/sites.rb in nimbu-api-0.4.4 vs lib/nimbu-api/endpoints/sites.rb in nimbu-api-0.5.0

- old
+ new

@@ -1,34 +1,32 @@ # encoding: utf-8 +# frozen_string_literal: true module Nimbu module Endpoints class Sites < Endpoint - - def list(*args) + def list(*args, &block) require_authentication arguments(args) response = get_request("/sites", arguments.params) return response unless block_given? - response.each { |el| yield el } + response.each(&block) end - alias :all :list + alias_method :all, :list def get(*args) require_authentication - arguments(args, :required => [:site_id]) + arguments(args, required: [:site_id]) get_request("/sites/#{site_id}", arguments.params) end - alias :find :get + alias_method :find, :get - private def require_authentication - raise ArgumentError, 'You need to be authenticated to access the sites' unless authenticated? + raise ArgumentError, "You need to be authenticated to access the sites" unless authenticated? end - end # Authorizations end # Endpoints end # Nimbu