Class: Twilio::REST::Memory::V1::DataMappingList
- Inherits:
-
ListResource
- Object
- ListResource
- Twilio::REST::Memory::V1::DataMappingList
- Defined in:
- lib/twilio-ruby/rest/memory/v1/data_mapping.rb
Defined Under Namespace
Classes: CreateDataMappingInput, DataMappingCore, MappingTraitItem
Instance Method Summary collapse
-
#create(create_data_mapping_input: nil) ⇒ DataMappingInstance
Create the DataMappingInstance.
-
#create_with_metadata(create_data_mapping_input: nil) ⇒ DataMappingInstance
Create the DataMappingInstanceMetadata.
-
#each ⇒ Object
When passed a block, yields DataMappingInstance records from the API.
-
#get_page(target_url) ⇒ Page
Retrieve a single page of DataMappingInstance records from the API.
-
#initialize(version, store_id: nil) ⇒ DataMappingList
constructor
Initialize the DataMappingList.
-
#list(page_token: :unset, order_by: :unset, type: :unset, limit: nil, page_size: nil) ⇒ Array
Lists DataMappingInstance records from the API as a list.
-
#list_with_metadata(page_token: :unset, order_by: :unset, type: :unset, limit: nil, page_size: nil) ⇒ Array
Array of up to limit results.
-
#page(page_token: :unset, order_by: :unset, type: :unset, page_size: :unset) ⇒ Page
Page of DataMappingInstance.
-
#stream(page_token: :unset, order_by: :unset, type: :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, store_id: nil) ⇒ DataMappingList
Initialize the DataMappingList
160 161 162 163 164 165 166 167 168 |
# File 'lib/twilio-ruby/rest/memory/v1/data_mapping.rb', line 160 def initialize(version, store_id: nil) apiV1Version = ApiV1Version.new version.domain, version super(apiV1Version) # Path Solution @solution = { store_id: store_id } @uri = "/ControlPlane/Stores/#{@solution[:store_id]}/DataMappings" end |
Instance Method Details
#create(create_data_mapping_input: nil) ⇒ DataMappingInstance
Create the DataMappingInstance
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/twilio-ruby/rest/memory/v1/data_mapping.rb', line 173 def create(create_data_mapping_input: nil ) headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) headers['Content-Type'] = 'application/json' payload = @version.create('POST', @uri, headers: headers, data: create_data_mapping_input.to_json) DataMappingInstance.new( @version, payload, store_id: @solution[:store_id], ) end |
#create_with_metadata(create_data_mapping_input: nil) ⇒ DataMappingInstance
Create the DataMappingInstanceMetadata
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/twilio-ruby/rest/memory/v1/data_mapping.rb', line 194 def (create_data_mapping_input: nil ) headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) headers['Content-Type'] = 'application/json' response = @version.('POST', @uri, headers: headers, data: create_data_mapping_input.to_json) data_mapping_instance = DataMappingInstance.new( @version, response.body, store_id: @solution[:store_id], ) DataMappingInstanceMetadata.new( @version, data_mapping_instance, response.headers, response.status_code ) end |
#each ⇒ Object
When passed a block, yields DataMappingInstance records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.
304 305 306 307 308 309 310 311 312 313 314 315 316 |
# File 'lib/twilio-ruby/rest/memory/v1/data_mapping.rb', line 304 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 DataMappingInstance records from the API. Request is executed immediately.
347 348 349 350 351 352 353 |
# File 'lib/twilio-ruby/rest/memory/v1/data_mapping.rb', line 347 def get_page(target_url) response = @version.domain.request( 'GET', target_url ) DataMappingPage.new(@version, response, @solution) end |
#list(page_token: :unset, order_by: :unset, type: :unset, limit: nil, page_size: nil) ⇒ Array
Lists DataMappingInstance records from the API as a list.
Unlike stream(), this operation is eager and will load limit records into
memory before returning.
232 233 234 235 236 237 238 239 240 |
# File 'lib/twilio-ruby/rest/memory/v1/data_mapping.rb', line 232 def list(page_token: :unset, order_by: :unset, type: :unset, limit: nil, page_size: nil) self.stream( page_token: page_token, order_by: order_by, type: type, limit: limit, page_size: page_size ).entries end |
#list_with_metadata(page_token: :unset, order_by: :unset, type: :unset, limit: nil, page_size: nil) ⇒ Array
Returns Array of up to limit results.
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/twilio-ruby/rest/memory/v1/data_mapping.rb', line 284 def (page_token: :unset, order_by: :unset, type: :unset, limit: nil, page_size: nil) limits = @version.read_limits(limit, page_size) params = Twilio::Values.of({ 'pageToken' => page_token, 'orderBy' => order_by, 'type' => type, 'PageSize' => limits[:page_size], }); headers = Twilio::Values.of({}) response = @version.page('GET', @uri, params: params, headers: headers) DataMappingPageMetadata.new(@version, response, @solution, limits[:limit]) end |
#page(page_token: :unset, order_by: :unset, type: :unset, page_size: :unset) ⇒ Page
Returns Page of DataMappingInstance.
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
# File 'lib/twilio-ruby/rest/memory/v1/data_mapping.rb', line 326 def page(page_token: :unset, order_by: :unset, type: :unset, page_size: :unset) params = Twilio::Values.of({ 'pageToken' => page_token, 'orderBy' => order_by, 'type' => type, 'PageSize' => page_size, }) headers = Twilio::Values.of({}) response = @version.page('GET', @uri, params: params, headers: headers) DataMappingPage.new(@version, response, @solution) end |
#stream(page_token: :unset, order_by: :unset, type: :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.
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
# File 'lib/twilio-ruby/rest/memory/v1/data_mapping.rb', line 256 def stream(page_token: :unset, order_by: :unset, type: :unset, limit: nil, page_size: nil) limits = @version.read_limits(limit, page_size) page = self.page( page_token: page_token, order_by: order_by, type: type, 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
358 359 360 |
# File 'lib/twilio-ruby/rest/memory/v1/data_mapping.rb', line 358 def to_s '#<Twilio.Memory.V1.DataMappingList>' end |