Class: Naver::Searchad::Api::Auth::CustomerAccountCredentials

Inherits:
Object
  • Object
show all
Defined in:
lib/naver/searchad/api/auth.rb

Constant Summary collapse

TIMESTAMP_HEADER =
'X-Timestamp'.freeze
API_KEY_HEADER =
'X-API-KEY'.freeze
CUSTOMER_HEADER =
'X-Customer'.freeze
SIGNATURE_HEADER =
'X-Signature'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key, api_secret, customer_id) ⇒ CustomerAccountCredentials

Returns a new instance of CustomerAccountCredentials.



18
19
20
21
22
# File 'lib/naver/searchad/api/auth.rb', line 18

def initialize(api_key, api_secret, customer_id)
  @api_key = api_key
  @api_secret = api_secret
  @customer_id = customer_id
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



14
15
16
# File 'lib/naver/searchad/api/auth.rb', line 14

def api_key
  @api_key
end

#api_secretObject (readonly)

Returns the value of attribute api_secret.



15
16
17
# File 'lib/naver/searchad/api/auth.rb', line 15

def api_secret
  @api_secret
end

#customer_idObject (readonly)

Returns the value of attribute customer_id.



16
17
18
# File 'lib/naver/searchad/api/auth.rb', line 16

def customer_id
  @customer_id
end

Instance Method Details

#apply(hash, request_uri, method) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/naver/searchad/api/auth.rb', line 24

def apply(hash, request_uri, method)
  timestamp = Time.now.to_i

  hash[TIMESTAMP_HEADER] = timestamp
  hash[API_KEY_HEADER] = api_key
  hash[CUSTOMER_HEADER] = customer_id
  hash[SIGNATURE_HEADER] = generate_signature(api_secret, request_uri, method, timestamp)
end