Class: Plivo::Resources::PowerpackInterface
- Inherits:
-
Base::ResourceInterface
- Object
- Base::ResourceInterface
- Plivo::Resources::PowerpackInterface
- Defined in:
- lib/plivo/resources/powerpacks.rb
Constant Summary
Constants included from Utils
Instance Method Summary collapse
- #create(name, options = nil) ⇒ Object
- #each ⇒ Object
- #get(uuid) ⇒ Object
-
#initialize(client, resource_list_json = nil) ⇒ PowerpackInterface
constructor
A new instance of PowerpackInterface.
- #list(options = nil) ⇒ Object
Methods included from Utils
expected_type?, expected_value?, raise_invalid_request, valid_account?, valid_mainaccount?, valid_param?, valid_signature?, valid_subaccount?
Constructor Details
#initialize(client, resource_list_json = nil) ⇒ PowerpackInterface
Returns a new instance of PowerpackInterface.
563 564 565 566 567 568 |
# File 'lib/plivo/resources/powerpacks.rb', line 563 def initialize(client, resource_list_json = nil) @_name = 'Powerpack' @_resource_type = Powerpack @_identifier_string = 'powerpack' super end |
Instance Method Details
#create(name, options = nil) ⇒ Object
570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 |
# File 'lib/plivo/resources/powerpacks.rb', line 570 def create(name, = nil) valid_param?(:name, name, [String, Symbol], true) if name.nil? raise InvalidRequestError, 'powerpack name cannot be empty' end params = { name: name } return perform_create(params) if .nil? valid_param?(:options, , Hash, true) if .key?(:application_type) && valid_param?(:application_type, [:application_type], String, true) params[:application_type] = [:application_type] end if .key?(:application_id) && valid_param?(:application_id, [:application_id], String, true) params[:application_id] = [:application_id] end if .key?(:sticky_sender) && valid_param?(:sticky_sender, [:sticky_sender], [TrueClass, FalseClass], true) params[:sticky_sender] = [:sticky_sender] end if .key?(:local_connect) && valid_param?(:local_connect, [:local_connect], [TrueClass, FalseClass], true) params[:local_connect] = [:local_connect] end perform_create(params) end |
#each ⇒ Object
633 634 635 636 637 638 639 640 641 |
# File 'lib/plivo/resources/powerpacks.rb', line 633 def each offset = 0 loop do powerpack_list = list(offset: offset) powerpack_list[:objects].each { || yield } offset += 20 return unless powerpack_list.length == 20 end end |
#get(uuid) ⇒ Object
607 608 609 610 |
# File 'lib/plivo/resources/powerpacks.rb', line 607 def get(uuid) valid_param?(:uuid, uuid, [String, Symbol], true) perform_get(uuid) end |
#list(options = nil) ⇒ Object
612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 |
# File 'lib/plivo/resources/powerpacks.rb', line 612 def list( = nil) return perform_list if .nil? params = {} %i[offset limit].each do |param| if .key?(param) && valid_param?(param, [param], [Integer, Integer], true) params[param] = [param] end end if .key?(:limit) && ([:limit] > 20 || [: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 if .key?(:offset) && [:offset] < 0 raise_invalid_request("Offset can't be negative") end perform_list(params) end |