Module: CobotClient::UrlHelper
- Included in:
- ApiClient
- Defined in:
- lib/cobot_client/url_helper.rb
Constant Summary collapse
- @@site =
set this to override the site for accessing the cobot api
'https://www.cobot.me'
Class Method Summary collapse
Instance Method Summary collapse
-
#cobot_url(subdomain = 'www', *path_options) ⇒ Object
generates a url to access the cobot api see the spec for usage examples.
Class Method Details
.site ⇒ Object
7 8 9 |
# File 'lib/cobot_client/url_helper.rb', line 7 def self.site @@site end |
.site=(site) ⇒ Object
11 12 13 |
# File 'lib/cobot_client/url_helper.rb', line 11 def self.site=(site) @@site = site end |
Instance Method Details
#cobot_url(subdomain = 'www', *path_options) ⇒ Object
generates a url to access the cobot api see the spec for usage examples
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/cobot_client/url_helper.rb', line 17 def cobot_url(subdomain = 'www', *) path = .first.is_a?(String) ? .first : '/' = .find{|p| p.is_a?(Hash)} || {} url = URI.parse(CobotClient::UrlHelper.site) url.host = url.host.split('.').tap{|parts| parts[0] = subdomain}.join('.') url.path = path url.query = URI.encode_www_form([:params]) if [:params] && [:params].any? url.to_s end |