![header](./.github/header.png)
# contentful.rb - Contentful Ruby Delivery SDK [![Gem Version](https://badge.fury.io/rb/contentful.png)](http://badge.fury.io/rb/contentful) > Ruby SDK for the Contentful [Content Delivery API](https://www.contentful.com/developers/docs/references/content-delivery-api/) and [Content Preview API](https://www.contentful.com/developers/docs/references/content-preview-api/). It helps you to easily access your Content stored in Contentful with your Ruby applications. **What is Contentful?** [Contentful](https://www.contentful.com/) provides content infrastructure for digital teams to power websites, apps, and devices. Unlike a CMS, Contentful was built to integrate with the modern software stack. It offers a central hub for structured content, powerful management and delivery APIs, and a customizable web app that enable developers and content creators to ship their products faster.Name | Default | Description |
---|---|---|
access_token |
Required. Your access token. | |
space |
Required. Your space ID. | |
environment |
'master' | Your environment ID. |
api_url |
'cdn.contentful.com' |
Set the host used to build the request URIs. |
default_locale |
'en-US' |
Defines default locale for the client. |
secure |
true |
Defines whether to use HTTPS or HTTP. By default we use HTTPS. |
authentication_mechanism |
:header |
Sets the authentication mechanisms, valid options are :header or :query_string |
raise_errors |
true |
Determines whether errors are raised or returned. |
raise_for_empty_fields |
true |
Determines whether EmptyFieldError is raised when empty fields are requested on an entry or nil is returned. |
dynamic_entries |
:manual |
Determines if content type caching is enabled automatically or not,
allowing for accessing of fields even when they are not present on the response.
Valid options are :auto and :manual .
|
raw_mode |
false |
If enabled, API responses are not parsed and the raw response object is returned instead. |
resource_mapping |
{} |
Allows for overriding default resource classes with custom ones. |
entry_mapping |
{} |
Allows for overriding of specific entry classes by content type. |
gzip_encoded |
true |
Enables gzip response content encoding. |
max_rate_limit_retries |
1 |
To increase or decrease the retry attempts after a 429 Rate Limit error. Default value is 1. Using 0 will disable retry behaviour.
Each retry will be attempted after the value (in seconds) of the X-Contentful-RateLimit-Reset header,
which contains the amount of seconds until the next non rate limited request is available, has passed.
This is blocking per execution thread.
|
max_rate_limit_wait |
60 |
Maximum time to wait for next available request (in seconds). Default value is 60 seconds. Keep in mind that if you hit the hourly rate limit maximum, you can have up to 60 minutes of blocked requests. It is set to a default of 60 seconds in order to avoid blocking processes for too long, as rate limit retry behaviour is blocking per execution thread. |
max_include_resolution_depth |
20 |
Maximum amount of levels to resolve includes for SDK entities
(this is independent of API-level includes - it represents the maximum depth the include resolution
tree is allowed to resolved before falling back to Link objects).
This include resolution strategy is in place in order to avoid having infinite circular recursion on resources with circular dependencies.
Note: If you're using something like Rails::cache it's advisable to considerably lower this value
(around 5 has proven to be a good compromise - but keep it higher or equal than your maximum API-level include parameter if you need the entire tree resolution).
Note that when reuse_entries is enabled, the max include resolution depth only affects
deep chains of unique objects (ie, not simple circular references).
|
reuse_entries |
false |
When enabled, reuse hydrated Entry and Asset objects within the same request when possible.
Can result in a large speed increase and better handles cyclical object graphs.
This can be a good alternative to max_include_resolution_depth if your content model contains (or can contain) circular references.
Caching may break if this option is enabled, as it may generate stack errors.
When caching, deactivate this option and opt for a conservative max_include_resolution_depth value.
|
use_camel_case |
false |
When doing the v2 upgrade, all keys and accessors were changed to always use snake_case .
This option introduces the ability to use camelCase for keys and method accessors.
This is very useful for isomorphic applications.
|
proxy_host |
nil |
To be able to perform a request behind a proxy, this needs to be set. It can be a domain or IP address of the proxy server. |
proxy_port |
nil |
Specify the port number that is used by the proxy server for client connections. |
proxy_username |
nil |
Username for proxy authentication. |
proxy_password |
nil |
Password for proxy authentication. |
timeout_read |
nil |
Number of seconds the request waits to read from the server before timing out. |
timeout_write |
nil |
Number of seconds the request waits when writing to the server before timing out. |
timeout_connect |
nil |
Number of seconds the request waits to connect to the server before timing out. |
logger |
nil |
To enable logging pass a logger instance compatible with ::Logger . |
log_level |
::Logger::INFO |
The default severity is set to INFO and logs only the request attributes (headers, parameters and url). Setting it to DEBUG will also log the raw JSON response. |