Class: ContentfulModel::Client

Inherits:
Contentful::Client
  • Object
show all
Defined in:
lib/contentful_model/client.rb

Overview

Wrapper for the CDA Client

Constant Summary collapse

PREVIEW_API_URL =
'preview.contentful.com'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ Client



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/contentful_model/client.rb', line 8

def initialize(configuration)
  configuration[:resource_mapping] = configuration.fetch(:resource_mapping, {}).merge(
    'Asset' => ContentfulModel::Asset
  )

  if ContentfulModel.use_preview_api
    configuration[:api_url] = PREVIEW_API_URL
    configuration[:access_token] = configuration[:preview_access_token]
  end
  super({
    raise_errors: true,
    dynamic_entries: :auto,
    integration_name: 'contentful_model',
    integration_version: ::ContentfulModel::VERSION
  }.merge(configuration))
end