module FeatureFlagHelper
  def update_feature_flag(feature_name, new_variant, user_id)
    path = "#{ENV['FEATURES_SERVICE_URL']}/features/#{feature_name}/user/#{user_id}"
    body = { "variant_name": new_variant }.to_json
    begin
      response = HTTParty.put(path, body: body, headers: NO_AUTH_HEADERS)
      res = hash_from_response_object(response)
    rescue StandardError => e
      LOG.debug "Module: FeatureFlagHelper. Method: update_feature_flag. Message: #{e.message}"
      raise e
    end
    res
  end
end
