Class: Puree::Collection
Overview
Collection resource
Instance Method Summary collapse
-
#get(endpoint: nil, username: nil, password: nil, qty: nil) ⇒ HTTParty::Response
Get.
-
#initialize(resource_type: nil) ⇒ Collection
constructor
A new instance of Collection.
-
#uuid ⇒ Array<String>
Array of UUIDs.
Methods inherited from Resource
#content, #response, #set_content
Constructor Details
#initialize(resource_type: nil) ⇒ Collection
Returns a new instance of Collection.
7 8 9 10 |
# File 'lib/puree/collection.rb', line 7 def initialize(resource_type: nil) super(resource_type) @uuids = [] end |
Instance Method Details
#get(endpoint: nil, username: nil, password: nil, qty: nil) ⇒ HTTParty::Response
Get
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/puree/collection.rb', line 19 def get(endpoint:nil, username:nil, password:nil, qty:nil) # strip any trailing slash @endpoint = endpoint.sub(/(\/)+$/, '') @auth = Base64::strict_encode64(username + ':' + password) @options = { latest_api: true, resource_type: @resource_type.to_sym, rendering: :system, qty: qty } headers = { 'Accept' => 'application/xml', 'Authorization' => 'Basic ' + @auth } query = {} query['rendering'] = @options[:rendering] if @options[:qty] query['window.size'] = @options[:qty] end @response = HTTParty.get(url, query: query, headers: headers) end |
#uuid ⇒ Array<String>
Array of UUIDs
47 48 49 50 |
# File 'lib/puree/collection.rb', line 47 def uuid collect_uuid @uuids end |