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
GetSortedQueryParamString?, compute_signatureV3?, expected_type?, expected_value?, generate_url?, getMapFromQueryString?, is_one_among_string_url?, multi_valid_param?, raise_invalid_request, valid_account?, valid_date_format?, valid_mainaccount?, valid_multiple_destination_integers?, valid_multiple_destination_nos?, valid_param?, valid_range?, valid_signature?, valid_signatureV3?, valid_subaccount?, valid_url?
Constructor Details
#initialize(client, resource_list_json = nil) ⇒ PowerpackInterface
Returns a new instance of PowerpackInterface.
628 629 630 631 632 633 |
# File 'lib/plivo/resources/powerpacks.rb', line 628 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
635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 |
# File 'lib/plivo/resources/powerpacks.rb', line 635 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 if .key?(:number_priority) && valid_param?(:number_priority, [:number_priority], Array, true) params[:number_priority] = [:number_priority] end perform_create(params) end |
#each ⇒ Object
704 705 706 707 708 709 710 711 712 |
# File 'lib/plivo/resources/powerpacks.rb', line 704 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
678 679 680 681 |
# File 'lib/plivo/resources/powerpacks.rb', line 678 def get(uuid) valid_param?(:uuid, uuid, [String, Symbol], true) perform_get(uuid) end |
#list(options = nil) ⇒ Object
683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 |
# File 'lib/plivo/resources/powerpacks.rb', line 683 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 |