Class: DaFace::Api::PushSubscription
- Inherits:
-
Object
- Object
- DaFace::Api::PushSubscription
- Includes:
- Utilities
- Defined in:
- lib/da_face/api/push_subscription.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#end ⇒ Object
Returns the value of attribute end.
-
#hash ⇒ Object
Returns the value of attribute hash.
-
#hash_type ⇒ Object
readonly
Returns the value of attribute hash_type.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#initial_status ⇒ Object
Returns the value of attribute initial_status.
-
#last_request ⇒ Object
readonly
Returns the value of attribute last_request.
-
#last_success ⇒ Object
readonly
Returns the value of attribute last_success.
-
#lost_data ⇒ Object
readonly
Returns the value of attribute lost_data.
-
#name ⇒ Object
Returns the value of attribute name.
-
#output_params ⇒ Object
Returns the value of attribute output_params.
-
#output_type ⇒ Object
Returns the value of attribute output_type.
-
#playback_id ⇒ Object
Returns the value of attribute playback_id.
-
#remaining_bytes ⇒ Object
readonly
Returns the value of attribute remaining_bytes.
-
#start ⇒ Object
Returns the value of attribute start.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
Class Method Summary collapse
Instance Method Summary collapse
- #allowed_attributes ⇒ Object
- #assign_attributes!(data) ⇒ Object
- #create ⇒ Object
- #delete ⇒ Object
- #generate_config ⇒ Object
- #get ⇒ Object
-
#initialize(data = {}) ⇒ PushSubscription
constructor
A new instance of PushSubscription.
- #log ⇒ Object
- #lost_data? ⇒ Boolean
- #normalize_attributes! ⇒ Object
- #output_config ⇒ Object
- #output_params_config ⇒ Object
- #pause ⇒ Object
- #resume ⇒ Object
- #stop ⇒ Object
- #update ⇒ Object
- #update!(data = {}) ⇒ Object
- #validate ⇒ Object
Methods included from Utilities
#parse_json, #parse_timestamp, #parse_uri, #symbolize_keys
Constructor Details
#initialize(data = {}) ⇒ PushSubscription
Returns a new instance of PushSubscription.
12 13 14 15 16 |
# File 'lib/da_face/api/push_subscription.rb', line 12 def initialize data={} assign_attributes! data normalize_attributes! return self end |
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
9 10 11 |
# File 'lib/da_face/api/push_subscription.rb', line 9 def created_at @created_at end |
#end ⇒ Object
Returns the value of attribute end.
6 7 8 |
# File 'lib/da_face/api/push_subscription.rb', line 6 def end @end end |
#hash ⇒ Object
Returns the value of attribute hash.
6 7 8 |
# File 'lib/da_face/api/push_subscription.rb', line 6 def hash @hash end |
#hash_type ⇒ Object (readonly)
Returns the value of attribute hash_type.
9 10 11 |
# File 'lib/da_face/api/push_subscription.rb', line 9 def hash_type @hash_type end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
9 10 11 |
# File 'lib/da_face/api/push_subscription.rb', line 9 def id @id end |
#initial_status ⇒ Object
Returns the value of attribute initial_status.
6 7 8 |
# File 'lib/da_face/api/push_subscription.rb', line 6 def initial_status @initial_status end |
#last_request ⇒ Object (readonly)
Returns the value of attribute last_request.
9 10 11 |
# File 'lib/da_face/api/push_subscription.rb', line 9 def last_request @last_request end |
#last_success ⇒ Object (readonly)
Returns the value of attribute last_success.
9 10 11 |
# File 'lib/da_face/api/push_subscription.rb', line 9 def last_success @last_success end |
#lost_data ⇒ Object (readonly)
Returns the value of attribute lost_data.
9 10 11 |
# File 'lib/da_face/api/push_subscription.rb', line 9 def lost_data @lost_data end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/da_face/api/push_subscription.rb', line 6 def name @name end |
#output_params ⇒ Object
Returns the value of attribute output_params.
6 7 8 |
# File 'lib/da_face/api/push_subscription.rb', line 6 def output_params @output_params end |
#output_type ⇒ Object
Returns the value of attribute output_type.
6 7 8 |
# File 'lib/da_face/api/push_subscription.rb', line 6 def output_type @output_type end |
#playback_id ⇒ Object
Returns the value of attribute playback_id.
6 7 8 |
# File 'lib/da_face/api/push_subscription.rb', line 6 def playback_id @playback_id end |
#remaining_bytes ⇒ Object (readonly)
Returns the value of attribute remaining_bytes.
9 10 11 |
# File 'lib/da_face/api/push_subscription.rb', line 9 def remaining_bytes @remaining_bytes end |
#start ⇒ Object
Returns the value of attribute start.
6 7 8 |
# File 'lib/da_face/api/push_subscription.rb', line 6 def start @start end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
9 10 11 |
# File 'lib/da_face/api/push_subscription.rb', line 9 def status @status end |
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id.
9 10 11 |
# File 'lib/da_face/api/push_subscription.rb', line 9 def user_id @user_id end |
Class Method Details
Instance Method Details
#allowed_attributes ⇒ Object
34 35 36 37 38 39 |
# File 'lib/da_face/api/push_subscription.rb', line 34 def allowed_attributes [:name, :hash, :initial_status, :start, :end, :output_params, :output_type, :playback_id, :id, :created_at, :user_id, :hash_type, :status, :last_request, :last_success, :remaining_bytes, :lost_data] end |
#assign_attributes!(data) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/da_face/api/push_subscription.rb', line 18 def assign_attributes! data allowed_attributes.each do |attr| unless data[attr].nil? self.instance_variable_set("@#{attr}".to_sym, data[attr]) end end end |
#create ⇒ Object
99 100 101 102 103 |
# File 'lib/da_face/api/push_subscription.rb', line 99 def create data = DaFace::Api::Push.create self.generate_config return data if data.keys.include? :error update! data end |
#delete ⇒ Object
117 118 119 |
# File 'lib/da_face/api/push_subscription.rb', line 117 def delete DaFace::Api::Push.delete self.id end |
#generate_config ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/da_face/api/push_subscription.rb', line 49 def generate_config config = {} config['name'] = self.name if self.name config['output_type'] = self.output_type if self.output_type config['initial_status'] = self.initial_status if self.initial_status config['hash'] = self.hash if self.hash config['playback_id'] = self.playback_id if self.playback_id config['start'] = self.start.to_i if self.start config['end'] = self.end.to_i if self.end config.merge! self.output_params_config if self.output_params config end |
#get ⇒ Object
127 128 129 130 131 |
# File 'lib/da_face/api/push_subscription.rb', line 127 def get data = DaFace::Api::Push.get :id => self.id return data if data.keys.include? :error update! data end |
#log ⇒ Object
121 122 123 124 125 |
# File 'lib/da_face/api/push_subscription.rb', line 121 def log data = DaFace::Api::Push.log self.id return data if data.keys.include? :error DaFace::Api::PushLog.new data end |
#lost_data? ⇒ Boolean
63 64 65 |
# File 'lib/da_face/api/push_subscription.rb', line 63 def lost_data? self.lost_data end |
#normalize_attributes! ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/da_face/api/push_subscription.rb', line 41 def normalize_attributes! @last_request = (@last_request) if @last_request @last_success = (@last_success) if @last_success @start = (@start && @start > 0) ? (@start) : nil @end = (@end && @end > 0) ? (@end) : nil @created_at = (@created_at) if @created_at end |
#output_config ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/da_face/api/push_subscription.rb', line 81 def output_config config = {} config['output_type'] = self.output_type config.merge! self.output_params_config config end |
#output_params_config ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/da_face/api/push_subscription.rb', line 67 def output_params_config params = self.output_params.clone auth = params.delete :auth config = {} params.each do |key, value| config["output_params.#{key}"] = value end auth.each do |key, value| config["output_params.auth.#{key}"] = value end unless auth.nil? config end |
#pause ⇒ Object
105 106 107 |
# File 'lib/da_face/api/push_subscription.rb', line 105 def pause DaFace::Api::Push.pause self.id end |
#resume ⇒ Object
109 110 111 |
# File 'lib/da_face/api/push_subscription.rb', line 109 def resume DaFace::Api::Push.resume self.id end |
#stop ⇒ Object
113 114 115 |
# File 'lib/da_face/api/push_subscription.rb', line 113 def stop DaFace::Api::Push.stop self.id end |
#update ⇒ Object
89 90 91 92 93 |
# File 'lib/da_face/api/push_subscription.rb', line 89 def update params = {'id' => self.id, 'name' => self.name}.merge(self.output_config) data = DaFace::Api::Push.update params update! data end |
#update!(data = {}) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/da_face/api/push_subscription.rb', line 26 def update! data={} params = data.delete :output_params assign_attributes! data self.output_params.merge! params normalize_attributes! return self end |