Class: Towsta::Synchronizer
- Inherits:
-
Object
- Object
- Towsta::Synchronizer
- Defined in:
- lib/towsta/synchronizer.rb
Instance Attribute Summary collapse
-
#cache ⇒ Object
Returns the value of attribute cache.
-
#params ⇒ Object
Returns the value of attribute params.
-
#response ⇒ Object
Returns the value of attribute response.
-
#status ⇒ Object
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Synchronizer
constructor
A new instance of Synchronizer.
Constructor Details
#initialize(args = {}) ⇒ Synchronizer
Returns a new instance of Synchronizer.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/towsta/synchronizer.rb', line 6 def initialize args={} @params = solve_params args[:params] @cache = args[:cache] if synchronize args[:request] ||= :horizontals create_verticals if [:all, :structure].include? args[:request] populate_verticals if [:all, :horizontals].include? args[:request] puts " Ready to Towst!\n\n" @status = true else puts " Unable to keep Towsting!\n\n" @status = false end end |
Instance Attribute Details
#cache ⇒ Object
Returns the value of attribute cache.
4 5 6 |
# File 'lib/towsta/synchronizer.rb', line 4 def cache @cache end |
#params ⇒ Object
Returns the value of attribute params.
4 5 6 |
# File 'lib/towsta/synchronizer.rb', line 4 def params @params end |
#response ⇒ Object
Returns the value of attribute response.
4 5 6 |
# File 'lib/towsta/synchronizer.rb', line 4 def response @response end |
#status ⇒ Object
Returns the value of attribute status.
4 5 6 |
# File 'lib/towsta/synchronizer.rb', line 4 def status @status end |
Class Method Details
.authentication_request(params) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/towsta/synchronizer.rb', line 30 def self.authentication_request params begin uri = URI.parse("http://manager.towsta.com/authenticate") return JSON.parse Net::HTTP.post_form(uri, params).body.to_s, symbolize_names: true rescue return {status: false} end end |
.save_request(export) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/towsta/synchronizer.rb', line 21 def self.save_request export begin uri = URI.parse("http://manager.towsta.com/synchronizers/#{Towsta.secret}/import.json") return JSON.parse Net::HTTP.post_form(uri, {code: export.to_json}).body.to_s, symbolize_names: true rescue return {status: false, message: 'Internal Server Error'} end end |