kontent-delivery-sdk-ruby 2.0.12 → 2.0.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.md +21 -21
  3. data/README.md +575 -543
  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 -117
  8. data/lib/delivery/client/delivery_client.rb +176 -155
  9. data/lib/delivery/client/delivery_query.rb +302 -286
  10. data/lib/delivery/client/request_manager.rb +125 -121
  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 +158 -158
  16. data/lib/delivery/query_parameters/parameter_base.rb +46 -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 -0
  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 +110 -84
  33. data/lib/delivery/tests/filtering/items_gt.json +565 -565
  34. data/lib/delivery/tests/filtering/items_with_count.json +4985 -4985
  35. data/lib/delivery/tests/filtering/multiple.json +282 -282
  36. data/lib/delivery/tests/filtering/pagination_about_us.json +646 -646
  37. data/lib/delivery/tests/generic/items.json +4984 -4984
  38. data/lib/delivery/tests/generic/items/about_us.json +227 -227
  39. data/lib/delivery/tests/generic/items/aeropress_filters.json +138 -138
  40. data/lib/delivery/tests/generic/items/coffee_processing_techniques.json +168 -168
  41. data/lib/delivery/tests/generic/items/empty_rich_text.json +24 -0
  42. data/lib/delivery/tests/generic/items/rich_text_complex_tables.json +81 -0
  43. data/lib/delivery/tests/generic/items/where_does_coffee_come_from_.json +620 -620
  44. data/lib/delivery/tests/generic/taxonomies.json +126 -126
  45. data/lib/delivery/tests/generic/types.json +780 -780
  46. data/lib/delivery/tests/generic/types/brewer/elements/product_status.json +5 -5
  47. data/lib/delivery/tests/items_feed/articles_feed_1.json +39 -0
  48. data/lib/delivery/tests/items_feed/articles_feed_2.json +78 -0
  49. data/lib/delivery/tests/items_feed/articles_feed_3.json +104 -0
  50. data/lib/delivery/version.rb +7 -7
  51. data/lib/kontent-delivery-sdk-ruby.rb +20 -19
  52. metadata +40 -15
@@ -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,158 @@
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
+ 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