lib/backlog_kit/client.rb in backlog_kit-0.16.0 vs lib/backlog_kit/client.rb in backlog_kit-0.17.0

- old
+ new

@@ -41,10 +41,11 @@ USER_AGENT = "BacklogKit Ruby Gem #{BacklogKit::VERSION}".freeze attr_accessor( :space_id, + :second_level_domain, :top_level_domain, :api_key, :client_id, :client_secret, :refresh_token, @@ -55,22 +56,24 @@ # Initialize a new Client object with given options # # @param options [Hash] Initialize options # @option options [String] :space_id Backlog space id + # @option options [String] :second_level_domain Backlog second level domain # @option options [String] :top_level_domain Backlog top level domain # @option options [String] :api_key Backlog api key # @option options [String] :client_id Backlog OAuth client id # @option options [String] :client_secret Backlog OAuth client secret # @option options [String] :refresh_token Backlog OAuth refresh token def initialize(options = {}) - @space_id = ENV['BACKLOG_SPACE_ID'] - @top_level_domain = ENV['BACKLOG_TOP_LEVEL_DOMAIN'] || 'jp' - @api_key = ENV['BACKLOG_API_KEY'] - @client_id = ENV['BACKLOG_OAUTH_CLIENT_ID'] - @client_secret = ENV['BACKLOG_OAUTH_CLIENT_SECRET'] - @refresh_token = ENV['BACKLOG_OAUTH_REFRESH_TOKEN'] + @space_id = ENV['BACKLOG_SPACE_ID'] + @second_level_domain = ENV['BACKLOG_SECOND_LEVEL_DOMAIN'] || 'backlog' + @top_level_domain = ENV['BACKLOG_TOP_LEVEL_DOMAIN'] || 'com' + @api_key = ENV['BACKLOG_API_KEY'] + @client_id = ENV['BACKLOG_OAUTH_CLIENT_ID'] + @client_secret = ENV['BACKLOG_OAUTH_CLIENT_SECRET'] + @refresh_token = ENV['BACKLOG_OAUTH_REFRESH_TOKEN'] options.each do |key, value| instance_variable_set(:"@#{key}", value) end end @@ -150,10 +153,10 @@ faraday.adapter(Faraday.default_adapter) end end def host - "https://#{space_id}.backlog.#{top_level_domain}" + "https://#{space_id}.#{second_level_domain}.#{top_level_domain}" end def request_headers headers = { 'User-Agent' => USER_AGENT } headers['Authorization'] = "Bearer #{@access_token}" if oauth_request?