Class: AppReport::API::Jasper
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #build!(report) ⇒ Object
- #decode_report!(response_body) ⇒ Object
- #params_to_sign ⇒ Object
-
#validates_report!(report) ⇒ Object
validations.
Methods inherited from Base
#initialize, #sign_params, #signed_params
Constructor Details
This class inherits a constructor from AppReport::API::Base
Instance Method Details
#build!(report) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/app_report/api/jasper.rb', line 25 def build! report @report = report validates_report! @report @report.validates! @params = @report.attributes path = '/api/v1/factory/jasper/build.json' response = AppReport::Client.post path, signed_params decode_report! response.body end |
#decode_report!(response_body) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/app_report/api/jasper.rb', line 39 def decode_report! response_body response_body = MultiJson.load response_body report = response_body['report'] if report.blank? raise AppReport::Errors::APIResponseError, "API returned a blank report!" end AppReport::Decoder.decode report['encoded'], report['encoding'] end |
#params_to_sign ⇒ Object
21 22 23 |
# File 'lib/app_report/api/jasper.rb', line 21 def params_to_sign [:app_name, :template_name, :expires] end |
#validates_report!(report) ⇒ Object
validations
52 53 54 55 56 57 |
# File 'lib/app_report/api/jasper.rb', line 52 def validates_report! report unless report.kind_of? AppReport::Report::Jasper error_msg = "report must be a instance of AppReport::Report::Jasper not #{report.class.name}" raise AppReport::Errors::ValidationError, error_msg end end |