class Twilio::REST::Version

Attributes

domain[RW]

Public Class Methods

new(domain) click to toggle source
   # File lib/twilio-ruby/framework/rest/version.rb
36 def initialize(domain)
37   @domain = domain
38   @version = nil
39 end

Public Instance Methods

absolute_url(uri) click to toggle source
   # File lib/twilio-ruby/framework/rest/version.rb
41 def absolute_url(uri)
42   @domain.absolute_url(relative_uri(uri))
43 end
create(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil) click to toggle source
    # File lib/twilio-ruby/framework/rest/version.rb
142 def create(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil)
143   response = request(method, uri, params, data, headers, auth, timeout)
144 
145   if response.status_code < 200 || response.status_code >= 300
146     raise exception(response, 'Unable to create record')
147   end
148 
149   response.body
150 end
delete(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil) click to toggle source
    # File lib/twilio-ruby/framework/rest/version.rb
 97 def delete(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil)
 98   response = request(
 99     method,
100     uri,
101     params,
102     data,
103     headers,
104     auth,
105     timeout
106   )
107 
108   if response.status_code < 200 || response.status_code >= 300
109     raise exception(response, 'Unable to delete record')
110   end
111 
112   response.status_code == 204
113 end
exception(response, header) click to toggle source
   # File lib/twilio-ruby/framework/rest/version.rb
56 def exception(response, header)
57   Twilio::REST::RestError.new(header, response)
58 end
fetch(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil) click to toggle source
   # File lib/twilio-ruby/framework/rest/version.rb
60 def fetch(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil)
61   response = request(
62     method,
63     uri,
64     params,
65     data,
66     headers,
67     auth,
68     timeout
69   )
70 
71   # Note that 3XX response codes are allowed for fetches.
72   if response.status_code < 200 || response.status_code >= 400
73     raise exception(response, 'Unable to fetch record')
74   end
75 
76   response.body
77 end
page(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil) click to toggle source
    # File lib/twilio-ruby/framework/rest/version.rb
126 def page(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil)
127   request(
128     method,
129     uri,
130     params,
131     data,
132     headers,
133     auth,
134     timeout
135   )
136 end
read_limits(limit = nil, page_size = nil) click to toggle source
    # File lib/twilio-ruby/framework/rest/version.rb
115 def read_limits(limit = nil, page_size = nil)
116   unless limit.nil? || page_size
117     page_size = limit
118   end
119 
120   {
121     limit: limit || nil,
122     page_size: page_size || nil
123   }
124 end
relative_uri(uri) click to toggle source
   # File lib/twilio-ruby/framework/rest/version.rb
45 def relative_uri(uri)
46   "#{@version.chomp('/').gsub(/^\//, '')}/#{uri.chomp('/').gsub(/^\//, '')}"
47 end
request(method, uri, params = {}, data = {}, headers = {}, auth = nil, timeout = nil) click to toggle source
   # File lib/twilio-ruby/framework/rest/version.rb
49 def request(method, uri, params = {}, data = {}, headers = {}, auth = nil, timeout = nil)
50   url = relative_uri(uri)
51   params = params.delete_if { |_k, v| v.nil? }
52   data = data
53   @domain.request(method, url, params, data, headers, auth, timeout)
54 end
stream(page, limit: nil, page_limit: nil) click to toggle source
    # File lib/twilio-ruby/framework/rest/version.rb
138 def stream(page, limit: nil, page_limit: nil)
139   RecordStream.new(page, limit: limit, page_limit: page_limit)
140 end
update(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil) click to toggle source
   # File lib/twilio-ruby/framework/rest/version.rb
79 def update(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil)
80   response = request(
81     method,
82     uri,
83     params,
84     data,
85     headers,
86     auth,
87     timeout
88   )
89 
90   if response.status_code < 200 || response.status_code >= 300
91     raise exception(response, 'Unable to update record')
92   end
93 
94   response.body
95 end