Class: AppReport::API::Base
- Inherits:
-
Object
- Object
- AppReport::API::Base
- Defined in:
- lib/app_report/api/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #params_to_sign ⇒ Object
- #sign_params(params) ⇒ Object
- #signed_params ⇒ Object
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
23 24 25 |
# File 'lib/app_report/api/base.rb', line 23 def initialize @params = {} end |
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
21 22 23 |
# File 'lib/app_report/api/base.rb', line 21 def params @params end |
Instance Method Details
#params_to_sign ⇒ Object
27 28 29 |
# File 'lib/app_report/api/base.rb', line 27 def params_to_sign [] end |
#sign_params(params) ⇒ Object
31 32 33 34 |
# File 'lib/app_report/api/base.rb', line 31 def sign_params params string = params.map { |k, v| v.to_s }.join SimpleSigner.sign :secret_key => AppReport.settings.secret_key, :string => string end |
#signed_params ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/app_report/api/base.rb', line 36 def signed_params params = {} # include params that must be signed params_to_sign.each { |param| params[param] = @params[param]# unless params.include? param } # include configured keys params.merge! :app_name => AppReport.settings.app_name, :expires => Time.now.to_i + AppReport.settings.expires_signed_url_after # sign params params.merge! :signature => sign_params(params), :access_key => AppReport.settings.access_key # include not signed params @params.merge params end |