kontent-delivery-sdk-ruby 2.0.19 → 2.0.20

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 (50) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.md +21 -21
  3. data/README.md +583 -575
  4. data/bin/console +14 -14
  5. data/bin/setup +8 -8
  6. data/lib/delivery/builders/image_transformation_builder.rb +271 -271
  7. data/lib/delivery/builders/url_builder.rb +120 -120
  8. data/lib/delivery/client/delivery_client.rb +176 -176
  9. data/lib/delivery/client/delivery_query.rb +302 -302
  10. data/lib/delivery/client/request_manager.rb +125 -125
  11. data/lib/delivery/models/content_item.rb +153 -153
  12. data/lib/delivery/models/content_type.rb +41 -41
  13. data/lib/delivery/models/pagination.rb +22 -22
  14. data/lib/delivery/models/taxonomy_group.rb +39 -39
  15. data/lib/delivery/query_parameters/filters.rb +201 -158
  16. data/lib/delivery/query_parameters/parameter_base.rb +56 -46
  17. data/lib/delivery/query_parameters/query_string.rb +78 -78
  18. data/lib/delivery/resolvers/content_link_resolver.rb +102 -102
  19. data/lib/delivery/resolvers/inline_content_item_resolver.rb +75 -75
  20. data/lib/delivery/resolvers/linked_item_resolver.rb +37 -37
  21. data/lib/delivery/responses/delivery_element_response.rb +34 -34
  22. data/lib/delivery/responses/delivery_item_listing_response.rb +54 -54
  23. data/lib/delivery/responses/delivery_item_response.rb +40 -40
  24. data/lib/delivery/responses/delivery_items_feed_response.rb +58 -58
  25. data/lib/delivery/responses/delivery_taxonomy_listing_response.rb +47 -47
  26. data/lib/delivery/responses/delivery_taxonomy_response.rb +33 -33
  27. data/lib/delivery/responses/delivery_type_listing_response.rb +46 -46
  28. data/lib/delivery/responses/delivery_type_response.rb +32 -32
  29. data/lib/delivery/responses/response_base.rb +39 -39
  30. data/lib/delivery/tests/401.json +5 -5
  31. data/lib/delivery/tests/429.json +4 -4
  32. data/lib/delivery/tests/fake_responder.rb +105 -110
  33. data/lib/delivery/tests/filtering/items_with_count.json +5385 -4986
  34. data/lib/delivery/tests/filtering/{pagination_about_us.json → pagination.json} +761 -646
  35. data/lib/delivery/tests/generic/items.json +5383 -4984
  36. data/lib/delivery/tests/generic/items/about_us.json +276 -227
  37. data/lib/delivery/tests/generic/items/aeropress_filters.json +155 -138
  38. data/lib/delivery/tests/generic/items/coffee_processing_techniques.json +565 -168
  39. data/lib/delivery/tests/generic/items/where_does_coffee_come_from_.json +517 -621
  40. data/lib/delivery/tests/generic/taxonomies.json +203 -126
  41. data/lib/delivery/tests/generic/types.json +836 -781
  42. data/lib/delivery/tests/generic/types/brewer/elements/product_status.json +5 -5
  43. data/lib/delivery/tests/items_feed/articles_feed_1.json +39 -39
  44. data/lib/delivery/tests/items_feed/articles_feed_2.json +78 -78
  45. data/lib/delivery/tests/items_feed/articles_feed_3.json +104 -104
  46. data/lib/kontent-delivery-sdk-ruby.rb +20 -20
  47. metadata +20 -24
  48. data/lib/delivery/tests/filtering/items_gt.json +0 -566
  49. data/lib/delivery/tests/filtering/multiple.json +0 -283
  50. data/lib/delivery/version.rb +0 -7
@@ -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,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,158 +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
- def initialize(key, operator, values)
17
- super(key, operator, values)
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end
24
-
25
- # Extend String class to allow semantic typing of filters
26
- class String
27
- # Represents a filter that matches a content item if the specified content
28
- # element or system attribute has a value that contains all the specified
29
- # values. This filter is applicable to array values only, such as sitemap
30
- # location or value of Linked Items, Taxonomy and Multiple choice content elements.
31
- #
32
- # * *Args*:
33
- # - +Object+ One or more objects representing the values that must appear in the field
34
- #
35
- # * *Returns*:
36
- # - Kentico::Kontent::Delivery::QueryParameters::Filter
37
- def all(*args)
38
- Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[all]', *args)
39
- end
40
-
41
- # Represents a filter that matches a content item if the specified content
42
- # element or system attribute has a value that contains any the specified
43
- # values. This filter is applicable to array values only, such as sitemap
44
- # location or value of Linked Items, Taxonomy and Multiple choice content elements.
45
- #
46
- # * *Args*:
47
- # - +Object+ One or more objects representing the values that may appear in the field
48
- #
49
- # * *Returns*:
50
- # - Kentico::Kontent::Delivery::QueryParameters::Filter
51
- def any(*args)
52
- Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[any]', *args)
53
- end
54
-
55
- # Represents a filter that matches a content item if the specified content element
56
- # or system attribute has a value that contains the specified value.
57
- # This filter is applicable to array values only, such as sitemap location or value
58
- # of Linked Items, Taxonomy and Multiple choice content elements.
59
- #
60
- # * *Args*:
61
- # - +Object+ An object representing the value that must appear in the field
62
- #
63
- # * *Returns*:
64
- # - Kentico::Kontent::Delivery::QueryParameters::Filter
65
- def contains(*args)
66
- Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[contains]', *args)
67
- end
68
-
69
- # Represents a filter that matches a content item if the specified
70
- # content element or system attribute has the specified value.
71
- #
72
- # * *Args*:
73
- # - +Object+ An object representing the value that must equal the value in the field
74
- #
75
- # * *Returns*:
76
- # - Kentico::Kontent::Delivery::QueryParameters::Filter
77
- def eq(*args)
78
- Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '', *args)
79
- end
80
-
81
- # Represents a filter that matches a content item if the specified content
82
- # element or system attribute has a value that is greater than the
83
- # specified value.
84
- #
85
- # * *Args*:
86
- # - +Object+ An object representing the lowest possible value of the field, non-inclusive
87
- #
88
- # * *Returns*:
89
- # - Kentico::Kontent::Delivery::QueryParameters::Filter
90
- def gt(*args)
91
- Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[gt]', *args)
92
- end
93
-
94
- # Represents a filter that matches a content item if the specified content
95
- # element or system attribute has a value that is greater than or equal to
96
- # the specified value.
97
- #
98
- # * *Args*:
99
- # - +Object+ An object representing the lowest possible value of the field
100
- #
101
- # * *Returns*:
102
- # - Kentico::Kontent::Delivery::QueryParameters::Filter
103
- def gt_or_eq(*args)
104
- Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[gte]', *args)
105
- end
106
-
107
- # Represents a filter that matches a content item if the specified
108
- # content element or system attribute has a value that matches a
109
- # value in the specified list.
110
- #
111
- # * *Args*:
112
- # - +Object+ One or more objects representing the required values of the field
113
- #
114
- # * *Returns*:
115
- # - Kentico::Kontent::Delivery::QueryParameters::Filter
116
- def in(*args)
117
- Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[in]', *args)
118
- end
119
-
120
- # Represents a filter that matches a content item if the specified content
121
- # element or system attribute has a value that is less than the
122
- # specified value.
123
- #
124
- # * *Args*:
125
- # - +Object+ An object representing the highest possible value of the field, non-inclusive
126
- #
127
- # * *Returns*:
128
- # - Kentico::Kontent::Delivery::QueryParameters::Filter
129
- def lt(*args)
130
- Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[lt]', *args)
131
- end
132
-
133
- # Represents a filter that matches a content item if the specified content
134
- # element or system attribute has a value that is less than or equal to
135
- # the specified value.
136
- #
137
- # * *Args*:
138
- # - +Object+ An object representing the highest possible value of the field
139
- #
140
- # * *Returns*:
141
- # - Kentico::Kontent::Delivery::QueryParameters::Filter
142
- def lt_or_eq(*args)
143
- Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[lte]', *args)
144
- end
145
-
146
- # Represents a filter that matches a content item if the specified
147
- # content element or system attribute has a value that falls within
148
- # the specified range of values (both inclusive).
149
- #
150
- # * *Args*:
151
- # - +Object+ An object representing the lowest and highest possible values of the field
152
- #
153
- # * *Returns*:
154
- # - Kentico::Kontent::Delivery::QueryParameters::Filter
155
- def range(*args)
156
- Kentico::Kontent::Delivery::QueryParameters::Filter.new(self, '[range]', *args)
157
- end
158
- 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