Class: CardConnect::Service::RefundRequest
- Inherits:
-
Object
- Object
- CardConnect::Service::RefundRequest
- Includes:
- Utils
- Defined in:
- lib/cardconnect/services/refund/refund_request.rb
Constant Summary collapse
- REQUIRED_FIELDS =
[:merchid, :retref].freeze
- OPTIONAL_FIELDS =
[:amount].freeze
- FIELDS =
REQUIRED_FIELDS + OPTIONAL_FIELDS
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
-
#initialize(attrs = {}) ⇒ Object
constructor
Initializes a new Refund Request.
-
#payload ⇒ Object
Builds the request payload.
-
#valid? ⇒ Boolean
Indicates that the request is valid once it is built.
Methods included from Utils
#set_attributes, #symbolize_keys
Constructor Details
#initialize(attrs = {}) ⇒ Object
Initializes a new Refund Request
19 20 21 22 23 |
# File 'lib/cardconnect/services/refund/refund_request.rb', line 19 def initialize(attrs = {}) @errors = [] set_attributes(attrs, FIELDS) validate_required_fields end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
13 14 15 |
# File 'lib/cardconnect/services/refund/refund_request.rb', line 13 def errors @errors end |
Instance Method Details
#payload ⇒ Object
Builds the request payload
31 32 33 34 35 36 37 |
# File 'lib/cardconnect/services/refund/refund_request.rb', line 31 def payload payload = {} FIELDS.each do |field| payload.merge!(field => send(field)) end payload end |
#valid? ⇒ Boolean
Indicates that the request is valid once it is built.
26 27 28 |
# File 'lib/cardconnect/services/refund/refund_request.rb', line 26 def valid? errors.empty? end |