Class: C2eCore::Drops::CustomerDrop
- Inherits:
-
Liquid::Drop
- Object
- Liquid::Drop
- C2eCore::Drops::CustomerDrop
- Defined in:
- /build/app/mailers/c2e_core/drops/customer_drop.rb
Instance Method Summary collapse
-
#address ⇒ AddressDrop
-
Default address of customer as drop object.
-
-
#first_name ⇒ String
-
First name of customer.
-
-
#initialize(order) ⇒ CustomerDrop
constructor
A new instance of CustomerDrop.
-
#last_name ⇒ String
-
Last name of customer.
-
-
#orders_count ⇒ Integer
-
Orders count of customer in moment of finishing order.
-
-
#phone ⇒ String
-
Default formatted phone number of customer.
-
-
#unsubscribe_url ⇒ String
-
URL pointing to speedlo.cz/unsubscribe?token=ASDF.…
-
Constructor Details
#initialize(order) ⇒ CustomerDrop
Returns a new instance of CustomerDrop.
7 8 9 10 11 |
# File '/build/app/mailers/c2e_core/drops/customer_drop.rb', line 7 def initialize(order) super() @order = order @presenter = C2eCore::CustomerJsonPresenter.new(order.customer_json) end |
Instance Method Details
#address ⇒ AddressDrop
Returns - Default address of customer as drop object.
37 38 39 |
# File '/build/app/mailers/c2e_core/drops/customer_drop.rb', line 37 def address AddressDrop.new(@order.address, @order.gps) end |
#first_name ⇒ String
Returns - First name of customer. E.g.: “Tomáš”.
14 15 16 |
# File '/build/app/mailers/c2e_core/drops/customer_drop.rb', line 14 def first_name @presenter.first_name end |
#last_name ⇒ String
Returns - Last name of customer. E.g.: “Jedno”.
19 20 21 |
# File '/build/app/mailers/c2e_core/drops/customer_drop.rb', line 19 def last_name @presenter.last_name end |
#orders_count ⇒ Integer
Returns - Orders count of customer in moment of finishing order. E.g.: 42.
32 33 34 |
# File '/build/app/mailers/c2e_core/drops/customer_drop.rb', line 32 def orders_count @order.current_orders_count end |
#phone ⇒ String
Returns - Default formatted phone number of customer. If formatting is not possible, returns raw phone from DB. E.g.: “+420 987 654 321” or “+420987654321”.
25 26 27 28 29 |
# File '/build/app/mailers/c2e_core/drops/customer_drop.rb', line 25 def phone Phony.format!(@presenter.default_phone&.gsub("+", "")).to_s rescue Phony::FormattingError @presenter.default_phone end |
#unsubscribe_url ⇒ String
Returns - URL pointing to speedlo.cz/unsubscribe?token=ASDF.…
42 43 44 45 |
# File '/build/app/mailers/c2e_core/drops/customer_drop.rb', line 42 def unsubscribe_url C2eCore::Users::MarketingService.new(customer_id: @order.customer_id, company_branch_id: @order.company_branch_id) .unsubscribe_url end |