module Kong class Consumer include Base ATTRIBUTE_NAMES = %w(id custom_id username created_at).freeze API_END_POINT = '/consumers/'.freeze def delete self.oauth2_tokens.each do |token| token.delete end super end # List plugins # # @return [Array] def plugins Plugin.list({ consumer_id: self.id }) end # List OAuth applications # # @return [Array] def oauth_apps apps = [] response = client.get("#{@api_end_point}#{self.username}/oauth2") rescue nil if response response['data'].each do |attributes| apps << Kong::OAuthApp.new(attributes) end end apps end # List KeyAuth credentials # # @return [Array] def oauth2_tokens if self.custom_id OAuth2Token.list({ authenticated_userid: self.custom_id }) else [] end end # List Acls # # @return [Array] def acls acls = [] response = client.get("#{@api_end_point}#{self.username}/acls") rescue nil if response response['data'].each do |attributes| acls << Kong::Acl.new(attributes) end end acls end # List JWTs # # @return [Array] def jwts apps = [] response = client.get("#{@api_end_point}#{self.username}/jwt") rescue nil if response response['data'].each do |attributes| apps << Kong::JWT.new(attributes) end end apps end end end