Class: Divshare::PostArgs

Inherits:
Hash
  • Object
show all
Defined in:
lib/divshare/post_args.rb

Overview

This is a simple hash that initializes itself in a state appropriate to the request. Converts all keys and values to strings.

Instance Method Summary collapse

Constructor Details

#initialize(client, method, args) ⇒ PostArgs

Returns a new instance of PostArgs.



5
6
7
8
9
10
11
12
# File 'lib/divshare/post_args.rb', line 5

def initialize(client, method, args)
  post_args = args.merge({'method' => method, 'api_key' => client.api_key})
  if client.api_session_key #&& method.to_sym != :logout
    api_sig = client.sign(method, post_args)
    post_args.merge!({'api_session_key' => client.api_session_key, 'api_sig' => api_sig})
  end
  post_args.each { |k,v| self[k.to_s] = v.to_s }
end