Class: Plivo::Resources::RecordingInterface

Inherits:
Base::ResourceInterface show all
Defined in:
lib/plivo/resources/recordings.rb

Constant Summary

Constants included from Utils

Utils::TYPE_WHITELIST

Instance Method Summary collapse

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) ⇒ RecordingInterface

Returns a new instance of RecordingInterface.



44
45
46
47
48
49
50
# File 'lib/plivo/resources/recordings.rb', line 44

def initialize(client, resource_list_json = nil)
  @_name = 'Recording'
  @_resource_type = Recording
  @_identifier_string = 'recording_id'
  super
  @_is_voice_request = true
end

Instance Method Details

#delete(recording_id) ⇒ Object

Parameters:

  • recording_id (String)


136
137
138
139
140
# File 'lib/plivo/resources/recordings.rb', line 136

def delete(recording_id)
  valid_param?(:recording_id, recording_id, [String, Symbol], true)
  raise_invalid_request('Invalid recording_id passed') if recording_id.empty?
  Recording.new(@_client, resource_id: recording_id).delete
end

#eachObject



125
126
127
128
129
130
131
132
133
# File 'lib/plivo/resources/recordings.rb', line 125

def each
  offset = 0
  loop do
    recording_list = list(offset: offset)
    recording_list[:objects].each { |recording| yield recording }
    offset += 20
    return unless recording_list.length == 20
  end
end

#get(recording_id) ⇒ Object

Parameters:

  • recording_id (String)


119
120
121
122
123
# File 'lib/plivo/resources/recordings.rb', line 119

def get(recording_id)
  valid_param?(:recording_id, recording_id, [String, Symbol], true)
  raise_invalid_request('Invalid recording_id passed') if recording_id.empty?
  perform_get(recording_id)
end

#list(options = nil) ⇒ Object

Parameters:

  • options (Hash) (defaults to: nil)

Options Hash (options):

  • :subaccount (String)

    auth_id of the subaccount. Lists only those recordings of the main accounts which are tied to the specified subaccount.

  • :call_uuid (String)

    Used to filter recordings for a specific call.

  • :from_number (String)

    Used to filter recordings for a specific from_number.

  • :to_number (String)

    Used to filter recordings for a specific to_number.

  • :conference_name (String)

    Used to filter recordings for a specific conference_name.

  • :mpc_name (String)

    Used to filter recordings for a specific mpc_name.

  • :conference_uuid (String)

    Used to filter recordings for a specific conference_uuid.

  • :mpc_uuid (String)

    Used to filter recordings for a specific mpc_uuid.

  • :add_time (String)

    Used to filter out recordings according to the time they were added.The add_time filter is a comparative filter that can be used in the following four forms:

    • add_time__gt: gt stands for greater than. The format expected is YYYY-MM-DD HH:MM[:ss]. Eg:- To get all recordings that started after 2012-03-21 11:47, use add_time__gt=2012-03-21 11:47

    • add_time__gte: gte stands for greater than or equal. The format expected is YYYY-MM-DD HH:MM[:ss]. Eg:- To get all recordings that started after or exactly at 2012-03-21 11:47, use add_time__gte=2012-03-21 11:47

    • add_time__lt: lt stands for lesser than. The format expected is YYYY-MM-DD HH:MM[:ss]. Eg:- To get all recordings that started before 2012-03-21 11:47, use add_time__lt=2012-03-21 11:47

    • add_time__gte: lte stands for lesser than or equal. The format expected is YYYY-MM-DD HH:MM[:ss]. Eg:- To get all recordings that started before or exactly at 2012-03-21 11:47, use add_time__lte=2012-03-21 11:47

    • Note: The above filters can be combined to get recordings that started in a particular time range.

  • :recording_storage_duration (Int)
    • Used to filter out recordings according to the number of days they have been stored in the DB.The recording_storage_duration filter can be used in the following five forms:

    • recording_storage_duration: Takes an integer input and returns the recordings which are as old as that value.

    • recording_storage_duration__gt: gt stands for greater than. The format expected is an integer value. Eg:- To get all recordings that are older than 100 days, use recording_storage_duration__gt=100

    • recording_storage_duration__gte: gte stands for greater than or equal. The format expected is an integer value. Eg:- To get all recordings that are older than or equal to 100 days old, use recording_storage_duration__gte=100

    • recording_storage_duration__lt: lt stands for lesser than. The format expected is an integer value. Eg:- To get all recordings that are newer than 100 days, use recording_storage_duration__lt=100

    • recording_storage_duration__lte: lte stands for lesser than or equal. The format expected is an integer value. Eg:- To get all recordings that are newer than or equal to 100 days old, use recording_storage_duration__lte=100

    • Note: The above filters can be combined to get recordings that started in a particular time range.

  • :limit (Int)

    Used to display the number of results per page. The maximum number of results that can be fetched is 20.

  • :offset (Int)

    Denotes the number of value items by which the results should be offset. Eg:- If the result contains a 1000 values and limit is set to 10 and offset is set to 705, then values 706 through 715 are displayed in the results. This parameter is also used for pagination of the results.



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/plivo/resources/recordings.rb', line 76

def list(options = nil)
  return perform_list if options.nil?
  valid_param?(:options, options, Hash, true)

  params = {}
  params_expected = %i[
    call_uuid add_time__gt add_time__gte
    add_time__lt add_time__lte
    from_number to_number conference_uuid
    conference_name mpc_name mpc_uuid
    recording_storage_duration
    recording_storage_duration__gt recording_storage_duration__gte
    recording_storage_duration__lt recording_storage_duration__lte
  ]

  params_expected.each do |param|
    if options.key?(param) && valid_param?(param, options[param], [String, Symbol, Integer], true)
      params[param] = options[param]
    end
  end

  if options.key?(:subaccount) &&
     valid_subaccount?(options[:subaccount], true)
    params[:subaccount] = options[:subaccount]
  end

  %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