module AliyunSDK

The AliyunSDK module

Constants

VERSION

Public Class Methods

canonicalize(normalized) click to toggle source
# File lib/rpc_client.rb, line 37
def self.canonicalize(normalized)
  normalized.map { |element| "#{element.first}=#{element.last}" }.join('&')
end
encode(string) click to toggle source
# File lib/rpc_client.rb, line 48
def self.encode(string)
  encoded = CGI.escape string
  encoded.gsub(/[\+]/, '%20')
end
flat_params(params) click to toggle source
# File lib/rpc_client.rb, line 25
def self.flat_params(params)
  target = {}
  params.each do |key, value|
    if value.instance_of?(Array)
      replace_repeat_list(target, key, value)
    else
      target[key.to_s] = value
    end
  end
  target
end
normalize(params) click to toggle source
# File lib/rpc_client.rb, line 41
def self.normalize(params)
  flat_params(params)
    .sort
    .to_h
    .map { |key, value| [encode(key), encode(value)] }
end
replace_repeat_list(target, key, repeat) click to toggle source
# File lib/rpc_client.rb, line 12
def self.replace_repeat_list(target, key, repeat)
  repeat.each_with_index do |item, index|
    if item&.instance_of?(Hash)
      item.each_key do |k|
        target["#{key}.#{index.next}.#{k}"] = item[k].to_s
      end
    else
      target["#{key}.#{index.next}"] = item.to_s
    end
  end
  target
end