Class: SolidusDrip::ShopperActivity::Product

Inherits:
Base
  • Object
show all
Defined in:
lib/solidus_drip/shopper_activity/product.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#client

Instance Method Summary collapse

Constructor Details

#initialize(variant) ⇒ Product

ShopperActivity::Product relies on Spree::Variant data to be useful. We call super to initialize the client and then we set the variant attribute to be used in the API calls.

Parameters:

  • variant (Spree::Variant)

    the variant to be recorded



15
16
17
18
# File 'lib/solidus_drip/shopper_activity/product.rb', line 15

def initialize(variant)
  super
  @variant = variant
end

Instance Attribute Details

#variantObject

Returns the value of attribute variant.



6
7
8
# File 'lib/solidus_drip/shopper_activity/product.rb', line 6

def variant
  @variant
end

Instance Method Details

#product_activity(action) ⇒ Object

Product Activity helps identify variant updates.

Parameters:

  • action (String)

    the product action, ‘created`, `updated`, or `deleted`

See Also:



26
27
28
29
30
31
# File 'lib/solidus_drip/shopper_activity/product.rb', line 26

def product_activity(action)
  response = client.create_product_activity_event(product_data(action))
  handle_error_response(response) if !response.success?

  response.success?
end