Class: Twilio::REST::Memory::V1::ObservationList
- Inherits:
-
ListResource
- Object
- ListResource
- Twilio::REST::Memory::V1::ObservationList
- Defined in:
- lib/twilio-ruby/rest/memory/v1/observation.rb
Defined Under Namespace
Classes: CreateObservationsRequest, ObservationCore
Instance Method Summary collapse
-
#create(accept_encoding: :unset, content_encoding: :unset, create_observations_request: nil) ⇒ ObservationInstance
Create the ObservationInstance.
-
#create_with_metadata(accept_encoding: :unset, content_encoding: :unset, create_observations_request: nil) ⇒ ObservationInstance
Create the ObservationInstanceMetadata.
-
#each ⇒ Object
When passed a block, yields ObservationInstance records from the API.
-
#get_page(target_url) ⇒ Page
Retrieve a single page of ObservationInstance records from the API.
-
#initialize(version, store_id: nil, profile_id: nil) ⇒ ObservationList
constructor
Initialize the ObservationList.
-
#list(page_token: :unset, order_by: :unset, source: :unset, created_after: :unset, created_before: :unset, accept_encoding: :unset, limit: nil, page_size: nil) ⇒ Array
Lists ObservationInstance records from the API as a list.
-
#list_with_metadata(page_token: :unset, order_by: :unset, source: :unset, created_after: :unset, created_before: :unset, accept_encoding: :unset, limit: nil, page_size: nil) ⇒ Array
Array of up to limit results.
-
#page(page_token: :unset, order_by: :unset, source: :unset, created_after: :unset, created_before: :unset, accept_encoding: :unset, page_size: :unset) ⇒ Page
Page of ObservationInstance.
-
#stream(page_token: :unset, order_by: :unset, source: :unset, created_after: :unset, created_before: :unset, accept_encoding: :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, profile_id: nil) ⇒ ObservationList
Initialize the ObservationList
98 99 100 101 102 103 104 105 106 |
# File 'lib/twilio-ruby/rest/memory/v1/observation.rb', line 98 def initialize(version, store_id: nil, profile_id: nil) apiV1Version = ApiV1Version.new version.domain, version super(apiV1Version) # Path Solution @solution = { store_id: store_id, profile_id: profile_id } @uri = "/Stores/#{@solution[:store_id]}/Profiles/#{@solution[:profile_id]}/Observations" end |
Instance Method Details
#create(accept_encoding: :unset, content_encoding: :unset, create_observations_request: nil) ⇒ ObservationInstance
Create the ObservationInstance
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/twilio-ruby/rest/memory/v1/observation.rb', line 113 def create( accept_encoding: :unset, content_encoding: :unset, create_observations_request: nil ) headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Accept-Encoding' => accept_encoding, 'Content-Encoding' => content_encoding, }) headers['Content-Type'] = 'application/json' payload = @version.create('POST', @uri, headers: headers, data: create_observations_request.to_json) ObservationInstance.new( @version, payload, store_id: @solution[:store_id], profile_id: @solution[:profile_id], ) end |
#create_with_metadata(accept_encoding: :unset, content_encoding: :unset, create_observations_request: nil) ⇒ ObservationInstance
Create the ObservationInstanceMetadata
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/twilio-ruby/rest/memory/v1/observation.rb', line 140 def ( accept_encoding: :unset, content_encoding: :unset, create_observations_request: nil ) headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Accept-Encoding' => accept_encoding, 'Content-Encoding' => content_encoding, }) headers['Content-Type'] = 'application/json' response = @version.('POST', @uri, headers: headers, data: create_observations_request.to_json) observation_instance = ObservationInstance.new( @version, response.body, store_id: @solution[:store_id], profile_id: @solution[:profile_id], ) ObservationInstanceMetadata.new( @version, observation_instance, response.headers, response.status_code ) end |
#each ⇒ Object
When passed a block, yields ObservationInstance records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.
272 273 274 275 276 277 278 279 280 281 282 283 284 |
# File 'lib/twilio-ruby/rest/memory/v1/observation.rb', line 272 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 ObservationInstance records from the API. Request is executed immediately.
321 322 323 324 325 326 327 |
# File 'lib/twilio-ruby/rest/memory/v1/observation.rb', line 321 def get_page(target_url) response = @version.domain.request( 'GET', target_url ) ObservationPage.new(@version, response, @solution) end |
#list(page_token: :unset, order_by: :unset, source: :unset, created_after: :unset, created_before: :unset, accept_encoding: :unset, limit: nil, page_size: nil) ⇒ Array
Lists ObservationInstance records from the API as a list. Unlike stream(), this operation is eager and will load ‘limit` records into memory before returning.
185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/twilio-ruby/rest/memory/v1/observation.rb', line 185 def list(page_token: :unset, order_by: :unset, source: :unset, created_after: :unset, created_before: :unset, accept_encoding: :unset, limit: nil, page_size: nil) self.stream( page_token: page_token, order_by: order_by, source: source, created_after: created_after, created_before: created_before, accept_encoding: accept_encoding, limit: limit, page_size: page_size ).entries end |
#list_with_metadata(page_token: :unset, order_by: :unset, source: :unset, created_after: :unset, created_before: :unset, accept_encoding: :unset, limit: nil, page_size: nil) ⇒ Array
Returns Array of up to limit results.
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
# File 'lib/twilio-ruby/rest/memory/v1/observation.rb', line 249 def (page_token: :unset, order_by: :unset, source: :unset, created_after: :unset, created_before: :unset, accept_encoding: :unset, limit: nil, page_size: nil) limits = @version.read_limits(limit, page_size) params = Twilio::Values.of({ 'pageToken' => page_token, 'orderBy' => order_by, 'source' => source, 'createdAfter' => Twilio.serialize_iso8601_datetime(created_after), 'createdBefore' => Twilio.serialize_iso8601_datetime(created_before), 'Accept-Encoding' => accept_encoding, 'PageSize' => limits[:page_size], }); headers = Twilio::Values.of({}) response = @version.page('GET', @uri, params: params, headers: headers) ObservationPageMetadata.new(@version, response, @solution, limits[:limit]) end |
#page(page_token: :unset, order_by: :unset, source: :unset, created_after: :unset, created_before: :unset, accept_encoding: :unset, page_size: :unset) ⇒ Page
Returns Page of ObservationInstance.
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
# File 'lib/twilio-ruby/rest/memory/v1/observation.rb', line 297 def page(page_token: :unset, order_by: :unset, source: :unset, created_after: :unset, created_before: :unset, accept_encoding: :unset, page_size: :unset) params = Twilio::Values.of({ 'pageToken' => page_token, 'orderBy' => order_by, 'source' => source, 'createdAfter' => Twilio.serialize_iso8601_datetime(created_after), 'createdBefore' => Twilio.serialize_iso8601_datetime(created_before), 'Accept-Encoding' => accept_encoding, 'PageSize' => page_size, }) headers = Twilio::Values.of({}) response = @version.page('GET', @uri, params: params, headers: headers) ObservationPage.new(@version, response, @solution) end |
#stream(page_token: :unset, order_by: :unset, source: :unset, created_after: :unset, created_before: :unset, accept_encoding: :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.
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
# File 'lib/twilio-ruby/rest/memory/v1/observation.rb', line 215 def stream(page_token: :unset, order_by: :unset, source: :unset, created_after: :unset, created_before: :unset, accept_encoding: :unset, limit: nil, page_size: nil) limits = @version.read_limits(limit, page_size) page = self.page( page_token: page_token, order_by: order_by, source: source, created_after: created_after, created_before: created_before, accept_encoding: accept_encoding, 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
332 333 334 |
# File 'lib/twilio-ruby/rest/memory/v1/observation.rb', line 332 def to_s '#<Twilio.Memory.V1.ObservationList>' end |