contentful 2.1.1 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/Gemfile.lock +37 -46
  4. data/lib/contentful/array.rb +8 -1
  5. data/lib/contentful/entry.rb +9 -9
  6. data/lib/contentful/fields_resource.rb +9 -8
  7. data/lib/contentful/resource_builder.rb +1 -7
  8. data/lib/contentful/support.rb +22 -0
  9. data/lib/contentful/version.rb +1 -1
  10. data/spec/array_spec.rb +21 -0
  11. data/spec/fixtures/vcr_cassettes/array/nested_resources.yml +159 -0
  12. metadata +5 -106
  13. data/coverage/.last_run.json +0 -5
  14. data/coverage/.resultset.json +0 -1887
  15. data/coverage/.resultset.json.lock +0 -0
  16. data/coverage/assets/0.10.0/application.css +0 -799
  17. data/coverage/assets/0.10.0/application.js +0 -1707
  18. data/coverage/assets/0.10.0/colorbox/border.png +0 -0
  19. data/coverage/assets/0.10.0/colorbox/controls.png +0 -0
  20. data/coverage/assets/0.10.0/colorbox/loading.gif +0 -0
  21. data/coverage/assets/0.10.0/colorbox/loading_background.png +0 -0
  22. data/coverage/assets/0.10.0/favicon_green.png +0 -0
  23. data/coverage/assets/0.10.0/favicon_red.png +0 -0
  24. data/coverage/assets/0.10.0/favicon_yellow.png +0 -0
  25. data/coverage/assets/0.10.0/loading.gif +0 -0
  26. data/coverage/assets/0.10.0/magnify.png +0 -0
  27. data/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  28. data/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  29. data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  30. data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  31. data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  32. data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  33. data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  34. data/coverage/assets/0.10.0/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  35. data/coverage/assets/0.10.0/smoothness/images/ui-icons_222222_256x240.png +0 -0
  36. data/coverage/assets/0.10.0/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  37. data/coverage/assets/0.10.0/smoothness/images/ui-icons_454545_256x240.png +0 -0
  38. data/coverage/assets/0.10.0/smoothness/images/ui-icons_888888_256x240.png +0 -0
  39. data/coverage/assets/0.10.0/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  40. data/coverage/index.html +0 -11816
  41. data/doc/Contentful.html +0 -153
  42. data/doc/Contentful/AccessDenied.html +0 -161
  43. data/doc/Contentful/Array.html +0 -743
  44. data/doc/Contentful/ArrayCoercion.html +0 -244
  45. data/doc/Contentful/ArrayLike.html +0 -627
  46. data/doc/Contentful/Asset.html +0 -475
  47. data/doc/Contentful/BadRequest.html +0 -161
  48. data/doc/Contentful/BaseCoercion.html +0 -447
  49. data/doc/Contentful/BaseResource.html +0 -599
  50. data/doc/Contentful/BooleanCoercion.html +0 -244
  51. data/doc/Contentful/Client.html +0 -1606
  52. data/doc/Contentful/Constants.html +0 -636
  53. data/doc/Contentful/ContentType.html +0 -614
  54. data/doc/Contentful/ContentTypeCache.html +0 -430
  55. data/doc/Contentful/DateCoercion.html +0 -240
  56. data/doc/Contentful/DeletedAsset.html +0 -159
  57. data/doc/Contentful/DeletedEntry.html +0 -159
  58. data/doc/Contentful/DynamicEntry.html +0 -214
  59. data/doc/Contentful/Entry.html +0 -273
  60. data/doc/Contentful/Error.html +0 -424
  61. data/doc/Contentful/Field.html +0 -929
  62. data/doc/Contentful/FieldsResource.html +0 -501
  63. data/doc/Contentful/File.html +0 -520
  64. data/doc/Contentful/FloatCoercion.html +0 -240
  65. data/doc/Contentful/IntegerCoercion.html +0 -240
  66. data/doc/Contentful/Link.html +0 -251
  67. data/doc/Contentful/LinkCoercion.html +0 -160
  68. data/doc/Contentful/Locale.html +0 -447
  69. data/doc/Contentful/Location.html +0 -385
  70. data/doc/Contentful/LocationCoercion.html +0 -240
  71. data/doc/Contentful/NotFound.html +0 -161
  72. data/doc/Contentful/ObjectCoercion.html +0 -240
  73. data/doc/Contentful/RateLimitExceeded.html +0 -161
  74. data/doc/Contentful/Request.html +0 -889
  75. data/doc/Contentful/Resource.html +0 -117
  76. data/doc/Contentful/Resource/ArrayLike.html +0 -627
  77. data/doc/Contentful/Resource/AssetFields.html +0 -246
  78. data/doc/Contentful/Resource/AssetFields/ClassMethods.html +0 -174
  79. data/doc/Contentful/Resource/ClassMethods.html +0 -378
  80. data/doc/Contentful/Resource/CustomResource.html +0 -119
  81. data/doc/Contentful/Resource/Fields.html +0 -288
  82. data/doc/Contentful/Resource/Fields/ClassMethods.html +0 -187
  83. data/doc/Contentful/Resource/LocalizedFields.html +0 -305
  84. data/doc/Contentful/Resource/SystemProperties.html +0 -205
  85. data/doc/Contentful/Resource/SystemProperties/ClassMethods.html +0 -174
  86. data/doc/Contentful/ResourceBuilder.html +0 -969
  87. data/doc/Contentful/Response.html +0 -641
  88. data/doc/Contentful/ServerError.html +0 -161
  89. data/doc/Contentful/ServiceUnavailable.html +0 -161
  90. data/doc/Contentful/Space.html +0 -395
  91. data/doc/Contentful/StringCoercion.html +0 -244
  92. data/doc/Contentful/Support.html +0 -550
  93. data/doc/Contentful/SymbolCoercion.html +0 -171
  94. data/doc/Contentful/Sync.html +0 -655
  95. data/doc/Contentful/SyncPage.html +0 -801
  96. data/doc/Contentful/TextCoercion.html +0 -171
  97. data/doc/Contentful/Unauthorized.html +0 -161
  98. data/doc/Contentful/UnparsableJson.html +0 -161
  99. data/doc/Contentful/UnparsableResource.html +0 -137
  100. data/doc/_index.html +0 -537
  101. data/doc/class_list.html +0 -51
  102. data/doc/css/common.css +0 -1
  103. data/doc/css/full_list.css +0 -58
  104. data/doc/css/style.css +0 -481
  105. data/doc/file.CHANGELOG.html +0 -506
  106. data/doc/file.LICENSE.html +0 -72
  107. data/doc/file.README.html +0 -565
  108. data/doc/file_list.html +0 -66
  109. data/doc/frames.html +0 -17
  110. data/doc/index.html +0 -565
  111. data/doc/js/app.js +0 -243
  112. data/doc/js/full_list.js +0 -216
  113. data/doc/js/jquery.js +0 -4
  114. data/doc/method_list.html +0 -1115
  115. data/doc/top-level-namespace.html +0 -112
@@ -1,72 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>
7
- File: LICENSE
8
-
9
- &mdash; Documentation by YARD 0.9.5
10
-
11
- </title>
12
-
13
- <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
-
15
- <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
-
17
- <script type="text/javascript" charset="utf-8">
18
- pathId = "LICENSE";
19
- relpath = '';
20
- </script>
21
-
22
-
23
- <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
-
25
- <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
-
27
-
28
- </head>
29
- <body>
30
- <div class="nav_wrap">
31
- <iframe id="nav" src="file_list.html"></iframe>
32
- <div id="resizer"></div>
33
- </div>
34
-
35
- <div id="main" tabindex="-1">
36
- <div id="header">
37
- <div id="menu">
38
-
39
- <a href="_index.html">Index</a> &raquo;
40
- <span class="title">File: LICENSE</span>
41
-
42
- </div>
43
-
44
- <div id="search">
45
-
46
- <a class="full_list_link" id="class_list_link"
47
- href="class_list.html">
48
-
49
- <svg width="24" height="24">
50
- <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
51
- <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
52
- <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
53
- </svg>
54
- </a>
55
-
56
- </div>
57
- <div class="clear"></div>
58
- </div>
59
-
60
- <iframe id="search_frame" src="file_list.html"></iframe>
61
-
62
- <div id="content"><div id='filecontents'>The MIT License (MIT)<br/><br/>Copyright (c) 2014 Contentful GmbH - Jan Lelis<br/>Copyright (c) 2016 Contentful GmbH - David Litvak<br/><br/>Permission is hereby granted, free of charge, to any person obtaining a copy<br/>of this software and associated documentation files (the &quot;Software&quot;), to deal<br/>in the Software without restriction, including without limitation the rights<br/>to use, copy, modify, merge, publish, distribute, sublicense, and/or sell<br/>copies of the Software, and to permit persons to whom the Software is<br/>furnished to do so, subject to the following conditions:<br/><br/>The above copyright notice and this permission notice shall be included in<br/>all copies or substantial portions of the Software.<br/><br/>THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br/>IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br/>FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br/>AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br/>LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,<br/>OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN<br/>THE SOFTWARE.</div></div>
63
-
64
- <div id="footer">
65
- Generated on Tue Jul 25 15:15:32 2017 by
66
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
67
- 0.9.5 (ruby-2.4.1).
68
- </div>
69
-
70
- </div>
71
- </body>
72
- </html>
data/doc/file.README.html DELETED
@@ -1,565 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>
7
- File: README
8
-
9
- &mdash; Documentation by YARD 0.9.5
10
-
11
- </title>
12
-
13
- <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
-
15
- <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
-
17
- <script type="text/javascript" charset="utf-8">
18
- pathId = "README";
19
- relpath = '';
20
- </script>
21
-
22
-
23
- <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
-
25
- <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
-
27
-
28
- </head>
29
- <body>
30
- <div class="nav_wrap">
31
- <iframe id="nav" src="file_list.html"></iframe>
32
- <div id="resizer"></div>
33
- </div>
34
-
35
- <div id="main" tabindex="-1">
36
- <div id="header">
37
- <div id="menu">
38
-
39
- <a href="_index.html">Index</a> &raquo;
40
- <span class="title">File: README</span>
41
-
42
- </div>
43
-
44
- <div id="search">
45
-
46
- <a class="full_list_link" id="class_list_link"
47
- href="class_list.html">
48
-
49
- <svg width="24" height="24">
50
- <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
51
- <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
52
- <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
53
- </svg>
54
- </a>
55
-
56
- </div>
57
- <div class="clear"></div>
58
- </div>
59
-
60
- <iframe id="search_frame" src="file_list.html"></iframe>
61
-
62
- <div id="content"><div id='filecontents'>
63
- <h1 id="label-contentful.rb">contentful.rb</h1>
64
-
65
- <p><a href="http://badge.fury.io/rb/contentful"><img
66
- src="https://badge.fury.io/rb/contentful.png"></a> <a
67
- href="https://travis-ci.org/contentful/contentful.rb"><img
68
- src="https://travis-ci.org/contentful/contentful.rb.png"></a> <a
69
- href="https://coveralls.io/r/contentful/contentful.rb?branch=master"><img
70
- src="https://coveralls.io/repos/contentful/contentful.rb/badge.png?branch=master"></a></p>
71
-
72
- <p>Ruby client for the <a href="https://www.contentful.com">Contentful</a>
73
- Content Delivery API.</p>
74
-
75
- <p><a href="https://www.contentful.com">Contentful</a> is a content management
76
- platform for web applications, mobile apps and connected devices. It allows
77
- you to create, edit &amp; manage content in the cloud and publish it
78
- anywhere via powerful API. Contentful offers tools for managing editorial
79
- teams and enabling cooperation between organizations.</p>
80
-
81
- <p><strong>IMPORTANT</strong>: We&#39;re collecting feedback before releasing
82
- version 2.0.0 of the SDK, if you&#39;re interested in helping, please drop
83
- by this issue and help us improving: <a
84
- href="https://github.com/contentful/contentful.rb/issues/120">github.com/contentful/contentful.rb/issues/120</a></p>
85
-
86
- <h2 id="label-Setup">Setup</h2>
87
-
88
- <p>Add to your Gemfile and bundle:</p>
89
-
90
- <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>
91
- </code></pre>
92
-
93
- <h2 id="label-Usage">Usage</h2>
94
-
95
- <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'>Contentful</span><span class='op'>::</span><span class='const'>Client</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span>
96
- <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>
97
- <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>
98
- <span class='rparen'>)</span>
99
- </code></pre>
100
-
101
- <p>If you plan on using the <a
102
- href="https://www.contentful.com/developers/docs/references/content-preview-api/">Preview
103
- API</a> you need to specify the <code>api_url</code>:</p>
104
-
105
- <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'>Contentful</span><span class='op'>::</span><span class='const'>Client</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span>
106
- <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>
107
- <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>
108
- <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>
109
- <span class='rparen'>)</span>
110
- </code></pre>
111
-
112
- <p>You can query for entries, assets, etc. very similar as described in the <a
113
- href="https://www.contentful.com/developers/docs/references/content-delivery-api/">Delivery
114
- API Documentation</a>. Please note, that <strong>all methods of the Ruby
115
- client library are snake_cased, instead of JavaScript&#39;s
116
- camelCase</strong>:</p>
117
-
118
- <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>
119
- <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>
120
- </code></pre>
121
-
122
- <p>You can pass the usual filter options to the query:</p>
123
-
124
- <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)
125
- </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;
126
- </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
127
- </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
128
- </span></code></pre>
129
-
130
- <p>The results are returned as Contentful::Resource objects. Multiple results
131
- will be returned as Contentful::Array. The properties of a resource can be
132
- accessed through Ruby methods.</p>
133
-
134
- <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>
135
- <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;
136
- </span></code></pre>
137
-
138
- <p>System Properties behave the same and can be accessed via the
139
- <code>#sys</code> method.</p>
140
-
141
- <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;
142
- </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;
143
- </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; }
144
- </span></code></pre>
145
-
146
- <p>Entry Fields usually don&#39;t have direct method accessors, since they are
147
- based on individual content types. These fields can be accessed through the
148
- <code>#fields</code> method:</p>
149
-
150
- <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>
151
- <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
152
- </span></code></pre>
153
-
154
- <p>Please note, that no field type conversions will be done for entries by
155
- default.</p>
156
-
157
- <h3 id="label-Dynamic+Entries">Dynamic Entries</h3>
158
-
159
- <p>However, you can (and should) set <code>:dynamic_entries</code> to
160
- <code>:auto</code> in your client configuration. When using this option,
161
- the client will fetch all available content types and use them to create
162
- dynamic entries on the fly.</p>
163
-
164
- <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'>Contentful</span><span class='op'>::</span><span class='const'>Client</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span>
165
- <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>
166
- <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>
167
- <span class='label'>dynamic_entries:</span> <span class='symbol'>:auto</span>
168
- <span class='rparen'>)</span>
169
-
170
- <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;
171
- </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;
172
- </span></code></pre>
173
-
174
- <p>Dynamic entries will have getter classes for the fields and do type
175
- conversions properly.</p>
176
-
177
- <p>The <code>:auto</code> mode will fetch all content types on initialization.
178
- If you want to do it by hand later, you will need to set the option to
179
- <code>:manual</code> and call
180
- <code>client.update_dynamic_entry_cache!</code> to initialize all dynamic
181
- entries.</p>
182
-
183
- <h4 id="label-Using+different+locales">Using different locales</h4>
184
-
185
- <p>Entries can have multiple locales, by default, the client only fetches the
186
- entry with only its default locale. If you want to fetch a different locale
187
- you can do the following:</p>
188
-
189
- <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='lparen'>(</span><span class='label'>locale:</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>
190
- </code></pre>
191
-
192
- <p>Then all the fields will be fetched for the requested locale.</p>
193
-
194
- <p>Contentful Delivery API also allows to fetch all locales, you can do so by
195
- doing:</p>
196
-
197
- <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='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'>locale:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>*</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
198
-
199
- <span class='comment'># assuming the entry has a field called name
200
- </span><span class='id identifier rubyid_my_spanish_name'>my_spanish_name</span> <span class='op'>=</span> <span class='id identifier rubyid_entries'>entries</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</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'>es-AR</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='symbol'>:name</span><span class='rbracket'>]</span>
201
- </code></pre>
202
-
203
- <p>When requesting multiple locales, the object accessor shortcuts only work
204
- for the default locale.</p>
205
-
206
- <h3 id="label-Arrays">Arrays</h3>
207
-
208
- <p>Contentful::Array has an <code>#each</code> method that delegates to its
209
- items. It also includes Ruby&#39;s Enumerable module, providing methods
210
- like <code>#min</code> or <code>#first</code>. See the Ruby core
211
- documentation for further details.</p>
212
-
213
- <p>Arrays also have a <code>#next_page</code> URL, which will rerun the
214
- request with a increased skip parameter, as described in <a
215
- href="https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters/skip">the
216
- documentation</a>.</p>
217
-
218
- <h3 id="label-Links">Links</h3>
219
-
220
- <p>You can easily request a resource that is represented by a link by calling
221
- <code>#resolve</code>:</p>
222
-
223
- <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>
224
- <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>
225
- <span class='comment'># =&gt; #&lt;Contentful::Link: @sys={:type=&gt;&quot;Link&quot;, :linkType=&gt;&quot;Asset&quot;, :id=&gt;&quot;happycat&quot;}&gt;
226
- </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={ ...
227
- </span></code></pre>
228
-
229
- <h3 id="label-Assets">Assets</h3>
230
-
231
- <p>There is a helpful method to add image resize options for an asset image:</p>
232
-
233
- <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>
234
- <span class='comment'># =&gt; &quot;//images.contentful.com/cfexampleapi/3MZPnjZTIskAIIkuuosCss/
235
- </span><span class='comment'># 382a48dfa2cb16c47aa2c72f7b23bf09/happycatw.jpg&quot;
236
- </span>
237
- <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>
238
- <span class='comment'># =&gt; &quot;//images.contentful.com/cfexampleapi/3MZPnjZTIskAIIkuuosCss/
239
- </span><span class='comment'># 382a48dfa2cb16c47aa2c72f7b23bf09/happycatw.jpg?w=300&amp;h=200&amp;fm=jpg&amp;q=100&quot;
240
- </span></code></pre>
241
-
242
- <h3 id="label-Resource+Options">Resource Options</h3>
243
-
244
- <p>Resources, that have been requested directly (i.e. no child resources), can
245
- be fetched from the server again by calling <code>#reload</code>:</p>
246
-
247
- <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>
248
- <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
249
- </span></code></pre>
250
-
251
- <h3 id="label-Field+Type+-22Object-22">Field Type “Object”</h3>
252
-
253
- <p>While for known field types, the field data is accessible using methods or
254
- the <code>#fields</code> hash with symbol keys, it behaves differently for
255
- nested data of the type “Object”. The client will treat them as arbitrary
256
- hashes and will not parse the data inside, which also means, this data is
257
- indexed by Ruby strings, not symbols.</p>
258
-
259
- <h2 id="label-Client+Configuration+Options">Client Configuration Options</h2>
260
-
261
- <h3 id="label-3Aspace">:space</h3>
262
-
263
- <p>Required option. The name of the space you want to access.</p>
264
-
265
- <h3 id="label-3Aaccess_token">:access_token</h3>
266
-
267
- <p>Required option. The space&#39;s secret token.</p>
268
-
269
- <h3 id="label-3Asecure">:secure</h3>
270
-
271
- <p>Whether to use https. Defaults to <code>true</code>.</p>
272
-
273
- <h3 id="label-3Aauthentication_mechanism">:authentication_mechanism</h3>
274
-
275
- <p>How to authenticate with the API. Supports <code>:header</code> (default)
276
- or <code>:query_string</code>.</p>
277
-
278
- <h3 id="label-3Araise_errors">:raise_errors</h3>
279
-
280
- <p>If set to <code>true</code> (default), error responses will be raised. If
281
- set to <code>false</code>, the error objects will simply be returned.</p>
282
-
283
- <h3 id="label-3Adynamic_entries">:dynamic_entries</h3>
284
-
285
- <p><code>:auto</code> or <code>:manual</code>. See resource description above
286
- for details on usage.</p>
287
-
288
- <h3 id="label-3Araw_mode">:raw_mode</h3>
289
-
290
- <p>Defaults to <code>false</code>. If enabled, the API responses will not be
291
- parsed to resource objects. Might be useful for debugging.</p>
292
-
293
- <h3 id="label-3Aresource_mapping">:resource_mapping</h3>
294
-
295
- <p>See next paragraph for explanation</p>
296
-
297
- <h3 id="label-3Agzip_encoded">:gzip_encoded</h3>
298
-
299
- <p>Enables gzip response content encoding, default to: true</p>
300
-
301
- <h3 id="label-3Alogger">:logger</h3>
302
-
303
- <p>Logging is disabled by default, it can be enabled by setting a logger
304
- instance and a logging severity. <code>ruby client =
305
- Contentful::Client.new( access_token: &#39;b4c0n73n7fu1&#39;, space:
306
- &#39;cfexampleapi&#39;, logger: logger_instance, log_level:
307
- Logger::DEBUG ) </code> Example loggers:</p>
308
-
309
- <pre class="code ruby"><code class="ruby"><span class='const'>Rails</span><span class='period'>.</span><span class='id identifier rubyid_logger'>logger</span>
310
- <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>
311
- </code></pre>
312
-
313
- <h3 id="label-3Alog_level">:log_level</h3>
314
-
315
- <p>The default severity is set to INFO and logs only the request attributes
316
- (headers, parameters and url). Setting it to DEBUG will also log the raw
317
- JSON response.</p>
318
-
319
- <h3 id="label-3Aproxy_host">:proxy_host</h3>
320
-
321
- <p>To be able to perform a request behind a proxy, you need to specify a
322
- <code>:proxy_host</code>. This can be a domain or IP address of the proxy
323
- server.</p>
324
-
325
- <h3 id="label-3Aproxy_port">:proxy_port</h3>
326
-
327
- <p>Specify the port number that is used by the proxy server for client
328
- connections.</p>
329
-
330
- <h3 id="label-3Aport_password-2C+-3Aport_username">:port_password, :port_username</h3>
331
-
332
- <p>To use the proxy with authentication, you need to specify
333
- <code>port_username</code> and <code>port_password</code>.</p>
334
-
335
- <h3 id="label-3Amax_rate_limit_retries">:max_rate_limit_retries</h3>
336
-
337
- <p>To increase or decrease the retry attempts after a 429 Rate Limit error.
338
- Default value is 1. Using 0 will disable retry behaviour. Each retry will
339
- be attempted after the value (in seconds) of the
340
- <code>X-Contentful-RateLimit-Reset</code> header, which contains the amount
341
- of seconds until the next non rate limited request is available, has
342
- passed. This is blocking per execution thread.</p>
343
-
344
- <h3 id="label-3Amax_rate_limit_wait">:max_rate_limit_wait</h3>
345
-
346
- <p>Maximum time to wait for next available request (in seconds). Default value
347
- is 60 seconds. Keep in mind that if you hit the houly rate limit maximum,
348
- you can have up to 60 minutes of blocked requests. It is set to a default
349
- of 60 seconds in order to avoid blocking processes for too long, as rate
350
- limit retry behaviour is blocking per execution thread.</p>
351
-
352
- <h3 id="label-3Amax_include_resolution_depth">:max_include_resolution_depth</h3>
353
-
354
- <p>Maximum amount of levels to resolve includes for SDK entities (this is
355
- independent of API-level includes - it represents the maximum depth the
356
- include resolution tree is allowed to resolved before falling back to
357
- <code>Link</code> objects). This include resolution strategy is in place in
358
- order to avoid having infinite circular recursion on resources with
359
- circular dependencies. Defaults to 20. <em>Note</em>: If you&#39;re using
360
- something like <code>Rails::cache</code> it&#39;s advisable to considerably
361
- lower this value (around 5 has proven to be a good compromise - but keep it
362
- higher or equal than your maximum API-level include parameter if you need
363
- the entire tree resolution).</p>
364
-
365
- <h3 id="label-Proxy+example">Proxy example</h3>
366
-
367
- <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'>Contentful</span><span class='op'>::</span><span class='const'>Client</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span>
368
- <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>
369
- <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>
370
- <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>
371
- <span class='label'>proxy_port:</span> <span class='int'>8080</span><span class='comma'>,</span>
372
- <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>
373
- <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>
374
- <span class='rparen'>)</span>
375
- </code></pre>
376
-
377
- <h2 id="label-Advanced+Usage">Advanced Usage</h2>
378
-
379
- <h3 id="label-Custom+Resource+Classes">Custom Resource Classes</h3>
380
-
381
- <p>You can define your own classes that will be returned instead of the
382
- predefined ones. Consider, you want to build a better Asset class. One way
383
- to do this is:</p>
384
-
385
- <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'>Contentful</span><span class='op'>::</span><span class='const'>Asset</span>
386
- <span class='kw'>def</span> <span class='id identifier rubyid_https_image_url'>https_image_url</span>
387
- <span class='id identifier rubyid_image_url'>image_url</span><span class='period'>.</span><span class='id identifier rubyid_sub'>sub</span> <span class='tstring'><span class='regexp_beg'>%r&lt;</span><span class='tstring_content'>\A//</span><span class='regexp_end'>&gt;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>https://</span><span class='tstring_end'>&#39;</span></span>
388
- <span class='kw'>end</span>
389
- <span class='kw'>end</span>
390
- </code></pre>
391
-
392
- <p>You can register your custom class on client initialization:</p>
393
-
394
- <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'>Contentful</span><span class='op'>::</span><span class='const'>Client</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span>
395
- <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>
396
- <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>
397
- <span class='label'>resource_mapping:</span> <span class='lbrace'>{</span>
398
- <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>
399
- <span class='rbrace'>}</span>
400
- <span class='rparen'>)</span>
401
- </code></pre>
402
-
403
- <p>More information on <code>:resource_mapping</code> can be found in
404
- examples/resource_mapping.rb and more on custom classes in
405
- examples/custom_classes.rb</p>
406
-
407
- <p>You can also register custom entry classes to be used based on the
408
- entry&#39;s content_type using the :entry_mapping configuration:</p>
409
-
410
- <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'>Contentful</span><span class='op'>::</span><span class='const'>Entry</span>
411
- <span class='comment'># define methods based on :fields, etc
412
- </span><span class='kw'>end</span>
413
-
414
- <span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'>Contentful</span><span class='op'>::</span><span class='const'>Client</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span>
415
- <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>
416
- <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>
417
- <span class='label'>entry_mapping:</span> <span class='lbrace'>{</span>
418
- <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>cat</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='const'>Cat</span>
419
- <span class='rbrace'>}</span>
420
- <span class='rparen'>)</span>
421
-
422
- <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
423
- </span></code></pre>
424
-
425
- <h2 id="label-Synchronization">Synchronization</h2>
426
-
427
- <p>The client also includes a wrapper for the synchronization endpoint. You
428
- can initialize it with the options described in the <a
429
- href="https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/synchronization">Delivery
430
- API Documentation</a> or an URL you received from a previous sync:</p>
431
-
432
- <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'>Contentful</span><span class='op'>::</span><span class='const'>Client</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span>
433
- <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>
434
- <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>
435
- <span class='label'>default_locale:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>en-US</span><span class='tstring_end'>&#39;</span></span>
436
- <span class='rparen'>)</span>
437
-
438
- <span class='id identifier rubyid_sync'>sync</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'>Deletion</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span> <span class='comment'># Only returns deleted entries and assets
439
- </span><span class='id identifier rubyid_sync'>sync</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='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>https://cdn.contentful.com/spaces/cfexampleapi/sync?sync_token=w5ZGw6JFwqZmVcKsE8Kow4gr...sGPg</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='comment'># Continues a sync
440
- </span></code></pre>
441
-
442
- <p>You can access the results either wrapped in
443
- <code>Contentful::SyncPage</code> objects:</p>
444
-
445
- <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_sync'>sync</span><span class='period'>.</span><span class='id identifier rubyid_each_page'>each_page</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_page'>page</span><span class='op'>|</span>
446
- <span class='comment'># Find resources at: page.items
447
- </span><span class='kw'>end</span>
448
-
449
- <span class='comment'># More explicit version:
450
- </span><span class='id identifier rubyid_page'>page</span> <span class='op'>=</span> <span class='id identifier rubyid_sync'>sync</span><span class='period'>.</span><span class='id identifier rubyid_first_page'>first_page</span>
451
- <span class='kw'>until</span> <span class='id identifier rubyid_sync'>sync</span><span class='period'>.</span><span class='id identifier rubyid_completed?'>completed?</span>
452
- <span class='id identifier rubyid_page'>page</span> <span class='op'>=</span> <span class='id identifier rubyid_sync'>sync</span><span class='period'>.</span><span class='id identifier rubyid_next_page'>next_page</span>
453
- <span class='kw'>end</span>
454
- </code></pre>
455
-
456
- <p>Or directly iterative over all resources:</p>
457
-
458
- <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_sync'>sync</span><span class='period'>.</span><span class='id identifier rubyid_each_item'>each_item</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_resource'>resource</span><span class='op'>|</span>
459
- <span class='comment'># ...
460
- </span><span class='kw'>end</span>
461
- </code></pre>
462
-
463
- <p>When a sync is completed, the next sync url can be read from the Sync or
464
- SyncPage object:</p>
465
-
466
- <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_sync'>sync</span><span class='period'>.</span><span class='id identifier rubyid_next_sync_url'>next_sync_url</span>
467
- </code></pre>
468
-
469
- <p><strong>Please note</strong> that synchronization entries come in all
470
- locales, so make sure, you supply a :default_locale property to the client
471
- configuration, when using the sync feature. This locale will be returned by
472
- default, when you call <code>Entry#fields</code>. The other localized data
473
- will also be saved and can be accessed by calling the fields method with a
474
- locale parameter:</p>
475
-
476
- <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>
477
- <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
478
- </span></code></pre>
479
-
480
- <h2 id="label-Workarounds">Workarounds</h2>
481
- <ul><li>
482
- <p>When an entry has related entries that are unpublished, they still end up
483
- in the resource as unresolved links. We consider this correct, because it
484
- is in line with the API responses and our other SDKs. However, you can use
485
- the workaround from <a href="/../../issues/60">issue #60</a> if you happen
486
- to want this working differently.</p>
487
- </li></ul>
488
-
489
- <h2 id="label-Migrating+to+2.x">Migrating to 2.x</h2>
490
-
491
- <p>If you&#39;re a <code>0.x</code> or a <code>1.x</code> user of this gem,
492
- and are planning to migrate to the current <code>2.x</code> branch. There
493
- are a few breaking changes you have to take into account:</p>
494
- <ul><li>
495
- <p><code>Contentful::Link#resolve</code> and
496
- <code>Contentful::Array#next_page</code> now require a
497
- <code>Contentful::Client</code> instance as a parameter.</p>
498
- </li><li>
499
- <p><code>Contentful::CustomResource</code> does no longer exist, custom entry
500
- classes can now inherit from <code>Contentful::Entry</code> and have proper
501
- marshalling working.</p>
502
- </li><li>
503
- <p><code>Contentful::Resource</code> does no longer exist, all resource
504
- classes now inherit from <code>Contentful::BaseResource</code>.
505
- <code>Contentful::Entry</code> and <code>Contentful::Asset</code> inherit
506
- from <code>Contentful::FieldsResource</code> which is a subclass of
507
- <code>Contentful::BaseResource</code>.</p>
508
- </li><li>
509
- <p><code>Contentful::DynamicEntry</code> does no longer exist, if code checked
510
- against that base class, it should now check against
511
- <code>Contentful::Entry</code> instead.</p>
512
- </li><li>
513
- <p><code>Contentful::Client#dynamic_entry_cache</code> <em>(private)</em> has
514
- been extracted to it&#39;s own class, and can be now manually cleared by
515
- using <code>Contentful::ContentTypeCache::clear</code>.</p>
516
- </li><li>
517
- <p><code>Contentful::BaseResource#sys</code> and
518
- <code>Contentful::FieldsResource#fields</code> internal representation for
519
- keys are now snake cased to match the instance accessors. E.g.
520
- <code>entry.fields[:myField]</code> previously had the accessor
521
- <code>entry.my_field</code>, now it is
522
- <code>entry.fields[:my_field]</code>. The value in both cases would
523
- correspond to the same field, only change is to unify the style. If code
524
- accessed the values through the <code>#sys</code> or <code>#fields</code>
525
- methods, keys now need to be snake cased.</p>
526
- </li><li>
527
- <p>Circular references are handled as individual objects to simplify
528
- marshalling and reduce stack errors, this introduces a performance hit on
529
- extremely interconnected content. Therefore, to limit the impact of
530
- circular references, an additional configuration flag
531
- <code>max_include_resolution_depth</code> has been added. It is set to 20
532
- by default (which corresponds to the maximum include level value * 2). This
533
- allows for non-circular but highly connected content to resolve properly.
534
- In very interconnected content, it also allows to reduce this number to
535
- improve performance. For a more in depth look into this you can read <a
536
- href="https://github.com/contentful/contentful.rb/issues/124#issuecomment-287002469">this
537
- issue</a>.</p>
538
- </li><li>
539
- <p><code>#inspect</code> now offers a clearer and better output for all
540
- resources. If your code had assertions based on the string representation
541
- of the resources, update to the new format
542
- <code>&lt;Contentful::#{RESOURCE_CLASS}#{additional_info}
543
- id=&quot;#{RESOURCE_ID}&quot;&gt;</code>.</p>
544
- </li></ul>
545
-
546
- <p>For more information on the internal changes present in the 2.x release,
547
- please read the <a href="CHANGELOG.md">CHANGELOG</a></p>
548
-
549
- <h2 id="label-License">License</h2>
550
-
551
- <p>Copyright © 2014 Contentful GmbH - Jan Lelis. Copyright © 2016 Contentfuk
552
- GmbH - David Litvak.</p>
553
-
554
- <p>See LICENSE.txt for further details.</p>
555
- </div></div>
556
-
557
- <div id="footer">
558
- Generated on Tue Jul 25 15:15:32 2017 by
559
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
560
- 0.9.5 (ruby-2.4.1).
561
- </div>
562
-
563
- </div>
564
- </body>
565
- </html>