lib/zendesk2/organizations.rb in zendesk2-1.9.0 vs lib/zendesk2/organizations.rb in zendesk2-1.10.0
- old
+ new
@@ -1,5 +1,6 @@
+# frozen_string_literal: true
class Zendesk2::Organizations
include Zendesk2::Collection
include Zendesk2::PagedCollection
include Zendesk2::Searchable
@@ -10,34 +11,35 @@
attribute :user_id, type: :integer
assoc_accessor :user
def find_by_external_id(external_id)
- body = cistern.get_organization_by_external_id("external_id" => external_id).body
- if data = body.delete("organizations")
- collection = self.clone.load(data)
- collection.merge_attributes(Cistern::Hash.slice(body, "count", "next_page", "previous_page"))
+ body = cistern.get_organization_by_external_id('external_id' => external_id).body
+ data = body.delete('organizations')
+ if data
+ collection = clone.load(data)
+ collection.merge_attributes(Cistern::Hash.slice(body, 'count', 'next_page', 'previous_page'))
collection
end
end
self.collection_method = :get_organizations
- self.collection_root = "organizations"
+ self.collection_root = 'organizations'
self.model_method = :get_organization
- self.model_root = "organization"
- self.search_type = "organization"
+ self.model_root = 'organization'
+ self.search_type = 'organization'
self.search_request = :search_organization
- def collection_page(params={})
- collection_method = if self.user_id
+ def collection_page(params = {})
+ collection_method = if user_id
:get_user_organizations
else
:get_organizations
end
- body = cistern.send(collection_method, Cistern::Hash.stringify_keys(self.attributes.merge(params))).body
+ body = cistern.send(collection_method, Cistern::Hash.stringify_keys(attributes.merge(params))).body
- self.load(body[collection_root])
- self.merge_attributes(Cistern::Hash.slice(body, "count", "next_page", "previous_page"))
+ load(body[collection_root])
+ merge_attributes(Cistern::Hash.slice(body, 'count', 'next_page', 'previous_page'))
self
end
end