Module: EventMachine::Instagram::Subscriptions
- Included in:
- EventMachine::Instagram
- Defined in:
- lib/em-instagram/api/subscriptions.rb
Instance Method Summary collapse
- #subscribe(*args) ⇒ Object
- #subscribe_next ⇒ Object
- #subscribe_to(options) ⇒ Object
- #subscriptions(params = {}) ⇒ Object
- #unsubscribe(params = {}) ⇒ Object
Instance Method Details
#subscribe(*args) ⇒ Object
17 18 19 20 |
# File 'lib/em-instagram/api/subscriptions.rb', line 17 def subscribe(*args) @subscription_queue.push(*args) subscribe_next end |
#subscribe_next ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/em-instagram/api/subscriptions.rb', line 26 def subscribe_next if @subscription_queue.empty? self.logger.debug "subscribed." else self.subscription_queue.pop { |hash| subscribe_to(hash); subscribe_next } end end |
#subscribe_to(options) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/em-instagram/api/subscriptions.rb', line 5 def subscribe_to() = .merge(:aspect => 'media', :callback_url => self.callback_url) request_body = default_params.merge(:aspect => 'media', :callback_url => self.callback_url).merge() request = request(:post, "/v1/subscriptions", :body => request_body) request.errback { |error| self.logger.debug "subscription error: #{error}"; EventMachine::add_timer(15) { subscribe_to } } request.callback { |response| self.logger.debug "next subscription..."; EventMachine::next_tick { subscribe_next } } end |
#subscriptions(params = {}) ⇒ Object
13 14 15 |
# File 'lib/em-instagram/api/subscriptions.rb', line 13 def subscriptions(params = {}) request :get, "/v1/subscriptions", :query => default_params.merge(params) end |
#unsubscribe(params = {}) ⇒ Object
22 23 24 |
# File 'lib/em-instagram/api/subscriptions.rb', line 22 def unsubscribe(params = {}) request :delete, "/v1/subscriptions", :query => default_params.merge(params) end |