Class: Twilio::REST::Webhooks::V1::SharedKeyList
- Inherits:
-
ListResource
- Object
- ListResource
- Twilio::REST::Webhooks::V1::SharedKeyList
- Defined in:
- lib/twilio-ruby/rest/webhooks/v1/shared_key.rb
Defined Under Namespace
Classes: PatchSharedKey, PostSharedKey
Instance Method Summary collapse
-
#create(idempotency_key: :unset, post_shared_key: nil) ⇒ SharedKeyInstance
Create the SharedKeyInstance.
-
#create_with_metadata(idempotency_key: :unset, post_shared_key: nil) ⇒ SharedKeyInstance
Create the SharedKeyInstanceMetadata.
-
#each ⇒ Object
When passed a block, yields SharedKeyInstance records from the API.
-
#get_page(target_url) ⇒ Page
Retrieve a single page of SharedKeyInstance records from the API.
-
#initialize(version) ⇒ SharedKeyList
constructor
Initialize the SharedKeyList.
-
#list(page_token: :unset, limit: nil, page_size: nil) ⇒ Array
Lists SharedKeyInstance records from the API as a list.
-
#list_with_metadata(page_token: :unset, limit: nil, page_size: nil) ⇒ Array
Array of up to limit results.
-
#page(page_token: :unset, page_size: :unset) ⇒ Page
Page of SharedKeyInstance.
-
#stream(page_token: :unset, limit: nil, page_size: nil) ⇒ Enumerable
Streams Instance records from the API as an Enumerable.
-
#to_s ⇒ Object
Provide a user friendly representation.
Constructor Details
#initialize(version) ⇒ SharedKeyList
Initialize the SharedKeyList
80 81 82 83 84 85 86 87 88 |
# File 'lib/twilio-ruby/rest/webhooks/v1/shared_key.rb', line 80 def initialize(version) apiV1Version = ApiV1Version.new version.domain, version super(apiV1Version) # Path Solution @solution = { } @uri = "/Webhooks/SharedKeys" end |
Instance Method Details
#create(idempotency_key: :unset, post_shared_key: nil) ⇒ SharedKeyInstance
Create the SharedKeyInstance
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/twilio-ruby/rest/webhooks/v1/shared_key.rb', line 94 def create( idempotency_key: :unset, post_shared_key: nil ) headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Idempotency-Key' => idempotency_key, }) headers['Content-Type'] = 'application/json' headers['Accept'] = '*/*' payload = @version.create('POST', @uri, headers: headers, data: post_shared_key.to_json) SharedKeyInstance.new( @version, payload, ) end |
#create_with_metadata(idempotency_key: :unset, post_shared_key: nil) ⇒ SharedKeyInstance
Create the SharedKeyInstanceMetadata
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/twilio-ruby/rest/webhooks/v1/shared_key.rb', line 117 def ( idempotency_key: :unset, post_shared_key: nil ) headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Idempotency-Key' => idempotency_key, }) headers['Content-Type'] = 'application/json' headers['Accept'] = '*/*' response = @version.('POST', @uri, headers: headers, data: post_shared_key.to_json) shared_key_instance = SharedKeyInstance.new( @version, response.body, ) SharedKeyInstanceMetadata.new( @version, shared_key_instance, response.headers, response.status_code ) end |
#each ⇒ Object
When passed a block, yields SharedKeyInstance records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.
216 217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/twilio-ruby/rest/webhooks/v1/shared_key.rb', line 216 def each limits = @version.read_limits page = self.page(page_size: limits[:page_size], ) return [].each if page.nil? result = @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) return [].each if result.nil? result.each {|x| yield x} end |
#get_page(target_url) ⇒ Page
Retrieve a single page of SharedKeyInstance records from the API. Request is executed immediately.
255 256 257 258 259 260 261 |
# File 'lib/twilio-ruby/rest/webhooks/v1/shared_key.rb', line 255 def get_page(target_url) response = @version.domain.request( 'GET', target_url ) SharedKeyPage.new(@version, response, @solution) end |
#list(page_token: :unset, limit: nil, page_size: nil) ⇒ Array
Lists SharedKeyInstance records from the API as a list.
Unlike stream(), this operation is eager and will load limit records into
memory before returning.
154 155 156 157 158 159 160 |
# File 'lib/twilio-ruby/rest/webhooks/v1/shared_key.rb', line 154 def list(page_token: :unset, limit: nil, page_size: nil) self.stream( page_token: page_token, limit: limit, page_size: page_size ).entries end |
#list_with_metadata(page_token: :unset, limit: nil, page_size: nil) ⇒ Array
Returns Array of up to limit results.
198 199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/twilio-ruby/rest/webhooks/v1/shared_key.rb', line 198 def (page_token: :unset, limit: nil, page_size: nil) limits = @version.read_limits(limit, page_size) params = Twilio::Values.of({ 'pageToken' => page_token, 'PageSize' => limits[:page_size], }); headers = Twilio::Values.of({}) response = @version.page('GET', @uri, params: params, headers: headers) SharedKeyPageMetadata.new(@version, response, @solution, limits[:limit]) end |
#page(page_token: :unset, page_size: :unset) ⇒ Page
Returns Page of SharedKeyInstance.
236 237 238 239 240 241 242 243 244 245 246 247 248 |
# File 'lib/twilio-ruby/rest/webhooks/v1/shared_key.rb', line 236 def page(page_token: :unset, page_size: :unset) params = Twilio::Values.of({ 'pageToken' => page_token, 'PageSize' => page_size, }) headers = Twilio::Values.of({}) response = @version.page('GET', @uri, params: params, headers: headers) SharedKeyPage.new(@version, response, @solution) end |
#stream(page_token: :unset, limit: nil, page_size: nil) ⇒ Enumerable
Streams Instance records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached.
174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/twilio-ruby/rest/webhooks/v1/shared_key.rb', line 174 def stream(page_token: :unset, limit: nil, page_size: nil) limits = @version.read_limits(limit, page_size) page = self.page( page_token: page_token, page_size: limits[:page_size], ) return [].each if page.nil? result = @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) return [].each if result.nil? result end |
#to_s ⇒ Object
Provide a user friendly representation
266 267 268 |
# File 'lib/twilio-ruby/rest/webhooks/v1/shared_key.rb', line 266 def to_s '#<Twilio.Webhooks.V1.SharedKeyList>' end |