6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'app/services/spree/seeds/api_keys.rb', line 6
def call
Spree::Store.find_each do |store|
unless store.api_keys.active.publishable.where(channel_id: nil).exists?
store.api_keys.create!(name: 'Default', key_type: 'publishable')
end
wholesale = store.channels.find_by(code: Channels::WHOLESALE_CODE)
if wholesale && !store.api_keys.active.publishable.where(channel: wholesale).exists?
store.api_keys.create!(name: 'Storefront (Wholesale)', key_type: 'publishable', channel: wholesale)
end
end
end
|