contentful 2.15.3 → 2.16.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (247) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -0
  3. data/README.md +22 -11
  4. data/lib/contentful/array_like.rb +11 -2
  5. data/lib/contentful/asset.rb +4 -0
  6. data/lib/contentful/base_resource.rb +14 -2
  7. data/lib/contentful/client.rb +1 -2
  8. data/lib/contentful/fields_resource.rb +1 -0
  9. data/lib/contentful/version.rb +1 -1
  10. metadata +4 -367
  11. data/.gitignore +0 -7
  12. data/.rspec +0 -1
  13. data/.rubocop.yml +0 -31
  14. data/.rubocop_todo.yml +0 -35
  15. data/.travis.yml +0 -15
  16. data/.yardopts +0 -4
  17. data/Gemfile +0 -9
  18. data/Gemfile.lock +0 -166
  19. data/Guardfile +0 -24
  20. data/RELEASE.md +0 -8
  21. data/Rakefile +0 -33
  22. data/contentful.gemspec +0 -44
  23. data/coverage/.last_run.json +0 -5
  24. data/coverage/.resultset.json +0 -5086
  25. data/coverage/.resultset.json.lock +0 -0
  26. data/coverage/assets/0.10.2/application.css +0 -799
  27. data/coverage/assets/0.10.2/application.js +0 -1707
  28. data/coverage/assets/0.10.2/colorbox/border.png +0 -0
  29. data/coverage/assets/0.10.2/colorbox/controls.png +0 -0
  30. data/coverage/assets/0.10.2/colorbox/loading.gif +0 -0
  31. data/coverage/assets/0.10.2/colorbox/loading_background.png +0 -0
  32. data/coverage/assets/0.10.2/favicon_green.png +0 -0
  33. data/coverage/assets/0.10.2/favicon_red.png +0 -0
  34. data/coverage/assets/0.10.2/favicon_yellow.png +0 -0
  35. data/coverage/assets/0.10.2/loading.gif +0 -0
  36. data/coverage/assets/0.10.2/magnify.png +0 -0
  37. data/coverage/assets/0.10.2/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  38. data/coverage/assets/0.10.2/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  39. data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  40. data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  41. data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  42. data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  43. data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  44. data/coverage/assets/0.10.2/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  45. data/coverage/assets/0.10.2/smoothness/images/ui-icons_222222_256x240.png +0 -0
  46. data/coverage/assets/0.10.2/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  47. data/coverage/assets/0.10.2/smoothness/images/ui-icons_454545_256x240.png +0 -0
  48. data/coverage/assets/0.10.2/smoothness/images/ui-icons_888888_256x240.png +0 -0
  49. data/coverage/assets/0.10.2/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  50. data/coverage/index.html +0 -0
  51. data/doc/Contentful/AccessDenied.html +0 -159
  52. data/doc/Contentful/Array.html +0 -844
  53. data/doc/Contentful/ArrayCoercion.html +0 -242
  54. data/doc/Contentful/ArrayLike.html +0 -624
  55. data/doc/Contentful/Asset.html +0 -486
  56. data/doc/Contentful/BadGateway.html +0 -159
  57. data/doc/Contentful/BadRequest.html +0 -159
  58. data/doc/Contentful/BaseCoercion.html +0 -445
  59. data/doc/Contentful/BaseResource.html +0 -598
  60. data/doc/Contentful/BooleanCoercion.html +0 -242
  61. data/doc/Contentful/Client.html +0 -1738
  62. data/doc/Contentful/ContentType.html +0 -617
  63. data/doc/Contentful/ContentTypeCache.html +0 -428
  64. data/doc/Contentful/DateCoercion.html +0 -244
  65. data/doc/Contentful/DeletedAsset.html +0 -156
  66. data/doc/Contentful/DeletedEntry.html +0 -156
  67. data/doc/Contentful/EmptyFieldError.html +0 -217
  68. data/doc/Contentful/Entry.html +0 -334
  69. data/doc/Contentful/Error.html +0 -407
  70. data/doc/Contentful/Field.html +0 -935
  71. data/doc/Contentful/FieldsResource.html +0 -583
  72. data/doc/Contentful/File.html +0 -218
  73. data/doc/Contentful/FloatCoercion.html +0 -238
  74. data/doc/Contentful/IntegerCoercion.html +0 -238
  75. data/doc/Contentful/Link.html +0 -246
  76. data/doc/Contentful/LinkCoercion.html +0 -156
  77. data/doc/Contentful/Locale.html +0 -536
  78. data/doc/Contentful/Location.html +0 -382
  79. data/doc/Contentful/LocationCoercion.html +0 -238
  80. data/doc/Contentful/NotFound.html +0 -159
  81. data/doc/Contentful/ObjectCoercion.html +0 -238
  82. data/doc/Contentful/RateLimitExceeded.html +0 -346
  83. data/doc/Contentful/Request.html +0 -895
  84. data/doc/Contentful/ResourceBuilder.html +0 -1067
  85. data/doc/Contentful/ResourceReferences.html +0 -254
  86. data/doc/Contentful/Response.html +0 -708
  87. data/doc/Contentful/RichTextCoercion.html +0 -238
  88. data/doc/Contentful/ServerError.html +0 -159
  89. data/doc/Contentful/ServiceUnavailable.html +0 -159
  90. data/doc/Contentful/Space.html +0 -392
  91. data/doc/Contentful/StringCoercion.html +0 -242
  92. data/doc/Contentful/StructuredTextCoercion.html +0 -238
  93. data/doc/Contentful/Support.html +0 -788
  94. data/doc/Contentful/SymbolCoercion.html +0 -169
  95. data/doc/Contentful/Sync.html +0 -653
  96. data/doc/Contentful/SyncPage.html +0 -807
  97. data/doc/Contentful/TextCoercion.html +0 -169
  98. data/doc/Contentful/Unauthorized.html +0 -159
  99. data/doc/Contentful/UnparsableJson.html +0 -159
  100. data/doc/Contentful/UnparsableResource.html +0 -135
  101. data/doc/Contentful.html +0 -157
  102. data/doc/_index.html +0 -563
  103. data/doc/class_list.html +0 -51
  104. data/doc/css/common.css +0 -1
  105. data/doc/css/full_list.css +0 -58
  106. data/doc/css/style.css +0 -496
  107. data/doc/file.CHANGELOG.html +0 -708
  108. data/doc/file.LICENSE.html +0 -70
  109. data/doc/file.README.html +0 -758
  110. data/doc/file_list.html +0 -66
  111. data/doc/frames.html +0 -17
  112. data/doc/index.html +0 -758
  113. data/doc/js/app.js +0 -303
  114. data/doc/js/full_list.js +0 -216
  115. data/doc/js/jquery.js +0 -4
  116. data/doc/method_list.html +0 -1187
  117. data/doc/top-level-namespace.html +0 -110
  118. data/examples/custom_classes.rb +0 -39
  119. data/examples/example_queries.rb +0 -26
  120. data/examples/raise_errors.rb +0 -20
  121. data/examples/raw_mode.rb +0 -14
  122. data/spec/array_spec.rb +0 -167
  123. data/spec/asset_spec.rb +0 -192
  124. data/spec/auto_includes_spec.rb +0 -12
  125. data/spec/client_class_spec.rb +0 -86
  126. data/spec/client_configuration_spec.rb +0 -377
  127. data/spec/content_type_spec.rb +0 -49
  128. data/spec/deleted_asset_spec.rb +0 -38
  129. data/spec/deleted_entry_spec.rb +0 -38
  130. data/spec/entry_spec.rb +0 -777
  131. data/spec/error_class_spec.rb +0 -327
  132. data/spec/error_requests_spec.rb +0 -87
  133. data/spec/field_spec.rb +0 -95
  134. data/spec/file_spec.rb +0 -33
  135. data/spec/fixtures/json_responses/400_details_errors_object.json +0 -14
  136. data/spec/fixtures/json_responses/400_details_errors_string.json +0 -12
  137. data/spec/fixtures/json_responses/400_details_string.json +0 -8
  138. data/spec/fixtures/json_responses/403_reasons.json +0 -13
  139. data/spec/fixtures/json_responses/404_details_string.json +0 -8
  140. data/spec/fixtures/json_responses/404_id.json +0 -11
  141. data/spec/fixtures/json_responses/404_sys_type.json +0 -12
  142. data/spec/fixtures/json_responses/404_type.json +0 -10
  143. data/spec/fixtures/json_responses/content_type.json +0 -83
  144. data/spec/fixtures/json_responses/default_400.json +0 -7
  145. data/spec/fixtures/json_responses/default_401.json +0 -7
  146. data/spec/fixtures/json_responses/default_403.json +0 -7
  147. data/spec/fixtures/json_responses/default_404.json +0 -7
  148. data/spec/fixtures/json_responses/default_429.json +0 -7
  149. data/spec/fixtures/json_responses/default_500.json +0 -7
  150. data/spec/fixtures/json_responses/default_502.json +0 -7
  151. data/spec/fixtures/json_responses/default_503.json +0 -7
  152. data/spec/fixtures/json_responses/includes.json +0 -111
  153. data/spec/fixtures/json_responses/link_array.json +0 -43
  154. data/spec/fixtures/json_responses/not_found.json +0 -13
  155. data/spec/fixtures/json_responses/nyancat.json +0 -48
  156. data/spec/fixtures/json_responses/other_error.json +0 -9
  157. data/spec/fixtures/json_responses/other_error_no_details.json +0 -8
  158. data/spec/fixtures/json_responses/other_error_no_message.json +0 -8
  159. data/spec/fixtures/json_responses/other_error_no_request_id.json +0 -8
  160. data/spec/fixtures/json_responses/other_error_nothing.json +0 -6
  161. data/spec/fixtures/json_responses/self_link.json +0 -82
  162. data/spec/fixtures/json_responses/unparsable.json +0 -13
  163. data/spec/fixtures/vcr_cassettes/array/marshal_custom_classes.yml +0 -159
  164. data/spec/fixtures/vcr_cassettes/array/marshal_unpublished.yml +0 -315
  165. data/spec/fixtures/vcr_cassettes/array/nested_resources.yml +0 -159
  166. data/spec/fixtures/vcr_cassettes/array.yml +0 -288
  167. data/spec/fixtures/vcr_cassettes/arrayField.yml +0 -87
  168. data/spec/fixtures/vcr_cassettes/array_page_1.yml +0 -106
  169. data/spec/fixtures/vcr_cassettes/array_page_2.yml +0 -73
  170. data/spec/fixtures/vcr_cassettes/asset/select_empty_array.yml +0 -104
  171. data/spec/fixtures/vcr_cassettes/asset/select_no_sys.yml +0 -119
  172. data/spec/fixtures/vcr_cassettes/asset/select_one_field.yml +0 -97
  173. data/spec/fixtures/vcr_cassettes/asset/select_only_sys.yml +0 -88
  174. data/spec/fixtures/vcr_cassettes/asset.yml +0 -96
  175. data/spec/fixtures/vcr_cassettes/assets/issues_129.yml +0 -90
  176. data/spec/fixtures/vcr_cassettes/assets/issues_jekyll_46.yml +0 -115
  177. data/spec/fixtures/vcr_cassettes/bad_request.yml +0 -76
  178. data/spec/fixtures/vcr_cassettes/content_type.yml +0 -147
  179. data/spec/fixtures/vcr_cassettes/entries/empty_fields.yml +0 -246
  180. data/spec/fixtures/vcr_cassettes/entries/issue_117.yml +0 -201
  181. data/spec/fixtures/vcr_cassettes/entries/issue_125.yml +0 -198
  182. data/spec/fixtures/vcr_cassettes/entries/rich_text.yml +0 -1707
  183. data/spec/fixtures/vcr_cassettes/entries/rich_text_hydration_issue.yml +0 -460
  184. data/spec/fixtures/vcr_cassettes/entries/rich_text_nested_fields.yml +0 -653
  185. data/spec/fixtures/vcr_cassettes/entries/rich_text_unresolved_relationships.yml +0 -983
  186. data/spec/fixtures/vcr_cassettes/entries/unresolvable_assets.yml +0 -89
  187. data/spec/fixtures/vcr_cassettes/entries/unresolvable_filter.yml +0 -159
  188. data/spec/fixtures/vcr_cassettes/entries/unresolvable_filter_deeply_nested.yml +0 -167
  189. data/spec/fixtures/vcr_cassettes/entries.yml +0 -561
  190. data/spec/fixtures/vcr_cassettes/entry/custom_resource.yml +0 -168
  191. data/spec/fixtures/vcr_cassettes/entry/include_resolution.yml +0 -101
  192. data/spec/fixtures/vcr_cassettes/entry/include_resolution_uniques.yml +0 -81
  193. data/spec/fixtures/vcr_cassettes/entry/json_objects.yml +0 -88
  194. data/spec/fixtures/vcr_cassettes/entry/json_objects_client.yml +0 -86
  195. data/spec/fixtures/vcr_cassettes/entry/marshal_138.yml +0 -159
  196. data/spec/fixtures/vcr_cassettes/entry/marshal_unpublished.yml +0 -303
  197. data/spec/fixtures/vcr_cassettes/entry/marshall.yml +0 -293
  198. data/spec/fixtures/vcr_cassettes/entry/raw.yml +0 -201
  199. data/spec/fixtures/vcr_cassettes/entry/search_link_to_asset.yml +0 -81
  200. data/spec/fixtures/vcr_cassettes/entry/search_link_to_entry.yml +0 -81
  201. data/spec/fixtures/vcr_cassettes/entry/search_link_to_entry_with_custom_query.yml +0 -115
  202. data/spec/fixtures/vcr_cassettes/entry/select_empty_array.yml +0 -111
  203. data/spec/fixtures/vcr_cassettes/entry/select_no_sys.yml +0 -102
  204. data/spec/fixtures/vcr_cassettes/entry/select_one_field.yml +0 -76
  205. data/spec/fixtures/vcr_cassettes/entry/select_one_field_proper.yml +0 -114
  206. data/spec/fixtures/vcr_cassettes/entry/select_only_sys.yml +0 -111
  207. data/spec/fixtures/vcr_cassettes/entry.yml +0 -102
  208. data/spec/fixtures/vcr_cassettes/entry_cache.yml +0 -288
  209. data/spec/fixtures/vcr_cassettes/entry_locales.yml +0 -104
  210. data/spec/fixtures/vcr_cassettes/field.yml +0 -147
  211. data/spec/fixtures/vcr_cassettes/human.yml +0 -118
  212. data/spec/fixtures/vcr_cassettes/linkField.yml +0 -83
  213. data/spec/fixtures/vcr_cassettes/locale.yml +0 -83
  214. data/spec/fixtures/vcr_cassettes/locale_from_environment.yml +0 -121
  215. data/spec/fixtures/vcr_cassettes/location.yml +0 -193
  216. data/spec/fixtures/vcr_cassettes/multi_locale_array_reference.yml +0 -196
  217. data/spec/fixtures/vcr_cassettes/multi_locale_reference.yml +0 -214
  218. data/spec/fixtures/vcr_cassettes/not_found.yml +0 -76
  219. data/spec/fixtures/vcr_cassettes/nyancat.yml +0 -102
  220. data/spec/fixtures/vcr_cassettes/query_array_1.yml +0 -89
  221. data/spec/fixtures/vcr_cassettes/query_array_2.yml +0 -89
  222. data/spec/fixtures/vcr_cassettes/ratelimit.yml +0 -64
  223. data/spec/fixtures/vcr_cassettes/ratelimit_retry.yml +0 -294
  224. data/spec/fixtures/vcr_cassettes/reloaded_entry.yml +0 -102
  225. data/spec/fixtures/vcr_cassettes/space.yml +0 -83
  226. data/spec/fixtures/vcr_cassettes/sync_deleted_asset.yml +0 -174
  227. data/spec/fixtures/vcr_cassettes/sync_deleted_entry.yml +0 -89
  228. data/spec/fixtures/vcr_cassettes/sync_deletion.yml +0 -191
  229. data/spec/fixtures/vcr_cassettes/sync_environment.yml +0 -81
  230. data/spec/fixtures/vcr_cassettes/sync_page.yml +0 -637
  231. data/spec/fixtures/vcr_cassettes/sync_page_2.yml +0 -71
  232. data/spec/fixtures/vcr_cassettes/sync_page_short.yml +0 -106
  233. data/spec/fixtures/vcr_cassettes/unauthorized.yml +0 -64
  234. data/spec/fixtures/vcr_cassettes/unavailable.yml +0 -76
  235. data/spec/link_spec.rb +0 -50
  236. data/spec/locale_spec.rb +0 -37
  237. data/spec/location_spec.rb +0 -25
  238. data/spec/request_spec.rb +0 -57
  239. data/spec/resource_building_spec.rb +0 -31
  240. data/spec/response_spec.rb +0 -62
  241. data/spec/space_spec.rb +0 -31
  242. data/spec/spec_helper.rb +0 -14
  243. data/spec/support/client.rb +0 -6
  244. data/spec/support/json_responses.rb +0 -18
  245. data/spec/support/vcr.rb +0 -16
  246. data/spec/sync_page_spec.rb +0 -103
  247. data/spec/sync_spec.rb +0 -180
data/doc/index.html DELETED
@@ -1,758 +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.20
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="class_list.html?1"></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
- <div id="content"><div id='filecontents'>
61
- <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>
62
-
63
- <h1 id="label-contentful.rb+-+Contentful+Ruby+Delivery+SDK">contentful.rb - Contentful Ruby Delivery SDK</h1>
64
-
65
- <p><a href="http://badge.fury.io/rb/contentful"><img src="https://badge.fury.io/rb/contentful.png"></a></p>
66
-
67
- <blockquote>
68
- <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>
69
- </blockquote>
70
- <p align="center">
71
- <img src="https://img.shields.io/badge/Status-Maintained-green.svg" alt="This repository is actively maintained" /> &nbsp;
72
- <a href="LICENSE.txt">
73
- <img src="https://img.shields.io/badge/license-MIT-brightgreen.svg" alt="MIT License" />
74
- </a>
75
- &nbsp;
76
- <a href="https://travis-ci.org/contentful/contentful.rb">
77
- <img src="https://travis-ci.org/contentful/contentful.rb.svg?branch=master" alt="Build Status">
78
- </a>
79
- </p><p align="center">
80
- <a href="https://rubygems.org/gems/contentful">
81
- <img src="https://img.shields.io/gem/v/contentful.svg" alt="RubyGems version">
82
- </a>
83
- &nbsp;
84
- <a href="https://rubygems.org/gems/contentful">
85
- <img src="https://img.shields.io/gem/dt/contentful.svg" alt="RubyGems downloads">
86
- </a>
87
- </p>
88
- <p><strong>What is Contentful?</strong></p>
89
-
90
- <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>
91
-
92
- <p>&lt;details&gt; &lt;summary&gt;Table of contents&lt;/summary&gt;</p>
93
- <!-- TOC --><ul><li>
94
- <p><a href="#contentfulrb---contentful-ruby-delivery-sdk">contentful.rb - Contentful Ruby Delivery SDK</a></p>
95
- </li><li>
96
- <p><a href="#core-features">Core Features</a></p>
97
- </li><li>
98
- <p><a href="#getting-started">Getting started</a></p>
99
- <ul><li>
100
- <p><a href="#installation">Installation</a></p>
101
- </li><li>
102
- <p><a href="#your-first-request">Your first request</a></p>
103
- </li><li>
104
- <p><a href="#using-this-sdk-with-the-preview-api">Using this SDK with the Preview API</a></p>
105
- </li><li>
106
- <p><a href="#authentication">Authentication</a></p>
107
- </li></ul>
108
- </li><li>
109
- <p><a href="#documentation--references">Documentation & References</a></p>
110
- <ul><li>
111
- <p><a href="#configuration">Configuration</a></p>
112
- </li><li>
113
- <p><a href="#reference-documentation">Reference documentation</a></p>
114
- </li><li>
115
- <p><a href="#basic-queries">Basic queries</a></p>
116
- </li><li>
117
- <p><a href="#filtering-options">Filtering options</a></p>
118
- </li><li>
119
- <p><a href="#accessing-fields-and-sys-properties">Accessing fields and sys properties</a></p>
120
- </li><li>
121
- <p><a href="#dynamic-entries">Dynamic entries</a></p>
122
- </li><li>
123
- <p><a href="#using-different-locales">Using different locales</a></p>
124
- </li><li>
125
- <p><a href="#arrays">Arrays</a></p>
126
- </li><li>
127
- <p><a href="#links">Links</a></p>
128
- </li><li>
129
- <p><a href="#assets">Assets</a></p>
130
- </li><li>
131
- <p><a href="#resource-options">Resource options</a></p>
132
- </li><li>
133
- <p><a href="#field-type-object">Field type Object</a></p>
134
- </li><li>
135
- <p><a href="#advanced-concepts">Advanced concepts</a></p>
136
- </li><li>
137
- <p><a href="#proxy-example">Proxy example</a></p>
138
- </li><li>
139
- <p><a href="#custom-resource-classes">Custom resource classes</a></p>
140
- </li><li>
141
- <p><a href="#synchronization">Synchronization</a></p>
142
- </li><li>
143
- <p><a href="#migrating-to-2x">Migrating to 2.x</a></p>
144
- </li><li>
145
- <p><a href="#tutorials--other-resources">Tutorials & other resources</a></p>
146
- </li></ul>
147
- </li><li>
148
- <p><a href="#reach-out-to-us">Reach out to us</a></p>
149
- <ul><li>
150
- <p><a href="#you-have-questions-about-how-to-use-this-library">You have questions about how to use this library?</a></p>
151
- </li><li>
152
- <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>
153
- </li><li>
154
- <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>
155
- </li></ul>
156
- </li><li>
157
- <p><a href="#get-involved">Get involved</a></p>
158
- </li><li>
159
- <p><a href="#license">License</a></p>
160
- </li><li>
161
- <p><a href="#code-of-conduct">Code of Conduct</a></p>
162
- </li></ul>
163
- <!-- /TOC -->
164
- <p>&lt;/details&gt;</p>
165
-
166
- <h2 id="label-Core+Features">Core Features</h2>
167
- <ul><li>
168
- <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>
169
- </li><li>
170
- <p><a href="https://www.contentful.com/developers/docs/concepts/sync/">Synchronization</a></p>
171
- </li><li>
172
- <p><a href="https://www.contentful.com/developers/docs/concepts/locales/">Localization support</a></p>
173
- </li><li>
174
- <p><a href="https://www.contentful.com/developers/docs/concepts/links/">Link resolution</a></p>
175
- </li><li>
176
- <p>Built in rate limiting recovery procedures</p>
177
- </li><li>
178
- <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>
179
- </li></ul>
180
-
181
- <h2 id="label-Getting+started">Getting started</h2>
182
-
183
- <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>
184
- <ul><li>
185
- <p><a href="#installation">Installation</a></p>
186
- </li><li>
187
- <p><a href="#your-first-request">Your first request</a></p>
188
- </li><li>
189
- <p><a href="#using-this-sdk-with-the-preview-api">Using this SDK with the Preview API</a></p>
190
- </li><li>
191
- <p><a href="#authentication">Authentication</a></p>
192
- </li><li>
193
- <p><a href="#documentation--references">Documentation & References</a></p>
194
- </li></ul>
195
-
196
- <h3 id="label-Installation">Installation</h3>
197
-
198
- <p>Add to your Gemfile and bundle:</p>
199
-
200
- <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>
201
- </code></pre>
202
-
203
- <p>Or install it directly from your console:</p>
204
-
205
- <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>
206
- </code></pre>
207
-
208
- <h3 id="label-Your+first+request">Your first request</h3>
209
-
210
- <p>The following code snippet is the most basic one you can use to get some content from Contentful with this SDK:</p>
211
-
212
- <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>
213
-
214
- <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>
215
- <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
216
- </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
217
- </span><span class='rparen'>)</span>
218
-
219
- <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.
220
- </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>
221
- </code></pre>
222
-
223
- <h3 id="label-Using+this+SDK+with+the+Preview+API">Using this SDK with the Preview API</h3>
224
-
225
- <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>
226
-
227
- <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>
228
-
229
- <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>
230
- <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>
231
- <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>
232
- <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>
233
- <span class='rparen'>)</span>
234
- </code></pre>
235
-
236
- <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>
237
-
238
- <h3 id="label-Authentication">Authentication</h3>
239
-
240
- <p>To get your own content from Contentful, an app should authenticate with an OAuth bearer token.</p>
241
-
242
- <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>
243
-
244
- <p>Don&#39;t forget to also get your Space ID.</p>
245
-
246
- <p>For more information, check the <a href="https://www.contentful.com/developers/docs/references/authentication/">Contentful REST API reference on Authentication</a>.</p>
247
-
248
- <h2 id="label-Documentation+-26+References">Documentation &amp; References</h2>
249
- <ul><li>
250
- <p><a href="#configuration">Configuration</a></p>
251
- </li><li>
252
- <p><a href="#reference-documentation">Reference documentation</a></p>
253
- </li><li>
254
- <p><a href="#tutorials--other-resources">Tutorials & other resources</a></p>
255
- </li><li>
256
- <p><a href="#advanced-concepts">Advanced Concepts</a></p>
257
- </li><li>
258
- <p><a href="#migrating-to-2x">Migrating to 2.x</a></p>
259
- </li></ul>
260
-
261
- <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>
262
-
263
- <h3 id="label-Configuration">Configuration</h3>
264
-
265
- <p>The client constructor supports several options you may set to achieve the expected behavior:</p>
266
-
267
- <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>
268
- <span class='comment'># ... your options here ...
269
- </span><span class='rparen'>)</span>
270
- </code></pre>
271
- <table>
272
- <thead>
273
- <tr>
274
- <th>Name</th>
275
- <th>Default</th>
276
- <th>Description</th>
277
- </tr>
278
- </thead>
279
- <tbody>
280
- <tr>
281
- <td><code>access_token</code></td>
282
- <td></td>
283
- <td><strong>Required</strong>. Your access token.</td>
284
- </tr>
285
- <tr>
286
- <td><code>space</code></td>
287
- <td></td>
288
- <td><strong>Required</strong>. Your space ID.</td>
289
- </tr>
290
- <tr>
291
- <td><code>environment</code></td>
292
- <td>'master'</td>
293
- <td>Your environment ID.</td>
294
- </tr>
295
- <tr>
296
- <td><code>api_url</code></td>
297
- <td><code>'cdn.contentful.com'</code></td>
298
- <td>Set the host used to build the request URIs.</td>
299
- </tr>
300
- <tr>
301
- <td><code>default_locale</code></td>
302
- <td><code>'en-US'</code></td>
303
- <td>Defines default locale for the client.</td>
304
- </tr>
305
- <tr>
306
- <td><code>secure</code></td>
307
- <td><code>true</code></td>
308
- <td>Defines whether to use HTTPS or HTTP. By default we use HTTPS.</td>
309
- </tr>
310
- <tr>
311
- <td><code>authentication_mechanism</code></td>
312
- <td><code>:header</code></td>
313
- <td>Sets the authentication mechanisms, valid options are <code>:header</code> or <code>:query_string</code></td>
314
- </tr>
315
- <tr>
316
- <td><code>raise_errors</code></td>
317
- <td><code>true</code></td>
318
- <td>Determines whether errors are raised or returned.</td>
319
- </tr>
320
- <tr>
321
- <td><code>raise_for_empty_fields</code></td>
322
- <td><code>true</code></td>
323
- <td>Determines whether <code>EmptyFieldError</code> is raised when empty fields are requested on an entry or <code>nil</code> is returned.</td>
324
- </tr>
325
- <tr>
326
- <td><code>dynamic_entries</code></td>
327
- <td><code>:manual</code></td>
328
- <td>
329
- Determines if content type caching is enabled automatically or not,
330
- allowing for accessing of fields even when they are not present on the response.
331
- Valid options are <code>:auto</code> and <code>:manual</code>.
332
- </td>
333
- </tr>
334
- <tr>
335
- <td><code>raw_mode</code></td>
336
- <td><code>false</code></td>
337
- <td>If enabled, API responses are not parsed and the raw response object is returned instead.</td>
338
- </tr>
339
- <tr>
340
- <td><code>resource_mapping</code></td>
341
- <td><code>{}</code></td>
342
- <td>Allows for overriding default resource classes with custom ones.</td>
343
- </tr>
344
- <tr>
345
- <td><code>entry_mapping</code></td>
346
- <td><code>{}</code></td>
347
- <td>Allows for overriding of specific entry classes by content type.</td>
348
- </tr>
349
- <tr>
350
- <td><code>gzip_encoded</code></td>
351
- <td><code>true</code></td>
352
- <td>Enables gzip response content encoding.</td>
353
- </tr>
354
- <tr>
355
- <td><code>max_rate_limit_retries</code></td>
356
- <td><code>1</code></td>
357
- <td>
358
- To increase or decrease the retry attempts after a 429 Rate Limit error. Default value is 1. Using 0 will disable retry behaviour.
359
- Each retry will be attempted after the value (in seconds) of the <code>X-Contentful-RateLimit-Reset</code> header,
360
- which contains the amount of seconds until the next non rate limited request is available, has passed.
361
- This is blocking per execution thread.
362
- </td>
363
- </tr>
364
- <tr>
365
- <td><code>max_rate_limit_wait</code></td>
366
- <td><code>60</code></td>
367
- <td>
368
- Maximum time to wait for next available request (in seconds). Default value is 60 seconds.
369
- Keep in mind that if you hit the hourly rate limit maximum, you can have up to 60 minutes of blocked requests.
370
- It is set to a default of 60 seconds in order to avoid blocking processes for too long, as rate limit retry behaviour
371
- is blocking per execution thread.
372
- </td>
373
- </tr>
374
- <tr>
375
- <td><code>max_include_resolution_depth</code></td>
376
- <td><code>20</code></td>
377
- <td>
378
- Maximum amount of levels to resolve includes for SDK entities
379
- (this is independent of API-level includes - it represents the maximum depth the include resolution
380
- tree is allowed to resolved before falling back to <code>Link</code> objects).
381
- This include resolution strategy is in place in order to avoid having infinite circular recursion on resources with circular dependencies.
382
- <strong>Note</strong>: If you're using something like <code>Rails::cache</code> it's advisable to considerably lower this value
383
- (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).
384
- Note that when <code>reuse_entries</code> is enabled, the max include resolution depth only affects
385
- deep chains of unique objects (ie, not simple circular references).
386
- </td>
387
- </tr>
388
- <tr>
389
- <td><code>reuse_entries</code></td>
390
- <td><code>false</code></td>
391
- <td>
392
- When enabled, reuse hydrated Entry and Asset objects within the same request when possible.
393
- Can result in a large speed increase and better handles cyclical object graphs.
394
- This can be a good alternative to <code>max_include_resolution_depth</code> if your content model contains (or can contain) circular references.
395
- <strong>Caching may break if this option is enabled, as it may generate stack errors.</strong>
396
- When caching, deactivate this option and opt for a conservative <code>max_include_resolution_depth</code> value.
397
- </td>
398
- </tr>
399
- <tr>
400
- <td><code>use_camel_case</code></td>
401
- <td><code>false</code></td>
402
- <td>
403
- When doing the v2 upgrade, all keys and accessors were changed to always use <code>snake_case</code>.
404
- This option introduces the ability to use <code>camelCase</code> for keys and method accessors.
405
- This is very useful for isomorphic applications.
406
- </td>
407
- </tr>
408
- <tr>
409
- <td><code>proxy_host</code></td>
410
- <td><code>nil</code></td>
411
- <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>
412
- </tr>
413
- <tr>
414
- <td><code>proxy_port</code></td>
415
- <td><code>nil</code></td>
416
- <td>Specify the port number that is used by the proxy server for client connections.</td>
417
- </tr>
418
- <tr>
419
- <td><code>proxy_username</code></td>
420
- <td><code>nil</code></td>
421
- <td>Username for proxy authentication.</td>
422
- </tr>
423
- <tr>
424
- <td><code>proxy_password</code></td>
425
- <td><code>nil</code></td>
426
- <td>Password for proxy authentication.</td>
427
- </tr>
428
- <tr>
429
- <td><code>timeout_read</code></td>
430
- <td><code>nil</code></td>
431
- <td>Number of seconds the request waits to read from the server before timing out.</td>
432
- </tr>
433
- <tr>
434
- <td><code>timeout_write</code></td>
435
- <td><code>nil</code></td>
436
- <td>Number of seconds the request waits when writing to the server before timing out.</td>
437
- </tr>
438
- <tr>
439
- <td><code>timeout_connect</code></td>
440
- <td><code>nil</code></td>
441
- <td>Number of seconds the request waits to connect to the server before timing out.</td>
442
- </tr>
443
- <tr>
444
- <td><code>logger</code></td>
445
- <td><code>nil</code></td>
446
- <td>To enable logging pass a logger instance compatible with <code>::Logger</code>.</td>
447
- </tr>
448
- <tr>
449
- <td><code>log_level</code></td>
450
- <td><code>::Logger::INFO</code></td>
451
- <td>
452
- The default severity is set to INFO and logs only the request attributes (headers, parameters and url).
453
- Setting it to DEBUG will also log the raw JSON response.
454
- </td>
455
- </tr>
456
- </tbody>
457
- </table>
458
- <h3 id="label-Reference+documentation">Reference documentation</h3>
459
-
460
- <h4 id="label-Basic+queries">Basic queries</h4>
461
-
462
- <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>
463
- <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>
464
- <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>
465
- <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>
466
- <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>
467
- <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>
468
- </code></pre>
469
-
470
- <h4 id="label-Filtering+options">Filtering options</h4>
471
-
472
- <p>You can pass the usual filter options to the query:</p>
473
-
474
- <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)
475
- </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;
476
- </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
477
- </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
478
- </span></code></pre>
479
-
480
- <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>
481
-
482
- <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>
483
-
484
- <h4 id="label-Accessing+fields+and+sys+properties">Accessing fields and sys properties</h4>
485
-
486
- <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>
487
- <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;
488
- </span></code></pre>
489
-
490
- <p>System Properties behave the same and can be accessed via the <code>#sys</code> method.</p>
491
-
492
- <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;
493
- </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;
494
- </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; }
495
- </span></code></pre>
496
-
497
- <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>
498
-
499
- <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>
500
- <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;
501
- </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;
502
- </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;
503
- </span></code></pre>
504
-
505
- <h4 id="label-Dynamic+entries">Dynamic entries</h4>
506
-
507
- <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 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>
508
-
509
- <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>
510
- <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>
511
- <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>
512
- <span class='label'>dynamic_entries:</span> <span class='symbol'>:auto</span>
513
- <span class='rparen'>)</span>
514
-
515
- <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;
516
- </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;
517
- </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;
518
- </span></code></pre>
519
-
520
- <p>Dynamic entries will have getter classes for the fields and do type conversions properly.</p>
521
-
522
- <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 the cache.</p>
523
-
524
- <h4 id="label-Using+different+locales">Using different locales</h4>
525
-
526
- <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 you can do the following:</p>
527
-
528
- <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>
529
- </code></pre>
530
-
531
- <p>Then all the fields will be fetched for the requested locale.</p>
532
-
533
- <p>Contentful Delivery API also allows to fetch all locales, you can do so by doing:</p>
534
-
535
- <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>
536
-
537
- <span class='comment'># assuming the entry has a field called name
538
- </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>
539
- </code></pre>
540
-
541
- <p>When requesting multiple locales, the object accessor shortcuts only work for the default locale.</p>
542
-
543
- <h4 id="label-Arrays">Arrays</h4>
544
-
545
- <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>
546
-
547
- <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>
548
-
549
- <h4 id="label-Links">Links</h4>
550
-
551
- <p>You can easily request a resource that is represented by a link by calling <code>#resolve</code>:</p>
552
-
553
- <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>
554
- <span class='id identifier rubyid_happycat'>happycat</span><span class='period'>.</span><span class='id identifier rubyid_image'>image</span>
555
- <span class='comment'># =&gt; #&lt;Contentful::Link: @sys={:type=&gt;&quot;Link&quot;, :linkType=&gt;&quot;Asset&quot;, :id=&gt;&quot;happycat&quot;}&gt;
556
- </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={ ...
557
- </span></code></pre>
558
-
559
- <h3 id="label-Assets">Assets</h3>
560
-
561
- <p>There is a helpful method to add image resize options for an asset image:</p>
562
-
563
- <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>
564
- <span class='comment'># =&gt; &quot;//images.contentful.com/cfexampleapi/3MZPnjZTIskAIIkuuosCss/
565
- </span><span class='comment'># 382a48dfa2cb16c47aa2c72f7b23bf09/happycatw.jpg&quot;
566
- </span>
567
- <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>
568
- <span class='comment'># =&gt; &quot;//images.contentful.com/cfexampleapi/3MZPnjZTIskAIIkuuosCss/
569
- </span><span class='comment'># 382a48dfa2cb16c47aa2c72f7b23bf09/happycatw.jpg?w=300&amp;h=200&amp;fm=jpg&amp;q=100&quot;
570
- </span></code></pre>
571
-
572
- <h4 id="label-Resource+options">Resource options</h4>
573
-
574
- <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>
575
-
576
- <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>
577
- <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
578
- </span></code></pre>
579
-
580
- <h4 id="label-Field+type+Object">Field type <code>Object</code></h4>
581
-
582
- <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.</p>
583
-
584
- <h3 id="label-Advanced+concepts">Advanced concepts</h3>
585
-
586
- <h4 id="label-Proxy+example">Proxy example</h4>
587
-
588
- <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>
589
- <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>
590
- <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>
591
- <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>
592
- <span class='label'>proxy_port:</span> <span class='int'>8080</span><span class='comma'>,</span>
593
- <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>
594
- <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>
595
- <span class='rparen'>)</span>
596
- </code></pre>
597
-
598
- <h4 id="label-Custom+resource+classes">Custom resource classes</h4>
599
-
600
- <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>
601
-
602
- <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>
603
- <span class='kw'>def</span> <span class='id identifier rubyid_https_image_url'>https_image_url</span>
604
- <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>
605
- <span class='kw'>end</span>
606
- <span class='kw'>end</span>
607
- </code></pre>
608
-
609
- <p>You can register your custom class on client initialization:</p>
610
-
611
- <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>
612
- <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>
613
- <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>
614
- <span class='label'>resource_mapping:</span> <span class='lbrace'>{</span>
615
- <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>
616
- <span class='rbrace'>}</span>
617
- <span class='rparen'>)</span>
618
- </code></pre>
619
-
620
- <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>
621
-
622
- <p>You can also register custom entry classes to be used based on the entry&#39;s content_type using the <code>:entry_mapping</code> configuration:</p>
623
-
624
- <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>
625
- <span class='comment'># define methods based on :fields, etc
626
- </span><span class='kw'>end</span>
627
-
628
- <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>
629
- <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>
630
- <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>
631
- <span class='label'>entry_mapping:</span> <span class='lbrace'>{</span>
632
- <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>
633
- <span class='rbrace'>}</span>
634
- <span class='rparen'>)</span>
635
-
636
- <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
637
- </span></code></pre>
638
-
639
- <h4 id="label-Synchronization">Synchronization</h4>
640
-
641
- <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>
642
-
643
- <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>
644
- <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>
645
- <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>
646
- <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>
647
- <span class='rparen'>)</span>
648
-
649
- <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
650
- </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
651
- </span></code></pre>
652
-
653
- <p>You can access the results either wrapped in <code>Contentful::SyncPage</code> objects:</p>
654
-
655
- <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>
656
- <span class='comment'># Find resources at: page.items
657
- </span><span class='kw'>end</span>
658
-
659
- <span class='comment'># More explicit version:
660
- </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>
661
- <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>
662
- <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>
663
- <span class='kw'>end</span>
664
- </code></pre>
665
-
666
- <p>Or directly iterative over all resources:</p>
667
-
668
- <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>
669
- <span class='comment'># ...
670
- </span><span class='kw'>end</span>
671
- </code></pre>
672
-
673
- <p>When a sync is completed, the next sync url can be read from the Sync or SyncPage object:</p>
674
-
675
- <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>
676
- </code></pre>
677
-
678
- <p><strong>Please note</strong> that synchronization entries come in all locales, so make sure, you supply a :default_locale property to the client configuration, when using the sync feature. This locale will be returned by default, when you call <code>Entry#fields</code>. The other localized data will also be saved and can be accessed by calling the fields method with a locale parameter:</p>
679
-
680
- <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>
681
- <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
682
- </span></code></pre>
683
-
684
- <h3 id="label-Migrating+to+2.x">Migrating to 2.x</h3>
685
-
686
- <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>
687
- <ul><li>
688
- <p><code>Contentful::Link#resolve</code> and <code>Contentful::Array#next_page</code> now require a <code>Contentful::Client</code> instance as a parameter.</p>
689
- </li><li>
690
- <p><code>Contentful::CustomResource</code> does no longer exist, custom entry classes can now inherit from <code>Contentful::Entry</code> and have proper marshalling working.</p>
691
- </li><li>
692
- <p><code>Contentful::Resource</code> does no longer exist, all resource classes now inherit from <code>Contentful::BaseResource</code>. <code>Contentful::Entry</code> and <code>Contentful::Asset</code> inherit from <code>Contentful::FieldsResource</code> which is a subclass of <code>Contentful::BaseResource</code>.</p>
693
- </li><li>
694
- <p><code>Contentful::DynamicEntry</code> does no longer exist, if code checked against that base class, it should now check against <code>Contentful::Entry</code> instead.</p>
695
- </li><li>
696
- <p><code>Contentful::Client#dynamic_entry_cache</code> <em>(private)</em> has been extracted to it&#39;s own class, and can be now manually cleared by using <code>Contentful::ContentTypeCache::clear</code>.</p>
697
- </li><li>
698
- <p><code>Contentful::BaseResource#sys</code> and <code>Contentful::FieldsResource#fields</code> internal representation for keys are now snake cased to match the instance accessors. E.g. <code>entry.fields[:myField]</code> previously had the accessor <code>entry.my_field</code>, now it is <code>entry.fields[:my_field]</code>. The value in both cases would correspond to the same field, only change is to unify the style. If code accessed the values through the <code>#sys</code> or <code>#fields</code> methods, keys now need to be snake cased.</p>
699
- </li><li>
700
- <p>Circular references are handled as individual objects to simplify marshalling and reduce stack errors, this introduces a performance hit on extremely interconnected content. Therefore, to limit the impact of circular references, an additional configuration flag <code>max_include_resolution_depth</code> has been added. It is set to 20 by default (which corresponds to the maximum include level value * 2). This allows for non-circular but highly connected content to resolve properly. In very interconnected content, it also allows to reduce this number to improve performance. For a more in depth look into this you can read <a href="https://github.com/contentful/contentful.rb/issues/124#issuecomment-287002469">this issue</a>.</p>
701
- </li><li>
702
- <p><code>#inspect</code> now offers a clearer and better output for all resources. If your code had assertions based on the string representation of the resources, update to the new format <code>&lt;Contentful::#{RESOURCE_CLASS}#{additional_info} id=&quot;#{RESOURCE_ID}&quot;&gt;</code>.</p>
703
- </li></ul>
704
-
705
- <p>For more information on the internal changes present in the 2.x release, please read the <a href="CHANGELOG.md">CHANGELOG</a></p>
706
-
707
- <h3 id="label-Tutorials+-26+other+resources">Tutorials &amp; other resources</h3>
708
- <ul><li>
709
- <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>
710
- </li><li>
711
- <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>
712
- </li></ul>
713
-
714
- <h2 id="label-Reach+out+to+us">Reach out to us</h2>
715
-
716
- <h3 id="label-You+have+questions+about+how+to+use+this+library-3F">You have questions about how to use this library?</h3>
717
- <ul><li>
718
- <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>
719
- </li><li>
720
- <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>
721
- </li></ul>
722
-
723
- <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>
724
- <ul><li>
725
- <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>
726
- </li></ul>
727
-
728
- <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>
729
- <ul><li>
730
- <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>
731
- </li></ul>
732
-
733
- <h2 id="label-Get+involved">Get involved</h2>
734
-
735
- <p><a href="http://makeapullrequest.com"><img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?maxAge=31557600"></a></p>
736
-
737
- <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>
738
-
739
- <h2 id="label-License">License</h2>
740
-
741
- <p>This repository is published under the <a href="LICENSE.txt">MIT</a> license.</p>
742
-
743
- <h2 id="label-Code+of+Conduct">Code of Conduct</h2>
744
-
745
- <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>
746
-
747
- <p><a href="https://github.com/contentful-developer-relations/community-code-of-conduct">Read our full Code of Conduct</a>.</p>
748
- </div></div>
749
-
750
- <div id="footer">
751
- Generated on Wed Apr 15 13:47:01 2020 by
752
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
753
- 0.9.20 (ruby-2.6.3).
754
- </div>
755
-
756
- </div>
757
- </body>
758
- </html>