Module: BlackStack::API
- Defined in:
- lib/functions.rb
Constant Summary collapse
- @@api_key =
API connection parameters
nil- @@api_protocol =
Api-key of the client who will be the owner of a process.
nil- @@api_domain =
Protocol, HTTP or HTTPS, of the BlackStack server where this process will be registered.
nil- @@api_port =
Domain of the BlackStack server where this process will be registered.
nil- @@api_less_secure_port =
Port of the BlackStack server where this process will be registered.
nil
Class Method Summary collapse
- .api_domain ⇒ Object
-
.api_key ⇒ Object
API connection getters and setters.
- .api_less_secure_port ⇒ Object
- .api_less_secure_url ⇒ Object
- .api_port ⇒ Object
- .api_protocol ⇒ Object
- .api_url ⇒ Object
- .set_api_key(s) ⇒ Object
- .set_api_url(h) ⇒ Object
Class Method Details
.api_domain ⇒ Object
18 19 20 |
# File 'lib/functions.rb', line 18 def self.api_domain @@api_domain end |
.api_key ⇒ Object
API connection getters and setters
12 13 14 |
# File 'lib/functions.rb', line 12 def self.api_key() @@api_key end |
.api_less_secure_port ⇒ Object
24 25 26 |
# File 'lib/functions.rb', line 24 def self.api_less_secure_port @@api_less_secure_port end |
.api_less_secure_url ⇒ Object
30 31 32 |
# File 'lib/functions.rb', line 30 def self.api_less_secure_url() "http://#{BlackStack::API.api_domain}:#{BlackStack::API.api_less_secure_port}" end |
.api_port ⇒ Object
21 22 23 |
# File 'lib/functions.rb', line 21 def self.api_port @@api_port end |
.api_protocol ⇒ Object
15 16 17 |
# File 'lib/functions.rb', line 15 def self.api_protocol @@api_protocol end |
.api_url ⇒ Object
27 28 29 |
# File 'lib/functions.rb', line 27 def self.api_url() "#{BlackStack::API.api_protocol}://#{BlackStack::API.api_domain}:#{BlackStack::API.api_port}" end |
.set_api_key(s) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/functions.rb', line 33 def self.set_api_key(s) # validate: the parameter s is required raise 'The parameter s is required' unless s # validate: the parameter s must be a string raise 'The parameter s must be a string' unless s.is_a?(String) # map values @@api_key = s end |
.set_api_url(h) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/functions.rb', line 43 def self.set_api_url(h) # validate: the parameter h is requred raise "The parameter h is required." if h.nil? # validate: the parameter h must be a hash raise "The parameter h must be a hash" unless h.is_a?(Hash) # validate: the :api_key key is required raise 'The key :api_key is required' unless h.has_key?(:api_key) # validate: the :api_protocol key is required raise 'The key :api_protocol is required' unless h.has_key?(:api_domain) # validate: the :api_domain key is required raise 'The key :api_domain is required' unless h.has_key?(:api_domain) # validate: the :api_port key is required raise 'The key :api_port is required' unless h.has_key?(:api_port) # validate: the :api_key key is a string raise 'The key :api_key must be a string' unless h[:api_key].is_a?(String) # validate: the :api_protocol key is a string raise 'The key :api_protocol must be a string' unless h[:api_protocol].is_a?(String) # validate: the :api_domain key is a string raise 'The key :api_domain must be a string' unless h[:api_domain].is_a?(String) # validate: the :api_port key is an integer, or a string that can be converted to an integer raise 'The key :api_port must be an integer' unless h[:api_port].is_a?(Integer) || (h[:api_port].is_a?(String) && h[:api_port].to_i.to_s == h[:api_port]) # validate: the :api_less_secure_port key is an integer, or a string that can be converted to an integer raise 'The key :api_less_secure_port must be an integer' unless h[:api_less_secure_port].is_a?(Integer) || (h[:api_less_secure_port].is_a?(String) && h[:api_less_secure_port].to_i.to_s == h[:api_less_secure_port]) # map the values @@api_key = h[:api_key] @@api_protocol = h[:api_protocol] @@api_domain = h[:api_domain] @@api_port = h[:api_port].to_i @@api_less_secure_port = h[:api_less_secure_port].to_i end |