require 'faraday' require 'getty_connect/version' module GettyConnect module Config # GettyConnect endpoints # https://api.gettyimages.com/apis DEFAULT_API_VERSION = "v1" DEFAULT_CREATE_SESSION_ENDPOINT = "#{DEFAULT_API_VERSION}/session/CreateSession" DEFAULT_RENEW_SESSION_ENDPOINT = "#{DEFAULT_API_VERSION}/session/RenewSession" DEFAULT_SEARCH_ENDPOINT = "#{DEFAULT_API_VERSION}/search/SearchForImages" DEFAULT_IMAGE_DETAILS_ENDPOINT = "#{DEFAULT_API_VERSION}/search/GetImageDetails" DEFAULT_DOWNLOAD_AUTH_ENDPOINT = "#{DEFAULT_API_VERSION}/download/GetImageDownloadAuthorizations" DEFAULT_DOWNLOAD_REQUEST_ENDPOINT = "#{DEFAULT_API_VERSION}/download/CreateDownloadRequest" DEFAULT_DOWNLOAD_LARGEST_ENDPOINT = "#{DEFAULT_API_VERSION}/download/GetLargestImageDownloadAuthorizations" DEFAULT_USER_AGENT = "GettyConnect Ruby Gem #{GettyConnect::VERSION}" # Authentication DEFAULT_SYSTEM_ID = "3131" # nil DEFAULT_SYSTEM_PASSWORD = "I7zZycelG4VxeG0lPJdVZCZwDI7zn4rUIJwUd7V/V+0=" # nil DEFAULT_API_USERNAME = "avos_api" # nil DEFAULT_API_PASSWORD = "S3p4PmAtkuppoKT" # nil # An array of valid keys in the options hash # when configuring a {GettyConnect::Client} VALID_OPTIONS_KEYS = [ :create_session_endpoint, :renew_session_endpoint, :search_endpoint, :image_details_endpoint, :download_auth_endpoint, :download_request_endpoint, :download_largest_endpoint, :user_agent, :system_id, :system_password, :api_username, :api_password, :api_version ] attr_accessor(*VALID_OPTIONS_KEYS) # When this module is extended, set all configuration options # to their default values def self.extended(base) base.reset end # Convenience method to allow configuration options to be set in a block def configure yield self self end def options VALID_OPTIONS_KEYS.inject({}){|o,k| o.merge!(k => send(k)) } end # Reset all configuration options to defaults def reset self.create_session_endpoint = DEFAULT_CREATE_SESSION_ENDPOINT self.renew_session_endpoint = DEFAULT_RENEW_SESSION_ENDPOINT self.search_endpoint = DEFAULT_SEARCH_ENDPOINT self.image_details_endpoint = DEFAULT_IMAGE_DETAILS_ENDPOINT self.download_auth_endpoint = DEFAULT_DOWNLOAD_AUTH_ENDPOINT self.download_request_endpoint = DEFAULT_DOWNLOAD_REQUEST_ENDPOINT self.download_largest_endpoint = DEFAULT_DOWNLOAD_LARGEST_ENDPOINT self.user_agent = DEFAULT_USER_AGENT self.system_id = DEFAULT_SYSTEM_ID self.system_password = DEFAULT_SYSTEM_PASSWORD self.api_username = DEFAULT_API_USERNAME self.api_password = DEFAULT_API_PASSWORD self.api_version = DEFAULT_API_VERSION self end end end