## # This code was generated by # \ / _ _ _| _ _ # | (_)\/(_)(_|\/| |(/_ v1.0.0 # / / module Twilio module REST class Preview < Domain class Wireless < Version class DeviceContext < InstanceContext class UsageList < ListResource ## # Initialize the UsageList # @param [Version] version Version that contains the resource # @param [String] device_sid The device_sid # @return [UsageList] UsageList def initialize(version, device_sid: nil) super(version) # Path Solution @solution = { device_sid: device_sid } end ## # Provide a user friendly representation def to_s '#' end end class UsagePage < Page ## # Initialize the UsagePage # @param [Version] version Version that contains the resource # @param [Response] response Response from the API # @param [Hash] solution Path solution for the resource # @param [String] device_sid The device_sid # @return [UsagePage] UsagePage def initialize(version, response, solution) super(version, response) # Path Solution @solution = solution end ## # Build an instance of UsageInstance # @param [Hash] payload Payload response from the API # @return [UsageInstance] UsageInstance def get_instance(payload) return UsageInstance.new( @version, payload, device_sid: @solution['device_sid'], ) end ## # Provide a user friendly representation def to_s '' end end class UsageContext < InstanceContext ## # Initialize the UsageContext # @param [Version] version Version that contains the resource # @param [String] device_sid The device_sid # @return [UsageContext] UsageContext def initialize(version, device_sid) super(version) # Path Solution @solution = { device_sid: device_sid, } @uri = "/Devices/#{@solution[:device_sid]}/Usage" end ## # Fetch a UsageInstance # @param [String] end_ The end # @param [String] start The start # @return [UsageInstance] Fetched UsageInstance def fetch(end_: nil, start: nil) params = { 'End' => end_, 'Start' => start, } payload = @version.fetch( 'GET', @uri, params, ) return UsageInstance.new( @version, payload, device_sid: @solution['device_sid'], ) end ## # Provide a user friendly representation def to_s context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') "#" end end class UsageInstance < InstanceResource ## # Initialize the UsageInstance # @param [Version] version Version that contains the resource # @param [Hash] payload payload that contains response from Twilio # @param [String] device_sid The device_sid # @return [UsageInstance] UsageInstance def initialize(version, payload, device_sid: nil) super(version) # Marshaled Properties @properties = { 'device_sid' => payload['device_sid'], 'device_alias' => payload['device_alias'], '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 = { 'device_sid' => device_sid, } end ## # Generate an instance context for the instance, the context is capable of # performing various actions. All instance actions are proxied to the context # @param [Version] version Version that contains the resource # @return [UsageContext] UsageContext for this UsageInstance def context unless @instance_context @instance_context = UsageContext.new( @version, @params['device_sid'], ) end @instance_context end def device_sid @properties['device_sid'] end def device_alias @properties['device_alias'] end def account_sid @properties['account_sid'] end def period @properties['period'] end def commands_usage @properties['commands_usage'] end def commands_costs @properties['commands_costs'] end def data_usage @properties['data_usage'] end def data_costs @properties['data_costs'] end def url @properties['url'] end ## # Fetch a UsageInstance # @param [String] end_ The end # @param [String] start The start # @return [UsageInstance] Fetched UsageInstance def fetch(end_: nil, start: nil) @context.fetch( start: start, ) end ## # Provide a user friendly representation def to_s context = @params.map{|k, v| "#{k}: #{v}"}.join(" ") "" end end end end end end end