Class: WCC::Arena::SignedPath

Inherits:
Object
  • Object
show all
Defined in:
lib/wcc/arena/signed_path.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ SignedPath

Returns a new instance of SignedPath.



9
10
11
12
13
14
# File 'lib/wcc/arena/signed_path.rb', line 9

def initialize(args={})
  @path = args.fetch(:path)
  @session_id = args.fetch(:session_id)
  @api_secret = args.fetch(:api_secret)
  @query = args.fetch(:query) { Hash.new }
end

Instance Attribute Details

#api_secretObject (readonly)

Returns the value of attribute api_secret.



7
8
9
# File 'lib/wcc/arena/signed_path.rb', line 7

def api_secret
  @api_secret
end

#pathObject (readonly)

Returns the value of attribute path.



7
8
9
# File 'lib/wcc/arena/signed_path.rb', line 7

def path
  @path
end

#queryObject (readonly)

Returns the value of attribute query.



7
8
9
# File 'lib/wcc/arena/signed_path.rb', line 7

def query
  @query
end

#session_idObject (readonly)

Returns the value of attribute session_id.



7
8
9
# File 'lib/wcc/arena/signed_path.rb', line 7

def session_id
  @session_id
end

Instance Method Details

#api_sigObject



30
31
32
# File 'lib/wcc/arena/signed_path.rb', line 30

def api_sig
  Digest::MD5.hexdigest("#{api_secret}_#{path_with_session.downcase}")
end

#callObject



16
17
18
19
20
21
# File 'lib/wcc/arena/signed_path.rb', line 16

def call
  [
    path_with_session,
    "api_sig=#{api_sig}",
  ].join("&")
end

#path_with_sessionObject



23
24
25
26
27
28
# File 'lib/wcc/arena/signed_path.rb', line 23

def path_with_session
  [
    path,
    URI.encode_www_form(query.merge(api_session: session_id)),
  ].join("?")
end