Class: Caseflow::Responses::Caseflow
- Inherits:
-
Common::Base
- Object
- Common::Base
- Caseflow::Responses::Caseflow
- Defined in:
- lib/caseflow/responses/caseflow.rb
Overview
Model for a caseflow’ responses. Body is passed straight through from caseflow with a validation check that it matches the expected schema.
Instance Attribute Summary collapse
-
#body ⇒ Integer
Validated response body.
-
#status ⇒ Integer
The HTTP status code.
Attributes inherited from Common::Base
Instance Method Summary collapse
-
#initialize(body, status) ⇒ Caseflow
constructor
A new instance of Caseflow.
Methods inherited from Common::Base
#changed, #changed?, #changes, default_sort, filterable_attributes, max_per_page, per_page, sortable_attributes
Constructor Details
#initialize(body, status) ⇒ Caseflow
Returns a new instance of Caseflow.
23 24 25 26 |
# File 'lib/caseflow/responses/caseflow.rb', line 23 def initialize(body, status) self.body = body if json_format_is_valid?(body) self.status = status end |
Instance Attribute Details
#body ⇒ Integer
Returns Validated response body.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/caseflow/responses/caseflow.rb', line 19 class Caseflow < Common::Base attribute :body, String attribute :status, Integer def initialize(body, status) self.body = body if json_format_is_valid?(body) self.status = status end private def json_format_is_valid?(body) schema_path = Rails.root.join('lib', 'caseflow', 'schema', 'appeals.json').to_s JSON::Validator.validate!(schema_path, body, strict: false) end end |
#status ⇒ Integer
Returns The HTTP status code.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/caseflow/responses/caseflow.rb', line 19 class Caseflow < Common::Base attribute :body, String attribute :status, Integer def initialize(body, status) self.body = body if json_format_is_valid?(body) self.status = status end private def json_format_is_valid?(body) schema_path = Rails.root.join('lib', 'caseflow', 'schema', 'appeals.json').to_s JSON::Validator.validate!(schema_path, body, strict: false) end end |