Class: Kameleoon::Network::UrlProvider
- Inherits:
-
Object
- Object
- Kameleoon::Network::UrlProvider
- Defined in:
- lib/kameleoon/network/url_provider.rb
Overview
UrlProvider is used as a source of URLs for network calls.
Constant Summary collapse
- TRACKING_PATH =
'/visit/events'
- VISITOR_DATA_PATH =
'/visit/visitor'
- GET_DATA_PATH =
'/map/map'
- POST_DATA_PATH =
'/map/maps'
- ACCESS_TOKEN_PATH =
'/oauth/token'
- CONFIGURATION_API_URL_FORMAT =
'https://sdk-config.kameleoon.eu/%s'
- RT_CONFIGURATION_URL =
'https://events.kameleoon.com:8110/sse'
- DEFAULT_DATA_API_DOMAIN =
'data.kameleoon.io'
- TEST_DATA_API_DOMAIN =
'data.kameleoon.net'
- DEFAULT_AUTOMATION_API_DOMAIN =
'api.kameleoon.com'
- TEST_AUTOMATION_API_DOMAIN =
'api.kameleoon.net'
Instance Attribute Summary collapse
-
#automation_api_domain ⇒ Object
readonly
Returns the value of attribute automation_api_domain.
-
#data_api_domain ⇒ Object
readonly
Returns the value of attribute data_api_domain.
-
#site_code ⇒ Object
readonly
Returns the value of attribute site_code.
Instance Method Summary collapse
- #apply_data_api_domain(domain) ⇒ Object
-
#initialize(site_code, data_api_domain = DEFAULT_DATA_API_DOMAIN, automation_api_domain = DEFAULT_AUTOMATION_API_DOMAIN) ⇒ UrlProvider
constructor
A new instance of UrlProvider.
- #make_access_token_url ⇒ Object
- #make_api_data_get_request_url(key) ⇒ Object
- #make_configuration_url(environment = nil, timestamp = nil) ⇒ Object
- #make_real_time_url ⇒ Object
- #make_tracking_url ⇒ Object
- #make_visitor_data_get_url(visitor_code, filter, is_unique_identifier = false) ⇒ Object
Constructor Details
#initialize(site_code, data_api_domain = DEFAULT_DATA_API_DOMAIN, automation_api_domain = DEFAULT_AUTOMATION_API_DOMAIN) ⇒ UrlProvider
Returns a new instance of UrlProvider.
26 27 28 29 30 31 32 33 34 |
# File 'lib/kameleoon/network/url_provider.rb', line 26 def initialize( site_code, data_api_domain = DEFAULT_DATA_API_DOMAIN, automation_api_domain = DEFAULT_AUTOMATION_API_DOMAIN ) @site_code = site_code @data_api_domain = data_api_domain @automation_api_domain = automation_api_domain end |
Instance Attribute Details
#automation_api_domain ⇒ Object (readonly)
Returns the value of attribute automation_api_domain.
24 25 26 |
# File 'lib/kameleoon/network/url_provider.rb', line 24 def automation_api_domain @automation_api_domain end |
#data_api_domain ⇒ Object (readonly)
Returns the value of attribute data_api_domain.
24 25 26 |
# File 'lib/kameleoon/network/url_provider.rb', line 24 def data_api_domain @data_api_domain end |
#site_code ⇒ Object (readonly)
Returns the value of attribute site_code.
24 25 26 |
# File 'lib/kameleoon/network/url_provider.rb', line 24 def site_code @site_code end |
Instance Method Details
#apply_data_api_domain(domain) ⇒ Object
36 37 38 |
# File 'lib/kameleoon/network/url_provider.rb', line 36 def apply_data_api_domain(domain) @data_api_domain = domain if domain.is_a?(String) end |
#make_access_token_url ⇒ Object
88 89 90 |
# File 'lib/kameleoon/network/url_provider.rb', line 88 def make_access_token_url "https://#{@automation_api_domain}#{ACCESS_TOKEN_PATH}" end |
#make_api_data_get_request_url(key) ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/kameleoon/network/url_provider.rb', line 66 def make_api_data_get_request_url(key) params = { siteCode: @site_code, key: key } "https://#{@data_api_domain}#{GET_DATA_PATH}?#{UriHelper.encode_query(params)}" end |
#make_configuration_url(environment = nil, timestamp = nil) ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'lib/kameleoon/network/url_provider.rb', line 74 def make_configuration_url(environment = nil, = nil) url = format(CONFIGURATION_API_URL_FORMAT, @site_code) params = {} params[:environment] = environment unless environment.nil? params[:ts] = unless .nil? url = "#{url}?#{UriHelper.encode_query(params)}" unless params.empty? url end |
#make_real_time_url ⇒ Object
83 84 85 86 |
# File 'lib/kameleoon/network/url_provider.rb', line 83 def make_real_time_url params = { siteCode: @site_code } "#{RT_CONFIGURATION_URL}?#{UriHelper.encode_query(params)}" end |
#make_tracking_url ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/kameleoon/network/url_provider.rb', line 40 def make_tracking_url params = { sdkName: SDK_NAME, sdkVersion: SDK_VERSION, siteCode: @site_code, bodyUa: true } "https://#{@data_api_domain}#{TRACKING_PATH}?#{UriHelper.encode_query(params)}" end |
#make_visitor_data_get_url(visitor_code, filter, is_unique_identifier = false) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/kameleoon/network/url_provider.rb', line 50 def make_visitor_data_get_url(visitor_code, filter, is_unique_identifier = false) params = { siteCode: @site_code } params[is_unique_identifier ? :mappingValue : :visitorCode] = visitor_code params[:maxNumberPreviousVisits] = filter.previous_visit_amount params[:version] = 0 params[:kcs] = true if filter.kcs params[:currentVisit] = true if filter.current_visit params[:customData] = true if filter.custom_data params[:conversion] = true if filter.conversions params[:geolocation] = true if filter.geolocation params[:experiment] = true if filter.experiments params[:page] = true if filter.page_views params[:staticData] = true if filter.device || filter.browser || filter. "https://#{@data_api_domain}#{VISITOR_DATA_PATH}?#{UriHelper.encode_query(params)}" end |