Class: Atol::Request::PostDocument::Sell::Body
- Inherits:
-
Object
- Object
- Atol::Request::PostDocument::Sell::Body
- Defined in:
- lib/atol/request/post_document/sell/body.rb
Instance Method Summary collapse
-
#initialize(external_id:, phone: '', email: '', items:, payments: nil, config: nil, **options) ⇒ Body
constructor
A new instance of Body.
- #to_h ⇒ Object
- #to_json(*_args) ⇒ Object
Constructor Details
#initialize(external_id:, phone: '', email: '', items:, payments: nil, config: nil, **options) ⇒ Body
Returns a new instance of Body.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/atol/request/post_document/sell/body.rb', line 11 def initialize(external_id:, phone: '', email: '', items:, payments: nil, config: nil, **) raise(Atol::EmptyClientContactError) if phone.empty? && email.empty? raise(Atol::EmptySellItemsError) if items.empty? total = items.sum { |item| item[:sum] } validate_payments!(payments, total) @config = config || Atol.config @external_id = external_id @phone = phone @email = email @items = items @total = total @payments = payments end |
Instance Method Details
#to_h ⇒ Object
27 28 29 |
# File 'lib/atol/request/post_document/sell/body.rb', line 27 def to_h build_body.clone end |
#to_json(*_args) ⇒ Object
31 32 33 |
# File 'lib/atol/request/post_document/sell/body.rb', line 31 def to_json(*_args) build_body.to_json end |