doc/index.html in contentful-2.8.0 vs doc/index.html in contentful-2.8.1

- old
+ new

@@ -4,11 +4,11 @@ <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title> File: README - &mdash; Documentation by YARD 0.9.9 + &mdash; Documentation by YARD 0.9.12 </title> <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" /> @@ -56,75 +56,481 @@ </div> <div class="clear"></div> </div> <div id="content"><div id='filecontents'> -<h1 id="label-contentful.rb">contentful.rb</h1> +<p><img src="./.github/header.png"> &lt;p align=“center”&gt; &lt;a href=“<a +href="https://www.contentful.com/slack">www.contentful.com/slack</a>/”&gt; +&lt;img src=“<a +href="https://img.shields.io/badge/-Join%20Community%20Slack-2AB27B.svg?logo=slack&maxAge=31557600">img.shields.io/badge/-Join%20Community%20Slack-2AB27B.svg?logo=slack&maxAge=31557600</a>” +alt=“Join Contentful Community Slack”&gt; &lt;/a&gt;   &lt;a href=“<a +href="https://www.contentfulcommunity.com">www.contentfulcommunity.com</a>/”&gt; +&lt;img src=“<a +href="https://img.shields.io/badge/-Join%20Community%20Forum-3AB2E6.svg?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MiA1OSI+CiAgPHBhdGggZmlsbD0iI0Y4RTQxOCIgZD0iTTE4IDQxYTE2IDE2IDAgMCAxIDAtMjMgNiA2IDAgMCAwLTktOSAyOSAyOSAwIDAgMCAwIDQxIDYgNiAwIDEgMCA5LTkiIG1hc2s9InVybCgjYikiLz4KICA8cGF0aCBmaWxsPSIjNTZBRUQyIiBkPSJNMTggMThhMTYgMTYgMCAwIDEgMjMgMCA2IDYgMCAxIDAgOS05QTI5IDI5IDAgMCAwIDkgOWE2IDYgMCAwIDAgOSA5Ii8+CiAgPHBhdGggZmlsbD0iI0UwNTM0RSIgZD0iTTQxIDQxYTE2IDE2IDAgMCAxLTIzIDAgNiA2IDAgMSAwLTkgOSAyOSAyOSAwIDAgMCA0MSAwIDYgNiAwIDAgMC05LTkiLz4KICA8cGF0aCBmaWxsPSIjMUQ3OEE0IiBkPSJNMTggMThhNiA2IDAgMSAxLTktOSA2IDYgMCAwIDEgOSA5Ii8+CiAgPHBhdGggZmlsbD0iI0JFNDMzQiIgZD0iTTE4IDUwYTYgNiAwIDEgMS05LTkgNiA2IDAgMCAxIDkgOSIvPgo8L3N2Zz4K&maxAge=31557600">img.shields.io/badge/-Join%20Community%20Forum-3AB2E6.svg?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MiA1OSI+CiAgPHBhdGggZmlsbD0iI0Y4RTQxOCIgZD0iTTE4IDQxYTE2IDE2IDAgMCAxIDAtMjMgNiA2IDAgMCAwLTktOSAyOSAyOSAwIDAgMCAwIDQxIDYgNiAwIDEgMCA5LTkiIG1hc2s9InVybCgjYikiLz4KICA8cGF0aCBmaWxsPSIjNTZBRUQyIiBkPSJNMTggMThhMTYgMTYgMCAwIDEgMjMgMCA2IDYgMCAxIDAgOS05QTI5IDI5IDAgMCAwIDkgOWE2IDYgMCAwIDAgOSA5Ii8+CiAgPHBhdGggZmlsbD0iI0UwNTM0RSIgZD0iTTQxIDQxYTE2IDE2IDAgMCAxLTIzIDAgNiA2IDAgMSAwLTkgOSAyOSAyOSAwIDAgMCA0MSAwIDYgNiAwIDAgMC05LTkiLz4KICA8cGF0aCBmaWxsPSIjMUQ3OEE0IiBkPSJNMTggMThhNiA2IDAgMSAxLTktOSA2IDYgMCAwIDEgOSA5Ii8+CiAgPHBhdGggZmlsbD0iI0JFNDMzQiIgZD0iTTE4IDUwYTYgNiAwIDEgMS05LTkgNiA2IDAgMCAxIDkgOSIvPgo8L3N2Zz4K&maxAge=31557600</a>” +alt=“Join Contentful Community Forum”&gt; &lt;/a&gt; &lt;/p&gt;</p> +<h1 id="label-contentful.rb+-+Contentful+Ruby+Delivery+SDK">contentful.rb - Contentful Ruby Delivery SDK</h1> + <p><a href="http://badge.fury.io/rb/contentful"><img -src="https://badge.fury.io/rb/contentful.png"></a> <a -href="https://travis-ci.org/contentful/contentful.rb"><img -src="https://travis-ci.org/contentful/contentful.rb.png"></a></p> +src="https://badge.fury.io/rb/contentful.png"></a></p> -<p>Ruby client for the <a href="https://www.contentful.com">Contentful</a> -Content Delivery API.</p> +<blockquote> +<p>Ruby SDK for the Contentful <a +href="https://www.contentful.com/developers/docs/references/content-delivery-api/">Content +Delivery API</a> and <a +href="https://www.contentful.com/developers/docs/references/content-preview-api/">Content +Preview API</a>. It helps you to easily access your Content stored in +Contentful with your Ruby applications.</p> +</blockquote> +<p align="center"> + <img src="https://img.shields.io/badge/Status-Maintained-green.svg" alt="This repository is actively maintained" /> &nbsp; + <a href="LICENSE.txt"> + <img src="https://img.shields.io/badge/license-MIT-brightgreen.svg" alt="MIT License" /> + </a> + &nbsp; + <a href="https://travis-ci.org/contentful/contentful.rb"> + <img src="https://travis-ci.org/contentful/contentful.rb.svg?branch=master" alt="Build Status"> + </a> +</p><p align="center"> + <a href="https://rubygems.org/gems/contentful"> + <img src="https://img.shields.io/gem/v/contentful.svg" alt="RubyGems version"> + </a> + &nbsp; + <a href="https://rubygems.org/gems/contentful"> + <img src="https://img.shields.io/gem/dt/contentful.svg" alt="RubyGems downloads"> + </a> +</p> +<p><strong>What is Contentful?</strong></p> -<p><a href="https://www.contentful.com">Contentful</a> provides a content -infrastructure for digital teams to power content in 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 digital products faster.</p> +<p><a href="https://www.contentful.com/">Contentful</a> 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.</p> -<h2 id="label-Setup">Setup</h2> +<p>&lt;details&gt; &lt;summary&gt;Table of contents&lt;/summary&gt;</p> +<!-- TOC --><ul><li> +<p><a href="#contentfulrb---contentful-ruby-delivery-sdk">contentful.rb - +Contentful Ruby Delivery SDK</a></p> +</li><li> +<p><a href="#core-features">Core Features</a></p> +</li><li> +<p><a href="#getting-started">Getting started</a></p> +<ul><li> +<p><a href="#installation">Installation</a></p> +</li><li> +<p><a href="#your-first-request">Your first request</a></p> +</li><li> +<p><a href="#using-this-sdk-with-the-preview-api">Using this SDK with the +Preview API</a></p> +</li><li> +<p><a href="#authentication">Authentication</a></p> +</li></ul> +</li><li> +<p><a href="#documentation--references">Documentation & References</a></p> +<ul><li> +<p><a href="#configuration">Configuration</a></p> +</li><li> +<p><a href="#reference-documentation">Reference documentation</a></p> +</li><li> +<p><a href="#basic-queries">Basic queries</a></p> +</li><li> +<p><a href="#filtering-options">Filtering options</a></p> +</li><li> +<p><a href="#accessing-fields-and-sys-properties">Accessing fields and sys +properties</a></p> +</li><li> +<p><a href="#dynamic-entries">Dynamic entries</a></p> +</li><li> +<p><a href="#using-different-locales">Using different locales</a></p> +</li><li> +<p><a href="#arrays">Arrays</a></p> +</li><li> +<p><a href="#links">Links</a></p> +</li><li> +<p><a href="#assets">Assets</a></p> +</li><li> +<p><a href="#resource-options">Resource options</a></p> +</li><li> +<p><a href="#field-type-object">Field type Object</a></p> +</li><li> +<p><a href="#advanced-concepts">Advanced concepts</a></p> +</li><li> +<p><a href="#proxy-example">Proxy example</a></p> +</li><li> +<p><a href="#custom-resource-classes">Custom resource classes</a></p> +</li><li> +<p><a href="#synchronization">Synchronization</a></p> +</li><li> +<p><a href="#migrating-to-2x">Migrating to 2.x</a></p> +</li><li> +<p><a href="#tutorials--other-resources">Tutorials & other resources</a></p> +</li></ul> +</li><li> +<p><a href="#reach-out-to-us">Reach out to us</a></p> +<ul><li> +<p><a href="#you-have-questions-about-how-to-use-this-library">You have +questions about how to use this library?</a></p> +</li><li> +<p><a href="#you-found-a-bug-or-want-to-propose-a-feature">You found a bug or +want to propose a feature?</a></p> +</li><li> +<p><a +href="#you-need-to-share-confidential-information-or-have-other-questions">You +need to share confidential information or have other questions?</a></p> +</li></ul> +</li><li> +<p><a href="#get-involved">Get involved</a></p> +</li><li> +<p><a href="#license">License</a></p> +</li><li> +<p><a href="#code-of-conduct">Code of Conduct</a></p> +</li></ul> +<!-- /TOC --> +<p>&lt;/details&gt;</p> +<h2 id="label-Core+Features">Core Features</h2> +<ul><li> +<p>Content retrieval through <a +href="https://www.contentful.com/developers/docs/references/content-delivery-api/">Content +Delivery API</a> and <a +href="https://www.contentful.com/developers/docs/references/content-preview-api/">Content +Preview API</a>.</p> +</li><li> +<p><a +href="https://www.contentful.com/developers/docs/concepts/sync/">Synchronization</a></p> +</li><li> +<p><a +href="https://www.contentful.com/developers/docs/concepts/locales/">Localization +support</a></p> +</li><li> +<p><a href="https://www.contentful.com/developers/docs/concepts/links/">Link +resolution</a></p> +</li><li> +<p>Built in rate limiting recovery procedures</p> +</li><li> +<p>Supports <a +href="https://www.contentful.com/developers/docs/concepts/multiple-environments/">Environments</a> +(<strong>since v2.6.0 - 16. April 2018</strong>)</p> +</li></ul> + +<h2 id="label-Getting+started">Getting started</h2> + +<p>In order to get started with the Contentful Ruby SDK you&#39;ll need not +only to install it, but also to get credentials which will allow you to +have access to your content in Contentful.</p> +<ul><li> +<p><a href="#installation">Installation</a></p> +</li><li> +<p><a href="#your-first-request">Your first request</a></p> +</li><li> +<p><a href="#using-this-sdk-with-the-preview-api">Using this SDK with the +Preview API</a></p> +</li><li> +<p><a href="#authentication">Authentication</a></p> +</li><li> +<p><a href="#documentation--references">Documentation & References</a></p> +</li></ul> + +<h3 id="label-Installation">Installation</h3> + <p>Add to your Gemfile and bundle:</p> <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>contentful</span><span class='tstring_end'>&#39;</span></span> </code></pre> -<h2 id="label-Usage">Usage</h2> +<p>Or install it directly from your console:</p> -<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Contentful.html" title="Contentful (module)">Contentful</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Contentful/Client.html" title="Contentful::Client (class)">Client</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Contentful/Client.html#initialize-instance_method" title="Contentful::Client#initialize (method)">new</a></span></span><span class='lparen'>(</span> - <span class='label'>access_token:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>b4c0n73n7fu1</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> - <span class='label'>space:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>cfexampleapi</span><span class='tstring_end'>&#39;</span></span> -<span class='rparen'>)</span> +<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='id identifier rubyid_i'>i</span> <span class='id identifier rubyid_contentful'>contentful</span> </code></pre> -<p>If you plan on using the <a -href="https://www.contentful.com/developers/docs/references/content-preview-api/">Preview -API</a> you need to specify the <code>api_url</code>:</p> +<h3 id="label-Your+first+request">Your first request</h3> -<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Contentful.html" title="Contentful (module)">Contentful</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Contentful/Client.html" title="Contentful::Client (class)">Client</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Contentful/Client.html#initialize-instance_method" title="Contentful::Client#initialize (method)">new</a></span></span><span class='lparen'>(</span> - <span class='label'>access_token:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>b4c0n73n7fu1</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> +<p>The following code snippet is the most basic one you can use to get some +content from Contentful with this SDK:</p> + +<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>contentful</span><span class='tstring_end'>&#39;</span></span> + +<span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Contentful.html" title="Contentful (module)">Contentful</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Contentful/Client.html" title="Contentful::Client (class)">Client</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Contentful/Client.html#initialize-instance_method" title="Contentful::Client#initialize (method)">new</a></span></span><span class='lparen'>(</span> + <span class='label'>space:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>cfexampleapi</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='comment'># This is the space ID. A space is like a project folder in Contentful terms +</span> <span class='label'>access_token:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>b4c0n73n7fu1</span><span class='tstring_end'>&#39;</span></span> <span class='comment'># This is the access token for this space. Normally you get both ID and the token in the Contentful web app +</span><span class='rparen'>)</span> + +<span class='comment'># This API call will request an entry with the specified ID from the space defined at the top, using a space-specific access token. +</span><span class='id identifier rubyid_entry'>entry</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_entry'>entry</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>nyancat</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> +</code></pre> + +<h3 id="label-Using+this+SDK+with+the+Preview+API">Using this SDK with the Preview API</h3> + +<p>This SDK can also be used with the Preview API. In order to do so, you need +to use the Preview API Access token, available on the same page where you +get the Delivery API token, and specify the host of the preview API, such +as:</p> + +<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_require'>require</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>contentful</span><span class='tstring_end'>&#39;</span></span> + +<span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Contentful.html" title="Contentful (module)">Contentful</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Contentful/Client.html" title="Contentful::Client (class)">Client</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Contentful/Client.html#initialize-instance_method" title="Contentful::Client#initialize (method)">new</a></span></span><span class='lparen'>(</span> <span class='label'>space:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>cfexampleapi</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> + <span class='label'>access_token:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>b4c0n73n7fu1</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>api_url:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>preview.contentful.com</span><span class='tstring_end'>&#39;</span></span> <span class='rparen'>)</span> </code></pre> <p>You can query for entries, assets, etc. very similar as described in the <a href="https://www.contentful.com/developers/docs/references/content-delivery-api/">Delivery API Documentation</a>. Please note, that <strong>all methods of the Ruby client library are snake_cased, instead of JavaScript&#39;s camelCase</strong>:</p> -<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_content_types'>content_types</span> -<span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_entry'>entry</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>nyancat</span><span class='tstring_end'>&#39;</span></span> +<h3 id="label-Authentication">Authentication</h3> + +<p>To get your own content from Contentful, an app should authenticate with an +OAuth bearer token.</p> + +<p>You can create API keys using the <a +href="https://app.contentful.com">Contentful web interface</a>. Go to the +app, open the space that you want to access (top left corner lists all the +spaces), and navigate to the APIs area. Open the API Keys section and +create your first token. Done.</p> + +<p>Don&#39;t forget to also get your Space ID.</p> + +<p>For more information, check the <a +href="https://www.contentful.com/developers/docs/references/authentication/">Contentful +REST API reference on Authentication</a>.</p> + +<h2 id="label-Documentation+-26+References">Documentation &amp; References</h2> +<ul><li> +<p><a href="#configuration">Configuration</a></p> +</li><li> +<p><a href="#reference-documentation">Reference documentation</a></p> +</li><li> +<p><a href="#tutorials--other-resources">Tutorials & other resources</a></p> +</li><li> +<p><a href="#advanced-concepts">Advanced Concepts</a></p> +</li><li> +<p><a href="#migrating-to-2x">Migrating to 2.x</a></p> +</li></ul> + +<p>To help you get the most out of this SDK, we&#39;ve prepared all available +client configuration options, reference documentation, tutorials and other +examples that will help you learn and understand how to use this library.</p> + +<h3 id="label-Configuration">Configuration</h3> + +<p>The client constructor supports several options you may set to achieve the +expected behavior:</p> + +<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Contentful.html" title="Contentful (module)">Contentful</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Contentful/Client.html" title="Contentful::Client (class)">Client</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Contentful/Client.html#initialize-instance_method" title="Contentful::Client#initialize (method)">new</a></span></span><span class='lparen'>(</span> + <span class='comment'># ... your options here ... +</span><span class='rparen'>)</span> </code></pre> +<table> + <thead> + <tr> + <th>Name</th> + <th>Default</th> + <th>Description</th> + </tr> + </thead> + <tbody> + <tr> + <td><code>access_token</code></td> + <td></td> + <td><strong>Required</strong>. Your access token.</td> + </tr> + <tr> + <td><code>space</code></td> + <td></td> + <td><strong>Required</strong>. Your space ID.</td> + </tr> + <tr> + <td><code>environment</code></td> + <td>'master'</td> + <td>Your environment ID.</td> + </tr> + <tr> + <td><code>api_url</code></td> + <td><code>'cdn.contentful.com'</code></td> + <td>Set the host used to build the request URIs.</td> + </tr> + <tr> + <td><code>default_locale</code></td> + <td><code>'en-US'</code></td> + <td>Defines default locale for the client.</td> + </tr> + <tr> + <td><code>environment</code></td> + <td><code>'master'</code></td> + <td>Defines default environment to access.</td> + </tr> + <tr> + <td><code>secure</code></td> + <td><code>true</code></td> + <td>Defines whether to use HTTPS or HTTP. By default we use HTTPS.</td> + </tr> + <tr> + <td><code>authentication_mechanism</code></td> + <td><code>:header</code></td> + <td>Sets the authentication mechanisms, valid options are <code>:header</code> or <code>:query_string</code></td> + </tr> + <tr> + <td><code>raise_errors</code></td> + <td><code>true</code></td> + <td>Determines whether errors are raised or returned.</td> + </tr> + <tr> + <td><code>dynamic_entries</code></td> + <td><code>:manual</code></td> + <td> + 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 <code>:auto</code> and <code>:manual</code>. + </td> + </tr> + <tr> + <td><code>raw_mode</code></td> + <td><code>false</code></td> + <td>If enabled, API responses are not parsed and the raw response object is returned instead.</td> + </tr> + <tr> + <td><code>resource_mapping</code></td> + <td><code>{}</code></td> + <td>Allows for overriding default resource classes with custom ones.</td> + </tr> + <tr> + <td><code>entry_mapping</code></td> + <td><code>{}</code></td> + <td>Allows for overriding of specific entry classes by content type.</td> + </tr> + <tr> + <td><code>gzip_encoded</code></td> + <td><code>true</code></td> + <td>Enables gzip response content encoding.</td> + </tr> + <tr> + <td><code>max_rate_limit_retries</code></td> + <td><code>1</code></td> + <td> + 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 <code>X-Contentful-RateLimit-Reset</code> header, + which contains the amount of seconds until the next non rate limited request is available, has passed. + This is blocking per execution thread. + </td> + </tr> + <tr> + <td><code>max_rate_limit_wait</code></td> + <td><code>60</code></td> + <td> + 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. + </td> + </tr> + <tr> + <td><code>max_include_resolution_depth</code></td> + <td><code>20</code></td> + <td> + 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 <code>Link</code> objects). + This include resolution strategy is in place in order to avoid having infinite circular recursion on resources with circular dependencies. + <strong>Note</strong>: If you're using something like <code>Rails::cache</code> 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 <code>reuse_entries</code> is enabled, the max include resolution depth only affects + deep chains of unique objects (ie, not simple circular references). + </td> + </tr> + <tr> + <td><code>reuse_entries</code></td> + <td><code>false</code></td> + <td> + 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 <code>max_include_resolution_depth</code> if your content model contains (or can contain) circular references. + <strong>Caching may break if this option is enabled, as it may generate stack errors.</strong> + When caching, deactivate this option and opt for a conservative <code>max_include_resolution_depth</code> value. + </td> + </tr> + <tr> + <td><code>use_camel_case</code></td> + <td><code>false</code></td> + <td> + When doing the v2 upgrade, all keys and accessors were changed to always use <code>snake_case</code>. + This option introduces the ability to use <code>camelCase</code> for keys and method accessors. + This is very useful for isomorphic applications. + </td> + </tr> + <tr> + <td><code>proxy_host</code></td> + <td><code>nil</code></td> + <td>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.</td> + </tr> + <tr> + <td><code>proxy_port</code></td> + <td><code>nil</code></td> + <td>Specify the port number that is used by the proxy server for client connections.</td> + </tr> + <tr> + <td><code>proxy_username</code></td> + <td><code>nil</code></td> + <td>Username for proxy authentication.</td> + </tr> + <tr> + <td><code>proxy_password</code></td> + <td><code>nil</code></td> + <td>Password for proxy authentication.</td> + </tr> + <tr> + <td><code>logger</code></td> + <td><code>nil</code></td> + <td>To enable logging pass a logger instance compatible with <code>::Logger</code>.</td> + </tr> + <tr> + <td><code>log_level</code></td> + <td><code>::Logger::INFO</code></td> + <td> + 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. + </td> + </tr> + </tbody> +</table> +<h3 id="label-Reference+documentation">Reference documentation</h3> +<h4 id="label-Basic+queries">Basic queries</h4> + +<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_content_types'>content_types</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_content_types'>content_types</span> +<span class='id identifier rubyid_cat_content_type'>cat_content_type</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_content_type'>content_type</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>cat</span><span class='tstring_end'>&#39;</span></span> +<span class='id identifier rubyid_nyancat'>nyancat</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_entry'>entry</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>nyancat</span><span class='tstring_end'>&#39;</span></span> +<span class='id identifier rubyid_entries'>entries</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_entries'>entries</span> +<span class='id identifier rubyid_assets'>assets</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_assets'>assets</span> +<span class='id identifier rubyid_nyancat_asset'>nyancat_asset</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_asset'>asset</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>nyancat</span><span class='tstring_end'>&#39;</span></span> +</code></pre> + +<h4 id="label-Filtering+options">Filtering options</h4> + <p>You can pass the usual filter options to the query:</p> <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_entries'>entries</span><span class='lparen'>(</span><span class='label'>content_type:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>cat</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='comment'># query for a content-type by its ID (not name) </span><span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_entries'>entries</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>sys.id[ne]</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>nyancat</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='comment'># query for all entries except &#39;nyancat&#39; </span><span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_entries'>entries</span><span class='lparen'>(</span><span class='label'>include:</span> <span class='int'>1</span><span class='rparen'>)</span> <span class='comment'># include one level of linked resources </span><span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_entries'>entries</span><span class='lparen'>(</span><span class='label'>content_type:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>cat</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>include:</span> <span class='int'>1</span><span class='rparen'>)</span> <span class='comment'># you can also combine multiple parameters </span></code></pre> -<p>The results are returned as Contentful::Resource objects. Multiple results -will be returned as Contentful::Array. The properties of a resource can be -accessed through Ruby methods.</p> +<p>To read more about filtering options you can check our <a +href="https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters">search +parameters documentation</a>.</p> +<p>The results are returned as <code>Contentful::BaseResource</code> objects. +Multiple results will be returned as <code>Contentful::Array</code>. The +properties of a resource can be accessed through Ruby methods.</p> + +<h4 id="label-Accessing+fields+and+sys+properties">Accessing fields and sys properties</h4> + <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_content_type'>content_type</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_content_type'>content_type</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>cat</span><span class='tstring_end'>&#39;</span></span> <span class='id identifier rubyid_content_type'>content_type</span><span class='period'>.</span><span class='id identifier rubyid_description'>description</span> <span class='comment'># &quot;Meow.&quot; </span></code></pre> <p>System Properties behave the same and can be accessed via the @@ -133,46 +539,46 @@ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_content_type'>content_type</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span> <span class='comment'># =&gt; &#39;cat&#39; </span><span class='id identifier rubyid_entry'>entry</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span> <span class='comment'># =&gt; &#39;Entry&#39; </span><span class='id identifier rubyid_asset'>asset</span><span class='period'>.</span><span class='id identifier rubyid_sys'>sys</span> <span class='comment'># { id: &#39;...&#39;, type: &#39;...&#39; } </span></code></pre> -<p>Entry Fields usually don&#39;t have direct method accessors, since they are -based on individual content types. These fields can be accessed through the -<code>#fields</code> method:</p> +<p>Entry fields also have direct accessors and will be coerced to the type +defined in it&#39;s content type. However, if using <code>dynamic_entries: +:manual</code>, coercion will not be done.</p> <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_entry'>entry</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_entry'>entry</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>nyancat</span><span class='tstring_end'>&#39;</span></span> -<span class='id identifier rubyid_entry'>entry</span><span class='period'>.</span><span class='id identifier rubyid_fields'>fields</span><span class='lbracket'>[</span><span class='symbol'>:color</span><span class='rbracket'>]</span> <span class='comment'># rainbow +<span class='id identifier rubyid_entry'>entry</span><span class='period'>.</span><span class='id identifier rubyid_fields'>fields</span><span class='lbracket'>[</span><span class='symbol'>:color</span><span class='rbracket'>]</span> <span class='comment'># &#39;rainbow&#39; +</span><span class='id identifier rubyid_entry'>entry</span><span class='period'>.</span><span class='id identifier rubyid_color'>color</span> <span class='comment'># &#39;rainbow&#39; +</span><span class='id identifier rubyid_entry'>entry</span><span class='period'>.</span><span class='id identifier rubyid_birthday'>birthday</span> <span class='comment'># #&lt;DateTime: 2011-04-04T22:00:00+00:00 ((2455656j,79200s,0n),+0s,2299161j)&gt; </span></code></pre> -<p>Please note, that no field type conversions will be done for entries by -default.</p> +<h4 id="label-Dynamic+entries">Dynamic entries</h4> -<h3 id="label-Dynamic+Entries">Dynamic Entries</h3> - <p>However, you can (and should) set <code>:dynamic_entries</code> to <code>:auto</code> in your client configuration. When using this option, -the client will fetch all available content types and use them to create -dynamic entries on the fly.</p> +the client will cache all available content types and use them to hydrate +entries when fields are missing in the response and coerce fields to their +proper types.</p> <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Contentful.html" title="Contentful (module)">Contentful</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Contentful/Client.html" title="Contentful::Client (class)">Client</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Contentful/Client.html#initialize-instance_method" title="Contentful::Client#initialize (method)">new</a></span></span><span class='lparen'>(</span> <span class='label'>access_token:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>b4c0n73n7fu1</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>space:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>cfexampleapi</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>dynamic_entries:</span> <span class='symbol'>:auto</span> <span class='rparen'>)</span> -<span class='id identifier rubyid_entry'>entry</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_entry'>entry</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>nyancat</span><span class='tstring_end'>&#39;</span></span> <span class='comment'># =&gt; #&lt;Contentful::DynamicEntry[cat]: ...&gt; +<span class='id identifier rubyid_entry'>entry</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_entry'>entry</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>nyancat</span><span class='tstring_end'>&#39;</span></span> <span class='comment'># =&gt; #&lt;Contentful::Entry[cat]: ...&gt; </span><span class='id identifier rubyid_entry'>entry</span><span class='period'>.</span><span class='id identifier rubyid_color'>color</span> <span class='comment'># =&gt; &#39;rainbow&#39; +</span><span class='id identifier rubyid_entry'>entry</span><span class='period'>.</span><span class='id identifier rubyid_birthday'>birthday</span> <span class='comment'># #&lt;DateTime: 2011-04-04T22:00:00+00:00 ((2455656j,79200s,0n),+0s,2299161j)&gt; </span></code></pre> <p>Dynamic entries will have getter classes for the fields and do type conversions properly.</p> <p>The <code>:auto</code> mode will fetch all content types on initialization. If you want to do it by hand later, you will need to set the option to <code>:manual</code> and call -<code>client.update_dynamic_entry_cache!</code> to initialize all dynamic -entries.</p> +<code>client.update_dynamic_entry_cache!</code> to initialize the cache.</p> <h4 id="label-Using+different+locales">Using different locales</h4> <p>Entries can have multiple locales, by default, the client only fetches the entry with only its default locale. If you want to fetch a different locale @@ -193,11 +599,11 @@ </code></pre> <p>When requesting multiple locales, the object accessor shortcuts only work for the default locale.</p> -<h3 id="label-Arrays">Arrays</h3> +<h4 id="label-Arrays">Arrays</h4> <p>Contentful::Array has an <code>#each</code> method that delegates to its items. It also includes Ruby&#39;s Enumerable module, providing methods like <code>#min</code> or <code>#first</code>. See the Ruby core documentation for further details.</p> @@ -205,198 +611,66 @@ <p>Arrays also have a <code>#next_page</code> URL, which will rerun the request with a increased skip parameter, as described in <a href="https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters/skip">the documentation</a>.</p> -<h3 id="label-Links">Links</h3> +<h4 id="label-Links">Links</h4> <p>You can easily request a resource that is represented by a link by calling <code>#resolve</code>:</p> <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_happycat'>happycat</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_entry'>entry</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>happycat</span><span class='tstring_end'>&#39;</span></span> -<span class='id identifier rubyid_happycat'>happycat</span><span class='period'>.</span><span class='id identifier rubyid_fields'>fields</span><span class='lbracket'>[</span><span class='symbol'>:image</span><span class='rbracket'>]</span> +<span class='id identifier rubyid_happycat'>happycat</span><span class='period'>.</span><span class='id identifier rubyid_image'>image</span> <span class='comment'># =&gt; #&lt;Contentful::Link: @sys={:type=&gt;&quot;Link&quot;, :linkType=&gt;&quot;Asset&quot;, :id=&gt;&quot;happycat&quot;}&gt; -</span><span class='id identifier rubyid_happycat'>happycat</span><span class='period'>.</span><span class='id identifier rubyid_fields'>fields</span><span class='lbracket'>[</span><span class='symbol'>:image</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_resolve'>resolve</span> <span class='comment'># =&gt; #&lt;Contentful::Asset: @fields={ ... +</span><span class='id identifier rubyid_happycat'>happycat</span><span class='period'>.</span><span class='id identifier rubyid_image'>image</span><span class='period'>.</span><span class='id identifier rubyid_resolve'>resolve</span><span class='lparen'>(</span><span class='id identifier rubyid_client'>client</span><span class='rparen'>)</span> <span class='comment'># =&gt; #&lt;Contentful::Asset: @fields={ ... </span></code></pre> <h3 id="label-Assets">Assets</h3> <p>There is a helpful method to add image resize options for an asset image:</p> -<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_asset'>asset</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>happycat</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_image_url'>image_url</span> +<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_asset'>asset</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>happycat</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_url'>url</span> <span class='comment'># =&gt; &quot;//images.contentful.com/cfexampleapi/3MZPnjZTIskAIIkuuosCss/ </span><span class='comment'># 382a48dfa2cb16c47aa2c72f7b23bf09/happycatw.jpg&quot; </span> -<span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_asset'>asset</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>happycat</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_image_url'>image_url</span> <span class='label'>width:</span> <span class='int'>300</span><span class='comma'>,</span> <span class='label'>height:</span> <span class='int'>200</span><span class='comma'>,</span> <span class='label'>format:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>jpg</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>quality:</span> <span class='int'>100</span> +<span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_asset'>asset</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>happycat</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_url'>url</span><span class='lparen'>(</span><span class='label'>width:</span> <span class='int'>300</span><span class='comma'>,</span> <span class='label'>height:</span> <span class='int'>200</span><span class='comma'>,</span> <span class='label'>format:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>jpg</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>quality:</span> <span class='int'>100</span><span class='rparen'>)</span> <span class='comment'># =&gt; &quot;//images.contentful.com/cfexampleapi/3MZPnjZTIskAIIkuuosCss/ </span><span class='comment'># 382a48dfa2cb16c47aa2c72f7b23bf09/happycatw.jpg?w=300&amp;h=200&amp;fm=jpg&amp;q=100&quot; </span></code></pre> -<h3 id="label-Resource+Options">Resource Options</h3> +<h4 id="label-Resource+options">Resource options</h4> <p>Resources, that have been requested directly (i.e. no child resources), can be fetched from the server again by calling <code>#reload</code>:</p> <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_entries'>entries</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_entries'>entries</span> <span class='id identifier rubyid_entries'>entries</span><span class='period'>.</span><span class='id identifier rubyid_reload'>reload</span> <span class='comment'># Fetches the array of entries again </span></code></pre> -<h3 id="label-Field+Type+-22Object-22">Field Type “Object”</h3> +<h4 id="label-Field+type+Object">Field type <code>Object</code></h4> <p>While for known field types, the field data is accessible using methods or the <code>#fields</code> hash with symbol keys, it behaves differently for nested data of the type “Object”. The client will treat them as arbitrary -hashes and will not parse the data inside, which also means, this data is -indexed by Ruby strings, not symbols.</p> +hashes and will not parse the data inside.</p> -<h2 id="label-Client+Configuration+Options">Client Configuration Options</h2> +<h3 id="label-Advanced+concepts">Advanced concepts</h3> -<h3 id="label-3Aspace">:space</h3> +<h4 id="label-Proxy+example">Proxy example</h4> -<p>Required option. The name of the space you want to access.</p> - -<h3 id="label-3Aaccess_token">:access_token</h3> - -<p>Required option. The space&#39;s secret token.</p> - -<h3 id="label-3Adefault_locale">:default_locale</h3> - -<p>Defines default locale for the client. Defaults to <code>en-US</code>.</p> - -<h3 id="label-3Aenvironment">:environment</h3> - -<p>Defines default environment to access. Defaults to <code>master</code>.</p> - -<h3 id="label-3Asecure">:secure</h3> - -<p>Whether to use https. Defaults to <code>true</code>.</p> - -<h3 id="label-3Aauthentication_mechanism">:authentication_mechanism</h3> - -<p>How to authenticate with the API. Supports <code>:header</code> (default) -or <code>:query_string</code>.</p> - -<h3 id="label-3Araise_errors">:raise_errors</h3> - -<p>If set to <code>true</code> (default), error responses will be raised. If -set to <code>false</code>, the error objects will simply be returned.</p> - -<h3 id="label-3Adynamic_entries">:dynamic_entries</h3> - -<p><code>:auto</code> or <code>:manual</code>. See resource description above -for details on usage.</p> - -<h3 id="label-3Araw_mode">:raw_mode</h3> - -<p>Defaults to <code>false</code>. If enabled, the API responses will not be -parsed to resource objects. Might be useful for debugging.</p> - -<h3 id="label-3Aresource_mapping">:resource_mapping</h3> - -<p>See next paragraph for explanation</p> - -<h3 id="label-3Agzip_encoded">:gzip_encoded</h3> - -<p>Enables gzip response content encoding, default to: true</p> - -<h3 id="label-3Alogger">:logger</h3> - -<p>Logging is disabled by default, it can be enabled by setting a logger -instance and a logging severity. <code>ruby client = -Contentful::Client.new( access_token: &#39;b4c0n73n7fu1&#39;, space: -&#39;cfexampleapi&#39;, logger: logger_instance, log_level: -Logger::DEBUG ) </code> Example loggers:</p> - -<pre class="code ruby"><code class="ruby"><span class='const'>Rails</span><span class='period'>.</span><span class='id identifier rubyid_logger'>logger</span> -<span class='const'>Logger</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>logfile.log</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> -</code></pre> - -<h3 id="label-3Alog_level">:log_level</h3> - -<p>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.</p> - -<h3 id="label-3Aproxy_host">:proxy_host</h3> - -<p>To be able to perform a request behind a proxy, you need to specify a -<code>:proxy_host</code>. This can be a domain or IP address of the proxy -server.</p> - -<h3 id="label-3Aproxy_port">:proxy_port</h3> - -<p>Specify the port number that is used by the proxy server for client -connections.</p> - -<h3 id="label-3Aport_password-2C+-3Aport_username">:port_password, :port_username</h3> - -<p>To use the proxy with authentication, you need to specify -<code>port_username</code> and <code>port_password</code>.</p> - -<h3 id="label-3Amax_rate_limit_retries">:max_rate_limit_retries</h3> - -<p>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 -<code>X-Contentful-RateLimit-Reset</code> header, which contains the amount -of seconds until the next non rate limited request is available, has -passed. This is blocking per execution thread.</p> - -<h3 id="label-3Amax_rate_limit_wait">:max_rate_limit_wait</h3> - -<p>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.</p> - -<h3 id="label-3Areuse_entries">:reuse_entries</h3> - -<p>When true, 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 -<code>max_include_resolution_depth</code> if your content model contains -(or can contain) circular references.</p> - -<h3 id="label-3Amax_include_resolution_depth">:max_include_resolution_depth</h3> - -<p>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 -<code>Link</code> objects). This include resolution strategy is in place in -order to avoid having infinite circular recursion on resources with -circular dependencies. Defaults to 20. <em>Note</em>: If you&#39;re using -something like <code>Rails::cache</code> it&#39;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 <code>reuse_entries</code> is -enabled, the max include resolution depth only affects deep chains of -unique objects (ie, not simple circular references).</p> - -<h3 id="label-3Ause_camel_case">:use_camel_case</h3> - -<p>When doing the v2 upgrade, all keys and accessors were changed to always -use <code>snake_case</code>. This option introduces the ability to use -<code>camelCase</code> for keys and method accessors. This is very useful -for isomorphic applications.</p> - -<h3 id="label-Proxy+example">Proxy example</h3> - <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Contentful.html" title="Contentful (module)">Contentful</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Contentful/Client.html" title="Contentful::Client (class)">Client</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Contentful/Client.html#initialize-instance_method" title="Contentful::Client#initialize (method)">new</a></span></span><span class='lparen'>(</span> <span class='label'>access_token:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>b4c0n73n7fu1</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>space:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>cfexampleapi</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>proxy_host:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>127.0.0.1</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>proxy_port:</span> <span class='int'>8080</span><span class='comma'>,</span> <span class='label'>proxy_username:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>username</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>proxy_password:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>secret_password</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='rparen'>)</span> </code></pre> -<h2 id="label-Advanced+Usage">Advanced Usage</h2> +<h4 id="label-Custom+resource+classes">Custom resource classes</h4> -<h3 id="label-Custom+Resource+Classes">Custom Resource Classes</h3> - <p>You can define your own classes that will be returned instead of the predefined ones. Consider, you want to build a better Asset class. One way to do this is:</p> <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>MyBetterAsset</span> <span class='op'>&lt;</span> <span class='const'><span class='object_link'><a href="Contentful.html" title="Contentful (module)">Contentful</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Contentful/Asset.html" title="Contentful::Asset (class)">Asset</a></span></span> @@ -415,16 +689,18 @@ <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Asset</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='const'>MyBetterAsset</span> <span class='rbrace'>}</span> <span class='rparen'>)</span> </code></pre> -<p>More information on <code>:resource_mapping</code> can be found in -examples/resource_mapping.rb and more on custom classes in -examples/custom_classes.rb</p> +<p>More information on <code>:resource_mapping</code> can be found in <a +href="./examples/resource_mapping.rb">examples/resource_mapping.rb</a> and +more on custom classes in <a +href="./examples/custom_classes.rb">examples/custom_classes.rb</a>.</p> <p>You can also register custom entry classes to be used based on the -entry&#39;s content_type using the :entry_mapping configuration:</p> +entry&#39;s content_type using the <code>:entry_mapping</code> +configuration:</p> <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>Cat</span> <span class='op'>&lt;</span> <span class='const'><span class='object_link'><a href="Contentful.html" title="Contentful (module)">Contentful</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Contentful/Entry.html" title="Contentful::Entry (class)">Entry</a></span></span> <span class='comment'># define methods based on :fields, etc </span><span class='kw'>end</span> @@ -437,11 +713,11 @@ <span class='rparen'>)</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_entry'>entry</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>nyancat</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='comment'># is instance of Cat </span></code></pre> -<h2 id="label-Synchronization">Synchronization</h2> +<h4 id="label-Synchronization">Synchronization</h4> <p>The client also includes a wrapper for the synchronization endpoint. You can initialize it with the options described in the <a href="https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/synchronization">Delivery API Documentation</a> or an URL you received from a previous sync:</p> @@ -492,21 +768,12 @@ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_first_entry'>first_entry</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_sync'>sync</span><span class='lparen'>(</span><span class='label'>initial:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>type:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Entry</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_first_page'>first_page</span><span class='period'>.</span><span class='id identifier rubyid_items'>items</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span> <span class='id identifier rubyid_first_entry'>first_entry</span><span class='period'>.</span><span class='id identifier rubyid_fields'>fields</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>de-DE</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='comment'># Returns German localizations </span></code></pre> -<h2 id="label-Workarounds">Workarounds</h2> -<ul><li> -<p>When an entry has related entries that are unpublished, they still end up -in the resource as unresolved links. We consider this correct, because it -is in line with the API responses and our other SDKs. However, you can use -the workaround from <a href="/../../issues/60">issue #60</a> if you happen -to want this working differently.</p> -</li></ul> +<h3 id="label-Migrating+to+2.x">Migrating to 2.x</h3> -<h2 id="label-Migrating+to+2.x">Migrating to 2.x</h2> - <p>If you&#39;re a <code>0.x</code> or a <code>1.x</code> user of this gem, and are planning to migrate to the current <code>2.x</code> branch. There are a few breaking changes you have to take into account:</p> <ul><li> <p><code>Contentful::Link#resolve</code> and @@ -561,21 +828,82 @@ </li></ul> <p>For more information on the internal changes present in the 2.x release, please read the <a href="CHANGELOG.md">CHANGELOG</a></p> +<h3 id="label-Tutorials+-26+other+resources">Tutorials &amp; other resources</h3> +<ul><li> +<p>This library is a wrapper around our Contentful Delivery REST API. Some +more specific details such as search parameters and pagination are better +explained on the <a +href="https://www.contentful.com/developers/docs/references/content-delivery-api/">REST +API reference</a>, and you can also get a better understanding of how the +requests look under the hood.</p> +</li><li> +<p>Check the <a +href="https://www.contentful.com/developers/docs/ruby/">Contentful for +Ruby</a> page for Tutorials, Demo Apps, and more information on other ways +of using Ruby with Contentful</p> +</li></ul> + +<h2 id="label-Reach+out+to+us">Reach out to us</h2> + +<h3 id="label-You+have+questions+about+how+to+use+this+library-3F">You have questions about how to use this library?</h3> +<ul><li> +<p>Reach out to our community forum: <a +href="https://support.contentful.com/"><img +src="https://img.shields.io/badge/-Join%20Community%20Forum-3AB2E6.svg?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MiA1OSI+CiAgPHBhdGggZmlsbD0iI0Y4RTQxOCIgZD0iTTE4IDQxYTE2IDE2IDAgMCAxIDAtMjMgNiA2IDAgMCAwLTktOSAyOSAyOSAwIDAgMCAwIDQxIDYgNiAwIDEgMCA5LTkiIG1hc2s9InVybCgjYikiLz4KICA8cGF0aCBmaWxsPSIjNTZBRUQyIiBkPSJNMTggMThhMTYgMTYgMCAwIDEgMjMgMCA2IDYgMCAxIDAgOS05QTI5IDI5IDAgMCAwIDkgOWE2IDYgMCAwIDAgOSA5Ii8+CiAgPHBhdGggZmlsbD0iI0UwNTM0RSIgZD0iTTQxIDQxYTE2IDE2IDAgMCAxLTIzIDAgNiA2IDAgMSAwLTkgOSAyOSAyOSAwIDAgMCA0MSAwIDYgNiAwIDAgMC05LTkiLz4KICA8cGF0aCBmaWxsPSIjMUQ3OEE0IiBkPSJNMTggMThhNiA2IDAgMSAxLTktOSA2IDYgMCAwIDEgOSA5Ii8+CiAgPHBhdGggZmlsbD0iI0JFNDMzQiIgZD0iTTE4IDUwYTYgNiAwIDEgMS05LTkgNiA2IDAgMCAxIDkgOSIvPgo8L3N2Zz4K&maxAge=31557600"></a></p> +</li><li> +<p>Jump into our community slack channel: <a +href="https://www.contentful.com/slack/"><img +src="https://img.shields.io/badge/-Join%20Community%20Slack-2AB27B.svg?logo=slack&maxAge=31557600"></a></p> +</li></ul> + +<h3 id="label-You+found+a+bug+or+want+to+propose+a+feature-3F">You found a bug or want to propose a feature?</h3> +<ul><li> +<p>File an issue here on GitHub: <a +href="https://github.com/contentful/contentful.rb/issues/new"><img +src="https://img.shields.io/badge/-Create%20Issue-6cc644.svg?logo=github&maxAge=31557600"></a>. +Make sure to remove any credential from your code before sharing it.</p> +</li></ul> + +<h3 id="label-You+need+to+share+confidential+information+or+have+other+questions-3F">You need to share confidential information or have other questions?</h3> +<ul><li> +<p>File a support ticket at our Contentful Customer Support: <a +href="https://www.contentful.com/support/"><img +src="https://img.shields.io/badge/-Submit%20Support%20Ticket-3AB2E6.svg?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MiA1OSI+CiAgPHBhdGggZmlsbD0iI0Y4RTQxOCIgZD0iTTE4IDQxYTE2IDE2IDAgMCAxIDAtMjMgNiA2IDAgMCAwLTktOSAyOSAyOSAwIDAgMCAwIDQxIDYgNiAwIDEgMCA5LTkiIG1hc2s9InVybCgjYikiLz4KICA8cGF0aCBmaWxsPSIjNTZBRUQyIiBkPSJNMTggMThhMTYgMTYgMCAwIDEgMjMgMCA2IDYgMCAxIDAgOS05QTI5IDI5IDAgMCAwIDkgOWE2IDYgMCAwIDAgOSA5Ii8+CiAgPHBhdGggZmlsbD0iI0UwNTM0RSIgZD0iTTQxIDQxYTE2IDE2IDAgMCAxLTIzIDAgNiA2IDAgMSAwLTkgOSAyOSAyOSAwIDAgMCA0MSAwIDYgNiAwIDAgMC05LTkiLz4KICA8cGF0aCBmaWxsPSIjMUQ3OEE0IiBkPSJNMTggMThhNiA2IDAgMSAxLTktOSA2IDYgMCAwIDEgOSA5Ii8+CiAgPHBhdGggZmlsbD0iI0JFNDMzQiIgZD0iTTE4IDUwYTYgNiAwIDEgMS05LTkgNiA2IDAgMCAxIDkgOSIvPgo8L3N2Zz4K&maxAge=31557600"></a></p> +</li></ul> + +<h2 id="label-Get+involved">Get involved</h2> + +<p><a href="http://makeapullrequest.com"><img +src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?maxAge=31557600"></a></p> + +<p>We appreciate any help on our repositories. For more details about how to +contribute see our <a href="CONTRIBUTING.md">CONTRIBUTING.md</a> document.</p> + <h2 id="label-License">License</h2> -<p>Copyright © 2014 Contentful GmbH - Jan Lelis. Copyright © 2016 Contentful -GmbH - David Litvak.</p> +<p>This repository is published under the <a href="LICENSE.txt">MIT</a> +license.</p> -<p>See LICENSE.txt for further details.</p> +<h2 id="label-Code+of+Conduct">Code of Conduct</h2> + +<p>We want to provide a safe, inclusive, welcoming, and harassment-free space +and experience for all participants, regardless of gender identity and +expression, sexual orientation, disability, physical appearance, +socioeconomic status, body size, ethnicity, nationality, level of +experience, age, religion (or lack thereof), or other identity markers.</p> + +<p><a +href="https://github.com/contentful-developer-relations/community-code-of-conduct">Read +our full Code of Conduct</a>.</p> </div></div> <div id="footer"> - Generated on Fri Apr 27 14:03:36 2018 by + Generated on Thu Aug 16 14:17:49 2018 by <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> - 0.9.9 (ruby-2.5.1). + 0.9.12 (ruby-2.5.1). </div> </div> </body> </html> \ No newline at end of file