Class: Atol::Request::PostDocument::Item::Body
- Inherits:
-
Object
- Object
- Atol::Request::PostDocument::Item::Body
- Defined in:
- lib/atol/request/post_document/item/body.rb
Constant Summary collapse
- BadPaymentMethodError =
Class.new(StandardError)
- BadPaymentObjectError =
Class.new(StandardError)
- PAYMENT_METHODS =
[ 'full_prepayment', 'prepayment', 'advance', 'full_payment', 'partial_payment', 'credit', 'credit_payment' ]
- PAYMENT_OBJECTS =
[ 'commodity', 'excise', 'job', 'service', 'gambling_bet', 'gambling_prize', 'lottery', 'lottery_prize', 'intellectual_activity', 'payment', 'agent_commission', 'composite', 'another' ]
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#name ⇒ Object
Returns the value of attribute name.
-
#payment_method ⇒ Object
Returns the value of attribute payment_method.
-
#payment_object ⇒ Object
Returns the value of attribute payment_object.
-
#price ⇒ Object
Returns the value of attribute price.
-
#quantity ⇒ Object
Returns the value of attribute quantity.
Instance Method Summary collapse
-
#initialize(config: nil, name:, price:, quantity: 1, payment_method:, payment_object:) ⇒ Body
constructor
A new instance of Body.
- #to_h ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(config: nil, name:, price:, quantity: 1, payment_method:, payment_object:) ⇒ Body
Returns a new instance of Body.
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/atol/request/post_document/item/body.rb', line 26 def initialize(config: nil, name:, price:, quantity: 1, payment_method:, payment_object:) raise Atol::ZeroItemQuantityError if quantity.to_i.zero? raise BadPaymentMethodError unless PAYMENT_METHODS.include?(payment_method.to_s) raise BadPaymentObjectError unless PAYMENT_OBJECTS.include?(payment_object.to_s) self.config = config || Atol.config self.name = name self.price = price.to_f self.quantity = quantity.to_f self.payment_method = payment_method.to_s self.payment_object = payment_object.to_s end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
24 25 26 |
# File 'lib/atol/request/post_document/item/body.rb', line 24 def config @config end |
#name ⇒ Object
Returns the value of attribute name.
24 25 26 |
# File 'lib/atol/request/post_document/item/body.rb', line 24 def name @name end |
#payment_method ⇒ Object
Returns the value of attribute payment_method.
24 25 26 |
# File 'lib/atol/request/post_document/item/body.rb', line 24 def payment_method @payment_method end |
#payment_object ⇒ Object
Returns the value of attribute payment_object.
24 25 26 |
# File 'lib/atol/request/post_document/item/body.rb', line 24 def payment_object @payment_object end |
#price ⇒ Object
Returns the value of attribute price.
24 25 26 |
# File 'lib/atol/request/post_document/item/body.rb', line 24 def price @price end |
#quantity ⇒ Object
Returns the value of attribute quantity.
24 25 26 |
# File 'lib/atol/request/post_document/item/body.rb', line 24 def quantity @quantity end |
Instance Method Details
#to_h ⇒ Object
39 40 41 |
# File 'lib/atol/request/post_document/item/body.rb', line 39 def to_h body.clone end |
#to_json ⇒ Object
43 44 45 |
# File 'lib/atol/request/post_document/item/body.rb', line 43 def to_json body.to_json end |