Class: SpreeKlaviyo::BackInStockSubscriptionPresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/spree_klaviyo/back_in_stock_subscription_presenter.rb

Instance Method Summary collapse

Constructor Details

#initialize(email:, variant_id:) ⇒ BackInStockSubscriptionPresenter

Returns a new instance of BackInStockSubscriptionPresenter.



3
4
5
6
# File 'app/presenters/spree_klaviyo/back_in_stock_subscription_presenter.rb', line 3

def initialize(email:, variant_id:)
  @email = email
  @variant_id = variant_id
end

Instance Method Details

#callObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/presenters/spree_klaviyo/back_in_stock_subscription_presenter.rb', line 8

def call
  {
    data: {
      type: 'back-in-stock-subscription',
      attributes: {
        channels: %w[EMAIL],
        profile: {
          data: {
            type: 'profile',
            attributes: {
              email: email
            }
          }
        }
      },
      relationships: {
        variant: {
          data: {
            type: 'catalog-variant',
            id: "$custom:::$default:::#{variant_id}"
          }
        }
      }
    }
  }
end