Class: Naver::Searchad::Api::Auth::CustomerAcccountCredentials

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) ⇒ CustomerAcccountCredentials

Returns a new instance of CustomerAcccountCredentials.



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

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.



11
12
13
# File 'lib/naver/searchad/api/auth.rb', line 11

def api_key
  @api_key
end

#api_secretObject (readonly)

Returns the value of attribute api_secret.



12
13
14
# File 'lib/naver/searchad/api/auth.rb', line 12

def api_secret
  @api_secret
end

#customer_idObject (readonly)

Returns the value of attribute customer_id.



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

def customer_id
  @customer_id
end

Instance Method Details

#apply(hash, request_uri, method) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/naver/searchad/api/auth.rb', line 21

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