contentful-management 3.11.0 → 3.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/codeql.yml +32 -0
  3. data/CHANGELOG.md +3 -0
  4. data/README.md +127 -1
  5. data/lib/contentful/management/client.rb +27 -0
  6. data/lib/contentful/management/client_taxonomy_concept_methods_factory.rb +34 -0
  7. data/lib/contentful/management/client_taxonomy_concept_scheme_methods_factory.rb +34 -0
  8. data/lib/contentful/management/content_type.rb +3 -0
  9. data/lib/contentful/management/resource/metadata.rb +8 -1
  10. data/lib/contentful/management/resource_builder.rb +5 -1
  11. data/lib/contentful/management/resource_requester.rb +11 -0
  12. data/lib/contentful/management/taxonomy_concept.rb +144 -0
  13. data/lib/contentful/management/taxonomy_concept_scheme.rb +108 -0
  14. data/lib/contentful/management/version.rb +1 -1
  15. data/spec/fixtures/vcr_cassettes/asset/update_with_concepts.yml +137 -0
  16. data/spec/fixtures/vcr_cassettes/content_type/update_with_metadata.yml +171 -0
  17. data/spec/fixtures/vcr_cassettes/entry/update_with_concepts.yml +182 -0
  18. data/spec/fixtures/vcr_cassettes/taxonomy_concept/all.yml +83 -0
  19. data/spec/fixtures/vcr_cassettes/taxonomy_concept/ancestors.yml +155 -0
  20. data/spec/fixtures/vcr_cassettes/taxonomy_concept/create.yml +77 -0
  21. data/spec/fixtures/vcr_cassettes/taxonomy_concept/create_with_id.yml +78 -0
  22. data/spec/fixtures/vcr_cassettes/taxonomy_concept/descendants.yml +153 -0
  23. data/spec/fixtures/vcr_cassettes/taxonomy_concept/destroy.yml +152 -0
  24. data/spec/fixtures/vcr_cassettes/taxonomy_concept/find.yml +79 -0
  25. data/spec/fixtures/vcr_cassettes/taxonomy_concept/total.yml +77 -0
  26. data/spec/fixtures/vcr_cassettes/taxonomy_concept/update.yml +158 -0
  27. data/spec/fixtures/vcr_cassettes/taxonomy_concept_scheme/all.yml +80 -0
  28. data/spec/fixtures/vcr_cassettes/taxonomy_concept_scheme/create.yml +78 -0
  29. data/spec/fixtures/vcr_cassettes/taxonomy_concept_scheme/destroy.yml +150 -0
  30. data/spec/fixtures/vcr_cassettes/taxonomy_concept_scheme/find.yml +78 -0
  31. data/spec/fixtures/vcr_cassettes/taxonomy_concept_scheme/total.yml +77 -0
  32. data/spec/fixtures/vcr_cassettes/taxonomy_concept_scheme/update.yml +155 -0
  33. data/spec/lib/contentful/management/asset_spec.rb +20 -0
  34. data/spec/lib/contentful/management/content_type_spec.rb +22 -0
  35. data/spec/lib/contentful/management/entry_spec.rb +22 -1
  36. data/spec/lib/contentful/management/taxonomy_concept_scheme_spec.rb +85 -0
  37. data/spec/lib/contentful/management/taxonomy_concept_spec.rb +116 -0
  38. metadata +46 -1
@@ -0,0 +1,78 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.contentful.com/organizations/4kQeJmhUWIKtNNmMkketza/taxonomy/concept-schemes/2hNivoHTKM4MbTM4519T5E
6
+ body:
7
+ encoding: UTF-8
8
+ string: ''
9
+ headers:
10
+ X-Contentful-User-Agent:
11
+ - sdk contentful-management.rb/3.11.0; platform ruby/3.4.3; os macOS/24;
12
+ Authorization:
13
+ - Bearer <ACCESS_TOKEN>
14
+ Content-Type:
15
+ - application/vnd.contentful.management.v1+json
16
+ Connection:
17
+ - close
18
+ Host:
19
+ - api.contentful.com
20
+ User-Agent:
21
+ - http.rb/5.0.1
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ Connection:
28
+ - close
29
+ Content-Length:
30
+ - '617'
31
+ Content-Type:
32
+ - application/json; charset=utf-8
33
+ X-Contentful-Ratelimit-Hour-Limit:
34
+ - '36000'
35
+ X-Contentful-Ratelimit-Second-Limit:
36
+ - '10'
37
+ X-Contentful-Ratelimit-Reset:
38
+ - '0'
39
+ X-Contentful-Ratelimit-Hour-Remaining:
40
+ - '35999'
41
+ X-Contentful-Ratelimit-Second-Remaining:
42
+ - '9'
43
+ X-Contentful-Route:
44
+ - "/organizations/:organizationId/taxonomy/concept-schemes/:id"
45
+ Cache-Control:
46
+ - no-cache
47
+ Accept-Ranges:
48
+ - bytes
49
+ X-Content-Type-Options:
50
+ - nosniff
51
+ Server:
52
+ - Contentful
53
+ Contentful-Api:
54
+ - cma
55
+ Contentful-Upstream:
56
+ - taxonomy-service
57
+ Access-Control-Allow-Origin:
58
+ - "*"
59
+ Access-Control-Allow-Headers:
60
+ - Accept,Accept-Language,Authorization,Cache-Control,CF-Context,Content-Length,Content-Range,Content-Type,DNT,Destination,Expires,If-Match,If-Modified-Since,If-None-Match,Keep-Alive,Last-Modified,Origin,Pragma,Range,User-Agent,X-Http-Method-Override,X-Mx-ReqToken,X-Requested-With,X-Contentful-Version,X-Contentful-Content-Type,X-Contentful-Organization,X-Contentful-Skip-Transformation,X-Contentful-Tag-Visibility,X-Contentful-User-Agent,X-Contentful-Enable-Alpha-Feature,X-Contentful-Source-Environment,X-Contentful-Team,X-Contentful-Parent-Id,x-contentful-validate-only,X-Contentful-Skip-UI-Draft-Validation,X-Contentful-Marketplace,X-Contentful-UI-Content-Auto-Save,cf-trace,X-Contentful-Comment-Body-Format,X-Contentful-Parent-Entity-Reference,X-Contentful-Include-Invocation-Metadata,X-Contentful-Async-Ai-Action,x-contentful-ai-actions-platform
61
+ Access-Control-Expose-Headers:
62
+ - Etag,x-contentful-request-id,x-contentful-ai-actions-ratelimit-reset
63
+ Access-Control-Allow-Methods:
64
+ - DELETE,GET,HEAD,POST,PUT,PATCH,OPTIONS
65
+ Access-Control-Max-Age:
66
+ - '1728000'
67
+ Date:
68
+ - Wed, 22 Oct 2025 13:07:06 GMT
69
+ X-Contentful-Request-Id:
70
+ - ffe98bdc-198d-4b52-8d3f-e276895ba69a
71
+ Strict-Transport-Security:
72
+ - max-age=15768000
73
+ body:
74
+ encoding: UTF-8
75
+ string: '{"sys":{"id":"2hNivoHTKM4MbTM4519T5E","type":"TaxonomyConceptScheme","createdAt":"2025-09-14T06:37:32.431Z","updatedAt":"2025-09-15T12:42:23.839Z","organization":{"sys":{"id":"4kQeJmhUWIKtNNmMkketza","type":"Link","linkType":"Organization"}},"createdBy":{"sys":{"id":"59Erm8D1JuuD273aXNb65T","type":"Link","linkType":"User"}},"updatedBy":{"sys":{"id":"59Erm8D1JuuD273aXNb65T","type":"Link","linkType":"User"}},"version":3},"uri":null,"topConcepts":[],"concepts":[{"sys":{"id":"greenSofas","type":"Link","linkType":"TaxonomyConcept"}}],"totalConcepts":1,"prefLabel":{"en-US":"Home
76
+ Products"},"definition":{"en-US":""}}'
77
+ recorded_at: Wed, 22 Oct 2025 13:07:06 GMT
78
+ recorded_with: VCR 6.2.0
@@ -0,0 +1,77 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.contentful.com/organizations/4kQeJmhUWIKtNNmMkketza/taxonomy/concept-schemes/total
6
+ body:
7
+ encoding: UTF-8
8
+ string: ''
9
+ headers:
10
+ X-Contentful-User-Agent:
11
+ - sdk contentful-management.rb/3.11.0; platform ruby/3.4.3; os macOS/24;
12
+ Authorization:
13
+ - Bearer <ACCESS_TOKEN>
14
+ Content-Type:
15
+ - application/vnd.contentful.management.v1+json
16
+ Connection:
17
+ - close
18
+ Host:
19
+ - api.contentful.com
20
+ User-Agent:
21
+ - http.rb/5.0.1
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ Connection:
28
+ - close
29
+ Content-Length:
30
+ - '11'
31
+ Content-Type:
32
+ - application/json; charset=utf-8
33
+ X-Contentful-Ratelimit-Second-Limit:
34
+ - '10'
35
+ X-Contentful-Ratelimit-Reset:
36
+ - '0'
37
+ X-Contentful-Ratelimit-Hour-Remaining:
38
+ - '35999'
39
+ X-Contentful-Ratelimit-Second-Remaining:
40
+ - '9'
41
+ X-Contentful-Ratelimit-Hour-Limit:
42
+ - '36000'
43
+ X-Contentful-Route:
44
+ - "/organizations/:organizationId/taxonomy/concept-schemes/total"
45
+ Cache-Control:
46
+ - no-cache
47
+ Accept-Ranges:
48
+ - bytes
49
+ X-Content-Type-Options:
50
+ - nosniff
51
+ Server:
52
+ - Contentful
53
+ Contentful-Api:
54
+ - cma
55
+ Contentful-Upstream:
56
+ - taxonomy-service
57
+ Access-Control-Allow-Origin:
58
+ - "*"
59
+ Access-Control-Allow-Headers:
60
+ - Accept,Accept-Language,Authorization,Cache-Control,CF-Context,Content-Length,Content-Range,Content-Type,DNT,Destination,Expires,If-Match,If-Modified-Since,If-None-Match,Keep-Alive,Last-Modified,Origin,Pragma,Range,User-Agent,X-Http-Method-Override,X-Mx-ReqToken,X-Requested-With,X-Contentful-Version,X-Contentful-Content-Type,X-Contentful-Organization,X-Contentful-Skip-Transformation,X-Contentful-Tag-Visibility,X-Contentful-User-Agent,X-Contentful-Enable-Alpha-Feature,X-Contentful-Source-Environment,X-Contentful-Team,X-Contentful-Parent-Id,x-contentful-validate-only,X-Contentful-Skip-UI-Draft-Validation,X-Contentful-Marketplace,X-Contentful-UI-Content-Auto-Save,cf-trace,X-Contentful-Comment-Body-Format,X-Contentful-Parent-Entity-Reference,X-Contentful-Include-Invocation-Metadata,X-Contentful-Async-Ai-Action,x-contentful-ai-actions-platform,X-Contentful-User-Id
61
+ Access-Control-Expose-Headers:
62
+ - Etag,x-contentful-request-id,x-contentful-ai-actions-ratelimit-reset
63
+ Access-Control-Allow-Methods:
64
+ - DELETE,GET,HEAD,POST,PUT,PATCH,OPTIONS
65
+ Access-Control-Max-Age:
66
+ - '1728000'
67
+ Date:
68
+ - Fri, 24 Oct 2025 08:29:42 GMT
69
+ X-Contentful-Request-Id:
70
+ - 5c6509d2-b4bb-41d4-b838-dc210807805d
71
+ Strict-Transport-Security:
72
+ - max-age=15768000
73
+ body:
74
+ encoding: UTF-8
75
+ string: '{"total":2}'
76
+ recorded_at: Fri, 24 Oct 2025 08:29:42 GMT
77
+ recorded_with: VCR 6.2.0
@@ -0,0 +1,155 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.contentful.com/organizations/4kQeJmhUWIKtNNmMkketza/taxonomy/concept-schemes/2hNivoHTKM4MbTM4519T5E
6
+ body:
7
+ encoding: UTF-8
8
+ string: ''
9
+ headers:
10
+ X-Contentful-User-Agent:
11
+ - sdk contentful-management.rb/3.11.0; platform ruby/3.4.3; os macOS/24;
12
+ Authorization:
13
+ - Bearer <ACCESS_TOKEN>
14
+ Content-Type:
15
+ - application/vnd.contentful.management.v1+json
16
+ Connection:
17
+ - close
18
+ Host:
19
+ - api.contentful.com
20
+ User-Agent:
21
+ - http.rb/5.0.1
22
+ response:
23
+ status:
24
+ code: 200
25
+ message: OK
26
+ headers:
27
+ Connection:
28
+ - close
29
+ Content-Length:
30
+ - '617'
31
+ Content-Type:
32
+ - application/json; charset=utf-8
33
+ X-Contentful-Ratelimit-Hour-Remaining:
34
+ - '35999'
35
+ X-Contentful-Ratelimit-Second-Remaining:
36
+ - '9'
37
+ X-Contentful-Ratelimit-Hour-Limit:
38
+ - '36000'
39
+ X-Contentful-Ratelimit-Second-Limit:
40
+ - '10'
41
+ X-Contentful-Ratelimit-Reset:
42
+ - '0'
43
+ X-Contentful-Route:
44
+ - "/organizations/:organizationId/taxonomy/concept-schemes/:id"
45
+ Cache-Control:
46
+ - no-cache
47
+ Accept-Ranges:
48
+ - bytes
49
+ X-Content-Type-Options:
50
+ - nosniff
51
+ Server:
52
+ - Contentful
53
+ Contentful-Api:
54
+ - cma
55
+ Contentful-Upstream:
56
+ - taxonomy-service
57
+ Access-Control-Allow-Origin:
58
+ - "*"
59
+ Access-Control-Allow-Headers:
60
+ - Accept,Accept-Language,Authorization,Cache-Control,CF-Context,Content-Length,Content-Range,Content-Type,DNT,Destination,Expires,If-Match,If-Modified-Since,If-None-Match,Keep-Alive,Last-Modified,Origin,Pragma,Range,User-Agent,X-Http-Method-Override,X-Mx-ReqToken,X-Requested-With,X-Contentful-Version,X-Contentful-Content-Type,X-Contentful-Organization,X-Contentful-Skip-Transformation,X-Contentful-Tag-Visibility,X-Contentful-User-Agent,X-Contentful-Enable-Alpha-Feature,X-Contentful-Source-Environment,X-Contentful-Team,X-Contentful-Parent-Id,x-contentful-validate-only,X-Contentful-Skip-UI-Draft-Validation,X-Contentful-Marketplace,X-Contentful-UI-Content-Auto-Save,cf-trace,X-Contentful-Comment-Body-Format,X-Contentful-Parent-Entity-Reference,X-Contentful-Include-Invocation-Metadata,X-Contentful-Async-Ai-Action,x-contentful-ai-actions-platform
61
+ Access-Control-Expose-Headers:
62
+ - Etag,x-contentful-request-id,x-contentful-ai-actions-ratelimit-reset
63
+ Access-Control-Allow-Methods:
64
+ - DELETE,GET,HEAD,POST,PUT,PATCH,OPTIONS
65
+ Access-Control-Max-Age:
66
+ - '1728000'
67
+ Date:
68
+ - Wed, 22 Oct 2025 13:10:46 GMT
69
+ X-Contentful-Request-Id:
70
+ - 333db422-2961-49d0-a52d-34b1a7578a10
71
+ Strict-Transport-Security:
72
+ - max-age=15768000
73
+ body:
74
+ encoding: UTF-8
75
+ string: '{"sys":{"id":"2hNivoHTKM4MbTM4519T5E","type":"TaxonomyConceptScheme","createdAt":"2025-09-14T06:37:32.431Z","updatedAt":"2025-09-15T12:42:23.839Z","organization":{"sys":{"id":"4kQeJmhUWIKtNNmMkketza","type":"Link","linkType":"Organization"}},"createdBy":{"sys":{"id":"59Erm8D1JuuD273aXNb65T","type":"Link","linkType":"User"}},"updatedBy":{"sys":{"id":"59Erm8D1JuuD273aXNb65T","type":"Link","linkType":"User"}},"version":3},"uri":null,"topConcepts":[],"concepts":[{"sys":{"id":"greenSofas","type":"Link","linkType":"TaxonomyConcept"}}],"totalConcepts":1,"prefLabel":{"en-US":"Home
76
+ Products"},"definition":{"en-US":""}}'
77
+ recorded_at: Wed, 22 Oct 2025 13:10:46 GMT
78
+ - request:
79
+ method: patch
80
+ uri: https://api.contentful.com/organizations/4kQeJmhUWIKtNNmMkketza/taxonomy/concept-schemes/2hNivoHTKM4MbTM4519T5E
81
+ body:
82
+ encoding: UTF-8
83
+ string: '[{"op":"add","path":"/prefLabel/en-US","value":"New Scheme Name"}]'
84
+ headers:
85
+ X-Contentful-User-Agent:
86
+ - sdk contentful-management.rb/3.11.0; platform ruby/3.4.3; os macOS/24;
87
+ Authorization:
88
+ - Bearer <ACCESS_TOKEN>
89
+ Content-Type:
90
+ - application/json-patch+json
91
+ X-Contentful-Version:
92
+ - '3'
93
+ Connection:
94
+ - close
95
+ Host:
96
+ - api.contentful.com
97
+ User-Agent:
98
+ - http.rb/5.0.1
99
+ response:
100
+ status:
101
+ code: 200
102
+ message: OK
103
+ headers:
104
+ Connection:
105
+ - close
106
+ Content-Length:
107
+ - '619'
108
+ Content-Type:
109
+ - application/json; charset=utf-8
110
+ X-Contentful-Ratelimit-Hour-Remaining:
111
+ - '35998'
112
+ X-Contentful-Ratelimit-Second-Remaining:
113
+ - '8'
114
+ X-Contentful-Ratelimit-Hour-Limit:
115
+ - '36000'
116
+ X-Contentful-Ratelimit-Second-Limit:
117
+ - '10'
118
+ X-Contentful-Ratelimit-Reset:
119
+ - '0'
120
+ X-Contentful-Route:
121
+ - "/organizations/:organizationId/taxonomy/concept-schemes/:id"
122
+ Cache-Control:
123
+ - no-cache
124
+ X-Content-Type-Options:
125
+ - nosniff
126
+ Server:
127
+ - Contentful
128
+ Contentful-Api:
129
+ - cma
130
+ Contentful-Upstream:
131
+ - taxonomy-service
132
+ Access-Control-Allow-Origin:
133
+ - "*"
134
+ Access-Control-Allow-Headers:
135
+ - Accept,Accept-Language,Authorization,Cache-Control,CF-Context,Content-Length,Content-Range,Content-Type,DNT,Destination,Expires,If-Match,If-Modified-Since,If-None-Match,Keep-Alive,Last-Modified,Origin,Pragma,Range,User-Agent,X-Http-Method-Override,X-Mx-ReqToken,X-Requested-With,X-Contentful-Version,X-Contentful-Content-Type,X-Contentful-Organization,X-Contentful-Skip-Transformation,X-Contentful-Tag-Visibility,X-Contentful-User-Agent,X-Contentful-Enable-Alpha-Feature,X-Contentful-Source-Environment,X-Contentful-Team,X-Contentful-Parent-Id,x-contentful-validate-only,X-Contentful-Skip-UI-Draft-Validation,X-Contentful-Marketplace,X-Contentful-UI-Content-Auto-Save,cf-trace,X-Contentful-Comment-Body-Format,X-Contentful-Parent-Entity-Reference,X-Contentful-Include-Invocation-Metadata,X-Contentful-Async-Ai-Action,x-contentful-ai-actions-platform
136
+ Access-Control-Expose-Headers:
137
+ - Etag,x-contentful-request-id,x-contentful-ai-actions-ratelimit-reset
138
+ Access-Control-Allow-Methods:
139
+ - DELETE,GET,HEAD,POST,PUT,PATCH,OPTIONS
140
+ Access-Control-Max-Age:
141
+ - '1728000'
142
+ Accept-Ranges:
143
+ - bytes
144
+ Date:
145
+ - Wed, 22 Oct 2025 13:10:47 GMT
146
+ X-Contentful-Request-Id:
147
+ - 9ad5db54-aac3-4541-8ab9-e36b1c4a2f99
148
+ Strict-Transport-Security:
149
+ - max-age=15768000
150
+ body:
151
+ encoding: UTF-8
152
+ string: '{"sys":{"id":"2hNivoHTKM4MbTM4519T5E","type":"TaxonomyConceptScheme","createdAt":"2025-09-14T06:37:32.431Z","updatedAt":"2025-10-22T13:10:46.957Z","organization":{"sys":{"id":"4kQeJmhUWIKtNNmMkketza","type":"Link","linkType":"Organization"}},"createdBy":{"sys":{"id":"59Erm8D1JuuD273aXNb65T","type":"Link","linkType":"User"}},"updatedBy":{"sys":{"id":"59Erm8D1JuuD273aXNb65T","type":"Link","linkType":"User"}},"version":4},"uri":null,"topConcepts":[],"concepts":[{"sys":{"id":"greenSofas","type":"Link","linkType":"TaxonomyConcept"}}],"totalConcepts":1,"prefLabel":{"en-US":"New
153
+ Scheme Name"},"definition":{"en-US":""}}'
154
+ recorded_at: Wed, 22 Oct 2025 13:10:47 GMT
155
+ recorded_with: VCR 6.2.0
@@ -370,6 +370,26 @@ module Contentful
370
370
  expect(asset.file.properties[:fileName]).to eq 'codequest.jpg'
371
371
  end
372
372
  end
373
+
374
+ it 'updates asset with concepts' do
375
+ vcr('asset/update_with_concepts') do
376
+ asset = subject.find('56PfMcxCLyzuXP3k7k0yL5')
377
+ concepts = [
378
+ {
379
+ 'sys' => {
380
+ 'type' => 'Link',
381
+ 'linkType' => 'TaxonomyConcept',
382
+ 'id' => 'livingRoom'
383
+ }
384
+ }
385
+ ]
386
+ asset.update(_metadata: { concepts: concepts, tags: [] })
387
+ expect(asset._metadata[:concepts]).to be_a(::Array)
388
+ expect(asset._metadata[:concepts].first).to be_a(Contentful::Management::Link)
389
+ expect(asset._metadata[:concepts].first.id).to eq('livingRoom')
390
+ expect(asset._metadata[:concepts].first.link_type).to eq('TaxonomyConcept')
391
+ end
392
+ end
373
393
  end
374
394
  describe '#save' do
375
395
  it 'updated' do
@@ -6,6 +6,7 @@ module Contentful
6
6
  module Management
7
7
  describe ContentType do
8
8
  let(:token) { ENV.fetch('CF_TEST_CMA_TOKEN', '<ACCESS_TOKEN>') }
9
+
9
10
  let(:space_id) { 'yr5m0jky5hsh' }
10
11
  let!(:client) { Client.new(token) }
11
12
  let(:content_type_id) { '5DSpuKrl04eMAGQoQckeIq' }
@@ -353,6 +354,27 @@ module Contentful
353
354
  end
354
355
  end
355
356
 
357
+ it 'updates content_type with metadata' do
358
+ vcr('content_type/update_with_metadata') do
359
+ content_type = subject.find('author')
360
+ metadata = {
361
+ taxonomy: [
362
+ {
363
+ 'sys' => {
364
+ 'type' => 'Link',
365
+ 'linkType' => 'TaxonomyConcept',
366
+ 'id' => 'newConcept'
367
+ }
368
+ }
369
+ ]
370
+ }
371
+ content_type.update(_metadata: metadata)
372
+ expect(content_type._metadata[:taxonomy]).to be_truthy
373
+ expect(content_type._metadata[:taxonomy].first['sys']['id']).to eq 'newConcept'
374
+ expect(content_type._metadata[:taxonomy].first['sys']['linkType']).to eq 'TaxonomyConcept'
375
+ end
376
+ end
377
+
356
378
  it 'update with multiple locales' do
357
379
  vcr('content_type/entry/update_only_with_localized_fields') do
358
380
  space = client.spaces.find('v2umtz8ths9v')
@@ -555,6 +555,27 @@ describe Contentful::Management::Entry do
555
555
  expect(p.fields).to match(expected)
556
556
  end
557
557
  end
558
+
559
+ it 'can update entry with concepts' do
560
+ vcr('entry/update_with_concepts') do
561
+ entry = subject.find('2aJVtypYfQajNbNN9TvEfd')
562
+ concepts = [
563
+ {
564
+ 'sys' => {
565
+ 'type' => 'Link',
566
+ 'linkType' => 'TaxonomyConcept',
567
+ 'id' => 'livingRoom'
568
+ }
569
+ }
570
+ ]
571
+ entry.update(_metadata: { concepts: concepts, tags: [] })
572
+ expect(entry._metadata[:concepts]).to be_a(::Array)
573
+ expect(entry._metadata[:concepts].first).to be_a(Contentful::Management::Link)
574
+ expect(entry._metadata[:concepts].first.id).to eq('livingRoom')
575
+ expect(entry._metadata[:concepts].first.link_type).to eq('TaxonomyConcept')
576
+ end
577
+ end
578
+
558
579
  end
559
580
 
560
581
  describe '#save' do
@@ -1255,4 +1276,4 @@ describe Contentful::Management::Entry do
1255
1276
  end
1256
1277
  end
1257
1278
  end
1258
- end
1279
+ end
@@ -0,0 +1,85 @@
1
+ require 'spec_helper'
2
+ require 'contentful/management/taxonomy_concept_scheme'
3
+ require 'contentful/management/client'
4
+
5
+ module Contentful
6
+ module Management
7
+ describe TaxonomyConceptScheme do
8
+ let(:token) { ENV.fetch('CF_TEST_CMA_TOKEN', '<ACCESS_TOKEN>') }
9
+
10
+ let(:organization_id) { '4kQeJmhUWIKtNNmMkketza' }
11
+ let(:concept_scheme_id) { '2hNivoHTKM4MbTM4519T5E' }
12
+ let(:client) { Client.new(token, raise_errors: true) }
13
+
14
+ subject { client.taxonomy_concept_schemes(organization_id) }
15
+
16
+ describe '.find' do
17
+ it 'returns a Contentful::Management::TaxonomyConceptScheme' do
18
+ vcr('taxonomy_concept_scheme/find') do
19
+ concept_scheme = subject.find(concept_scheme_id)
20
+ expect(concept_scheme).to be_a Contentful::Management::TaxonomyConceptScheme
21
+ expect(concept_scheme.id).to eq concept_scheme_id
22
+ expect(concept_scheme.pref_label['en-US']).to eq 'Home Products'
23
+ end
24
+ end
25
+ end
26
+
27
+ describe '.all' do
28
+ it 'returns an array of taxonomy concept schemes' do
29
+ vcr('taxonomy_concept_scheme/all') do
30
+ schemes = subject.all
31
+ expect(schemes).to be_a(Contentful::Management::Array)
32
+ expect(schemes.first).to be_a(Contentful::Management::TaxonomyConceptScheme)
33
+ end
34
+ end
35
+ end
36
+
37
+ describe '.total' do
38
+ it 'returns the total number of concept schemes' do
39
+ vcr('taxonomy_concept_scheme/total') do
40
+ total = subject.total
41
+ expect(total).to be_a(Integer)
42
+ end
43
+ end
44
+ end
45
+
46
+ describe '.create' do
47
+ it 'creates a taxonomy concept scheme' do
48
+ vcr('taxonomy_concept_scheme/create') do
49
+ scheme = subject.create(
50
+ prefLabel: { 'en-US' => 'New Scheme' }
51
+ )
52
+ expect(scheme).to be_a(Contentful::Management::TaxonomyConceptScheme)
53
+ expect(scheme.pref_label['en-US']).to eq('New Scheme')
54
+ end
55
+ end
56
+ end
57
+
58
+ describe '#update' do
59
+ it 'updates a taxonomy concept scheme' do
60
+ vcr('taxonomy_concept_scheme/update') do
61
+ scheme = subject.find(concept_scheme_id)
62
+ updated_scheme = scheme.update([
63
+ { op: 'add', path: '/prefLabel/en-US', value: 'New Scheme Name' }
64
+ ])
65
+ expect(updated_scheme).to be_a(Contentful::Management::TaxonomyConceptScheme)
66
+ expect(updated_scheme.pref_label['en-US']).to eq('New Scheme Name')
67
+ end
68
+ end
69
+ end
70
+
71
+ describe '#destroy' do
72
+ it 'deletes a taxonomy concept scheme' do
73
+ vcr('taxonomy_concept_scheme/destroy') do
74
+ scheme = subject.find(concept_scheme_id)
75
+ result = scheme.destroy
76
+ expect(result).to be_truthy
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
83
+
84
+
85
+
@@ -0,0 +1,116 @@
1
+ require 'spec_helper'
2
+ require 'contentful/management/taxonomy_concept'
3
+ require 'contentful/management/client'
4
+
5
+ module Contentful
6
+ module Management
7
+ describe TaxonomyConcept do
8
+ let(:token) { ENV.fetch('CF_TEST_CMA_TOKEN', '<ACCESS_TOKEN>') }
9
+
10
+ let(:organization_id) { '4kQeJmhUWIKtNNmMkketza' }
11
+ let(:concept_id) { '5KHXWlmxvntrrB09szapUp' }
12
+ let(:client) { Client.new(token) }
13
+
14
+ subject { client.taxonomy_concepts(organization_id) }
15
+
16
+ describe '.find' do
17
+ it 'returns a Contentful::Management::TaxonomyConcept' do
18
+ vcr('taxonomy_concept/find') do
19
+ concept = subject.find(concept_id)
20
+ expect(concept).to be_a Contentful::Management::TaxonomyConcept
21
+ expect(concept.id).to eq concept_id
22
+ expect(concept.pref_label['en-US']).to eq 'Sofas'
23
+ end
24
+ end
25
+ end
26
+
27
+ describe '.all' do
28
+ it 'returns an array of taxonomy concepts' do
29
+ vcr('taxonomy_concept/all') do
30
+ concepts = subject.all
31
+ expect(concepts).to be_a(Contentful::Management::Array)
32
+ expect(concepts.first).to be_a(Contentful::Management::TaxonomyConcept)
33
+ end
34
+ end
35
+ end
36
+
37
+ describe '.total' do
38
+ it 'returns the total number of concepts' do
39
+ vcr('taxonomy_concept/total') do
40
+ total = subject.total
41
+ expect(total).to be_a(Integer)
42
+ end
43
+ end
44
+ end
45
+
46
+ describe '.create' do
47
+ it 'creates a taxonomy concept' do
48
+ vcr('taxonomy_concept/create') do
49
+ concept = subject.create(
50
+ prefLabel: { 'en-US' => 'Bicycles' }
51
+ )
52
+ expect(concept).to be_a(Contentful::Management::TaxonomyConcept)
53
+ expect(concept.pref_label['en-US']).to eq('Bicycles')
54
+ end
55
+ end
56
+
57
+ it 'creates a taxonomy concept with a user-defined id' do
58
+ vcr('taxonomy_concept/create_with_id') do
59
+ concept = subject.create(
60
+ id: 'my-custom-id',
61
+ prefLabel: { 'en-US' => 'Custom Bicycles' }
62
+ )
63
+ expect(concept).to be_a(Contentful::Management::TaxonomyConcept)
64
+ expect(concept.id).to eq('my-custom-id')
65
+ expect(concept.pref_label['en-US']).to eq('Custom Bicycles')
66
+ end
67
+ end
68
+ end
69
+
70
+ describe '#update' do
71
+ it 'updates a taxonomy concept' do
72
+ vcr('taxonomy_concept/update') do
73
+ concept = subject.find(concept_id)
74
+ updated_concept = concept.update([
75
+ { op: 'add', path: '/prefLabel/en-US', value: 'New Label' }
76
+ ])
77
+ expect(updated_concept).to be_a(Contentful::Management::TaxonomyConcept)
78
+ expect(updated_concept.pref_label['en-US']).to eq('New Label')
79
+ end
80
+ end
81
+ end
82
+
83
+ describe '#ancestors' do
84
+ it 'returns an array of ancestor concepts' do
85
+ vcr('taxonomy_concept/ancestors') do
86
+ concept = subject.find('livingRoom')
87
+ ancestors = concept.ancestors
88
+ expect(ancestors).to be_a(Contentful::Management::Array)
89
+ expect(ancestors.first).to be_a(Contentful::Management::TaxonomyConcept)
90
+ end
91
+ end
92
+ end
93
+
94
+ describe '#descendants' do
95
+ it 'returns an array of descendant concepts' do
96
+ vcr('taxonomy_concept/descendants') do
97
+ concept = subject.find('greenSofas')
98
+ descendants = concept.descendants
99
+ expect(descendants).to be_a(Contentful::Management::Array)
100
+ expect(descendants.first).to be_a(Contentful::Management::TaxonomyConcept)
101
+ end
102
+ end
103
+ end
104
+
105
+ describe '#destroy' do
106
+ it 'deletes a taxonomy concept' do
107
+ vcr('taxonomy_concept/destroy') do
108
+ concept = subject.find(concept_id)
109
+ result = concept.destroy
110
+ expect(result).to be_truthy
111
+ end
112
+ end
113
+ end
114
+ end
115
+ end
116
+ end