class Plivo::Resources::SubaccountInterface
@!method get @!method create @!method list
Public Class Methods
Source
# File lib/plivo/resources/accounts.rb, line 54 def initialize(client, resource_list_json = nil) @_name = 'Subaccount' @_resource_type = Subaccount @_identifier_string = 'auth_id' super end
Calls superclass method
Plivo::Base::ResourceInterface::new
Public Instance Methods
Source
# File lib/plivo/resources/accounts.rb, line 69 def create(name, enabled = false) valid_param?(:name, name, [String, Symbol], true) valid_param?(:enabled, enabled, [TrueClass, FalseClass], true, [true, false]) params = { name: name, enabled: enabled } perform_create(params) end
@param [String] name @param [Boolean] enabled
Source
# File lib/plivo/resources/accounts.rb, line 119 def delete(subaccount_id, cascade = false) valid_subaccount?(subaccount_id, true) Subaccount.new(@_client, resource_id: subaccount_id).delete(cascade) end
Source
# File lib/plivo/resources/accounts.rb, line 105 def each offset = 0 loop do subaccount_list = list(offset: offset) subaccount_list[:objects].each { |subaccount| yield subaccount } offset += 20 return unless subaccount_list.length == 20 end end
Source
# File lib/plivo/resources/accounts.rb, line 62 def get(subaccount_id) valid_subaccount?(subaccount_id, true) perform_get(subaccount_id) end
@param [String] subaccount_id
Source
# File lib/plivo/resources/accounts.rb, line 83 def list(options = nil) return perform_list if options.nil? params = {} %i[offset limit].each do |param| if options.key?(param) && valid_param?(param, options[param], [Integer, Integer], true) params[param] = options[param] end end if options.key?(:limit) && (options[:limit] > 20 || options[:limit] <= 0) raise_invalid_request('The maximum number of results that can be '\ "fetched is 20. limit can't be more than 20 or less than 1") end raise_invalid_request("Offset can't be negative") if options.key?(:offset) && options[:offset] < 0 perform_list(params) end
@param [Array] options
Source
# File lib/plivo/resources/accounts.rb, line 115 def update(subaccount_id, name, enabled = false) Subaccount.new(@_client, resource_id: subaccount_id).update(name, enabled) end