Module: GettyUp::API::CreateSession

Includes:
Util
Included in:
Client
Defined in:
lib/getty_up/api/create_session.rb

Constant Summary collapse

ENDPOINT =
"https://connect.gettyimages.com/v1/session/CreateSession"

Instance Method Summary collapse

Methods included from Util

#post_json

Instance Method Details

#create_sessionObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/getty_up/api/create_session.rb', line 10

def create_session
  request = {
    :RequestHeader => {},
    :CreateSessionRequestBody =>
    {
      :SystemId => @system_id,
      :SystemPassword => @system_password,
      :UserName => @api_username,
      :UserPassword => @api_password
    }
  }

  response = post_json(request, ENDPOINT)

  @token = response["CreateSessionResult"]["Token"]
  @status = response["ResponseHeader"]["Status"]
  @secure_token = response["CreateSessionResult"]["SecureToken"]
  @token_duration = response["CreateSessionResult"]["TokenDurationMinutes"]
  @token_expiration = @token_duration.minutes.from_now
end

#session_valid?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/getty_up/api/create_session.rb', line 31

def session_valid?
  @token_expiration.present? && @token_expiration > Time.now
end