Class: Twilio::REST::Preview::Wireless::SimContext::UsageInstance

Inherits:
InstanceResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/preview/wireless/sim/usage.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, sim_sid: nil) ⇒ UsageInstance

Initialize the UsageInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • account_sid (String)

    The SID of the Account that created this Usage resource.

  • sid (String)

    The SID of the Call resource to fetch.



142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/twilio-ruby/rest/preview/wireless/sim/usage.rb', line 142

def initialize(version, payload , sim_sid: nil)
    super(version)
    
    # Marshaled Properties
    @properties = { 
        'sim_sid' => payload['sim_sid'],
        'sim_unique_name' => payload['sim_unique_name'],
        'account_sid' => payload['account_sid'],
        'period' => payload['period'],
        'commands_usage' => payload['commands_usage'],
        'commands_costs' => payload['commands_costs'],
        'data_usage' => payload['data_usage'],
        'data_costs' => payload['data_costs'],
        'url' => payload['url'],
    }

    # Context
    @instance_context = nil
    @params = { 'sim_sid' => sim_sid  || @properties['sim_sid']  , }
end

Instance Method Details

#account_sidString

Returns:

  • (String)


188
189
190
# File 'lib/twilio-ruby/rest/preview/wireless/sim/usage.rb', line 188

def 
    @properties['account_sid']
end

#commands_costsHash

Returns:

  • (Hash)


206
207
208
# File 'lib/twilio-ruby/rest/preview/wireless/sim/usage.rb', line 206

def commands_costs
    @properties['commands_costs']
end

#commands_usageHash

Returns:

  • (Hash)


200
201
202
# File 'lib/twilio-ruby/rest/preview/wireless/sim/usage.rb', line 200

def commands_usage
    @properties['commands_usage']
end

#contextUsageContext

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context

Returns:



167
168
169
170
171
172
# File 'lib/twilio-ruby/rest/preview/wireless/sim/usage.rb', line 167

def context
    unless @instance_context
        @instance_context = UsageContext.new(@version , @params['sim_sid'])
    end
    @instance_context
end

#data_costsHash

Returns:

  • (Hash)


218
219
220
# File 'lib/twilio-ruby/rest/preview/wireless/sim/usage.rb', line 218

def data_costs
    @properties['data_costs']
end

#data_usageHash

Returns:

  • (Hash)


212
213
214
# File 'lib/twilio-ruby/rest/preview/wireless/sim/usage.rb', line 212

def data_usage
    @properties['data_usage']
end

#fetch(end_: :unset, start: :unset) ⇒ UsageInstance

Fetch the UsageInstance

Parameters:

  • end_ (String) (defaults to: :unset)
  • start (String) (defaults to: :unset)

Returns:



233
234
235
236
237
238
239
240
241
242
# File 'lib/twilio-ruby/rest/preview/wireless/sim/usage.rb', line 233

def fetch(
    end_: :unset, 
    start: :unset
)

    context.fetch(
        end_: end_, 
        start: start, 
    )
end

#inspectObject

Provide a detailed, user friendly representation



253
254
255
256
# File 'lib/twilio-ruby/rest/preview/wireless/sim/usage.rb', line 253

def inspect
    values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
    "<Twilio.Preview.Wireless.UsageInstance #{values}>"
end

#periodHash

Returns:

  • (Hash)


194
195
196
# File 'lib/twilio-ruby/rest/preview/wireless/sim/usage.rb', line 194

def period
    @properties['period']
end

#sim_sidString

Returns:

  • (String)


176
177
178
# File 'lib/twilio-ruby/rest/preview/wireless/sim/usage.rb', line 176

def sim_sid
    @properties['sim_sid']
end

#sim_unique_nameString

Returns:

  • (String)


182
183
184
# File 'lib/twilio-ruby/rest/preview/wireless/sim/usage.rb', line 182

def sim_unique_name
    @properties['sim_unique_name']
end

#to_sObject

Provide a user friendly representation



246
247
248
249
# File 'lib/twilio-ruby/rest/preview/wireless/sim/usage.rb', line 246

def to_s
    values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
    "<Twilio.Preview.Wireless.UsageInstance #{values}>"
end

#urlString

Returns:

  • (String)


224
225
226
# File 'lib/twilio-ruby/rest/preview/wireless/sim/usage.rb', line 224

def url
    @properties['url']
end