Class: Twilio::REST::Memory::V1::IdentifierList
- Inherits:
-
ListResource
- Object
- ListResource
- Twilio::REST::Memory::V1::IdentifierList
- Defined in:
- lib/twilio-ruby/rest/memory/v1/identifier.rb
Defined Under Namespace
Classes: Identifier, IdentifierUpdate
Instance Method Summary collapse
-
#create(identifier: nil) ⇒ IdentifierInstance
Create the IdentifierInstance.
-
#create_with_metadata(identifier: nil) ⇒ IdentifierInstance
Create the IdentifierInstanceMetadata.
-
#each ⇒ Object
When passed a block, yields IdentifierInstance records from the API.
-
#get_page(target_url) ⇒ Page
Retrieve a single page of IdentifierInstance records from the API.
-
#initialize(version, store_id: nil, profile_id: nil) ⇒ IdentifierList
constructor
Initialize the IdentifierList.
-
#list(limit: nil, page_size: nil) ⇒ Array
Lists IdentifierInstance records from the API as a list.
-
#page(page_size: :unset) ⇒ Page
Page of IdentifierInstance.
-
#stream(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) ⇒ IdentifierList
Initialize the IdentifierList
98 99 100 101 102 103 104 105 106 |
# File 'lib/twilio-ruby/rest/memory/v1/identifier.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]}/Identifiers" end |
Instance Method Details
#create(identifier: nil) ⇒ IdentifierInstance
Create the IdentifierInstance
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/twilio-ruby/rest/memory/v1/identifier.rb', line 111 def create(identifier: 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: identifier.to_json) IdentifierInstance.new( @version, payload, store_id: @solution[:store_id], profile_id: @solution[:profile_id], ) end |
#create_with_metadata(identifier: nil) ⇒ IdentifierInstance
Create the IdentifierInstanceMetadata
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/twilio-ruby/rest/memory/v1/identifier.rb', line 133 def (identifier: nil ) headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) headers['Content-Type'] = 'application/json' response = @version.('POST', @uri, headers: headers, data: identifier.to_json) identifier_instance = IdentifierInstance.new( @version, response.body, store_id: @solution[:store_id], profile_id: @solution[:profile_id], ) IdentifierInstanceMetadata.new( @version, identifier_instance, response.headers, response.status_code ) end |
#each ⇒ Object
When passed a block, yields IdentifierInstance records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.
205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/twilio-ruby/rest/memory/v1/identifier.rb', line 205 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 IdentifierInstance records from the API. Request is executed immediately.
242 243 244 245 246 247 248 |
# File 'lib/twilio-ruby/rest/memory/v1/identifier.rb', line 242 def get_page(target_url) response = @version.domain.request( 'GET', target_url ) IdentifierPage.new(@version, response, @solution) end |
#list(limit: nil, page_size: nil) ⇒ Array
Lists IdentifierInstance records from the API as a list.
Unlike stream(), this operation is eager and will load limit records into
memory before returning.
169 170 171 172 173 174 |
# File 'lib/twilio-ruby/rest/memory/v1/identifier.rb', line 169 def list(limit: nil, page_size: nil) self.stream( limit: limit, page_size: page_size ).entries end |
#page(page_size: :unset) ⇒ Page
Returns Page of IdentifierInstance.
224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/twilio-ruby/rest/memory/v1/identifier.rb', line 224 def page(page_size: :unset) params = Twilio::Values.of({ 'PageSize' => page_size, }) headers = Twilio::Values.of({}) response = @version.page('GET', @uri, params: params, headers: headers) IdentifierPage.new(@version, response, @solution) end |
#stream(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.
187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/twilio-ruby/rest/memory/v1/identifier.rb', line 187 def stream(limit: nil, page_size: nil) limits = @version.read_limits(limit, page_size) 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 end |
#to_s ⇒ Object
Provide a user friendly representation
253 254 255 |
# File 'lib/twilio-ruby/rest/memory/v1/identifier.rb', line 253 def to_s '#<Twilio.Memory.V1.IdentifierList>' end |