lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb in twilio-ruby-5.0.0.rc9 vs lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb in twilio-ruby-5.0.0.rc10

- old
+ new

@@ -14,11 +14,10 @@ ## # Initialize the TriggerList # @param [Version] version Version that contains the resource # @param [String] account_sid A 34 character string that uniquely identifies this # resource. - # @return [TriggerList] TriggerList def initialize(version, account_sid: nil) super(version) # Path Solution @@ -45,11 +44,10 @@ # non-recurring triggers. One of `daily`, `monthly`, or `yearly` for recurring # triggers. A trigger will only fire once during each recurring period. # Recurring periods are in GMT. # @param [trigger.TriggerField] trigger_by The field in the UsageRecord that fires # the trigger. One of `count`, `usage`, or `price` - # @return [TriggerInstance] Newly created TriggerInstance def create(callback_url: nil, trigger_value: nil, usage_category: nil, callback_method: nil, friendly_name: nil, recurring: nil, trigger_by: nil) data = { 'CallbackUrl' => callback_url, 'TriggerValue' => trigger_value, @@ -67,11 +65,11 @@ ) return TriggerInstance.new( @version, payload, - account_sid: @solution['account_sid'], + account_sid: @solution[:account_sid], ) end ## # Lists TriggerInstance records from the API as a list. @@ -87,11 +85,10 @@ # guarantees to never return more than limit. Default is no limit # @param [Integer] page_size Number of records to fetch per request, when not set will use # the default value of 50 records. If no page_size is defined # but a limit is defined, stream() will attempt to read the # limit with the most efficient page size, i.e. min(limit, 1000) - # @return [Array] Array of up to limit results def list(recurring: nil, trigger_by: nil, usage_category: nil, limit: nil, page_size: nil) self.stream( recurring: recurring, trigger_by: trigger_by, @@ -115,11 +112,10 @@ # guarantees to never return more than limit. Default is no limit # @param [Integer] page_size Number of records to fetch per request, when not set will use # the default value of 50 records. If no page_size is defined # but a limit is defined, stream() will attempt to read the # limit with the most efficient page size, i.e. min(limit, 1000) - # @return [Enumerable] Enumerable that will yield up to limit results def stream(recurring: nil, trigger_by: nil, usage_category: nil, limit: nil, page_size: nil) limits = @version.read_limits(limit, page_size) page = self.page( @@ -170,11 +166,10 @@ # @param [trigger.UsageCategory] usage_category Only show UsageTriggers that watch # this usage category # @param [String] page_token PageToken provided by the API # @param [Integer] page_number Page Number, this value is simply for client state # @param [Integer] page_size Number of records to return, defaults to 50 - # @return [Page] Page of TriggerInstance def page(recurring: nil, trigger_by: nil, usage_category: nil, page_token: nil, page_number: nil, page_size: nil) params = { 'Recurring' => recurring, 'TriggerBy' => trigger_by, @@ -204,11 +199,10 @@ # @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] account_sid A 34 character string that uniquely identifies this # resource. - # @return [TriggerPage] TriggerPage def initialize(version, response, solution) super(version, response) # Path Solution @@ -216,17 +210,16 @@ end ## # Build an instance of TriggerInstance # @param [Hash] payload Payload response from the API - # @return [TriggerInstance] TriggerInstance def get_instance(payload) return TriggerInstance.new( @version, payload, - account_sid: @solution['account_sid'], + account_sid: @solution[:account_sid], ) end ## # Provide a user friendly representation @@ -239,11 +232,10 @@ ## # Initialize the TriggerContext # @param [Version] version Version that contains the resource # @param [String] account_sid The account_sid # @param [String] sid The usage-trigger Sid that uniquely identifies this resource - # @return [TriggerContext] TriggerContext def initialize(version, account_sid, sid) super(version) # Path Solution @@ -267,12 +259,12 @@ ) return TriggerInstance.new( @version, payload, - account_sid: @solution['account_sid'], - sid: @solution['sid'], + account_sid: @solution[:account_sid], + sid: @solution[:sid], ) end ## # Update the TriggerInstance @@ -280,11 +272,10 @@ # request to the CallbackUrl. GET or POST. # @param [String] callback_url Twilio will make a request to this url when the # trigger fires. # @param [String] friendly_name A user-specified, human-readable name for the # trigger. - # @return [TriggerInstance] Updated TriggerInstance def update(callback_method: nil, callback_url: nil, friendly_name: nil) data = { 'CallbackMethod' => callback_method, 'CallbackUrl' => callback_url, @@ -298,12 +289,12 @@ ) return TriggerInstance.new( @version, payload, - account_sid: @solution['account_sid'], - sid: @solution['sid'], + account_sid: @solution[:account_sid], + sid: @solution[:sid], ) end ## # Deletes the TriggerInstance @@ -326,11 +317,10 @@ # @param [Version] version Version that contains the resource # @param [Hash] payload payload that contains response from Twilio # @param [String] account_sid A 34 character string that uniquely identifies this # resource. # @param [String] sid The usage-trigger Sid that uniquely identifies this resource - # @return [TriggerInstance] TriggerInstance def initialize(version, payload, account_sid: nil, sid: nil) super(version) # Marshaled Properties @@ -363,11 +353,10 @@ ## # 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 [TriggerContext] TriggerContext for this TriggerInstance def context unless @instance_context @instance_context = TriggerContext.new( @version, @@ -444,41 +433,41 @@ ## # Fetch a TriggerInstance # @return [TriggerInstance] Fetched TriggerInstance def fetch - @context.fetch() + context.fetch end ## # Update the TriggerInstance # @param [String] callback_method The HTTP method Twilio will use when making a # request to the CallbackUrl. GET or POST. # @param [String] callback_url Twilio will make a request to this url when the # trigger fires. # @param [String] friendly_name A user-specified, human-readable name for the # trigger. - # @return [TriggerInstance] Updated TriggerInstance def update(callback_method: nil, callback_url: nil, friendly_name: nil) - @context.update( + context.update( + callback_method: callback_method, callback_url: callback_url, friendly_name: friendly_name, ) end ## # Deletes the TriggerInstance # @return [Boolean] true if delete succeeds, true otherwise def delete - @context.delete() + context.delete end ## # Provide a user friendly representation def to_s - context = @params.map{|k, v| "#{k}: #{v}"}.join(" ") - "<Twilio.Api.V2010.TriggerInstance #{context}>" + values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") + "<Twilio.Api.V2010.TriggerInstance #{values}>" end end end end end \ No newline at end of file