Class: SolidusContent::Providers::Contentful

Inherits:
Object
  • Object
show all
Defined in:
lib/solidus_content/providers/contentful.rb

Class Method Summary collapse

Class Method Details

.call(input) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/solidus_content/providers/contentful.rb', line 7

def call(input)
  require 'contentful' unless defined?(::Contentful)

  type_options = input.dig(:type_options)

  client = ::Contentful::Client.new(
    space: type_options[:contentful_space_id],
    access_token: type_options[:contentful_access_token],
  )

  entry = client.entry(input.dig(:options, :entry_id))

  input.merge(
    data: entry.fields,
    provider_client: client,
    provider_entry: entry,
  )
end

.entry_fieldsObject



30
31
32
# File 'lib/solidus_content/providers/contentful.rb', line 30

def entry_fields
  %i[entry_id]
end

.entry_type_fieldsObject



26
27
28
# File 'lib/solidus_content/providers/contentful.rb', line 26

def entry_type_fields
  %i[contentful_space_id contentful_access_token]
end