Sha256: e4e0a27870a1cbd59d6cb017b1bb525b2899d1f8d865ce8aed97c8e040b54e8a

Contents?: true

Size: 1.66 KB

Versions: 2

Compression:

Stored size: 1.66 KB

Contents

# frozen_string_literal: true

# Copyright 2020 ConvertKit, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

module InstagramBasicDisplay
  # Holds configuration values that are used to make requests against the
  # Instagram API
  class Configuration
    attr_accessor :client_id, :client_secret, :redirect_uri, :auth_token, :version

    # Constructor method
    #
    # @param auth_token [String] token that will be used to make requests
    #
    # @return void
    def initialize(auth_token: nil, version: 1)
      @version = version
      @client_id = set_client_id
      @client_secret = set_client_secret
      @redirect_uri = set_redirect_uri
      @auth_token = auth_token
    end

    def set_client_id
      if version == 1
        ENV.fetch('INSTAGRAM_CLIENT_ID')
      else
        ENV.fetch('INSTAGRAM_CLIENT_ID_V2')
      end
    end

    def set_client_secret
      if version == 1
        ENV.fetch('INSTAGRAM_CLIENT_SECRET')
      else
        ENV.fetch('INSTAGRAM_CLIENT_SECRET_V2')
      end
    end

    def set_redirect_uri
      if version == 1
        ENV.fetch('INSTAGRAM_REDIRECT_URI')
      else
        ENV.fetch('INSTAGRAM_REDIRECT_URI_V2')
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
instagram_basic_display-0.2.3 lib/instagram_basic_display/configuration.rb
instagram_basic_display-0.2.2 lib/instagram_basic_display/configuration.rb