Module: GettyConnect::Config

Included in:
GettyConnect
Defined in:
lib/getty_connect/config.rb

Constant Summary collapse

DEFAULT_API_VERSION =

GettyConnect endpoints api.gettyimages.com/apis

"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}"
DEFAULT_SYSTEM_ID =

Authentication

"3131"
DEFAULT_SYSTEM_PASSWORD =

nil

"I7zZycelG4VxeG0lPJdVZCZwDI7zn4rUIJwUd7V/V+0="
DEFAULT_API_USERNAME =

nil

"avos_api"
DEFAULT_API_PASSWORD =

nil

"S3p4PmAtkuppoKT"
VALID_OPTIONS_KEYS =

An array of valid keys in the options hash when configuring a GettyConnect::Client

[
  :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
]

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object

When this module is extended, set all configuration options to their default values



57
58
59
# File 'lib/getty_connect/config.rb', line 57

def self.extended(base)
  base.reset
end

Instance Method Details

#configure {|_self| ... } ⇒ Object

Convenience method to allow configuration options to be set in a block

Yields:

  • (_self)

Yield Parameters:



62
63
64
65
# File 'lib/getty_connect/config.rb', line 62

def configure
  yield self
  self
end

#optionsObject



67
68
69
# File 'lib/getty_connect/config.rb', line 67

def options
  VALID_OPTIONS_KEYS.inject({}){|o,k| o.merge!(k => send(k)) }
end

#resetObject

Reset all configuration options to defaults



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/getty_connect/config.rb', line 72

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