Class: TwilioRubyWrapper::Call
- Inherits:
-
Object
- Object
- TwilioRubyWrapper::Call
- Defined in:
- lib/twilio_ruby_wrapper/call.rb
Instance Attribute Summary collapse
-
#calls ⇒ Object
Returns the value of attribute calls.
-
#page_number ⇒ Object
Returns the value of attribute page_number.
-
#page_size ⇒ Object
Returns the value of attribute page_size.
Instance Method Summary collapse
- #condition(value, filter: { page: @page_number, page_size: @page_size }) ⇒ Object
- #filter(*args) ⇒ Object
- #find_by(*args) ⇒ Object
-
#initialize(account_sid:, auth_token:) ⇒ Call
constructor
A new instance of Call.
Constructor Details
#initialize(account_sid:, auth_token:) ⇒ Call
Returns a new instance of Call.
5 6 7 8 9 10 11 |
# File 'lib/twilio_ruby_wrapper/call.rb', line 5 def initialize(account_sid:, auth_token:) client = Twilio::REST::Client.new(account_sid, auth_token) @calls = client.account.calls @filter = {} @page_number = 0 @page_size = 50 end |
Instance Attribute Details
#calls ⇒ Object
Returns the value of attribute calls.
3 4 5 |
# File 'lib/twilio_ruby_wrapper/call.rb', line 3 def calls @calls end |
#page_number ⇒ Object
Returns the value of attribute page_number.
3 4 5 |
# File 'lib/twilio_ruby_wrapper/call.rb', line 3 def page_number @page_number end |
#page_size ⇒ Object
Returns the value of attribute page_size.
3 4 5 |
# File 'lib/twilio_ruby_wrapper/call.rb', line 3 def page_size @page_size end |
Instance Method Details
#condition(value, filter: { page: @page_number, page_size: @page_size }) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/twilio_ruby_wrapper/call.rb', line 30 def condition(value, filter: { page: @page_number, page_size: @page_size }) if !(Symbol === value) raise end condition = nil case value when :eq condition = -> (x) { -> (y) { y == x }} when :lt condition = -> (x) { -> (y) { y < x }} when :lteq condition = -> (x) { -> (y) { y <= x }} when :gt condition = -> (x) { -> (y) { y > x }} when :gteq condition = -> (x) { -> (y) { y >= x }} else raise end filter = @filter unless @filter.empty? CallCondition.new(calls: @calls, condition: condition, filter: filter) end |
#filter(*args) ⇒ Object
24 25 26 27 28 |
# File 'lib/twilio_ruby_wrapper/call.rb', line 24 def filter(*args) hash = args.first @filter = hash self end |
#find_by(*args) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/twilio_ruby_wrapper/call.rb', line 13 def find_by(*args) hash = args.first if !(Hash === hash) || hash.values.any? {|v| v.nil? || Array === v || Hash === v } || hash.size >= 2 raise end condition = self.condition(:eq) condition.find_by(*args) end |