Module: MicroService::Server::ClassMethods
- Defined in:
- lib/micro_service/server/class_methods.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#install(server_install_url, client_install_url, client_uninstall_url = "") ⇒ Object
Requests installation with a service.
Class Method Details
.extended(base) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/micro_service/server/class_methods.rb', line 4 def self.extended(base) #base.belongs_to :add_on, :class_name => "Jive::AddOn", :foreign_key => :jive_add_on_id #base.validates :jive_add_on_id, :presence => true #base.has_one :oauth_token, :class_name => "Jive::OauthToken", :as => :owner #base.serialize :config, Hash #base.after_create :fetch_oauth_token end |
Instance Method Details
#install(server_install_url, client_install_url, client_uninstall_url = "") ⇒ Object
Requests installation with a service
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/micro_service/server/class_methods.rb', line 13 def install(server_install_url, client_install_url, client_uninstall_url = "") require "open-uri" require "net/http" require "openssl" uri = URI.parse(server_install_url.to_s) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true if uri.scheme == "https" request = Net::HTTP::Post.new(uri.request_uri) request["Content-Type"] = "application/json" request.body = { install_url: client_install_url, uninstall_url: client_uninstall_url }.to_json response = http.request(request) # Failed to register with external service if !response.kind_of? Net::HTTPSuccess raise ::MicroService::Server::InstallError end end |