Class: Barion::Item

Inherits:
ApplicationRecord show all
Includes:
JsonSerializer
Defined in:
app/models/barion/item.rb

Overview

Represents an item in a transaction for Barion engine

Instance Method Summary collapse

Methods included from JsonSerializer

#deserialize, #deserialize_options, #key_names, #process_response, #serializable_hash

Instance Method Details

#item_total=(value) ⇒ Object



73
74
75
76
# File 'app/models/barion/item.rb', line 73

def item_total=(value)
  value = calculate_total if value.nil?
  super(value)
end

#quantity=(value) ⇒ Object



68
69
70
71
# File 'app/models/barion/item.rb', line 68

def quantity=(value)
  super(value.to_d)
  calculate_total
end

#serialize_optionsObject



51
52
53
54
55
56
57
58
59
60
61
# File 'app/models/barion/item.rb', line 51

def serialize_options
  {
    except: %i[id updated_at created_at],
    map: {
      keys: {
        _all: :camelize,
        sku: 'SKU'
      }
    }
  }
end

#unit_price=(value) ⇒ Object



63
64
65
66
# File 'app/models/barion/item.rb', line 63

def unit_price=(value)
  super(value.to_d)
  calculate_total
end