Class: Twilio::REST::Version
- Inherits:
-
Object
- Object
- Twilio::REST::Version
show all
- Defined in:
- lib/twilio-ruby/framework/rest/version.rb
Direct Known Subclasses
Accounts::V1, Api::V2010, Assistants::V1, Bulkexports::V1, Chat::V1, Chat::V2, Chat::V3, Content::V1, Content::V2, Conversations::V1, Events::V1, FlexApi::V1, FlexApi::V2, FrontlineApi::V1, Iam::V1, Insights::V1, Intelligence::V2, IpMessaging::V1, IpMessaging::V2, Lookups::V1, Lookups::V2, Marketplace::V1, Messaging::V1, Microvisor::V1, Monitor::V1, Notify::V1, Numbers::V1, Numbers::V2, Oauth::V1, Preview::HostedNumbers, Preview::Marketplace, Preview::Sync, Preview::Wireless, PreviewIam::V1, PreviewIam::Versionless, Pricing::V1, Pricing::V2, Proxy::V1, Routes::V2, Serverless::V1, Studio::V1, Studio::V2, Supersim::V1, Sync::V1, Taskrouter::V1, Trunking::V1, Trusthub::V1, Twilio::REST::Verify::V2, Twilio::REST::Video::V1, Twilio::REST::Voice::V1, Wireless::V1
Defined Under Namespace
Classes: RecordStream
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#absolute_url(uri) ⇒ Object
-
#create(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil) ⇒ Object
-
#delete(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil) ⇒ Object
-
#exception(response, header) ⇒ Object
-
#fetch(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil) ⇒ Object
-
#initialize(domain) ⇒ Version
constructor
A new instance of Version.
-
#page(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil) ⇒ Object
-
#read_limits(limit = nil, page_size = nil) ⇒ Object
-
#relative_uri(uri) ⇒ Object
-
#request(method, uri, params = {}, data = {}, headers = {}, auth = nil, timeout = nil) ⇒ Object
-
#stream(page, limit: nil, page_limit: nil) ⇒ Object
-
#update(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil) ⇒ Object
Constructor Details
#initialize(domain) ⇒ Version
Returns a new instance of Version.
36
37
38
39
|
# File 'lib/twilio-ruby/framework/rest/version.rb', line 36
def initialize(domain)
@domain = domain
@version = nil
end
|
Instance Attribute Details
#domain ⇒ Object
Returns the value of attribute domain.
6
7
8
|
# File 'lib/twilio-ruby/framework/rest/version.rb', line 6
def domain
@domain
end
|
Instance Method Details
#absolute_url(uri) ⇒ Object
41
42
43
|
# File 'lib/twilio-ruby/framework/rest/version.rb', line 41
def absolute_url(uri)
@domain.absolute_url(relative_uri(uri))
end
|
#create(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil) ⇒ Object
142
143
144
145
146
147
148
149
150
|
# File 'lib/twilio-ruby/framework/rest/version.rb', line 142
def create(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil)
response = request(method, uri, params, data, , auth, timeout)
if response.status_code < 200 || response.status_code >= 300
raise exception(response, 'Unable to create record')
end
response.body
end
|
#delete(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil) ⇒ Object
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/twilio-ruby/framework/rest/version.rb', line 97
def delete(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil)
response = request(
method,
uri,
params,
data,
,
auth,
timeout
)
if response.status_code < 200 || response.status_code >= 300
raise exception(response, 'Unable to delete record')
end
response.status_code == 204
end
|
#exception(response, header) ⇒ Object
56
57
58
|
# File 'lib/twilio-ruby/framework/rest/version.rb', line 56
def exception(response, )
Twilio::REST::RestError.new(, response)
end
|
#fetch(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil) ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/twilio-ruby/framework/rest/version.rb', line 60
def fetch(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil)
response = request(
method,
uri,
params,
data,
,
auth,
timeout
)
if response.status_code < 200 || response.status_code >= 400
raise exception(response, 'Unable to fetch record')
end
response.body
end
|
#page(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil) ⇒ Object
126
127
128
129
130
131
132
133
134
135
136
|
# File 'lib/twilio-ruby/framework/rest/version.rb', line 126
def page(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil)
request(
method,
uri,
params,
data,
,
auth,
timeout
)
end
|
#read_limits(limit = nil, page_size = nil) ⇒ Object
115
116
117
118
119
120
121
122
123
124
|
# File 'lib/twilio-ruby/framework/rest/version.rb', line 115
def read_limits(limit = nil, page_size = nil)
unless limit.nil? || page_size
page_size = limit
end
{
limit: limit || nil,
page_size: page_size || nil
}
end
|
#relative_uri(uri) ⇒ Object
45
46
47
|
# File 'lib/twilio-ruby/framework/rest/version.rb', line 45
def relative_uri(uri)
"#{@version.chomp('/').gsub(/^\//, '')}/#{uri.chomp('/').gsub(/^\//, '')}"
end
|
#request(method, uri, params = {}, data = {}, headers = {}, auth = nil, timeout = nil) ⇒ Object
49
50
51
52
53
54
|
# File 'lib/twilio-ruby/framework/rest/version.rb', line 49
def request(method, uri, params = {}, data = {}, = {}, auth = nil, timeout = nil)
url = relative_uri(uri)
params = params.delete_if { |_k, v| v.nil? }
data = data
@domain.request(method, url, params, data, , auth, timeout)
end
|
#stream(page, limit: nil, page_limit: nil) ⇒ Object
138
139
140
|
# File 'lib/twilio-ruby/framework/rest/version.rb', line 138
def stream(page, limit: nil, page_limit: nil)
RecordStream.new(page, limit: limit, page_limit: page_limit)
end
|
#update(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil) ⇒ Object
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/twilio-ruby/framework/rest/version.rb', line 79
def update(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil)
response = request(
method,
uri,
params,
data,
,
auth,
timeout
)
if response.status_code < 200 || response.status_code >= 300
raise exception(response, 'Unable to update record')
end
response.body
end
|