contentful 2.17.2 → 2.18.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +88 -16
- data/lib/contentful/array.rb +2 -1
- data/lib/contentful/base_resource.rb +1 -1
- data/lib/contentful/client.rb +38 -0
- data/lib/contentful/resource_builder.rb +6 -2
- data/lib/contentful/taxonomy_concept.rb +95 -0
- data/lib/contentful/taxonomy_concept_scheme.rb +51 -0
- data/lib/contentful/version.rb +1 -1
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c528da80cb5f6311e4777fb2e4df10669e4b68040999a897e56a6aa3175d93f
|
4
|
+
data.tar.gz: fbdceb0c8f8529e5c2447835a1769e5e6f630dcd96b5b7262884e3213275782c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e754c6ff56a14421791b440a4003d128e69550b8c40d4913d86af91ac63070047ddc0ebdf99d5a1fd72a6605f950b3f030c0edf50c8ffa976fffe7934461ab61
|
7
|
+
data.tar.gz: 7289773832ac258c0994d6e38dca5491d9c6954d788b3bb3fc904e24c0697a9789dd27a38957d893fbbc163dddfa9bb62c6a32b3f0b7b07a9be1e456c41f5ed4
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -56,6 +56,8 @@
|
|
56
56
|
- [Configuration](#configuration)
|
57
57
|
- [Reference documentation](#reference-documentation)
|
58
58
|
- [Basic queries](#basic-queries)
|
59
|
+
- [Taxonomy Concepts](#taxonomy-concepts)
|
60
|
+
- [Taxonomy Concept Schemes](#taxonomy-concept-schemes)
|
59
61
|
- [Filtering options](#filtering-options)
|
60
62
|
- [Accessing fields and sys properties](#accessing-fields-and-sys-properties)
|
61
63
|
- [Dynamic entries](#dynamic-entries)
|
@@ -381,6 +383,89 @@ nyancat = client.entry 'nyancat'
|
|
381
383
|
entries = client.entries
|
382
384
|
assets = client.assets
|
383
385
|
nyancat_asset = client.asset 'nyancat'
|
386
|
+
taxonomy_concept = client.taxonomy_concept '3DMf5gdax6J22AfcJ6fvsC'
|
387
|
+
taxonomy_concept_scheme = client.taxonomy_concept_scheme '7CzXPy6XvYYd0D7SomitgI'
|
388
|
+
```
|
389
|
+
|
390
|
+
### Assets
|
391
|
+
|
392
|
+
There is a helpful method to add image resize options for an asset image:
|
393
|
+
|
394
|
+
```ruby
|
395
|
+
client.asset('happycat').url
|
396
|
+
# => "//images.contentful.com/cfexampleapi/3MZPnjZTIskAIIkuuosCss/
|
397
|
+
# 382a48dfa2cb16c47aa2c72f7b23bf09/happycatw.jpg"
|
398
|
+
|
399
|
+
client.asset('happycat').url(width: 300, height: 200, format: 'jpg', quality: 100)
|
400
|
+
# => "//images.contentful.com/cfexampleapi/3MZPnjZTIskAIIkuuosCss/
|
401
|
+
# 382a48dfa2cb16c47aa2c72f7b23bf09/happycatw.jpg?w=300&h=200&fm=jpg&q=100"
|
402
|
+
```
|
403
|
+
|
404
|
+
### Taxonomy Concepts
|
405
|
+
|
406
|
+
You can retrieve taxonomy concepts using the taxonomy_concept method:
|
407
|
+
|
408
|
+
```ruby
|
409
|
+
# Get a specific taxonomy concept
|
410
|
+
concept = client.taxonomy_concept('3DMf5gdax6J22AfcJ6fvsC')
|
411
|
+
|
412
|
+
# Access basic properties
|
413
|
+
concept.sys[:id] # => '3DMf5gdax6J22AfcJ6fvsC'
|
414
|
+
concept.sys[:type] # => 'TaxonomyConcept'
|
415
|
+
concept.uri # => nil or URI string
|
416
|
+
|
417
|
+
# Access localized fields
|
418
|
+
concept.pref_label # => 'sofa'
|
419
|
+
concept.alt_labels # => []
|
420
|
+
concept.definition # => ''
|
421
|
+
concept.note # => ''
|
422
|
+
|
423
|
+
# Access relationships
|
424
|
+
concept.broader # => Array of broader concept links
|
425
|
+
concept.related # => Array of related concept links
|
426
|
+
concept.concept_schemes # => Array of concept scheme links
|
427
|
+
```
|
428
|
+
|
429
|
+
### Taxonomy Concept Schemes
|
430
|
+
|
431
|
+
You can retrieve taxonomy concept schemes using the taxonomy_concept_scheme method:
|
432
|
+
|
433
|
+
```ruby
|
434
|
+
# Get a specific taxonomy concept scheme
|
435
|
+
scheme = client.taxonomy_concept_scheme('7CzXPy6XvYYd0D7SomitgI')
|
436
|
+
|
437
|
+
# Access basic properties
|
438
|
+
scheme.sys[:id] # => '7CzXPy6XvYYd0D7SomitgI'
|
439
|
+
scheme.sys[:type] # => 'TaxonomyConceptScheme'
|
440
|
+
scheme.uri # => nil or URI string
|
441
|
+
scheme.total_concepts # => 1
|
442
|
+
|
443
|
+
# Access localized fields
|
444
|
+
scheme.pref_label # => 'furniture'
|
445
|
+
scheme.definition # => ''
|
446
|
+
|
447
|
+
# Access relationships
|
448
|
+
scheme.top_concepts # => Array of top concept links
|
449
|
+
scheme.concepts # => Array of concept links
|
450
|
+
|
451
|
+
# Get all taxonomy concept schemes
|
452
|
+
schemes = client.taxonomy_concept_schemes
|
453
|
+
|
454
|
+
# You can also use query parameters for filtering and pagination
|
455
|
+
schemes = client.taxonomy_concept_schemes(limit: 10, order: 'sys.createdAt')
|
456
|
+
schemes = client.taxonomy_concept_schemes(limit: 5, skip: 10)
|
457
|
+
|
458
|
+
# The result is a Contentful::Array that you can iterate over
|
459
|
+
schemes.each do |scheme|
|
460
|
+
puts "Scheme: #{scheme.pref_label} (ID: #{scheme.sys[:id]})"
|
461
|
+
puts "Total concepts: #{scheme.total_concepts}"
|
462
|
+
end
|
463
|
+
|
464
|
+
# Access pagination information
|
465
|
+
if schemes.next_page_url
|
466
|
+
next_page = schemes.next_page_url
|
467
|
+
# You can use this URL to get the next page of results
|
468
|
+
end
|
384
469
|
```
|
385
470
|
|
386
471
|
#### Filtering options
|
@@ -424,13 +509,14 @@ entry.color # 'rainbow'
|
|
424
509
|
entry.birthday # #<DateTime: 2011-04-04T22:00:00+00:00 ((2455656j,79200s,0n),+0s,2299161j)>
|
425
510
|
```
|
426
511
|
|
427
|
-
#### Accessing tags
|
512
|
+
#### Accessing tags and concepts
|
428
513
|
|
429
|
-
Tags can be accessed via the `#_metadata` method.
|
514
|
+
Tags and concepts can be accessed via the `#_metadata` method.
|
430
515
|
|
431
516
|
```ruby
|
432
517
|
entry = client.entry 'nyancat'
|
433
518
|
entry._metadata[:tags] # => [<Contentful::Link id='tagID'>]
|
519
|
+
entry._metadata[:concepts] # => [<Contentful::Link id='conceptID'>]
|
434
520
|
```
|
435
521
|
|
436
522
|
#### Dynamic entries
|
@@ -494,20 +580,6 @@ happycat.image
|
|
494
580
|
happycat.image.resolve(client) # => #<Contentful::Asset: @fields={ ...
|
495
581
|
```
|
496
582
|
|
497
|
-
### Assets
|
498
|
-
|
499
|
-
There is a helpful method to add image resize options for an asset image:
|
500
|
-
|
501
|
-
```ruby
|
502
|
-
client.asset('happycat').url
|
503
|
-
# => "//images.contentful.com/cfexampleapi/3MZPnjZTIskAIIkuuosCss/
|
504
|
-
# 382a48dfa2cb16c47aa2c72f7b23bf09/happycatw.jpg"
|
505
|
-
|
506
|
-
client.asset('happycat').url(width: 300, height: 200, format: 'jpg', quality: 100)
|
507
|
-
# => "//images.contentful.com/cfexampleapi/3MZPnjZTIskAIIkuuosCss/
|
508
|
-
# 382a48dfa2cb16c47aa2c72f7b23bf09/happycatw.jpg?w=300&h=200&fm=jpg&q=100"
|
509
|
-
```
|
510
|
-
|
511
583
|
#### Resource options
|
512
584
|
|
513
585
|
Resources, that have been requested directly (i.e. no child resources), can be fetched from the server again by calling `#reload`:
|
data/lib/contentful/array.rb
CHANGED
@@ -75,7 +75,8 @@ module Contentful
|
|
75
75
|
'ContentType' => 'content_types',
|
76
76
|
'Entry' => 'entries',
|
77
77
|
'Asset' => 'assets',
|
78
|
-
'Locale' => 'locales'
|
78
|
+
'Locale' => 'locales',
|
79
|
+
'TaxonomyConcept' => 'taxonomy_concepts'
|
79
80
|
}
|
80
81
|
|
81
82
|
client.public_send(plurals[items.first.type], query.merge(limit: limit, skip: new_skip))
|
@@ -98,7 +98,7 @@ module Contentful
|
|
98
98
|
def hydrate_metadata
|
99
99
|
result = {}
|
100
100
|
raw.fetch('metadata', {}).each do |k, v|
|
101
|
-
v = v.map { |
|
101
|
+
v = v.map { |item| build_link(item) } if %w[tags concepts].include?(k)
|
102
102
|
result[Support.snakify(k, @configuration[:use_camel_case]).to_sym] = v
|
103
103
|
end
|
104
104
|
result
|
data/lib/contentful/client.rb
CHANGED
@@ -215,6 +215,44 @@ module Contentful
|
|
215
215
|
Request.new(self, environment_url('/locales'), query).get
|
216
216
|
end
|
217
217
|
|
218
|
+
# Gets a specific taxonomy concept
|
219
|
+
#
|
220
|
+
# @param [String] id
|
221
|
+
# @param [Hash] query
|
222
|
+
#
|
223
|
+
# @return [Contentful::TaxonomyConcept]
|
224
|
+
def taxonomy_concept(id, query = {})
|
225
|
+
Request.new(self, environment_url('/taxonomy/concepts'), query, id).get
|
226
|
+
end
|
227
|
+
|
228
|
+
# Gets a collection of taxonomy concepts
|
229
|
+
#
|
230
|
+
# @param [Hash] query
|
231
|
+
#
|
232
|
+
# @return [Contentful::Array<Contentful::TaxonomyConcept>]
|
233
|
+
def taxonomy_concepts(query = {})
|
234
|
+
Request.new(self, environment_url('/taxonomy/concepts'), query).get
|
235
|
+
end
|
236
|
+
|
237
|
+
# Gets a specific taxonomy concept scheme
|
238
|
+
#
|
239
|
+
# @param [String] id
|
240
|
+
# @param [Hash] query
|
241
|
+
#
|
242
|
+
# @return [Contentful::TaxonomyConceptScheme]
|
243
|
+
def taxonomy_concept_scheme(id, query = {})
|
244
|
+
Request.new(self, environment_url('/taxonomy/concept-schemes'), query, id).get
|
245
|
+
end
|
246
|
+
|
247
|
+
# Gets a collection of taxonomy concept schemes
|
248
|
+
#
|
249
|
+
# @param [Hash] query
|
250
|
+
#
|
251
|
+
# @return [Contentful::Array<Contentful::TaxonomyConceptScheme>]
|
252
|
+
def taxonomy_concept_schemes(query = {})
|
253
|
+
Request.new(self, environment_url('/taxonomy/concept-schemes'), query).get
|
254
|
+
end
|
255
|
+
|
218
256
|
# Returns the base url for all of the client's requests
|
219
257
|
# @private
|
220
258
|
def base_url
|
@@ -9,6 +9,8 @@ require_relative 'deleted_entry'
|
|
9
9
|
require_relative 'deleted_asset'
|
10
10
|
require_relative 'locale'
|
11
11
|
require_relative 'includes'
|
12
|
+
require_relative 'taxonomy_concept'
|
13
|
+
require_relative 'taxonomy_concept_scheme'
|
12
14
|
|
13
15
|
module Contentful
|
14
16
|
# Transforms a Contentful::Response into a Contentful::Resource or a Contentful::Error
|
@@ -25,13 +27,15 @@ module Contentful
|
|
25
27
|
'Link' => Link,
|
26
28
|
'DeletedEntry' => DeletedEntry,
|
27
29
|
'DeletedAsset' => DeletedAsset,
|
28
|
-
'Locale' => Locale
|
30
|
+
'Locale' => Locale,
|
31
|
+
'TaxonomyConcept' => TaxonomyConcept,
|
32
|
+
'TaxonomyConceptScheme' => TaxonomyConceptScheme
|
29
33
|
}.freeze
|
30
34
|
# Default Entry Mapping
|
31
35
|
# @see _ README for more information on Entry Mapping
|
32
36
|
DEFAULT_ENTRY_MAPPING = {}.freeze
|
33
37
|
# Buildable Resources
|
34
|
-
BUILDABLES = %w[Entry Asset ContentType Space DeletedEntry DeletedAsset Locale].freeze
|
38
|
+
BUILDABLES = %w[Entry Asset ContentType Space DeletedEntry DeletedAsset Locale TaxonomyConcept TaxonomyConceptScheme].freeze
|
35
39
|
|
36
40
|
attr_reader :json, :default_locale, :endpoint, :depth, :localized, :resource_mapping, :entry_mapping, :resource, :query
|
37
41
|
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require_relative 'base_resource'
|
2
|
+
|
3
|
+
module Contentful
|
4
|
+
# Resource class for TaxonomyConcept.
|
5
|
+
# @see _ https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/taxonomy/concept
|
6
|
+
class TaxonomyConcept < BaseResource
|
7
|
+
attr_reader :uri, :notations, :broader, :related, :concept_schemes
|
8
|
+
|
9
|
+
def initialize(item, *)
|
10
|
+
super
|
11
|
+
|
12
|
+
@uri = item.fetch('uri', nil)
|
13
|
+
@notations = item.fetch('notations', [])
|
14
|
+
@broader = item.fetch('broader', [])
|
15
|
+
@related = item.fetch('related', [])
|
16
|
+
@concept_schemes = item.fetch('conceptSchemes', [])
|
17
|
+
end
|
18
|
+
|
19
|
+
# Returns true for resources that are taxonomy concepts
|
20
|
+
def taxonomy_concept?
|
21
|
+
true
|
22
|
+
end
|
23
|
+
|
24
|
+
# Returns false for resources that are not entries
|
25
|
+
def entry?
|
26
|
+
false
|
27
|
+
end
|
28
|
+
|
29
|
+
# Returns false for resources that are not assets
|
30
|
+
def asset?
|
31
|
+
false
|
32
|
+
end
|
33
|
+
|
34
|
+
# Access localized fields
|
35
|
+
def pref_label(locale = nil)
|
36
|
+
locale ||= default_locale
|
37
|
+
pref_label = raw.fetch('prefLabel', {})
|
38
|
+
pref_label.is_a?(Hash) ? pref_label.fetch(locale.to_s, nil) : pref_label
|
39
|
+
end
|
40
|
+
|
41
|
+
def alt_labels(locale = nil)
|
42
|
+
locale ||= default_locale
|
43
|
+
alt_labels = raw.fetch('altLabels', {})
|
44
|
+
alt_labels.is_a?(Hash) ? alt_labels.fetch(locale.to_s, []) : alt_labels
|
45
|
+
end
|
46
|
+
|
47
|
+
def hidden_labels(locale = nil)
|
48
|
+
locale ||= default_locale
|
49
|
+
hidden_labels = raw.fetch('hiddenLabels', {})
|
50
|
+
hidden_labels.is_a?(Hash) ? hidden_labels.fetch(locale.to_s, []) : hidden_labels
|
51
|
+
end
|
52
|
+
|
53
|
+
def note(locale = nil)
|
54
|
+
locale ||= default_locale
|
55
|
+
note = raw.fetch('note', {})
|
56
|
+
note.is_a?(Hash) ? note.fetch(locale.to_s, '') : note
|
57
|
+
end
|
58
|
+
|
59
|
+
def change_note(locale = nil)
|
60
|
+
locale ||= default_locale
|
61
|
+
change_note = raw.fetch('changeNote', {})
|
62
|
+
change_note.is_a?(Hash) ? change_note.fetch(locale.to_s, '') : change_note
|
63
|
+
end
|
64
|
+
|
65
|
+
def definition(locale = nil)
|
66
|
+
locale ||= default_locale
|
67
|
+
definition = raw.fetch('definition', {})
|
68
|
+
definition.is_a?(Hash) ? definition.fetch(locale.to_s, '') : definition
|
69
|
+
end
|
70
|
+
|
71
|
+
def editorial_note(locale = nil)
|
72
|
+
locale ||= default_locale
|
73
|
+
editorial_note = raw.fetch('editorialNote', {})
|
74
|
+
editorial_note.is_a?(Hash) ? editorial_note.fetch(locale.to_s, '') : editorial_note
|
75
|
+
end
|
76
|
+
|
77
|
+
def example(locale = nil)
|
78
|
+
locale ||= default_locale
|
79
|
+
example = raw.fetch('example', {})
|
80
|
+
example.is_a?(Hash) ? example.fetch(locale.to_s, '') : example
|
81
|
+
end
|
82
|
+
|
83
|
+
def history_note(locale = nil)
|
84
|
+
locale ||= default_locale
|
85
|
+
history_note = raw.fetch('historyNote', {})
|
86
|
+
history_note.is_a?(Hash) ? history_note.fetch(locale.to_s, '') : history_note
|
87
|
+
end
|
88
|
+
|
89
|
+
def scope_note(locale = nil)
|
90
|
+
locale ||= default_locale
|
91
|
+
scope_note = raw.fetch('scopeNote', {})
|
92
|
+
scope_note.is_a?(Hash) ? scope_note.fetch(locale.to_s, '') : scope_note
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require_relative 'base_resource'
|
2
|
+
|
3
|
+
module Contentful
|
4
|
+
# Resource class for TaxonomyConceptScheme.
|
5
|
+
# @see _ https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/taxonomy/concept-scheme
|
6
|
+
class TaxonomyConceptScheme < BaseResource
|
7
|
+
attr_reader :uri, :top_concepts, :concepts, :total_concepts
|
8
|
+
|
9
|
+
def initialize(item, *)
|
10
|
+
super
|
11
|
+
|
12
|
+
@uri = item.fetch('uri', nil)
|
13
|
+
@top_concepts = item.fetch('topConcepts', [])
|
14
|
+
@concepts = item.fetch('concepts', [])
|
15
|
+
@total_concepts = item.fetch('totalConcepts', 0)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Returns true for resources that are taxonomy concept schemes
|
19
|
+
def taxonomy_concept_scheme?
|
20
|
+
true
|
21
|
+
end
|
22
|
+
|
23
|
+
# Returns false for resources that are not taxonomy concepts
|
24
|
+
def taxonomy_concept?
|
25
|
+
false
|
26
|
+
end
|
27
|
+
|
28
|
+
# Returns false for resources that are not entries
|
29
|
+
def entry?
|
30
|
+
false
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns false for resources that are not assets
|
34
|
+
def asset?
|
35
|
+
false
|
36
|
+
end
|
37
|
+
|
38
|
+
# Access localized fields
|
39
|
+
def pref_label(locale = nil)
|
40
|
+
locale ||= default_locale
|
41
|
+
pref_label = raw.fetch('prefLabel', {})
|
42
|
+
pref_label.is_a?(Hash) ? pref_label.fetch(locale.to_s, nil) : pref_label
|
43
|
+
end
|
44
|
+
|
45
|
+
def definition(locale = nil)
|
46
|
+
locale ||= default_locale
|
47
|
+
definition = raw.fetch('definition', {})
|
48
|
+
definition.is_a?(Hash) ? definition.fetch(locale.to_s, '') : definition
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/contentful/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contentful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Contentful GmbH (Jan Lelis)
|
8
8
|
- Contentful GmbH (Andreas Tiefenthaler)
|
9
9
|
- Contentful GmbH (David Litvak Bruno)
|
10
|
+
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date:
|
13
|
+
date: 2025-07-24 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: http
|
@@ -278,11 +279,14 @@ files:
|
|
278
279
|
- lib/contentful/support.rb
|
279
280
|
- lib/contentful/sync.rb
|
280
281
|
- lib/contentful/sync_page.rb
|
282
|
+
- lib/contentful/taxonomy_concept.rb
|
283
|
+
- lib/contentful/taxonomy_concept_scheme.rb
|
281
284
|
- lib/contentful/version.rb
|
282
285
|
homepage: https://github.com/contentful/contentful.rb
|
283
286
|
licenses:
|
284
287
|
- MIT
|
285
288
|
metadata: {}
|
289
|
+
post_install_message:
|
286
290
|
rdoc_options: []
|
287
291
|
require_paths:
|
288
292
|
- lib
|
@@ -297,7 +301,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
297
301
|
- !ruby/object:Gem::Version
|
298
302
|
version: '0'
|
299
303
|
requirements: []
|
300
|
-
rubygems_version: 3.
|
304
|
+
rubygems_version: 3.5.22
|
305
|
+
signing_key:
|
301
306
|
specification_version: 4
|
302
307
|
summary: contentful
|
303
308
|
test_files: []
|