kontent-delivery-sdk-ruby 2.0.22 → 2.0.24
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/LICENSE.md +21 -21
- data/README.md +603 -602
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/lib/delivery/builders/image_transformation_builder.rb +272 -272
- data/lib/delivery/builders/url_builder.rb +123 -123
- data/lib/delivery/client/delivery_client.rb +184 -184
- data/lib/delivery/client/delivery_query.rb +302 -302
- data/lib/delivery/client/request_manager.rb +126 -127
- data/lib/delivery/models/content_item.rb +153 -153
- data/lib/delivery/models/content_type.rb +41 -41
- data/lib/delivery/models/language.rb +29 -29
- data/lib/delivery/models/pagination.rb +22 -22
- data/lib/delivery/models/taxonomy_group.rb +39 -39
- data/lib/delivery/query_parameters/filters.rb +201 -201
- data/lib/delivery/query_parameters/parameter_base.rb +56 -56
- data/lib/delivery/query_parameters/query_string.rb +78 -78
- data/lib/delivery/resolvers/content_link_resolver.rb +102 -102
- data/lib/delivery/resolvers/inline_content_item_resolver.rb +75 -75
- data/lib/delivery/resolvers/linked_item_resolver.rb +43 -37
- data/lib/delivery/responses/delivery_element_response.rb +34 -34
- data/lib/delivery/responses/delivery_item_listing_response.rb +54 -54
- data/lib/delivery/responses/delivery_item_response.rb +40 -40
- data/lib/delivery/responses/delivery_items_feed_response.rb +58 -58
- data/lib/delivery/responses/delivery_language_listing_response.rb +44 -44
- data/lib/delivery/responses/delivery_taxonomy_listing_response.rb +47 -47
- data/lib/delivery/responses/delivery_taxonomy_response.rb +33 -33
- data/lib/delivery/responses/delivery_type_listing_response.rb +46 -46
- data/lib/delivery/responses/delivery_type_response.rb +32 -32
- data/lib/delivery/responses/response_base.rb +39 -39
- data/lib/delivery/tests/401.json +5 -5
- data/lib/delivery/tests/429.json +4 -4
- data/lib/delivery/tests/fake_responder.rb +99 -105
- data/lib/delivery/tests/filtering/items_with_count.json +5384 -5384
- data/lib/delivery/tests/filtering/pagination.json +761 -761
- data/lib/delivery/tests/generic/items.json +5383 -5383
- data/lib/delivery/tests/generic/items/about_us.json +276 -276
- data/lib/delivery/tests/generic/items/aeropress_filters.json +155 -155
- data/lib/delivery/tests/generic/items/coffee_processing_techniques.json +565 -565
- data/lib/delivery/tests/generic/items/where_does_coffee_come_from_.json +598 -598
- data/lib/delivery/tests/generic/languages.json +23 -23
- data/lib/delivery/tests/generic/taxonomies.json +203 -203
- data/lib/delivery/tests/generic/taxonomies/manufacturer.json +29 -29
- data/lib/delivery/tests/generic/types.json +835 -835
- data/lib/delivery/tests/generic/types/brewer.json +88 -88
- data/lib/delivery/tests/generic/types/brewer/elements/product_status.json +5 -5
- data/lib/delivery/tests/items_feed/articles_feed_1.json +39 -39
- data/lib/delivery/tests/items_feed/articles_feed_2.json +78 -78
- data/lib/delivery/tests/items_feed/articles_feed_3.json +104 -104
- data/lib/kontent-delivery-sdk-ruby.rb +22 -22
- metadata +13 -32
@@ -1,41 +1,41 @@
|
|
1
|
-
require 'ostruct'
|
2
|
-
|
3
|
-
module Kentico
|
4
|
-
module Kontent
|
5
|
-
module Delivery
|
6
|
-
class ContentType
|
7
|
-
# Parses the 'elements' JSON object as a dynamic OpenStruct object.
|
8
|
-
#
|
9
|
-
# * *Returns*:
|
10
|
-
# - +OpenStruct+ The elements of the content type
|
11
|
-
def elements
|
12
|
-
@elements unless @elements.nil?
|
13
|
-
@elements = JSON.parse(
|
14
|
-
JSON.generate(@source['elements']),
|
15
|
-
object_class: OpenStruct
|
16
|
-
)
|
17
|
-
end
|
18
|
-
|
19
|
-
# Parses the 'system' JSON object as a dynamic OpenStruct object.
|
20
|
-
#
|
21
|
-
# * *Returns*:
|
22
|
-
# - +OpenStruct+ The system properties of the content type
|
23
|
-
def system
|
24
|
-
@system unless @system.nil?
|
25
|
-
@system = JSON.parse(
|
26
|
-
JSON.generate(@source['system']),
|
27
|
-
object_class: OpenStruct
|
28
|
-
)
|
29
|
-
end
|
30
|
-
|
31
|
-
# Constructor.
|
32
|
-
#
|
33
|
-
# * *Args*:
|
34
|
-
# - *source* (+JSON+) The response from a REST request for content types
|
35
|
-
def initialize(source)
|
36
|
-
@source = source
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
module Kentico
|
4
|
+
module Kontent
|
5
|
+
module Delivery
|
6
|
+
class ContentType
|
7
|
+
# Parses the 'elements' JSON object as a dynamic OpenStruct object.
|
8
|
+
#
|
9
|
+
# * *Returns*:
|
10
|
+
# - +OpenStruct+ The elements of the content type
|
11
|
+
def elements
|
12
|
+
@elements unless @elements.nil?
|
13
|
+
@elements = JSON.parse(
|
14
|
+
JSON.generate(@source['elements']),
|
15
|
+
object_class: OpenStruct
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Parses the 'system' JSON object as a dynamic OpenStruct object.
|
20
|
+
#
|
21
|
+
# * *Returns*:
|
22
|
+
# - +OpenStruct+ The system properties of the content type
|
23
|
+
def system
|
24
|
+
@system unless @system.nil?
|
25
|
+
@system = JSON.parse(
|
26
|
+
JSON.generate(@source['system']),
|
27
|
+
object_class: OpenStruct
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Constructor.
|
32
|
+
#
|
33
|
+
# * *Args*:
|
34
|
+
# - *source* (+JSON+) The response from a REST request for content types
|
35
|
+
def initialize(source)
|
36
|
+
@source = source
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -1,29 +1,29 @@
|
|
1
|
-
require 'ostruct'
|
2
|
-
|
3
|
-
module Kentico
|
4
|
-
module Kontent
|
5
|
-
module Delivery
|
6
|
-
class Language
|
7
|
-
# Parses the 'system' JSON object as a dynamic OpenStruct object.
|
8
|
-
#
|
9
|
-
# * *Returns*:
|
10
|
-
# - +OpenStruct+ The system properties of the language
|
11
|
-
def system
|
12
|
-
@system unless @system.nil?
|
13
|
-
@system = JSON.parse(
|
14
|
-
JSON.generate(@source['system']),
|
15
|
-
object_class: OpenStruct
|
16
|
-
)
|
17
|
-
end
|
18
|
-
|
19
|
-
# Constructor.
|
20
|
-
#
|
21
|
-
# * *Args*:
|
22
|
-
# - *source* (+JSON+) The response from a REST request for a language
|
23
|
-
def initialize(source)
|
24
|
-
@source = source
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
module Kentico
|
4
|
+
module Kontent
|
5
|
+
module Delivery
|
6
|
+
class Language
|
7
|
+
# Parses the 'system' JSON object as a dynamic OpenStruct object.
|
8
|
+
#
|
9
|
+
# * *Returns*:
|
10
|
+
# - +OpenStruct+ The system properties of the language
|
11
|
+
def system
|
12
|
+
@system unless @system.nil?
|
13
|
+
@system = JSON.parse(
|
14
|
+
JSON.generate(@source['system']),
|
15
|
+
object_class: OpenStruct
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Constructor.
|
20
|
+
#
|
21
|
+
# * *Args*:
|
22
|
+
# - *source* (+JSON+) The response from a REST request for a language
|
23
|
+
def initialize(source)
|
24
|
+
@source = source
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -1,22 +1,22 @@
|
|
1
|
-
module Kentico
|
2
|
-
module Kontent
|
3
|
-
module Delivery
|
4
|
-
# Holds pagination data from listing responses
|
5
|
-
class Pagination
|
6
|
-
attr_accessor :skip, :limit, :count, :next_page, :total_count
|
7
|
-
|
8
|
-
# Constructor.
|
9
|
-
#
|
10
|
-
# * *Args*:
|
11
|
-
# - *json* (+JSON+) The 'pagination' node of a listing reponse's JSON object
|
12
|
-
def initialize(json)
|
13
|
-
self.skip = json['skip']
|
14
|
-
self.limit = json['limit']
|
15
|
-
self.count = json['count']
|
16
|
-
self.next_page = json['next_page']
|
17
|
-
self.total_count = json['total_count']
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
1
|
+
module Kentico
|
2
|
+
module Kontent
|
3
|
+
module Delivery
|
4
|
+
# Holds pagination data from listing responses
|
5
|
+
class Pagination
|
6
|
+
attr_accessor :skip, :limit, :count, :next_page, :total_count
|
7
|
+
|
8
|
+
# Constructor.
|
9
|
+
#
|
10
|
+
# * *Args*:
|
11
|
+
# - *json* (+JSON+) The 'pagination' node of a listing reponse's JSON object
|
12
|
+
def initialize(json)
|
13
|
+
self.skip = json['skip']
|
14
|
+
self.limit = json['limit']
|
15
|
+
self.count = json['count']
|
16
|
+
self.next_page = json['next_page']
|
17
|
+
self.total_count = json['total_count']
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,39 +1,39 @@
|
|
1
|
-
module Kentico
|
2
|
-
module Kontent
|
3
|
-
module Delivery
|
4
|
-
class TaxonomyGroup
|
5
|
-
# Parses the 'terms' JSON node as a dynamic OpenStruct object.
|
6
|
-
#
|
7
|
-
# * *Returns*:
|
8
|
-
# - +OpenStruct+ The terms of the taxonomy group as a dynamic object
|
9
|
-
def terms
|
10
|
-
@terms unless @terms.nil?
|
11
|
-
@terms = JSON.parse(
|
12
|
-
JSON.generate(@source['terms']),
|
13
|
-
object_class: OpenStruct
|
14
|
-
)
|
15
|
-
end
|
16
|
-
|
17
|
-
# Parses the 'system' JSON node as a dynamic OpenStruct object.
|
18
|
-
#
|
19
|
-
# * *Returns*:
|
20
|
-
# - +OpenStruct+ The system properties of the taxonomy group
|
21
|
-
def system
|
22
|
-
@system unless @system.nil?
|
23
|
-
@system = JSON.parse(
|
24
|
-
JSON.generate(@source['system']),
|
25
|
-
object_class: OpenStruct
|
26
|
-
)
|
27
|
-
end
|
28
|
-
|
29
|
-
# Constructor.
|
30
|
-
#
|
31
|
-
# * *Args*:
|
32
|
-
# - *json* (+JSON+) A JSON node representing a taxonomy group
|
33
|
-
def initialize(source)
|
34
|
-
@source = source
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
1
|
+
module Kentico
|
2
|
+
module Kontent
|
3
|
+
module Delivery
|
4
|
+
class TaxonomyGroup
|
5
|
+
# Parses the 'terms' JSON node as a dynamic OpenStruct object.
|
6
|
+
#
|
7
|
+
# * *Returns*:
|
8
|
+
# - +OpenStruct+ The terms of the taxonomy group as a dynamic object
|
9
|
+
def terms
|
10
|
+
@terms unless @terms.nil?
|
11
|
+
@terms = JSON.parse(
|
12
|
+
JSON.generate(@source['terms']),
|
13
|
+
object_class: OpenStruct
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Parses the 'system' JSON node as a dynamic OpenStruct object.
|
18
|
+
#
|
19
|
+
# * *Returns*:
|
20
|
+
# - +OpenStruct+ The system properties of the taxonomy group
|
21
|
+
def system
|
22
|
+
@system unless @system.nil?
|
23
|
+
@system = JSON.parse(
|
24
|
+
JSON.generate(@source['system']),
|
25
|
+
object_class: OpenStruct
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Constructor.
|
30
|
+
#
|
31
|
+
# * *Args*:
|
32
|
+
# - *json* (+JSON+) A JSON node representing a taxonomy group
|
33
|
+
def initialize(source)
|
34
|
+
@source = source
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -1,201 +1,201 @@
|
|
1
|
-
require 'delivery/query_parameters/parameter_base'
|
2
|
-
|
3
|
-
module Kentico
|
4
|
-
module Kontent
|
5
|
-
module Delivery
|
6
|
-
module QueryParameters
|
7
|
-
# Provides the base class for filter implementations.
|
8
|
-
# See https://developer.kenticocloud.com/v1/reference#content-filtering
|
9
|
-
class Filter < ParameterBase
|
10
|
-
# Constructor.
|
11
|
-
#
|
12
|
-
# * *Args*:
|
13
|
-
# - *key* (+string+) The field to filter upon
|
14
|
-
# - *operator* (+string+) The Kentico Kontent filter being applied to the field, in brackets
|
15
|
-
# - *values* (+Object+) One or more values which will appear as the value of the query string parameter
|
16
|
-
# - *eq_sign* (+boolean+) If false, the equals sign is not generated in the parameter
|
17
|
-
def initialize(key, operator, values, eq_sign = true)
|
18
|
-
super(key, operator, values, eq_sign)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
# Extend String class to allow semantic typing of filters
|
27
|
-
class String
|
28
|
-
# Represents a filter that matches a content item if the specified content
|
29
|
-
# element or system attribute has a value that contains all the specified
|
30
|
-
# values. This filter is applicable to array values only, such as sitemap
|
31
|
-
# location or value of Linked Items, Taxonomy and Multiple choice content elements.
|
32
|
-
#
|
33
|
-
# * *Args*:
|
34
|
-
# - +Object+ One or more objects representing the values that must appear in the field
|
35
|
-
#
|
36
|
-
# * *Returns*:
|
37
|
-
# - Kentico::Kontent::Delivery::QueryParameters::Filter
|
38
|
-
def all(*args)
|
39
|
-
Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[all]', *args)
|
40
|
-
end
|
41
|
-
|
42
|
-
# Represents a filter that matches a content item if the specified content
|
43
|
-
# element or system attribute has a value that contains any the specified
|
44
|
-
# values. This filter is applicable to array values only, such as sitemap
|
45
|
-
# location or value of Linked Items, Taxonomy and Multiple choice content elements.
|
46
|
-
#
|
47
|
-
# * *Args*:
|
48
|
-
# - +Object+ One or more objects representing the values that may appear in the field
|
49
|
-
#
|
50
|
-
# * *Returns*:
|
51
|
-
# - Kentico::Kontent::Delivery::QueryParameters::Filter
|
52
|
-
def any(*args)
|
53
|
-
Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[any]', *args)
|
54
|
-
end
|
55
|
-
|
56
|
-
# Represents a filter that matches a content item if the specified content element
|
57
|
-
# or system attribute has a value that contains the specified value.
|
58
|
-
# This filter is applicable to array values only, such as sitemap location or value
|
59
|
-
# of Linked Items, Taxonomy and Multiple choice content elements.
|
60
|
-
#
|
61
|
-
# * *Args*:
|
62
|
-
# - +Object+ An object representing the value that must appear in the field
|
63
|
-
#
|
64
|
-
# * *Returns*:
|
65
|
-
# - Kentico::Kontent::Delivery::QueryParameters::Filter
|
66
|
-
def contains(*args)
|
67
|
-
Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[contains]', *args)
|
68
|
-
end
|
69
|
-
|
70
|
-
# Represents a filter that matches a content item if the specified
|
71
|
-
# content element or system attribute has the specified value.
|
72
|
-
#
|
73
|
-
# * *Args*:
|
74
|
-
# - +Object+ An object representing the value that must equal the value in the field
|
75
|
-
#
|
76
|
-
# * *Returns*:
|
77
|
-
# - Kentico::Kontent::Delivery::QueryParameters::Filter
|
78
|
-
def eq(*args)
|
79
|
-
Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '', *args)
|
80
|
-
end
|
81
|
-
|
82
|
-
# Represents a filter that matches a content item if the specified
|
83
|
-
# content element or system attribute does not have the specified value.
|
84
|
-
#
|
85
|
-
# * *Args*:
|
86
|
-
# - +Object+ An object representing the value that cannot exist in the element
|
87
|
-
#
|
88
|
-
# * *Returns*:
|
89
|
-
# - Kentico::Kontent::Delivery::QueryParameters::Filter
|
90
|
-
def not_eq(*args)
|
91
|
-
Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[neq]', *args)
|
92
|
-
end
|
93
|
-
|
94
|
-
# Represents a filter that matches a content item if the specified
|
95
|
-
# content element or system attribute does not have any value.
|
96
|
-
#
|
97
|
-
# * *Returns*:
|
98
|
-
# - Kentico::Kontent::Delivery::QueryParameters::Filter
|
99
|
-
def empty
|
100
|
-
Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[empty]', nil, false)
|
101
|
-
end
|
102
|
-
|
103
|
-
# Represents a filter that matches a content item if the specified
|
104
|
-
# content element or system attribute has any value.
|
105
|
-
#
|
106
|
-
# * *Returns*:
|
107
|
-
# - Kentico::Kontent::Delivery::QueryParameters::Filter
|
108
|
-
def not_empty
|
109
|
-
Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[nempty]', nil, false)
|
110
|
-
end
|
111
|
-
|
112
|
-
# Represents a filter that matches a content item if the specified
|
113
|
-
# content element or system attribute does not have the specified value.
|
114
|
-
#
|
115
|
-
# * *Args*:
|
116
|
-
# - +Object+ An object representing the value that cannot exist in the element
|
117
|
-
#
|
118
|
-
# * *Returns*:
|
119
|
-
# - Kentico::Kontent::Delivery::QueryParameters::Filter
|
120
|
-
def not_in(*args)
|
121
|
-
Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[nin]', *args)
|
122
|
-
end
|
123
|
-
|
124
|
-
# Represents a filter that matches a content item if the specified content
|
125
|
-
# element or system attribute has a value that is greater than the
|
126
|
-
# specified value.
|
127
|
-
#
|
128
|
-
# * *Args*:
|
129
|
-
# - +Object+ An object representing the lowest possible value of the field, non-inclusive
|
130
|
-
#
|
131
|
-
# * *Returns*:
|
132
|
-
# - Kentico::Kontent::Delivery::QueryParameters::Filter
|
133
|
-
def gt(*args)
|
134
|
-
Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[gt]', *args)
|
135
|
-
end
|
136
|
-
|
137
|
-
# Represents a filter that matches a content item if the specified content
|
138
|
-
# element or system attribute has a value that is greater than or equal to
|
139
|
-
# the specified value.
|
140
|
-
#
|
141
|
-
# * *Args*:
|
142
|
-
# - +Object+ An object representing the lowest possible value of the field
|
143
|
-
#
|
144
|
-
# * *Returns*:
|
145
|
-
# - Kentico::Kontent::Delivery::QueryParameters::Filter
|
146
|
-
def gt_or_eq(*args)
|
147
|
-
Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[gte]', *args)
|
148
|
-
end
|
149
|
-
|
150
|
-
# Represents a filter that matches a content item if the specified
|
151
|
-
# content element or system attribute has a value that matches a
|
152
|
-
# value in the specified list.
|
153
|
-
#
|
154
|
-
# * *Args*:
|
155
|
-
# - +Object+ One or more objects representing the required values of the field
|
156
|
-
#
|
157
|
-
# * *Returns*:
|
158
|
-
# - Kentico::Kontent::Delivery::QueryParameters::Filter
|
159
|
-
def in(*args)
|
160
|
-
Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[in]', *args)
|
161
|
-
end
|
162
|
-
|
163
|
-
# Represents a filter that matches a content item if the specified content
|
164
|
-
# element or system attribute has a value that is less than the
|
165
|
-
# specified value.
|
166
|
-
#
|
167
|
-
# * *Args*:
|
168
|
-
# - +Object+ An object representing the highest possible value of the field, non-inclusive
|
169
|
-
#
|
170
|
-
# * *Returns*:
|
171
|
-
# - Kentico::Kontent::Delivery::QueryParameters::Filter
|
172
|
-
def lt(*args)
|
173
|
-
Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[lt]', *args)
|
174
|
-
end
|
175
|
-
|
176
|
-
# Represents a filter that matches a content item if the specified content
|
177
|
-
# element or system attribute has a value that is less than or equal to
|
178
|
-
# the specified value.
|
179
|
-
#
|
180
|
-
# * *Args*:
|
181
|
-
# - +Object+ An object representing the highest possible value of the field
|
182
|
-
#
|
183
|
-
# * *Returns*:
|
184
|
-
# - Kentico::Kontent::Delivery::QueryParameters::Filter
|
185
|
-
def lt_or_eq(*args)
|
186
|
-
Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[lte]', *args)
|
187
|
-
end
|
188
|
-
|
189
|
-
# Represents a filter that matches a content item if the specified
|
190
|
-
# content element or system attribute has a value that falls within
|
191
|
-
# the specified range of values (both inclusive).
|
192
|
-
#
|
193
|
-
# * *Args*:
|
194
|
-
# - +Object+ An object representing the lowest and highest possible values of the field
|
195
|
-
#
|
196
|
-
# * *Returns*:
|
197
|
-
# - Kentico::Kontent::Delivery::QueryParameters::Filter
|
198
|
-
def range(*args)
|
199
|
-
Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[range]', *args)
|
200
|
-
end
|
201
|
-
end
|
1
|
+
require 'delivery/query_parameters/parameter_base'
|
2
|
+
|
3
|
+
module Kentico
|
4
|
+
module Kontent
|
5
|
+
module Delivery
|
6
|
+
module QueryParameters
|
7
|
+
# Provides the base class for filter implementations.
|
8
|
+
# See https://developer.kenticocloud.com/v1/reference#content-filtering
|
9
|
+
class Filter < ParameterBase
|
10
|
+
# Constructor.
|
11
|
+
#
|
12
|
+
# * *Args*:
|
13
|
+
# - *key* (+string+) The field to filter upon
|
14
|
+
# - *operator* (+string+) The Kentico Kontent filter being applied to the field, in brackets
|
15
|
+
# - *values* (+Object+) One or more values which will appear as the value of the query string parameter
|
16
|
+
# - *eq_sign* (+boolean+) If false, the equals sign is not generated in the parameter
|
17
|
+
def initialize(key, operator, values, eq_sign = true)
|
18
|
+
super(key, operator, values, eq_sign)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Extend String class to allow semantic typing of filters
|
27
|
+
class String
|
28
|
+
# Represents a filter that matches a content item if the specified content
|
29
|
+
# element or system attribute has a value that contains all the specified
|
30
|
+
# values. This filter is applicable to array values only, such as sitemap
|
31
|
+
# location or value of Linked Items, Taxonomy and Multiple choice content elements.
|
32
|
+
#
|
33
|
+
# * *Args*:
|
34
|
+
# - +Object+ One or more objects representing the values that must appear in the field
|
35
|
+
#
|
36
|
+
# * *Returns*:
|
37
|
+
# - Kentico::Kontent::Delivery::QueryParameters::Filter
|
38
|
+
def all(*args)
|
39
|
+
Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[all]', *args)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Represents a filter that matches a content item if the specified content
|
43
|
+
# element or system attribute has a value that contains any the specified
|
44
|
+
# values. This filter is applicable to array values only, such as sitemap
|
45
|
+
# location or value of Linked Items, Taxonomy and Multiple choice content elements.
|
46
|
+
#
|
47
|
+
# * *Args*:
|
48
|
+
# - +Object+ One or more objects representing the values that may appear in the field
|
49
|
+
#
|
50
|
+
# * *Returns*:
|
51
|
+
# - Kentico::Kontent::Delivery::QueryParameters::Filter
|
52
|
+
def any(*args)
|
53
|
+
Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[any]', *args)
|
54
|
+
end
|
55
|
+
|
56
|
+
# Represents a filter that matches a content item if the specified content element
|
57
|
+
# or system attribute has a value that contains the specified value.
|
58
|
+
# This filter is applicable to array values only, such as sitemap location or value
|
59
|
+
# of Linked Items, Taxonomy and Multiple choice content elements.
|
60
|
+
#
|
61
|
+
# * *Args*:
|
62
|
+
# - +Object+ An object representing the value that must appear in the field
|
63
|
+
#
|
64
|
+
# * *Returns*:
|
65
|
+
# - Kentico::Kontent::Delivery::QueryParameters::Filter
|
66
|
+
def contains(*args)
|
67
|
+
Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[contains]', *args)
|
68
|
+
end
|
69
|
+
|
70
|
+
# Represents a filter that matches a content item if the specified
|
71
|
+
# content element or system attribute has the specified value.
|
72
|
+
#
|
73
|
+
# * *Args*:
|
74
|
+
# - +Object+ An object representing the value that must equal the value in the field
|
75
|
+
#
|
76
|
+
# * *Returns*:
|
77
|
+
# - Kentico::Kontent::Delivery::QueryParameters::Filter
|
78
|
+
def eq(*args)
|
79
|
+
Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '', *args)
|
80
|
+
end
|
81
|
+
|
82
|
+
# Represents a filter that matches a content item if the specified
|
83
|
+
# content element or system attribute does not have the specified value.
|
84
|
+
#
|
85
|
+
# * *Args*:
|
86
|
+
# - +Object+ An object representing the value that cannot exist in the element
|
87
|
+
#
|
88
|
+
# * *Returns*:
|
89
|
+
# - Kentico::Kontent::Delivery::QueryParameters::Filter
|
90
|
+
def not_eq(*args)
|
91
|
+
Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[neq]', *args)
|
92
|
+
end
|
93
|
+
|
94
|
+
# Represents a filter that matches a content item if the specified
|
95
|
+
# content element or system attribute does not have any value.
|
96
|
+
#
|
97
|
+
# * *Returns*:
|
98
|
+
# - Kentico::Kontent::Delivery::QueryParameters::Filter
|
99
|
+
def empty
|
100
|
+
Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[empty]', nil, false)
|
101
|
+
end
|
102
|
+
|
103
|
+
# Represents a filter that matches a content item if the specified
|
104
|
+
# content element or system attribute has any value.
|
105
|
+
#
|
106
|
+
# * *Returns*:
|
107
|
+
# - Kentico::Kontent::Delivery::QueryParameters::Filter
|
108
|
+
def not_empty
|
109
|
+
Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[nempty]', nil, false)
|
110
|
+
end
|
111
|
+
|
112
|
+
# Represents a filter that matches a content item if the specified
|
113
|
+
# content element or system attribute does not have the specified value.
|
114
|
+
#
|
115
|
+
# * *Args*:
|
116
|
+
# - +Object+ An object representing the value that cannot exist in the element
|
117
|
+
#
|
118
|
+
# * *Returns*:
|
119
|
+
# - Kentico::Kontent::Delivery::QueryParameters::Filter
|
120
|
+
def not_in(*args)
|
121
|
+
Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[nin]', *args)
|
122
|
+
end
|
123
|
+
|
124
|
+
# Represents a filter that matches a content item if the specified content
|
125
|
+
# element or system attribute has a value that is greater than the
|
126
|
+
# specified value.
|
127
|
+
#
|
128
|
+
# * *Args*:
|
129
|
+
# - +Object+ An object representing the lowest possible value of the field, non-inclusive
|
130
|
+
#
|
131
|
+
# * *Returns*:
|
132
|
+
# - Kentico::Kontent::Delivery::QueryParameters::Filter
|
133
|
+
def gt(*args)
|
134
|
+
Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[gt]', *args)
|
135
|
+
end
|
136
|
+
|
137
|
+
# Represents a filter that matches a content item if the specified content
|
138
|
+
# element or system attribute has a value that is greater than or equal to
|
139
|
+
# the specified value.
|
140
|
+
#
|
141
|
+
# * *Args*:
|
142
|
+
# - +Object+ An object representing the lowest possible value of the field
|
143
|
+
#
|
144
|
+
# * *Returns*:
|
145
|
+
# - Kentico::Kontent::Delivery::QueryParameters::Filter
|
146
|
+
def gt_or_eq(*args)
|
147
|
+
Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[gte]', *args)
|
148
|
+
end
|
149
|
+
|
150
|
+
# Represents a filter that matches a content item if the specified
|
151
|
+
# content element or system attribute has a value that matches a
|
152
|
+
# value in the specified list.
|
153
|
+
#
|
154
|
+
# * *Args*:
|
155
|
+
# - +Object+ One or more objects representing the required values of the field
|
156
|
+
#
|
157
|
+
# * *Returns*:
|
158
|
+
# - Kentico::Kontent::Delivery::QueryParameters::Filter
|
159
|
+
def in(*args)
|
160
|
+
Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[in]', *args)
|
161
|
+
end
|
162
|
+
|
163
|
+
# Represents a filter that matches a content item if the specified content
|
164
|
+
# element or system attribute has a value that is less than the
|
165
|
+
# specified value.
|
166
|
+
#
|
167
|
+
# * *Args*:
|
168
|
+
# - +Object+ An object representing the highest possible value of the field, non-inclusive
|
169
|
+
#
|
170
|
+
# * *Returns*:
|
171
|
+
# - Kentico::Kontent::Delivery::QueryParameters::Filter
|
172
|
+
def lt(*args)
|
173
|
+
Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[lt]', *args)
|
174
|
+
end
|
175
|
+
|
176
|
+
# Represents a filter that matches a content item if the specified content
|
177
|
+
# element or system attribute has a value that is less than or equal to
|
178
|
+
# the specified value.
|
179
|
+
#
|
180
|
+
# * *Args*:
|
181
|
+
# - +Object+ An object representing the highest possible value of the field
|
182
|
+
#
|
183
|
+
# * *Returns*:
|
184
|
+
# - Kentico::Kontent::Delivery::QueryParameters::Filter
|
185
|
+
def lt_or_eq(*args)
|
186
|
+
Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[lte]', *args)
|
187
|
+
end
|
188
|
+
|
189
|
+
# Represents a filter that matches a content item if the specified
|
190
|
+
# content element or system attribute has a value that falls within
|
191
|
+
# the specified range of values (both inclusive).
|
192
|
+
#
|
193
|
+
# * *Args*:
|
194
|
+
# - +Object+ An object representing the lowest and highest possible values of the field
|
195
|
+
#
|
196
|
+
# * *Returns*:
|
197
|
+
# - Kentico::Kontent::Delivery::QueryParameters::Filter
|
198
|
+
def range(*args)
|
199
|
+
Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[range]', *args)
|
200
|
+
end
|
201
|
+
end
|