Class: Zm::Client::AccountsCollection

Inherits:
Base::AdminObjectsCollection show all
Defined in:
lib/zm/client/account/accounts_collection.rb

Overview

Collection Accounts

Constant Summary

Constants inherited from Base::ObjectsCollection

Base::ObjectsCollection::METHODS_MISSING_LIST

Instance Attribute Summary

Attributes inherited from Base::ObjectsCollection

#parent

Instance Method Summary collapse

Methods inherited from Base::AdminObjectsCollection

#attrs, #build_query, #clear, #count, #find_by, #find_by_or_nil, #find_each, #ldap, #make_query, #where

Methods inherited from Base::ObjectsCollection

#all, #find, #first, #logger, #method_missing, #new, #order, #page, #per_page, #respond_to_missing?

Methods included from Inspector

#inspect, #instance_variables_map, #to_h, #to_s

Constructor Details

#initialize(parent) ⇒ AccountsCollection

Returns a new instance of AccountsCollection.



7
8
9
10
11
12
# File 'lib/zm/client/account/accounts_collection.rb', line 7

def initialize(parent)
  @child_class = 
  @builder_class = AccountsBuilder
  @search_type = SearchType::
  super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Zm::Client::Base::ObjectsCollection

Instance Method Details

#build_find_by(hash) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/zm/client/account/accounts_collection.rb', line 21

def build_find_by(hash)
  soap_request = SoapElement.admin(SoapAdminConstants::)
   = SoapElement.create(SoapConstants::)
                            .add_attribute(SoapConstants::BY, hash.keys.first)
                            .add_content(hash.values.first)
  soap_request.add_node()
  soap_request.add_attribute(SoapConstants::ATTRS, attrs_comma)
  soap_request.add_attribute(SoapConstants::APPLY_COS, @apply_cos)
  soap_request
end

#find_by!(hash) ⇒ Object



14
15
16
17
18
19
# File 'lib/zm/client/account/accounts_collection.rb', line 14

def find_by!(hash)
  entry = sac.invoke(build_find_by(hash))[:GetAccountResponse][:account].first

  reset_query_params
  AccountJsnsInitializer.create(@parent, entry)
end

#quotas(domain_name: @domain_name, target_server_id: @target_server_id) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/zm/client/account/accounts_collection.rb', line 32

def quotas(domain_name: @domain_name, target_server_id: @target_server_id)
  return nil if domain_name.nil? && target_server_id.nil?

  if target_server_id.nil?
    @all_servers = SoapUtils::ON
  else
    sac.context.target_server(target_server_id)
  end

  jsns = {
    domain: domain_name,
    allServers: @all_servers,
    limit: @limit,
    offset: @offset,
    sortBy: @sort_by,
    sortAscending: @sort_ascending,
    refresh: @refresh
  }
  jsns.compact!

  soap_request = SoapElement.admin(SoapAdminConstants::GET_QUOTA_USAGE_REQUEST)
                            .add_attributes(jsns)
  json = sac.invoke(soap_request)

  sac.context.target_server(nil) unless target_server_id.nil?

  reset_query_params
  @builder_class.new(@parent, json).make
end