Module: Nuorder::Client::Oauth

Included in:
Nuorder::Client
Defined in:
lib/nuorder/client/oauth.rb

Constant Summary collapse

VERSION =
'1.0'
SIGNATURE_METHOD =
'HMAC-SHA1'

Instance Method Summary collapse

Instance Method Details

#oauth_headers(method, url, addons = nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/nuorder/client/oauth.rb', line 9

def oauth_headers(method, url, addons = nil)
  time = Time.now.to_i
  nonce = SecureRandom.hex(8)
  signature = build_signature(method, url, time, nonce, addons)
  oauth_header = build_oauth(time, nonce, signature, addons)
  {
      'Authorization' => "oAuth #{oauth_header}",
      'Accept' => 'application/json',
      'Content-Type' => 'application/json'
  }
end