Class: MedicalCopays::VBS::RequestData
- Inherits:
-
Object
- Object
- MedicalCopays::VBS::RequestData
- Defined in:
- app/services/medical_copays/vbs/request_data.rb
Overview
Object for handling VBS request parameters
Constant Summary collapse
- MOCK_VISTA_ACCOUNT_NUMBERS =
[5_160_000_000_012_345].freeze
Instance Attribute Summary collapse
- #edipi ⇒ String
- #errors ⇒ Array
- #user ⇒ User
- #vha_facility_hash ⇒ Hash
-
#vista_account_numbers ⇒ Object
readonly
Returns the value of attribute vista_account_numbers.
Class Method Summary collapse
-
.build(opts = {}) ⇒ RequestData
Builds a RequestData instance.
-
.schema_validation_options ⇒ Hash
The options to be passed to JSON::Validator#fully_validate.
-
.statements_schema ⇒ Hash
The schema for validating attribute data.
Instance Method Summary collapse
-
#initialize(opts) ⇒ RequestData
constructor
A new instance of RequestData.
-
#to_hash ⇒ Hash
The data to be posted to VBS.
-
#valid? ⇒ Boolean
Determine if the instance is valid based upon attribute data.
Constructor Details
#initialize(opts) ⇒ RequestData
Returns a new instance of RequestData.
70 71 72 73 74 75 76 |
# File 'app/services/medical_copays/vbs/request_data.rb', line 70 def initialize(opts) @user = opts[:user] @edipi = user.edipi @vha_facility_hash = user.vha_facility_hash @vista_account_numbers = MedicalCopays::VistaAccountNumbers.build(data: vha_facility_hash, user: @user) @errors = [] end |
Instance Attribute Details
#edipi ⇒ String
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'app/services/medical_copays/vbs/request_data.rb', line 16 class RequestData MOCK_VISTA_ACCOUNT_NUMBERS = [5_160_000_000_012_345].freeze attr_reader :user, :edipi, :vha_facility_hash, :vista_account_numbers attr_accessor :errors ## # Builds a RequestData instance # # @param opts [Hash] # @return [RequestData] an instance of this class # def self.build(opts = {}) new(opts) end ## # The schema for validating attribute data # # @return [Hash] # def self.statements_schema { 'type' => 'object', 'additionalProperties' => false, 'required' => %w[edipi vistaAccountNumbers], 'properties' => { 'edipi' => { 'type' => 'string' }, 'vistaAccountNumbers' => { 'type' => 'array', 'items' => { 'type' => 'integer', 'minLength' => 16, 'maxLength' => 16 } } } } end ## # The options to be passed to {JSON::Validator#fully_validate} # # @return [Hash] # def self. { errors_as_objects: true, version: :draft6 } end def initialize(opts) @user = opts[:user] @edipi = user.edipi @vha_facility_hash = user.vha_facility_hash @vista_account_numbers = MedicalCopays::VistaAccountNumbers.build(data: vha_facility_hash, user: @user) @errors = [] end ## # The data to be posted to VBS # # @return [Hash] # def to_hash { 'edipi' => edipi, 'vistaAccountNumbers' => Settings.mcp.vbs.mock_vista ? MOCK_VISTA_ACCOUNT_NUMBERS : vista_account_numbers.list } end ## # Determine if the instance is valid based upon attribute data # # @return [Boolean] # def valid? errors = JSON::Validator.fully_validate( self.class.statements_schema, to_hash, self.class. ) errors.blank? end end |
#errors ⇒ Array
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'app/services/medical_copays/vbs/request_data.rb', line 16 class RequestData MOCK_VISTA_ACCOUNT_NUMBERS = [5_160_000_000_012_345].freeze attr_reader :user, :edipi, :vha_facility_hash, :vista_account_numbers attr_accessor :errors ## # Builds a RequestData instance # # @param opts [Hash] # @return [RequestData] an instance of this class # def self.build(opts = {}) new(opts) end ## # The schema for validating attribute data # # @return [Hash] # def self.statements_schema { 'type' => 'object', 'additionalProperties' => false, 'required' => %w[edipi vistaAccountNumbers], 'properties' => { 'edipi' => { 'type' => 'string' }, 'vistaAccountNumbers' => { 'type' => 'array', 'items' => { 'type' => 'integer', 'minLength' => 16, 'maxLength' => 16 } } } } end ## # The options to be passed to {JSON::Validator#fully_validate} # # @return [Hash] # def self. { errors_as_objects: true, version: :draft6 } end def initialize(opts) @user = opts[:user] @edipi = user.edipi @vha_facility_hash = user.vha_facility_hash @vista_account_numbers = MedicalCopays::VistaAccountNumbers.build(data: vha_facility_hash, user: @user) @errors = [] end ## # The data to be posted to VBS # # @return [Hash] # def to_hash { 'edipi' => edipi, 'vistaAccountNumbers' => Settings.mcp.vbs.mock_vista ? MOCK_VISTA_ACCOUNT_NUMBERS : vista_account_numbers.list } end ## # Determine if the instance is valid based upon attribute data # # @return [Boolean] # def valid? errors = JSON::Validator.fully_validate( self.class.statements_schema, to_hash, self.class. ) errors.blank? end end |
#user ⇒ User
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'app/services/medical_copays/vbs/request_data.rb', line 16 class RequestData MOCK_VISTA_ACCOUNT_NUMBERS = [5_160_000_000_012_345].freeze attr_reader :user, :edipi, :vha_facility_hash, :vista_account_numbers attr_accessor :errors ## # Builds a RequestData instance # # @param opts [Hash] # @return [RequestData] an instance of this class # def self.build(opts = {}) new(opts) end ## # The schema for validating attribute data # # @return [Hash] # def self.statements_schema { 'type' => 'object', 'additionalProperties' => false, 'required' => %w[edipi vistaAccountNumbers], 'properties' => { 'edipi' => { 'type' => 'string' }, 'vistaAccountNumbers' => { 'type' => 'array', 'items' => { 'type' => 'integer', 'minLength' => 16, 'maxLength' => 16 } } } } end ## # The options to be passed to {JSON::Validator#fully_validate} # # @return [Hash] # def self. { errors_as_objects: true, version: :draft6 } end def initialize(opts) @user = opts[:user] @edipi = user.edipi @vha_facility_hash = user.vha_facility_hash @vista_account_numbers = MedicalCopays::VistaAccountNumbers.build(data: vha_facility_hash, user: @user) @errors = [] end ## # The data to be posted to VBS # # @return [Hash] # def to_hash { 'edipi' => edipi, 'vistaAccountNumbers' => Settings.mcp.vbs.mock_vista ? MOCK_VISTA_ACCOUNT_NUMBERS : vista_account_numbers.list } end ## # Determine if the instance is valid based upon attribute data # # @return [Boolean] # def valid? errors = JSON::Validator.fully_validate( self.class.statements_schema, to_hash, self.class. ) errors.blank? end end |
#vha_facility_hash ⇒ Hash
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'app/services/medical_copays/vbs/request_data.rb', line 16 class RequestData MOCK_VISTA_ACCOUNT_NUMBERS = [5_160_000_000_012_345].freeze attr_reader :user, :edipi, :vha_facility_hash, :vista_account_numbers attr_accessor :errors ## # Builds a RequestData instance # # @param opts [Hash] # @return [RequestData] an instance of this class # def self.build(opts = {}) new(opts) end ## # The schema for validating attribute data # # @return [Hash] # def self.statements_schema { 'type' => 'object', 'additionalProperties' => false, 'required' => %w[edipi vistaAccountNumbers], 'properties' => { 'edipi' => { 'type' => 'string' }, 'vistaAccountNumbers' => { 'type' => 'array', 'items' => { 'type' => 'integer', 'minLength' => 16, 'maxLength' => 16 } } } } end ## # The options to be passed to {JSON::Validator#fully_validate} # # @return [Hash] # def self. { errors_as_objects: true, version: :draft6 } end def initialize(opts) @user = opts[:user] @edipi = user.edipi @vha_facility_hash = user.vha_facility_hash @vista_account_numbers = MedicalCopays::VistaAccountNumbers.build(data: vha_facility_hash, user: @user) @errors = [] end ## # The data to be posted to VBS # # @return [Hash] # def to_hash { 'edipi' => edipi, 'vistaAccountNumbers' => Settings.mcp.vbs.mock_vista ? MOCK_VISTA_ACCOUNT_NUMBERS : vista_account_numbers.list } end ## # Determine if the instance is valid based upon attribute data # # @return [Boolean] # def valid? errors = JSON::Validator.fully_validate( self.class.statements_schema, to_hash, self.class. ) errors.blank? end end |
#vista_account_numbers ⇒ Object (readonly)
Returns the value of attribute vista_account_numbers.
19 20 21 |
# File 'app/services/medical_copays/vbs/request_data.rb', line 19 def vista_account_numbers @vista_account_numbers end |
Class Method Details
.build(opts = {}) ⇒ RequestData
Builds a RequestData instance
28 29 30 |
# File 'app/services/medical_copays/vbs/request_data.rb', line 28 def self.build(opts = {}) new(opts) end |
.schema_validation_options ⇒ Hash
The options to be passed to JSON::Validator#fully_validate
63 64 65 66 67 68 |
# File 'app/services/medical_copays/vbs/request_data.rb', line 63 def self. { errors_as_objects: true, version: :draft6 } end |
.statements_schema ⇒ Hash
The schema for validating attribute data
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/services/medical_copays/vbs/request_data.rb', line 37 def self.statements_schema { 'type' => 'object', 'additionalProperties' => false, 'required' => %w[edipi vistaAccountNumbers], 'properties' => { 'edipi' => { 'type' => 'string' }, 'vistaAccountNumbers' => { 'type' => 'array', 'items' => { 'type' => 'integer', 'minLength' => 16, 'maxLength' => 16 } } } } end |
Instance Method Details
#to_hash ⇒ Hash
The data to be posted to VBS
83 84 85 86 87 88 |
# File 'app/services/medical_copays/vbs/request_data.rb', line 83 def to_hash { 'edipi' => edipi, 'vistaAccountNumbers' => Settings.mcp.vbs.mock_vista ? MOCK_VISTA_ACCOUNT_NUMBERS : vista_account_numbers.list } end |
#valid? ⇒ Boolean
Determine if the instance is valid based upon attribute data
95 96 97 98 99 100 101 102 103 |
# File 'app/services/medical_copays/vbs/request_data.rb', line 95 def valid? errors = JSON::Validator.fully_validate( self.class.statements_schema, to_hash, self.class. ) errors.blank? end |