require 'rest-client'
require 'json'

module Roadmapster
  module Wizeline
    module BaseApi

      BASE_ENDPOINT = 'https://platform.wizelineroadmap.com/api/'

      def get(resource)
        JSON.parse(
          RestClient.get(
            "#{BASE_ENDPOINT}#{resource}",
            headers
          ).body,
          symbolize_names: true
        )
      end

      private

      def headers
        { authorization: "Bearer #{@api_token}", }
      end
    end
  end
end

require 'rest-client'
require 'json'

module Roadmapster
  module Wizeline
    module BaseApi

      BASE_ENDPOINT = "https://<subdomain>.wizelineroadmap.com/api/"

      def get(resource, **options)
        @resource_options = options
        JSON.parse(
          RestClient.get(
            "#{base_endpoint(options)}#{resource}",
            headers
          ).body,
          symbolize_names: true
        )
      end

      private

      def headers
        { authorization: "Bearer #{@api_token}", }
      end

      def base_endpoint(options)
        if options.empty?
          BASE_ENDPOINT.sub('<subdomain>', 'platform')
        else
          BASE_ENDPOINT.sub('<subdomain>', options[:organization_domain])
        end
      end
    end
  end
end

Refactor the base endpoint generation to support organization subdomains
Refactor the base endpoint generation to support organization subdomains
