Class: C2eCore::Drops::CustomerDrop

Inherits:
Liquid::Drop
  • Object
show all
Defined in:
/build/app/mailers/c2e_core/drops/customer_drop.rb

Instance Method Summary collapse

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

#addressAddressDrop

Returns - Default address of customer as drop object.

Returns:

  • (AddressDrop)
    • 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_nameString

Returns - First name of customer. E.g.: “Tomáš”.

Returns:

  • (String)
    • 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_nameString

Returns - Last name of customer. E.g.: “Jedno”.

Returns:

  • (String)
    • 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_countInteger

Returns - Orders count of customer in moment of finishing order. E.g.: 42.

Returns:

  • (Integer)
    • 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

#phoneString

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”.

Returns:

  • (String)
    • 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_urlString

Returns - URL pointing to speedlo.cz/unsubscribe?token=ASDF.…

Returns:



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