Module: ShopifyAPI::HmacParams

Extended by:
WEBrick::HTTPUtils
Defined in:
lib/shopify_api/hmac_params.rb

Class Method Summary collapse

Class Method Details

.encode(params) ⇒ Object



8
9
10
11
12
13
# File 'lib/shopify_api/hmac_params.rb', line 8

def self.encode(params)
  params
    .except(:signature, :hmac, :action, :controller)
    .map { |k,v| sprintf("%s=%s", encode_key(k), encode_value(v)) }
    .sort.join("&")
end

.encode_key(key) ⇒ Object



15
16
17
# File 'lib/shopify_api/hmac_params.rb', line 15

def self.encode_key(key)
  _escape(key.to_s, _make_regex('&=%'))
end

.encode_value(value) ⇒ Object



19
20
21
# File 'lib/shopify_api/hmac_params.rb', line 19

def self.encode_value(value)
  _escape(value.to_s, _make_regex('&%'))
end