twilio-ruby 3.3.0 → 3.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -36,30 +36,22 @@ module Twilio
36
36
  eigenclass = class << self; self; end
37
37
  eigenclass.send :define_method, :total, &lambda {response['total']}
38
38
  }
39
- # update the list's internal total if we just fetched the whole list
40
- @total = response['total'] if params.empty?
41
39
  resource_list
42
40
  end
43
41
 
44
42
  ##
45
- # Ask Twilio for the total number of items in the list and cache it.
43
+ # Ask Twilio for the total number of items in the list.
46
44
  # Calling this method makes an HTTP GET request to <tt>@uri</tt> with a
47
45
  # page size parameter of 1 to minimize data over the wire while still
48
- # obtaining the total. Don't use this or #total if you are planning to
46
+ # obtaining the total. Don't use this if you are planning to
49
47
  # call #list anyway, since the array returned from #list will have a
50
48
  # +total+ attribute as well.
51
- def total!
49
+ def total
52
50
  raise "Can't get a resource total without a REST Client" unless @client
53
51
  response = @client.get @uri, :page_size => 1
54
52
  @total = response['total']
55
53
  end
56
54
 
57
- ##
58
- # Return the cached total number of items in the list, or fetch and cache.
59
- def total
60
- @total ||= total!
61
- end
62
-
63
55
  ##
64
56
  # Return an empty instance resource object with the proper URI. Note that
65
57
  # this will never raise a Twilio::REST::RequestError on 404 since no HTTP
@@ -79,7 +71,8 @@ module Twilio
79
71
  def create(params = {})
80
72
  raise "Can't create a resource without a REST Client" unless @client
81
73
  response = @client.post @uri, params
82
- @instance_class.new "#{@uri}/#{response['sid']}", @client, response
74
+ @instance_class.new "#{@uri}/#{response[instance_sid_key]}", @client,
75
+ response
83
76
  end
84
77
 
85
78
  private
@@ -6,6 +6,26 @@ module Twilio
6
6
  def initialize(uri, client, params={})
7
7
  super uri, client, params
8
8
  resource :transcriptions
9
+ # grab a reference to the client's connection object for streaming
10
+ @connection = @client.instance_variable_get :@connection
11
+ end
12
+
13
+ def wav
14
+ scheme = @connection.use_ssl ? 'https' : 'http'
15
+ "#{scheme}://#{@connection.address}#{@uri}.wav"
16
+ end
17
+
18
+ def wav!(&block)
19
+ @connection.request_get @uri, &block
20
+ end
21
+
22
+ def mp3
23
+ scheme = @connection.use_ssl ? 'https' : 'http'
24
+ "#{scheme}://#{@connection.address}#{@uri}.mp3"
25
+ end
26
+
27
+ def mp3!(&block)
28
+ @connection.request_get "#{@uri}.mp3", &block
9
29
  end
10
30
  end
11
31
  end
@@ -1,3 +1,3 @@
1
1
  module Twilio
2
- VERSION = '3.3.0'
2
+ VERSION = '3.3.1'
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twilio-ruby
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
8
  - 3
9
- - 0
10
- version: 3.3.0
9
+ - 1
10
+ version: 3.3.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andrew Benton
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-08-10 00:00:00 -07:00
18
+ date: 2011-08-26 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency