contentful-management 1.10.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (303) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +3 -0
  3. data/CHANGELOG.md +48 -0
  4. data/README.md +92 -50
  5. data/lib/contentful/management/api_key.rb +25 -2
  6. data/lib/contentful/management/array.rb +3 -3
  7. data/lib/contentful/management/asset.rb +13 -8
  8. data/lib/contentful/management/client.rb +73 -60
  9. data/lib/contentful/management/client_api_key_methods_factory.rb +8 -0
  10. data/lib/contentful/management/client_asset_methods_factory.rb +0 -2
  11. data/lib/contentful/management/client_association_all_published_method_factory.rb +2 -3
  12. data/lib/contentful/management/client_association_methods_factory.rb +9 -9
  13. data/lib/contentful/management/client_content_type_methods_factory.rb +8 -2
  14. data/lib/contentful/management/client_editor_interface_methods_factory.rb +12 -6
  15. data/lib/contentful/management/client_entry_methods_factory.rb +1 -3
  16. data/lib/contentful/management/client_environment_methods_factory.rb +59 -0
  17. data/lib/contentful/management/client_organization_methods_factory.rb +1 -1
  18. data/lib/contentful/management/client_personal_access_tokens_methods_factory.rb +3 -3
  19. data/lib/contentful/management/client_role_methods_factory.rb +8 -0
  20. data/lib/contentful/management/client_snapshot_methods_factory.rb +8 -6
  21. data/lib/contentful/management/client_space_methods_factory.rb +2 -6
  22. data/lib/contentful/management/client_upload_methods_factory.rb +8 -0
  23. data/lib/contentful/management/client_user_methods_factory.rb +1 -1
  24. data/lib/contentful/management/client_webhook_call_methods_factory.rb +11 -6
  25. data/lib/contentful/management/client_webhook_health_methods_factory.rb +2 -2
  26. data/lib/contentful/management/client_webhook_methods_factory.rb +8 -0
  27. data/lib/contentful/management/content_type.rb +9 -7
  28. data/lib/contentful/management/content_type_editor_interface_methods_factory.rb +7 -3
  29. data/lib/contentful/management/content_type_entry_methods_factory.rb +2 -2
  30. data/lib/contentful/management/content_type_snapshot_methods_factory.rb +16 -2
  31. data/lib/contentful/management/dynamic_entry.rb +1 -1
  32. data/lib/contentful/management/editor_interface.rb +14 -6
  33. data/lib/contentful/management/entry.rb +12 -10
  34. data/lib/contentful/management/entry_association_methods_factory.rb +2 -2
  35. data/lib/contentful/management/environment.rb +138 -0
  36. data/lib/contentful/management/environment_asset_methods_factory.rb +11 -0
  37. data/lib/contentful/management/environment_association_methods_factory.rb +42 -0
  38. data/lib/contentful/management/environment_content_type_methods_factory.rb +11 -0
  39. data/lib/contentful/management/environment_editor_interface_methods_factory.rb +15 -0
  40. data/lib/contentful/management/environment_entry_methods_factory.rb +11 -0
  41. data/lib/contentful/management/environment_locale_methods_factory.rb +11 -0
  42. data/lib/contentful/management/environment_ui_extension_methods_factory.rb +11 -0
  43. data/lib/contentful/management/field.rb +3 -3
  44. data/lib/contentful/management/file.rb +2 -2
  45. data/lib/contentful/management/link.rb +21 -7
  46. data/lib/contentful/management/locale.rb +4 -2
  47. data/lib/contentful/management/organization.rb +1 -1
  48. data/lib/contentful/management/personal_access_token.rb +2 -2
  49. data/lib/contentful/management/resource.rb +34 -13
  50. data/lib/contentful/management/resource/all_published.rb +2 -2
  51. data/lib/contentful/management/resource/archiver.rb +12 -2
  52. data/lib/contentful/management/resource/environment_aware.rb +13 -0
  53. data/lib/contentful/management/resource/publisher.rb +12 -2
  54. data/lib/contentful/management/resource/refresher.rb +1 -1
  55. data/lib/contentful/management/resource_builder.rb +16 -14
  56. data/lib/contentful/management/response.rb +1 -1
  57. data/lib/contentful/management/role.rb +29 -2
  58. data/lib/contentful/management/snapshot.rb +13 -7
  59. data/lib/contentful/management/space.rb +14 -93
  60. data/lib/contentful/management/space_association_methods_factory.rb +1 -1
  61. data/lib/contentful/management/{space_locale_methods_factory.rb → space_environment_methods_factory.rb} +2 -6
  62. data/lib/contentful/management/space_membership.rb +3 -3
  63. data/lib/contentful/management/ui_extension.rb +4 -2
  64. data/lib/contentful/management/upload.rb +24 -1
  65. data/lib/contentful/management/user.rb +4 -4
  66. data/lib/contentful/management/validation.rb +5 -5
  67. data/lib/contentful/management/version.rb +1 -1
  68. data/lib/contentful/management/webhook.rb +26 -3
  69. data/lib/contentful/management/webhook_call.rb +8 -8
  70. data/lib/contentful/management/webhook_health.rb +2 -2
  71. data/spec/fixtures/vcr_cassettes/asset/143_assets_next_page.yml +2 -2
  72. data/spec/fixtures/vcr_cassettes/asset/all.yml +1 -1
  73. data/spec/fixtures/vcr_cassettes/asset/archive.yml +2 -2
  74. data/spec/fixtures/vcr_cassettes/asset/archive_published.yml +2 -2
  75. data/spec/fixtures/vcr_cassettes/asset/archived_false.yml +2 -2
  76. data/spec/fixtures/vcr_cassettes/asset/archived_true.yml +2 -2
  77. data/spec/fixtures/vcr_cassettes/asset/create.yml +2 -2
  78. data/spec/fixtures/vcr_cassettes/asset/create_with_already_used_id.yml +1 -1
  79. data/spec/fixtures/vcr_cassettes/asset/create_with_custom_id.yml +2 -2
  80. data/spec/fixtures/vcr_cassettes/asset/create_with_locale.yml +2 -2
  81. data/spec/fixtures/vcr_cassettes/asset/destroy.yml +2 -2
  82. data/spec/fixtures/vcr_cassettes/asset/destroy_published.yml +2 -2
  83. data/spec/fixtures/vcr_cassettes/asset/find.yml +1 -1
  84. data/spec/fixtures/vcr_cassettes/asset/find_not_found.yml +1 -1
  85. data/spec/fixtures/vcr_cassettes/asset/limited_assets_next_page.yml +2 -2
  86. data/spec/fixtures/vcr_cassettes/asset/locale.yml +1 -1
  87. data/spec/fixtures/vcr_cassettes/asset/process.yml +2 -2
  88. data/spec/fixtures/vcr_cassettes/asset/publish.yml +2 -2
  89. data/spec/fixtures/vcr_cassettes/asset/publish_after_create.yml +3 -3
  90. data/spec/fixtures/vcr_cassettes/asset/publish_already_published.yml +2 -2
  91. data/spec/fixtures/vcr_cassettes/asset/published_false.yml +2 -2
  92. data/spec/fixtures/vcr_cassettes/asset/published_true.yml +2 -2
  93. data/spec/fixtures/vcr_cassettes/asset/reload.yml +4 -4
  94. data/spec/fixtures/vcr_cassettes/asset/reload_with_fields.yml +2 -2
  95. data/spec/fixtures/vcr_cassettes/asset/save_update.yml +2 -2
  96. data/spec/fixtures/vcr_cassettes/asset/select_operator.yml +1 -1
  97. data/spec/fixtures/vcr_cassettes/asset/set_locale.yml +1 -1
  98. data/spec/fixtures/vcr_cassettes/asset/unarchive.yml +2 -2
  99. data/spec/fixtures/vcr_cassettes/asset/unarchive_already_unarchive.yml +2 -2
  100. data/spec/fixtures/vcr_cassettes/asset/unarchive_already_unarchived.yml +2 -2
  101. data/spec/fixtures/vcr_cassettes/asset/unpublish.yml +2 -2
  102. data/spec/fixtures/vcr_cassettes/asset/unpublish_already_unpublished.yml +2 -2
  103. data/spec/fixtures/vcr_cassettes/asset/update_file.yml +2 -2
  104. data/spec/fixtures/vcr_cassettes/asset/update_to_specified_locale.yml +2 -2
  105. data/spec/fixtures/vcr_cassettes/asset/update_with_default_locale_without_file.yml +2 -2
  106. data/spec/fixtures/vcr_cassettes/content_type/activate.yml +2 -2
  107. data/spec/fixtures/vcr_cassettes/content_type/activate_with_invalid_version.yml +2 -2
  108. data/spec/fixtures/vcr_cassettes/content_type/activated_false.yml +2 -2
  109. data/spec/fixtures/vcr_cassettes/content_type/activated_true.yml +2 -2
  110. data/spec/fixtures/vcr_cassettes/content_type/all.yml +1 -1
  111. data/spec/fixtures/vcr_cassettes/content_type/all_public.yml +1 -1
  112. data/spec/fixtures/vcr_cassettes/content_type/create.yml +1 -1
  113. data/spec/fixtures/vcr_cassettes/content_type/create_content_type_with_id.yml +1 -1
  114. data/spec/fixtures/vcr_cassettes/content_type/create_with_Array_field.yml +1 -1
  115. data/spec/fixtures/vcr_cassettes/content_type/create_with_Boolean_field.yml +1 -1
  116. data/spec/fixtures/vcr_cassettes/content_type/create_with_Date_field.yml +1 -1
  117. data/spec/fixtures/vcr_cassettes/content_type/create_with_Integer_field.yml +1 -1
  118. data/spec/fixtures/vcr_cassettes/content_type/create_with_Link_field.yml +1 -1
  119. data/spec/fixtures/vcr_cassettes/content_type/create_with_Location_field.yml +1 -1
  120. data/spec/fixtures/vcr_cassettes/content_type/create_with_Number_field.yml +1 -1
  121. data/spec/fixtures/vcr_cassettes/content_type/create_with_Object_field.yml +1 -1
  122. data/spec/fixtures/vcr_cassettes/content_type/create_with_Symbol_field.yml +1 -1
  123. data/spec/fixtures/vcr_cassettes/content_type/create_with_Text_field.yml +1 -1
  124. data/spec/fixtures/vcr_cassettes/content_type/deactivate.yml +2 -2
  125. data/spec/fixtures/vcr_cassettes/content_type/deactivate_already_deactivated.yml +2 -2
  126. data/spec/fixtures/vcr_cassettes/content_type/deactivate_with_entries.yml +2 -2
  127. data/spec/fixtures/vcr_cassettes/content_type/deactivate_with_version_change.yml +2 -2
  128. data/spec/fixtures/vcr_cassettes/content_type/destroy.yml +2 -2
  129. data/spec/fixtures/vcr_cassettes/content_type/destroy_activated.yml +2 -2
  130. data/spec/fixtures/vcr_cassettes/content_type/entry/all.yml +4 -4
  131. data/spec/fixtures/vcr_cassettes/content_type/entry/create.yml +4 -4
  132. data/spec/fixtures/vcr_cassettes/content_type/entry/create_only_with_localized_fields.yml +2 -2
  133. data/spec/fixtures/vcr_cassettes/content_type/entry/create_to_single_locale_only_with_localized_fields.yml +2 -2
  134. data/spec/fixtures/vcr_cassettes/content_type/entry/create_with_camel_case_id_to_multiple_locales.yml +2 -2
  135. data/spec/fixtures/vcr_cassettes/content_type/entry/create_with_entries.yml +3 -3
  136. data/spec/fixtures/vcr_cassettes/content_type/entry/create_with_entries_for_multiple_locales.yml +9 -9
  137. data/spec/fixtures/vcr_cassettes/content_type/entry/create_with_multiple_locales.yml +2 -2
  138. data/spec/fixtures/vcr_cassettes/content_type/entry/update_only_with_localized_fields.yml +3 -3
  139. data/spec/fixtures/vcr_cassettes/content_type/fields/add.yml +2 -2
  140. data/spec/fixtures/vcr_cassettes/content_type/fields/create.yml +2 -2
  141. data/spec/fixtures/vcr_cassettes/content_type/fields/create_array_types.yml +3 -3
  142. data/spec/fixtures/vcr_cassettes/content_type/fields/create_array_with_params.yml +2 -2
  143. data/spec/fixtures/vcr_cassettes/content_type/fields/create_with_params.yml +2 -2
  144. data/spec/fixtures/vcr_cassettes/content_type/fields/destroy.yml +2 -2
  145. data/spec/fixtures/vcr_cassettes/content_type/fields/update_field.yml +2 -2
  146. data/spec/fixtures/vcr_cassettes/content_type/find.yml +1 -1
  147. data/spec/fixtures/vcr_cassettes/content_type/find_not_found.yml +1 -1
  148. data/spec/fixtures/vcr_cassettes/content_type/issue_79.yml +3 -3
  149. data/spec/fixtures/vcr_cassettes/content_type/omitted_field.yml +4 -4
  150. data/spec/fixtures/vcr_cassettes/content_type/reload.yml +4 -4
  151. data/spec/fixtures/vcr_cassettes/content_type/save_new.yml +3 -3
  152. data/spec/fixtures/vcr_cassettes/content_type/save_updated.yml +2 -2
  153. data/spec/fixtures/vcr_cassettes/content_type/save_with_added_field.yml +2 -2
  154. data/spec/fixtures/vcr_cassettes/content_type/update.yml +2 -2
  155. data/spec/fixtures/vcr_cassettes/content_type/update_change_field_name.yml +2 -2
  156. data/spec/fixtures/vcr_cassettes/content_type/update_remove_field.yml +2 -2
  157. data/spec/fixtures/vcr_cassettes/content_type/update_with_fields.yml +2 -2
  158. data/spec/fixtures/vcr_cassettes/content_type/update_with_one_new_field.yml +2 -2
  159. data/spec/fixtures/vcr_cassettes/content_type/validation/in.yml +3 -3
  160. data/spec/fixtures/vcr_cassettes/content_type/validation/in_add.yml +3 -3
  161. data/spec/fixtures/vcr_cassettes/content_type/validation/in_update.yml +3 -3
  162. data/spec/fixtures/vcr_cassettes/content_type/validation/link_content_type.yml +3 -3
  163. data/spec/fixtures/vcr_cassettes/content_type/validation/link_field.yml +3 -3
  164. data/spec/fixtures/vcr_cassettes/content_type/validation/link_mimetype_group.yml +3 -3
  165. data/spec/fixtures/vcr_cassettes/content_type/validation/multiple_add.yml +3 -3
  166. data/spec/fixtures/vcr_cassettes/content_type/validation/present.yml +3 -3
  167. data/spec/fixtures/vcr_cassettes/content_type/validation/range.yml +3 -3
  168. data/spec/fixtures/vcr_cassettes/content_type/validation/range_update.yml +3 -3
  169. data/spec/fixtures/vcr_cassettes/content_type/validation/regexp.yml +3 -3
  170. data/spec/fixtures/vcr_cassettes/content_type/validation/size.yml +3 -3
  171. data/spec/fixtures/vcr_cassettes/content_type/validation/unique.yml +3 -3
  172. data/spec/fixtures/vcr_cassettes/editor_interfaces/default_for_space.yml +1 -1
  173. data/spec/fixtures/vcr_cassettes/editor_interfaces/update.yml +3 -3
  174. data/spec/fixtures/vcr_cassettes/entry/all.yml +1 -1
  175. data/spec/fixtures/vcr_cassettes/entry/archive.yml +2 -2
  176. data/spec/fixtures/vcr_cassettes/entry/archive_published.yml +2 -2
  177. data/spec/fixtures/vcr_cassettes/entry/archived_false.yml +2 -2
  178. data/spec/fixtures/vcr_cassettes/entry/archived_true.yml +2 -2
  179. data/spec/fixtures/vcr_cassettes/entry/content_type_entires.yml +1 -1
  180. data/spec/fixtures/vcr_cassettes/entry/create.yml +4 -4
  181. data/spec/fixtures/vcr_cassettes/entry/create_with_asset.yml +3 -3
  182. data/spec/fixtures/vcr_cassettes/entry/create_with_assets.yml +3 -3
  183. data/spec/fixtures/vcr_cassettes/entry/create_with_custom_id.yml +2 -2
  184. data/spec/fixtures/vcr_cassettes/entry/create_with_entries.yml +3 -3
  185. data/spec/fixtures/vcr_cassettes/entry/create_with_entry.yml +3 -3
  186. data/spec/fixtures/vcr_cassettes/entry/create_with_just_id.yml +4 -4
  187. data/spec/fixtures/vcr_cassettes/entry/create_with_location.yml +2 -2
  188. data/spec/fixtures/vcr_cassettes/entry/create_with_specified_locale.yml +3 -3
  189. data/spec/fixtures/vcr_cassettes/entry/create_with_symbols.yml +2 -2
  190. data/spec/fixtures/vcr_cassettes/entry/destory_published.yml +2 -2
  191. data/spec/fixtures/vcr_cassettes/entry/destroy.yml +2 -2
  192. data/spec/fixtures/vcr_cassettes/entry/fallback_undefined.yml +3 -3
  193. data/spec/fixtures/vcr_cassettes/entry/find-with-null-symbols.yml +2 -2
  194. data/spec/fixtures/vcr_cassettes/entry/find.yml +1 -1
  195. data/spec/fixtures/vcr_cassettes/entry/find_not_found.yml +1 -1
  196. data/spec/fixtures/vcr_cassettes/entry/issue_61_1.yml +6 -6
  197. data/spec/fixtures/vcr_cassettes/entry/issue_61_2.yml +6 -6
  198. data/spec/fixtures/vcr_cassettes/entry/issue_61_3.yml +6 -6
  199. data/spec/fixtures/vcr_cassettes/entry/issue_61_4.yml +6 -6
  200. data/spec/fixtures/vcr_cassettes/entry/issue_61_5.yml +305 -198
  201. data/spec/fixtures/vcr_cassettes/entry/issue_61_6.yml +5 -5
  202. data/spec/fixtures/vcr_cassettes/entry/issue_61_7.yml +6 -6
  203. data/spec/fixtures/vcr_cassettes/entry/issue_61_8.yml +6 -6
  204. data/spec/fixtures/vcr_cassettes/entry/issue_61_spaces.yml +143 -188
  205. data/spec/fixtures/vcr_cassettes/entry/issue_70.yml +3 -3
  206. data/spec/fixtures/vcr_cassettes/entry/issue_73.yml +4 -4
  207. data/spec/fixtures/vcr_cassettes/entry/issue_91.yml +2 -2
  208. data/spec/fixtures/vcr_cassettes/entry/limited_entries.yml +2 -2
  209. data/spec/fixtures/vcr_cassettes/entry/locales/fallback_to_default_locale.yml +2 -2
  210. data/spec/fixtures/vcr_cassettes/entry/locales/retrieve_localized.yml +2 -2
  211. data/spec/fixtures/vcr_cassettes/entry/locales/simple_assignments_use_default_locale.yml +2 -2
  212. data/spec/fixtures/vcr_cassettes/entry/locales/simple_assignments_use_specified_locale.yml +2 -2
  213. data/spec/fixtures/vcr_cassettes/entry/publish.yml +2 -2
  214. data/spec/fixtures/vcr_cassettes/entry/publish_already_published.yml +2 -2
  215. data/spec/fixtures/vcr_cassettes/entry/published_false.yml +2 -2
  216. data/spec/fixtures/vcr_cassettes/entry/published_true.yml +2 -2
  217. data/spec/fixtures/vcr_cassettes/entry/reload.yml +6 -6
  218. data/spec/fixtures/vcr_cassettes/entry/save_update.yml +2 -2
  219. data/spec/fixtures/vcr_cassettes/entry/search_filter/equality_operator.yml +2 -2
  220. data/spec/fixtures/vcr_cassettes/entry/search_filter/exclusion_operator.yml +2 -2
  221. data/spec/fixtures/vcr_cassettes/entry/search_filter/full_search.yml +2 -2
  222. data/spec/fixtures/vcr_cassettes/entry/search_filter/full_search_match_operator.yml +2 -2
  223. data/spec/fixtures/vcr_cassettes/entry/search_filter/including_linked_entries.yml +2 -2
  224. data/spec/fixtures/vcr_cassettes/entry/search_filter/inclusion_operator.yml +2 -2
  225. data/spec/fixtures/vcr_cassettes/entry/search_filter/inequality_operator.yml +2 -2
  226. data/spec/fixtures/vcr_cassettes/entry/search_filter/location_search_near_operator.yml +2 -2
  227. data/spec/fixtures/vcr_cassettes/entry/search_filter/location_search_within_operator.yml +2 -2
  228. data/spec/fixtures/vcr_cassettes/entry/search_filter/matching_array_fields.yml +2 -2
  229. data/spec/fixtures/vcr_cassettes/entry/search_filter/order_sys_createdAt.yml +2 -2
  230. data/spec/fixtures/vcr_cassettes/entry/search_filter/order_sys_updatedAt.yml +2 -2
  231. data/spec/fixtures/vcr_cassettes/entry/search_filter/range_operators_greater_than_or_equal.yml +2 -2
  232. data/spec/fixtures/vcr_cassettes/entry/search_filter/range_operators_less.yml +2 -2
  233. data/spec/fixtures/vcr_cassettes/entry/search_filter/reverse_order_sys_updatedAt.yml +2 -2
  234. data/spec/fixtures/vcr_cassettes/entry/select_operator.yml +1 -1
  235. data/spec/fixtures/vcr_cassettes/entry/service_unavailable.yml +1 -1
  236. data/spec/fixtures/vcr_cassettes/entry/too_many_requests.yml +5 -5
  237. data/spec/fixtures/vcr_cassettes/entry/too_many_requests_retry.yml +6 -6
  238. data/spec/fixtures/vcr_cassettes/entry/unarchive.yml +2 -2
  239. data/spec/fixtures/vcr_cassettes/entry/unarchive_already_unarchived.yml +2 -2
  240. data/spec/fixtures/vcr_cassettes/entry/unpublish.yml +2 -2
  241. data/spec/fixtures/vcr_cassettes/entry/unpublish_already_unpublished.yml +2 -2
  242. data/spec/fixtures/vcr_cassettes/entry/update.yml +4 -4
  243. data/spec/fixtures/vcr_cassettes/entry/update_bool_field.yml +4 -4
  244. data/spec/fixtures/vcr_cassettes/entry/update_unlocalized_field.yml +3 -3
  245. data/spec/fixtures/vcr_cassettes/entry/update_with_custom_locale.yml +3 -3
  246. data/spec/fixtures/vcr_cassettes/environment/all.yml +226 -0
  247. data/spec/fixtures/vcr_cassettes/environment/create.yml +155 -0
  248. data/spec/fixtures/vcr_cassettes/environment/destroy.yml +89 -0
  249. data/spec/fixtures/vcr_cassettes/environment/find.yml +155 -0
  250. data/spec/fixtures/vcr_cassettes/environment/find_2.yml +155 -0
  251. data/spec/fixtures/vcr_cassettes/environment/not_found.yml +98 -0
  252. data/spec/fixtures/vcr_cassettes/locale/all_for_space.yml +1 -1
  253. data/spec/fixtures/vcr_cassettes/locale/create_for_space.yml +2 -2
  254. data/spec/fixtures/vcr_cassettes/locale/destroy.yml +5 -5
  255. data/spec/fixtures/vcr_cassettes/locale/fallback_code.yml +3 -3
  256. data/spec/fixtures/vcr_cassettes/locale/find.yml +1 -1
  257. data/spec/fixtures/vcr_cassettes/locale/find_default.yml +1 -1
  258. data/spec/fixtures/vcr_cassettes/locale/find_for_space_not_found.yml +1 -1
  259. data/spec/fixtures/vcr_cassettes/locale/find_not_default.yml +1 -1
  260. data/spec/fixtures/vcr_cassettes/locale/find_not_optional.yml +1 -1
  261. data/spec/fixtures/vcr_cassettes/locale/find_optional.yml +1 -1
  262. data/spec/fixtures/vcr_cassettes/locale/reload.yml +3 -3
  263. data/spec/fixtures/vcr_cassettes/locale/update_both.yml +3 -3
  264. data/spec/fixtures/vcr_cassettes/locale/update_code.yml +3 -3
  265. data/spec/fixtures/vcr_cassettes/locale/update_name.yml +3 -3
  266. data/spec/fixtures/vcr_cassettes/snapshot/all.yml +1 -1
  267. data/spec/fixtures/vcr_cassettes/snapshot/ct_all.yml +1 -1
  268. data/spec/fixtures/vcr_cassettes/snapshot/ct_find.yml +1 -1
  269. data/spec/fixtures/vcr_cassettes/snapshot/ct_find_not_found.yml +1 -1
  270. data/spec/fixtures/vcr_cassettes/snapshot/find.yml +1 -1
  271. data/spec/fixtures/vcr_cassettes/snapshot/find_not_found.yml +1 -1
  272. data/spec/fixtures/vcr_cassettes/snapshot/properties.yml +2 -2
  273. data/spec/fixtures/vcr_cassettes/ui_extension/all.yml +1 -1
  274. data/spec/fixtures/vcr_cassettes/ui_extension/create.yml +1 -1
  275. data/spec/fixtures/vcr_cassettes/ui_extension/delete.yml +3 -3
  276. data/spec/fixtures/vcr_cassettes/ui_extension/find.yml +1 -1
  277. data/spec/fixtures/vcr_cassettes/upload/associate_with_asset.yml +3 -3
  278. data/spec/lib/contentful/management/api_key_spec.rb +7 -7
  279. data/spec/lib/contentful/management/asset_spec.rb +38 -57
  280. data/spec/lib/contentful/management/client_spec.rb +1 -1
  281. data/spec/lib/contentful/management/content_type_spec.rb +78 -78
  282. data/spec/lib/contentful/management/editor_interface_spec.rb +4 -4
  283. data/spec/lib/contentful/management/entry_spec.rb +104 -114
  284. data/spec/lib/contentful/management/environment_spec.rb +87 -0
  285. data/spec/lib/contentful/management/locale_spec.rb +22 -22
  286. data/spec/lib/contentful/management/role_spec.rb +11 -11
  287. data/spec/lib/contentful/management/snapshot_spec.rb +27 -27
  288. data/spec/lib/contentful/management/space_membership_spec.rb +6 -7
  289. data/spec/lib/contentful/management/space_spec.rb +0 -282
  290. data/spec/lib/contentful/management/ui_extension_spec.rb +8 -8
  291. data/spec/lib/contentful/management/upload_spec.rb +9 -9
  292. data/spec/lib/contentful/management/webhook_calls_spec.rb +6 -6
  293. data/spec/lib/contentful/management/webhook_health_spec.rb +3 -3
  294. data/spec/lib/contentful/management/webhook_spec.rb +14 -12
  295. metadata +28 -14
  296. data/lib/contentful/management/space_asset_methods_factory.rb +0 -13
  297. data/lib/contentful/management/space_association_all_published_method_factory.rb +0 -12
  298. data/lib/contentful/management/space_content_type_methods_factory.rb +0 -13
  299. data/lib/contentful/management/space_editor_interface_methods_factory.rb +0 -21
  300. data/lib/contentful/management/space_entry_methods_factory.rb +0 -21
  301. data/lib/contentful/management/space_ui_extension_methods_factory.rb +0 -15
  302. data/spec/fixtures/vcr_cassettes/asset/all_public.yml +0 -112
  303. data/spec/fixtures/vcr_cassettes/entry/all_public.yml +0 -102
@@ -291,7 +291,7 @@ module Contentful
291
291
 
292
292
  it 'effectively requests via proxy' do
293
293
  vcr(:proxy_request) {
294
- expect(subject).to receive(:proxy_send).twice.and_call_original
294
+ expect(subject).to receive(:proxy_send).once.and_call_original
295
295
  subject.spaces.find('zh42n1tmsaiq')
296
296
  }
297
297
  end
@@ -10,49 +10,49 @@ module Contentful
10
10
  let!(:client) { Client.new(token) }
11
11
  let(:content_type_id) { '5DSpuKrl04eMAGQoQckeIq' }
12
12
 
13
- subject { client.content_types }
13
+ subject { client.content_types(space_id, 'master') }
14
14
 
15
15
  describe '.all' do
16
16
  it 'class method also works' do
17
- vcr('content_type/all') { expect(Contentful::Management::ContentType.all(client, space_id)).to be_kind_of Contentful::Management::Array }
17
+ vcr('content_type/all') { expect(Contentful::Management::ContentType.all(client, space_id, 'master')).to be_kind_of Contentful::Management::Array }
18
18
  end
19
19
  it 'returns a Contentful::Array' do
20
- vcr('content_type/all') { expect(subject.all(space_id)).to be_kind_of Contentful::Management::Array }
20
+ vcr('content_type/all') { expect(subject.all).to be_kind_of Contentful::Management::Array }
21
21
  end
22
22
  it 'builds a Contentful::Management::ContentType object' do
23
- vcr('content_type/all') { expect(subject.all(space_id).first).to be_kind_of Contentful::Management::ContentType }
23
+ vcr('content_type/all') { expect(subject.all.first).to be_kind_of Contentful::Management::ContentType }
24
24
  end
25
25
  end
26
26
 
27
27
  describe '.all_published' do
28
28
  let!(:space_id) { 'bjwq7b86vgmm' }
29
29
  it 'class method also works' do
30
- vcr('content_type/all_public') { expect(Contentful::Management::ContentType.all_published(client, space_id)).to be_kind_of Contentful::Management::Array }
30
+ vcr('content_type/all_public') { expect(Contentful::Management::ContentType.all_published(client, space_id, 'master')).to be_kind_of Contentful::Management::Array }
31
31
  end
32
32
  it 'returns a Contentful::Array' do
33
- vcr('content_type/all_public') { expect(subject.all_published(space_id)).to be_kind_of Contentful::Management::Array }
33
+ vcr('content_type/all_public') { expect(subject.all_published).to be_kind_of Contentful::Management::Array }
34
34
  end
35
35
  it 'builds a Contentful::Management::ContentType object' do
36
- vcr('content_type/all_public') { expect(subject.all_published(space_id).first).to be_kind_of Contentful::Management::ContentType }
36
+ vcr('content_type/all_public') { expect(subject.all_published.first).to be_kind_of Contentful::Management::ContentType }
37
37
  end
38
38
  end
39
39
 
40
40
  describe '.find' do
41
41
  it 'class method also works' do
42
- vcr('content_type/find') { expect(Contentful::Management::ContentType.find(client, space_id, content_type_id)).to be_kind_of Contentful::Management::ContentType }
42
+ vcr('content_type/find') { expect(Contentful::Management::ContentType.find(client, space_id, 'master', content_type_id)).to be_kind_of Contentful::Management::ContentType }
43
43
  end
44
44
  it 'returns a Contentful::Management::ContentType' do
45
- vcr('content_type/find') { expect(subject.find(space_id, content_type_id)).to be_kind_of Contentful::Management::ContentType }
45
+ vcr('content_type/find') { expect(subject.find(content_type_id)).to be_kind_of Contentful::Management::ContentType }
46
46
  end
47
47
  it 'returns the content_type for a given key' do
48
48
  vcr('content_type/find') do
49
- content_type = subject.find(space_id, content_type_id)
49
+ content_type = subject.find(content_type_id)
50
50
  expect(content_type.id).to eql content_type_id
51
51
  end
52
52
  end
53
53
  it 'returns an error when content_type does not found' do
54
54
  vcr('content_type/find_not_found') do
55
- result = subject.find(space_id, 'not_exist')
55
+ result = subject.find('not_exist')
56
56
  expect(result).to be_kind_of Contentful::Management::NotFound
57
57
  end
58
58
  end
@@ -61,7 +61,7 @@ module Contentful
61
61
  describe '#destroy' do
62
62
  it 'returns Contentful::BadRequest error when content type is activated' do
63
63
  vcr('content_type/destroy_activated') do
64
- result = subject.find(space_id, '66jvD8UhNKmWGk24KKq0EW').destroy
64
+ result = subject.find('66jvD8UhNKmWGk24KKq0EW').destroy
65
65
  expect(result).to be_kind_of Contentful::Management::BadRequest
66
66
  message = [
67
67
  "HTTP status code: 400 Bad Request",
@@ -73,7 +73,7 @@ module Contentful
73
73
 
74
74
  it 'returns true when content type is not activated' do
75
75
  vcr('content_type/destroy') do
76
- result = subject.find(space_id, '66jvD8UhNKmWGk24KKq0EW').destroy
76
+ result = subject.find('66jvD8UhNKmWGk24KKq0EW').destroy
77
77
  expect(result).to eql true
78
78
  end
79
79
  end
@@ -83,13 +83,13 @@ module Contentful
83
83
  let(:active_content) { '4EnwylPOikyMGUIy8uQgQY' }
84
84
  it 'returns Contentful::Management::ContentType' do
85
85
  vcr('content_type/activate') do
86
- result = subject.find(space_id, active_content).activate
86
+ result = subject.find(active_content).activate
87
87
  expect(result).to be_kind_of Contentful::Management::ContentType
88
88
  end
89
89
  end
90
90
  it 'increases object version' do
91
91
  vcr('content_type/activate') do
92
- content_type = subject.find(space_id, active_content)
92
+ content_type = subject.find(active_content)
93
93
  initial_version = content_type.sys[:version]
94
94
  content_type.activate
95
95
  expect(content_type.sys[:version]).to eql initial_version + 1
@@ -97,7 +97,7 @@ module Contentful
97
97
  end
98
98
  it 'returns error when not valid version' do
99
99
  vcr('content_type/activate_with_invalid_version') do
100
- content_type = subject.find(space_id, active_content)
100
+ content_type = subject.find(active_content)
101
101
  content_type.sys[:version] = -1
102
102
  result = content_type.activate
103
103
  expect(result).to be_kind_of Contentful::Management::Conflict
@@ -109,14 +109,14 @@ module Contentful
109
109
  let(:deactivate_content) { '4EnwylPOikyMGUIy8uQgQY' }
110
110
  it 'returns Contentful::Management::ContentType' do
111
111
  vcr('content_type/deactivate') do
112
- content_type = subject.find(space_id, deactivate_content)
112
+ content_type = subject.find(deactivate_content)
113
113
  result = content_type.deactivate
114
114
  expect(result).to be_kind_of Contentful::Management::ContentType
115
115
  end
116
116
  end
117
117
  it 'increases object version' do
118
118
  vcr('content_type/deactivate_with_version_change') do
119
- content_type = subject.find(space_id, deactivate_content)
119
+ content_type = subject.find(deactivate_content)
120
120
  initial_version = content_type.sys[:version]
121
121
  content_type.activate
122
122
  expect(content_type.sys[:version]).to eql initial_version + 1
@@ -124,13 +124,13 @@ module Contentful
124
124
  end
125
125
  it 'returns error when has entries' do
126
126
  vcr('content_type/deactivate_with_entries') do
127
- result = subject.find(space_id, '5DSpuKrl04eMAGQoQckeIq').deactivate
127
+ result = subject.find('5DSpuKrl04eMAGQoQckeIq').deactivate
128
128
  expect(result).to be_kind_of Contentful::Management::BadRequest
129
129
  end
130
130
  end
131
131
  it 'returns error message when already deactivated' do
132
132
  vcr('content_type/deactivate_already_deactivated') do
133
- content_type = subject.find(space_id, deactivate_content)
133
+ content_type = subject.find(deactivate_content)
134
134
  content_type.sys[:version] = -1
135
135
  result = content_type.deactivate
136
136
  message = [
@@ -145,14 +145,14 @@ module Contentful
145
145
  describe '#active?' do
146
146
  it 'returns true if content_type is active' do
147
147
  vcr('content_type/activated_true') do
148
- content_type = subject.find(space_id, '4EnwylPOikyMGUIy8uQgQY')
148
+ content_type = subject.find('4EnwylPOikyMGUIy8uQgQY')
149
149
  content_type.activate
150
150
  expect(content_type.active?).to be_truthy
151
151
  end
152
152
  end
153
153
  it 'returns false if content_type is not active' do
154
154
  vcr('content_type/activated_false') do
155
- content_type = subject.find(space_id, '4EnwylPOikyMGUIy8uQgQY')
155
+ content_type = subject.find('4EnwylPOikyMGUIy8uQgQY')
156
156
  content_type.deactivate
157
157
  expect(content_type.active?).to be_falsey
158
158
  end
@@ -166,7 +166,6 @@ module Contentful
166
166
  it 'creates a content_type within a space without id and without fields' do
167
167
  vcr('content_type/create') do
168
168
  content_type = subject.create(
169
- space_id,
170
169
  name: content_type_name,
171
170
  description: content_type_description
172
171
  )
@@ -180,7 +179,6 @@ module Contentful
180
179
  vcr('content_type/create_content_type_with_id') do
181
180
  content_type_id = 'custom_id'
182
181
  content_type = subject.create(
183
- space_id,
184
182
  name: content_type_name,
185
183
  id: content_type_id
186
184
  )
@@ -199,7 +197,6 @@ module Contentful
199
197
  field.type = field_type
200
198
  field.link_type = 'Entry' if field_type == 'Link'
201
199
  content_type = subject.create(
202
- space_id,
203
200
  name: "#{ field_type }",
204
201
  description: "Content type with #{ field_type } field",
205
202
  fields: [field]
@@ -231,13 +228,13 @@ module Contentful
231
228
  name_field.name = 'name'
232
229
  name_field.type = 'Symbol'
233
230
 
234
- content_type = space.content_types.new
235
- content_type.id = 'omitted_ct'
236
- content_type.name = 'Omitted CT'
237
- content_type.fields = [omitted_field, name_field]
238
- content_type.display_field = 'name'
231
+ content_type = client.content_types(space.id, 'master').create(
232
+ id: 'omitted_ct',
233
+ name: 'Omitted CT',
234
+ fields: [omitted_field, name_field],
235
+ display_field: 'name'
236
+ )
239
237
 
240
- content_type.save
241
238
  content_type.activate
242
239
 
243
240
  content_type.reload
@@ -259,7 +256,7 @@ module Contentful
259
256
  let(:content_type_id) { 'qw3F2rn3FeoOiceqAiCSC' }
260
257
  it 'updates content_type name and description' do
261
258
  vcr('content_type/update') do
262
- content_type = subject.find(space_id, content_type_id)
259
+ content_type = subject.find(content_type_id)
263
260
  content_type.update(name: content_type_name, description: content_type_description)
264
261
  expect(content_type.name).to eq content_type_name
265
262
  expect(content_type.description).to eq content_type_description
@@ -268,7 +265,7 @@ module Contentful
268
265
 
269
266
  it 'updates content_type with fields (leave fields untouched)' do
270
267
  vcr('content_type/update_with_fields') do
271
- content_type = subject.find(space_id, content_type_id)
268
+ content_type = subject.find(content_type_id)
272
269
  content_type.update(name: content_type_name)
273
270
  expect(content_type.name).to eq content_type_name
274
271
  expect(content_type.fields.size).to eq 2
@@ -281,7 +278,7 @@ module Contentful
281
278
  field.id = 'blog_author'
282
279
  field.name = 'Author of blog'
283
280
  field.type = 'Text'
284
- content_type = subject.find(space_id, content_type_id)
281
+ content_type = subject.find(content_type_id)
285
282
  content_type.update(fields: content_type.fields + [field])
286
283
  expect(content_type.fields.size).to eq 5
287
284
  end
@@ -290,7 +287,7 @@ module Contentful
290
287
  it 'updates content_type updating existing field' do
291
288
  vcr('content_type/update_change_field_name') do
292
289
  new_field_name = 'blog_author'
293
- content_type = subject.find(space_id, content_type_id)
290
+ content_type = subject.find(content_type_id)
294
291
  field = content_type.fields.first
295
292
  field.name = new_field_name
296
293
  content_type.update(fields: content_type.fields)
@@ -301,7 +298,7 @@ module Contentful
301
298
 
302
299
  it 'updates content_type deleting existing field' do
303
300
  vcr('content_type/update_remove_field') do
304
- content_type = subject.find(space_id, content_type_id)
301
+ content_type = subject.find(content_type_id)
305
302
  field = content_type.fields.first
306
303
  content_type.update(fields: [field])
307
304
  expect(content_type.fields.size).to eq 1
@@ -311,7 +308,9 @@ module Contentful
311
308
  it 'update with multiple locales' do
312
309
  vcr('content_type/entry/update_only_with_localized_fields') do
313
310
  space = client.spaces.find('v2umtz8ths9v')
314
- entry = space.entries.find('2dEkgsQRnSW2QuW4AMaa86')
311
+ client.content_types(space.id, 'master').all # warmup cache
312
+
313
+ entry = client.entries(space.id, 'master').find('2dEkgsQRnSW2QuW4AMaa86')
315
314
  entry.name_with_locales = {'en-US' => 'Contentful EN up', 'de-DE' => 'Contentful DE up', 'pl-PL' => 'Contentful PL up'}
316
315
  entry.description_with_locales = {'en-US' => 'Description EN up', 'de-DE' => 'Description DE up', 'pl-PL' => 'Description PL up'}
317
316
  entry.save
@@ -324,7 +323,7 @@ module Contentful
324
323
  describe '#save' do
325
324
  it 'updated content type' do
326
325
  vcr('content_type/save_updated') do
327
- content_type = subject.find(space_id, content_type_id)
326
+ content_type = subject.find(content_type_id)
328
327
  content_type.name = 'NewName'
329
328
  content_type.save
330
329
  expect(content_type).to be_kind_of Contentful::Management::ContentType
@@ -334,7 +333,7 @@ module Contentful
334
333
 
335
334
  it 'with new field' do
336
335
  vcr('content_type/save_with_added_field') do
337
- content_type = subject.find(space_id, '2tDzYAg5MM6sIkwsOmM0Kc')
336
+ content_type = subject.find('2tDzYAg5MM6sIkwsOmM0Kc')
338
337
  field = Contentful::Management::Field.new
339
338
  field.id = 'blog_title'
340
339
  field.name = 'Blog Title'
@@ -350,14 +349,15 @@ module Contentful
350
349
  it 'saves new object' do
351
350
  vcr('content_type/save_new') do
352
351
  space = client.spaces.find(space_id)
353
- content_type = space.content_types.new
354
- content_type.name = 'Post title'
355
352
  field = Contentful::Management::Field.new
356
353
  field.id = 'my_text_field'
357
354
  field.name = 'My Text Field'
358
355
  field.type = 'Text'
359
- content_type.fields = [field]
360
- content_type.save
356
+
357
+ content_type = client.content_types(space.id, 'master').create(
358
+ name: 'Post title',
359
+ fields: [field]
360
+ )
361
361
  expect(content_type).to be_kind_of Contentful::Management::ContentType
362
362
  expect(content_type.name).to eq 'Post title'
363
363
  expect(content_type.fields.size).to eq 1
@@ -370,14 +370,14 @@ module Contentful
370
370
  let(:field_type) { 'Text' }
371
371
  it 'creates new field' do
372
372
  vcr('content_type/fields/create') do
373
- content_type = subject.find(space_id, content_type_id)
373
+ content_type = subject.find(content_type_id)
374
374
  content_type.fields.create(id: field_id, name: 'Eye color', type: field_type)
375
375
  expect(content_type.fields.size).to eq 12
376
376
  end
377
377
  end
378
378
  it 'creates new Link field with additional parameters' do
379
379
  vcr('content_type/fields/create_with_params') do
380
- content_type = subject.find(space_id, 'qw3F2rn3FeoOiceqAiCSC')
380
+ content_type = subject.find('qw3F2rn3FeoOiceqAiCSC')
381
381
  content_type.fields.create(id: 'blog_avatar', name: 'Blog avatar',
382
382
  type: 'Link',
383
383
  link_type: 'Asset',
@@ -394,7 +394,7 @@ module Contentful
394
394
  end
395
395
  it 'creates new Array field with additional parameters' do
396
396
  vcr('content_type/fields/create_array_with_params') do
397
- content_type = subject.find(space_id, '6xzrdCr33OMAeIYUgs6UKi')
397
+ content_type = subject.find('6xzrdCr33OMAeIYUgs6UKi')
398
398
  items = Contentful::Management::Field.new
399
399
  items.type = 'Link'
400
400
  items.link_type = 'Entry'
@@ -408,7 +408,7 @@ module Contentful
408
408
  end
409
409
  it 'updates existing field if matched id' do
410
410
  vcr('content_type/fields/update_field') do
411
- content_type = subject.find(space_id, '5DSpuKrl04eMAGQoQckeIq')
411
+ content_type = subject.find('5DSpuKrl04eMAGQoQckeIq')
412
412
  updated_name = 'Eyes color'
413
413
  content_type.fields.create(id: field_id, name: updated_name, type: field_type)
414
414
  expect(content_type.fields.size).to eq 12
@@ -421,7 +421,7 @@ module Contentful
421
421
  describe '#fields.add' do
422
422
  it 'creates new field' do
423
423
  vcr('content_type/fields/add') do
424
- content_type = subject.find(space_id, content_type_id)
424
+ content_type = subject.find(content_type_id)
425
425
  field = Contentful::Management::Field.new
426
426
  field.id = 'symbol'
427
427
  field.name = 'Symbol'
@@ -437,7 +437,7 @@ module Contentful
437
437
  describe '#fields.destroy' do
438
438
  it 'deletes field by id' do
439
439
  vcr('content_type/fields/destroy') do
440
- content_type = subject.find(space_id, content_type_id)
440
+ content_type = subject.find(content_type_id)
441
441
  content_type.fields.destroy('blog_title')
442
442
  expect(content_type.fields.size).to eq 10
443
443
  end
@@ -447,7 +447,7 @@ module Contentful
447
447
  describe '#entries.create' do
448
448
  it 'with Text field' do
449
449
  vcr('content_type/entry/create') do
450
- content_type = subject.find(space_id, content_type_id)
450
+ content_type = subject.find(content_type_id)
451
451
  entry = content_type.entries.create(name: 'Piotrek')
452
452
  expect(entry).to be_kind_of Contentful::Management::Entry
453
453
  expect(entry.fields[:name]).to eq 'Piotrek'
@@ -456,8 +456,8 @@ module Contentful
456
456
 
457
457
  it 'with entry' do
458
458
  vcr('content_type/entry/create_with_entries') do
459
- entry_en = client.entries.find(space_id, 'Qa8TW5nPWgiU4MA6AGYgq')
460
- content_type = subject.find(space_id, '6xzrdCr33OMAeIYUgs6UKi')
459
+ entry_en = client.entries(space_id, 'master').find('Qa8TW5nPWgiU4MA6AGYgq')
460
+ content_type = subject.find('6xzrdCr33OMAeIYUgs6UKi')
461
461
  entry = content_type.entries.create(blog_name: 'Piotrek',
462
462
  blog_entry: entry_en,
463
463
  blog_entries: [entry_en, entry_en, entry_en])
@@ -473,7 +473,7 @@ module Contentful
473
473
  context 'for multiple locales' do
474
474
  it 'for Text field' do
475
475
  vcr('content_type/entry/create_with_multiple_locales') do
476
- content_type = subject.find(space_id, '4EnwylPOikyMGUIy8uQgQY')
476
+ content_type = subject.find('4EnwylPOikyMGUIy8uQgQY')
477
477
  entry = content_type.entries.new
478
478
  entry.post_title_with_locales = {'en-US' => 'Company logo', 'pl' => 'Firmowe logo'}
479
479
  entry.post_body_with_locales = {'en-US' => 'Story about Contentful...', 'pl' => 'Historia o Contentful...'}
@@ -489,7 +489,7 @@ module Contentful
489
489
  end
490
490
  it 'with camel case api id' do
491
491
  vcr('content_type/entry/create_with_camel_case_id_to_multiple_locales') do
492
- content_type = subject.find(space_id, '4esHTHIVgc0uWkiwGwOsa6')
492
+ content_type = subject.find('4esHTHIVgc0uWkiwGwOsa6')
493
493
  entry = content_type.entries.new
494
494
  entry.car_mark_with_locales = {'en-US' => 'Mercedes Benz', 'pl' => 'Mercedes'}
495
495
  entry.car_city_plate_with_locales = {'en-US' => 'en', 'pl' => 'bia'}
@@ -509,12 +509,11 @@ module Contentful
509
509
  it 'with entries' do
510
510
  vcr('content_type/entry/create_with_entries_for_multiple_locales') do
511
511
  space = client.spaces.find(space_id)
512
- space.content_types # filling cache
513
512
 
514
- entry_en = space.entries.find('664EPJ6zHqAeMO6O0mGggU')
515
- entry_pl = space.entries.find('664EPJ6zHqAeMO6O0mGggU')
513
+ entry_en = client.entries(space.id, 'master').find('664EPJ6zHqAeMO6O0mGggU')
514
+ entry_pl = client.entries(space.id, 'master').find('664EPJ6zHqAeMO6O0mGggU')
516
515
 
517
- content_type = space.content_types.find('6xzrdCr33OMAeIYUgs6UKi')
516
+ content_type = client.content_types(space.id, 'master').find('6xzrdCr33OMAeIYUgs6UKi')
518
517
  entry = content_type.entries.new
519
518
  entry.blog_name_with_locales = {'en-US' => 'Contentful en', 'pl' => 'Contentful pl'}
520
519
  entry.blog_entries_with_locales = {'en-US' => [entry_en, entry_en], 'pl' => [entry_pl, entry_pl]}
@@ -527,12 +526,11 @@ module Contentful
527
526
  it 'with assets' do
528
527
  vcr('content_type/entry/create_with_entries_for_multiple_locales') do
529
528
  space = client.spaces.find(space_id)
530
- space.content_types # filling cache
531
529
 
532
- entry_en = space.entries.find('664EPJ6zHqAeMO6O0mGggU')
533
- entry_pl = space.entries.find('664EPJ6zHqAeMO6O0mGggU')
530
+ entry_en = client.entries(space.id, 'master').find('664EPJ6zHqAeMO6O0mGggU')
531
+ entry_pl = client.entries(space.id, 'master').find('664EPJ6zHqAeMO6O0mGggU')
534
532
 
535
- content_type = space.content_types.find('6xzrdCr33OMAeIYUgs6UKi')
533
+ content_type = client.content_types(space.id, 'master').find('6xzrdCr33OMAeIYUgs6UKi')
536
534
  entry = content_type.entries.new
537
535
  entry.blog_name_with_locales = {'en-US' => 'Contentful en', 'pl' => 'Contentful pl'}
538
536
  entry.blog_entries_with_locales = {'en-US' => [entry_en, entry_en], 'pl' => [entry_pl, entry_pl]}
@@ -545,7 +543,7 @@ module Contentful
545
543
  context 'only to unlocalized fields' do
546
544
  it 'return entry with valid parameters' do
547
545
  vcr('content_type/entry/create_only_with_localized_fields') do
548
- content_type = subject.find('v2umtz8ths9v', 'category_content_type')
546
+ content_type = described_class.find(client, 'v2umtz8ths9v', 'master', 'category_content_type')
549
547
  entry = content_type.entries.new
550
548
  entry.name_with_locales = {'en-US' => 'Contentful EN', 'de-DE' => 'Contentful DE', 'pl-PL' => 'Contentful PL'}
551
549
  entry.description_with_locales = {'en-US' => 'Description EN', 'de-DE' => 'Description DE', 'pl-PL' => 'Description PL'}
@@ -559,7 +557,7 @@ module Contentful
559
557
  context 'only to unlocalized fields' do
560
558
  it 'return entry with valid parameters' do
561
559
  vcr('content_type/entry/create_to_single_locale_only_with_localized_fields') do
562
- content_type = subject.find('v2umtz8ths9v', 'category_content_type')
560
+ content_type = described_class.find(client, 'v2umtz8ths9v', 'master', 'category_content_type')
563
561
  entry = content_type.entries.new
564
562
  entry.name = 'Some testing EN name'
565
563
  entry.description = ' some testing EN description '
@@ -579,7 +577,7 @@ module Contentful
579
577
  it 'returns entries' do
580
578
  vcr('content_type/entry/all') do
581
579
  space = client.spaces.find(space_id)
582
- content_type = space.content_types.find('category_content_type')
580
+ content_type = client.content_types(space.id, 'master').find('category_content_type')
583
581
  entries = content_type.entries.all
584
582
  expect(entries).to be_kind_of Contentful::Management::Array
585
583
  expect(entries.size).to eq 2
@@ -593,7 +591,7 @@ module Contentful
593
591
  let(:space_id) { 'bfsvtul0c41g' }
594
592
  it 'update the current version of the object to the version on the system' do
595
593
  vcr('content_type/reload') do
596
- content_type = subject.find(space_id, 'category_content_type')
594
+ content_type = described_class.find(client, space_id, 'master', 'category_content_type')
597
595
  content_type.sys[:version] = 999
598
596
  update_ct = content_type.update(name: 'Updated content type name')
599
597
  expect(update_ct).to be_kind_of Contentful::Management::Conflict
@@ -608,7 +606,7 @@ module Contentful
608
606
 
609
607
  describe '#validations' do
610
608
  let(:space) { client.spaces.find('v2umtz8ths9v') }
611
- let(:content_type) { space.content_types.find('category_content_type') }
609
+ let(:content_type) { client.content_types(space.id, 'master').find('category_content_type') }
612
610
 
613
611
  it "adds 'in validation' to a new field" do
614
612
  vcr('content_type/validation/in') do
@@ -654,7 +652,7 @@ module Contentful
654
652
  context 'range' do
655
653
  it 'adds `range` validation to field' do
656
654
  vcr('content_type/validation/range') do
657
- content_type = space.content_types.find('1JrDv4JJsYuY4KGEEgAsQU')
655
+ content_type = client.content_types(space.id, 'master').find('1JrDv4JJsYuY4KGEEgAsQU')
658
656
 
659
657
  validation_range = Contentful::Management::Validation.new
660
658
  validation_range.range = {min: 30, max: 100}
@@ -666,7 +664,7 @@ module Contentful
666
664
  end
667
665
  it 'change `range` validation to existing field' do
668
666
  vcr('content_type/validation/range_update') do
669
- content_type = space.content_types.find('1JrDv4JJsYuY4KGEEgAsQU')
667
+ content_type = client.content_types(space.id, 'master').find('1JrDv4JJsYuY4KGEEgAsQU')
670
668
 
671
669
  validation_range = Contentful::Management::Validation.new
672
670
  validation_range.range = {min: 50, max: 200}
@@ -679,7 +677,7 @@ module Contentful
679
677
  context 'present' do
680
678
  it 'adds `present` validation to field' do
681
679
  vcr('content_type/validation/present') do
682
- content_type = space.content_types.find('1JrDv4JJsYuY4KGEEgAsQU')
680
+ content_type = client.content_types(space.id, 'master').find('1JrDv4JJsYuY4KGEEgAsQU')
683
681
  validation_present = Contentful::Management::Validation.new
684
682
  validation_present.present = true
685
683
  content_type.fields.create(id: 'present', name: 'Present', type: 'Text', validations: [validation_present])
@@ -691,7 +689,7 @@ module Contentful
691
689
  context 'regexp' do
692
690
  it 'adds `regexp` validation to field' do
693
691
  vcr('content_type/validation/regexp') do
694
- content_type = space.content_types.find('1JrDv4JJsYuY4KGEEgAsQU')
692
+ content_type = client.content_types(space.id, 'master').find('1JrDv4JJsYuY4KGEEgAsQU')
695
693
  validation_regexp = Contentful::Management::Validation.new
696
694
  validation_regexp.regexp = {pattern: '^such', flags: 'im'}
697
695
  content_type.fields.create(id: 'text', name: 'Text', type: 'Text', validations: [validation_regexp])
@@ -704,7 +702,7 @@ module Contentful
704
702
  context 'linkContentType' do
705
703
  it 'adds `linkContentType` validation to field' do
706
704
  vcr('content_type/validation/link_content_type') do
707
- content_type = space.content_types.find('1JrDv4JJsYuY4KGEEgAsQU')
705
+ content_type = client.content_types(space.id, 'master').find('1JrDv4JJsYuY4KGEEgAsQU')
708
706
  validation_link_content_type = Contentful::Management::Validation.new
709
707
  validation_link_content_type.link_content_type = ['post_content_type']
710
708
  content_type.fields.create(id: 'entries', validations: [validation_link_content_type])
@@ -716,7 +714,7 @@ module Contentful
716
714
  context 'linkMimetypeGroup' do
717
715
  it 'adds `linkMimetypeGroup` validation to field' do
718
716
  vcr('content_type/validation/link_mimetype_group') do
719
- content_type = space.content_types.find('1JrDv4JJsYuY4KGEEgAsQU')
717
+ content_type = client.content_types(space.id, 'master').find('1JrDv4JJsYuY4KGEEgAsQU')
720
718
  validation_link_mimetype_group = Contentful::Management::Validation.new
721
719
  validation_link_mimetype_group.link_mimetype_group = 'image'
722
720
  content_type.fields.create(id: 'entries', validations: [validation_link_mimetype_group])
@@ -728,7 +726,7 @@ module Contentful
728
726
  context 'linkField' do
729
727
  it 'adds `linkField` validation to field' do
730
728
  vcr('content_type/validation/link_field') do
731
- content_type = space.content_types.find('1JrDv4JJsYuY4KGEEgAsQU')
729
+ content_type = client.content_types(space.id, 'master').find('1JrDv4JJsYuY4KGEEgAsQU')
732
730
  validation_link_mimetype_group = Contentful::Management::Validation.new
733
731
  validation_link_mimetype_group.link_field = true
734
732
  content_type.fields.create(id: 'link_field', validations: [validation_link_mimetype_group])
@@ -741,7 +739,7 @@ module Contentful
741
739
  let(:space) { client.spaces.find('iig6ari2cj2t') }
742
740
  it 'adds `unique` validation to field' do
743
741
  vcr('content_type/validation/unique') do
744
- content_type = space.content_types.find('1JrDv4JJsYuY4KGEEgAsQU')
742
+ content_type = client.content_types(space.id, 'master').find('1JrDv4JJsYuY4KGEEgAsQU')
745
743
  validation_unique = Contentful::Management::Validation.new
746
744
  validation_unique.unique = true
747
745
  content_type.fields.create(id: 'symbol', name: 'Slug', type: 'Symbol', validations: [validation_unique])
@@ -754,7 +752,7 @@ module Contentful
754
752
  context 'add multiple validations' do
755
753
  it 'create field with multiple validations' do
756
754
  vcr('content_type/validation/multiple_add') do
757
- content_type = space.content_types.find('1JrDv4JJsYuY4KGEEgAsQU')
755
+ content_type = client.content_types(space.id, 'master').find('1JrDv4JJsYuY4KGEEgAsQU')
758
756
  validation_in = Contentful::Management::Validation.new
759
757
  validation_in.in = %w( foo bar baz)
760
758
  validation_regexp = Contentful::Management::Validation.new
@@ -784,7 +782,8 @@ module Contentful
784
782
  field.type = 'Array'
785
783
  field.items = items
786
784
 
787
- content_type = space.content_types.new
785
+ content_type = client.content_types(space.id, 'master').new
786
+ content_type.space = space
788
787
  content_type.name = 'Testing Content Types'
789
788
  content_type.fields = [field]
790
789
  content_type.save
@@ -813,7 +812,8 @@ module Contentful
813
812
  field.name = 'name'
814
813
  field.type = 'Symbol'
815
814
 
816
- content_type = space.content_types.new
815
+ content_type = client.content_types(space.id, 'master').new
816
+ content_type.space = space
817
817
  content_type.id = 'isssue_79_ct'
818
818
  content_type.name = 'Issue 79 CT'
819
819
  content_type.fields = [field]