module Alipass::Template::Content
Public Class Methods
add(params)
click to toggle source
REQUIRED_PARAMS = [
:method, :timestamp, :app_id, :version, :sign, :sign_type, :tpl_id, :tpl_params, :recognition_type, :recognition_info
]
# File lib/alipass/template/content.rb, line 12 def self.add(params) gateway = 'https://openapi.alipay.com/gateway.do' params = { method: 'alipay.pass.tpl.content.add', timestamp: Time.now.strftime('%F %T'), format: 'json', app_id: Alipass.app_id, sign_type: 'RSA', version: '1.0' }.merge(params) params[:tpl_params].encode!('GBK', invalid: :replace, undef: :replace, replace: '') params[:sign] = Sign.generate(params) RestClient.post(gateway, params) do |response| JSON.parse(response.body) end end