lib/lime_survey/api.rb in lime_survey-0.10.0 vs lib/lime_survey/api.rb in lime_survey-0.10.1

- old
+ new

@@ -218,11 +218,11 @@ check_authentication post method_name, params end def post(method_name, params = []) - response = self.class.post(URL_ENDPOINT, body: modify_body(method_name, params), timeout: 60, headers: headers) + response = self.class.post(url_endpoint, body: modify_body(method_name, params), timeout: 60, headers: headers) OpenStruct.new body: JSON::parse(response.body), request: response.request, code: response.code end def check_authentication if token @@ -232,9 +232,12 @@ end end private + def url_endpoint + ENV.fetch("LIMESURVEY_API_URL", "not-implemented") + end def authenticate! response = get_session_key raise AuthenticationError.new(response.body.dig("result", "status")) if response.body.dig("result").is_a?(Hash) && response.body.dig("result", "status") == "Invalid user name or password" @token = response.body.dig("result")