Class: FlowcommerceSpree::Webhooks::ExperienceUpsertedV2

Inherits:
Object
  • Object
show all
Defined in:
app/services/flowcommerce_spree/webhooks/experience_upserted_v2.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, opts = {}) ⇒ ExperienceUpsertedV2

Returns a new instance of ExperienceUpsertedV2.



13
14
15
16
17
# File 'app/services/flowcommerce_spree/webhooks/experience_upserted_v2.rb', line 13

def initialize(data, opts = {})
  @data = data
  @opts = opts
  @errors = []
end

Instance Attribute Details

#errorsObject Also known as: full_messages

Returns the value of attribute errors.



6
7
8
# File 'app/services/flowcommerce_spree/webhooks/experience_upserted_v2.rb', line 6

def errors
  @errors
end

Class Method Details

.process(data, opts = {}) ⇒ Object



9
10
11
# File 'app/services/flowcommerce_spree/webhooks/experience_upserted_v2.rb', line 9

def self.process(data, opts = {})
  new(data, opts).process
end

Instance Method Details

#processObject



19
20
21
22
# File 'app/services/flowcommerce_spree/webhooks/experience_upserted_v2.rb', line 19

def process
  experience = @data['experience']
  Spree::Zones::Product.find_or_initialize_by(name: experience['key'].titleize).store_flow_io_data(experience)
end