kontent-delivery-sdk-ruby 2.0.19 → 2.0.20

Sign up to get free protection for your applications and to get access to all the features.
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,58 +1,58 @@
1
- require 'delivery/models/content_item'
2
- require 'delivery/models/pagination'
3
- require 'delivery/responses/response_base'
4
-
5
- module Kentico
6
- module Kontent
7
- module Delivery
8
- module Responses
9
- # The response of a successful query for content items.
10
- class DeliveryItemsFeedResponse < ResponseBase
11
- # A collection of Kentico::Kontent::Delivery::ContentItem objects from
12
- # a Kentico::Kontent::Delivery::DeliveryClient.items_feed call.
13
- #
14
- # * *Returns*:
15
- # - +Array+ One or more Kentico::Kontent::Delivery::ContentItem objects
16
- def items
17
- @items unless @items.nil?
18
- linked_items_resolver = Kentico::Kontent::Delivery::Resolvers::LinkedItemResolver.new @response['modular_content'], @content_link_url_resolver, @inline_content_item_resolver
19
- items = []
20
- @response['items'].each do |n|
21
- items << Kentico::Kontent::Delivery::ContentItem.new(
22
- n,
23
- @content_link_url_resolver,
24
- @inline_content_item_resolver,
25
- linked_items_resolver
26
- )
27
- end
28
- @items = items
29
- end
30
-
31
- def initialize(headers, body, query)
32
- @query = query
33
- @response = JSON.parse(body)
34
- @content_link_url_resolver = query.content_link_url_resolver
35
- @inline_content_item_resolver = query.inline_content_item_resolver
36
- super 200,
37
- "Success, #{items.length} items returned",
38
- headers,
39
- JSON.generate(@response)
40
- end
41
-
42
- def next_result
43
- @query.update_continuation continuation_token
44
- @query.execute
45
- end
46
-
47
- def more_results?
48
- !continuation_token.nil?
49
- end
50
-
51
- def continuation_token
52
- headers[Kentico::Kontent::Delivery::DeliveryQuery::HEADER_CONTINUATION]
53
- end
54
- end
55
- end
56
- end
57
- end
58
- end
1
+ require 'delivery/models/content_item'
2
+ require 'delivery/models/pagination'
3
+ require 'delivery/responses/response_base'
4
+
5
+ module Kentico
6
+ module Kontent
7
+ module Delivery
8
+ module Responses
9
+ # The response of a successful query for content items.
10
+ class DeliveryItemsFeedResponse < ResponseBase
11
+ # A collection of Kentico::Kontent::Delivery::ContentItem objects from
12
+ # a Kentico::Kontent::Delivery::DeliveryClient.items_feed call.
13
+ #
14
+ # * *Returns*:
15
+ # - +Array+ One or more Kentico::Kontent::Delivery::ContentItem objects
16
+ def items
17
+ @items unless @items.nil?
18
+ linked_items_resolver = Kentico::Kontent::Delivery::Resolvers::LinkedItemResolver.new @response['modular_content'], @content_link_url_resolver, @inline_content_item_resolver
19
+ items = []
20
+ @response['items'].each do |n|
21
+ items << Kentico::Kontent::Delivery::ContentItem.new(
22
+ n,
23
+ @content_link_url_resolver,
24
+ @inline_content_item_resolver,
25
+ linked_items_resolver
26
+ )
27
+ end
28
+ @items = items
29
+ end
30
+
31
+ def initialize(headers, body, query)
32
+ @query = query
33
+ @response = JSON.parse(body)
34
+ @content_link_url_resolver = query.content_link_url_resolver
35
+ @inline_content_item_resolver = query.inline_content_item_resolver
36
+ super 200,
37
+ "Success, #{items.length} items returned",
38
+ headers,
39
+ JSON.generate(@response)
40
+ end
41
+
42
+ def next_result
43
+ @query.update_continuation continuation_token
44
+ @query.execute
45
+ end
46
+
47
+ def more_results?
48
+ !continuation_token.nil?
49
+ end
50
+
51
+ def continuation_token
52
+ headers[Kentico::Kontent::Delivery::DeliveryQuery::HEADER_CONTINUATION]
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -1,47 +1,47 @@
1
- require 'delivery/models/taxonomy_group'
2
- require 'delivery/models/pagination'
3
- require 'delivery/responses/response_base'
4
-
5
- module Kentico
6
- module Kontent
7
- module Delivery
8
- module Responses
9
- # The response of a successful query for taxonomy groups.
10
- # See https://github.com/Kentico/kontent-delivery-sdk-ruby#taxonomy
11
- class DeliveryTaxonomyListingResponse < ResponseBase
12
- # Parses the 'pagination' JSON node of the response.
13
- #
14
- # * *Returns*:
15
- # - Kentico::Kontent::Delivery::Pagination
16
- def pagination
17
- @pagination unless @pagination.nil?
18
- @pagination = Pagination.new @response['pagination']
19
- end
20
-
21
- # Parses the 'taxonomies' JSON node of the response from a
22
- # Kentico::Kontent::Delivery::DeliveryClient.taxonomies call.
23
- #
24
- # * *Returns*:
25
- # - +Array+ The taxonomy groups as Kentico::Kontent::Delivery::TaxonomyGroup objects
26
- def taxonomies
27
- @taxonomies unless @taxonomies.nil?
28
- taxonomies = []
29
- @response['taxonomies'].each do |n|
30
- taxonomies << Kentico::Kontent::Delivery::TaxonomyGroup.new(n)
31
- end
32
- @taxonomies = taxonomies
33
- end
34
-
35
- def initialize(headers, body)
36
- @response = JSON.parse(body)
37
-
38
- super 200,
39
- "Success, #{taxonomies.length} taxonomies returned",
40
- headers,
41
- JSON.generate(@response)
42
- end
43
- end
44
- end
45
- end
46
- end
47
- end
1
+ require 'delivery/models/taxonomy_group'
2
+ require 'delivery/models/pagination'
3
+ require 'delivery/responses/response_base'
4
+
5
+ module Kentico
6
+ module Kontent
7
+ module Delivery
8
+ module Responses
9
+ # The response of a successful query for taxonomy groups.
10
+ # See https://github.com/Kentico/kontent-delivery-sdk-ruby#taxonomy
11
+ class DeliveryTaxonomyListingResponse < ResponseBase
12
+ # Parses the 'pagination' JSON node of the response.
13
+ #
14
+ # * *Returns*:
15
+ # - Kentico::Kontent::Delivery::Pagination
16
+ def pagination
17
+ @pagination unless @pagination.nil?
18
+ @pagination = Pagination.new @response['pagination']
19
+ end
20
+
21
+ # Parses the 'taxonomies' JSON node of the response from a
22
+ # Kentico::Kontent::Delivery::DeliveryClient.taxonomies call.
23
+ #
24
+ # * *Returns*:
25
+ # - +Array+ The taxonomy groups as Kentico::Kontent::Delivery::TaxonomyGroup objects
26
+ def taxonomies
27
+ @taxonomies unless @taxonomies.nil?
28
+ taxonomies = []
29
+ @response['taxonomies'].each do |n|
30
+ taxonomies << Kentico::Kontent::Delivery::TaxonomyGroup.new(n)
31
+ end
32
+ @taxonomies = taxonomies
33
+ end
34
+
35
+ def initialize(headers, body)
36
+ @response = JSON.parse(body)
37
+
38
+ super 200,
39
+ "Success, #{taxonomies.length} taxonomies returned",
40
+ headers,
41
+ JSON.generate(@response)
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -1,33 +1,33 @@
1
- require 'delivery/models/taxonomy_group'
2
- require 'delivery/responses/response_base'
3
-
4
- module Kentico
5
- module Kontent
6
- module Delivery
7
- module Responses
8
- # The response of a successful query for a taxonomy group.
9
- # See https://github.com/Kentico/kontent-delivery-sdk-ruby#taxonomy
10
- class DeliveryTaxonomyResponse < ResponseBase
11
- # Parses the response from a
12
- # Kentico::Kontent::Delivery::DeliveryClient.taxonomy call.
13
- #
14
- # * *Returns*:
15
- # - Kentico::Kontent::Delivery::TaxonomyGroup
16
- def taxonomy
17
- @taxonomy unless @taxonomy.nil?
18
- @taxonomy = Kentico::Kontent::Delivery::TaxonomyGroup.new(@response)
19
- end
20
-
21
- def initialize(headers, body)
22
- @response = JSON.parse(body)
23
-
24
- super 200,
25
- "Success, '#{taxonomy.system.codename}' returned",
26
- headers,
27
- JSON.generate(@response)
28
- end
29
- end
30
- end
31
- end
32
- end
33
- end
1
+ require 'delivery/models/taxonomy_group'
2
+ require 'delivery/responses/response_base'
3
+
4
+ module Kentico
5
+ module Kontent
6
+ module Delivery
7
+ module Responses
8
+ # The response of a successful query for a taxonomy group.
9
+ # See https://github.com/Kentico/kontent-delivery-sdk-ruby#taxonomy
10
+ class DeliveryTaxonomyResponse < ResponseBase
11
+ # Parses the response from a
12
+ # Kentico::Kontent::Delivery::DeliveryClient.taxonomy call.
13
+ #
14
+ # * *Returns*:
15
+ # - Kentico::Kontent::Delivery::TaxonomyGroup
16
+ def taxonomy
17
+ @taxonomy unless @taxonomy.nil?
18
+ @taxonomy = Kentico::Kontent::Delivery::TaxonomyGroup.new(@response)
19
+ end
20
+
21
+ def initialize(headers, body)
22
+ @response = JSON.parse(body)
23
+
24
+ super 200,
25
+ "Success, '#{taxonomy.system.codename}' returned",
26
+ headers,
27
+ JSON.generate(@response)
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,46 +1,46 @@
1
- require 'delivery/models/content_type'
2
- require 'delivery/models/pagination'
3
- require 'delivery/responses/response_base'
4
-
5
- module Kentico
6
- module Kontent
7
- module Delivery
8
- module Responses
9
- # The response of a successful query for content types.
10
- # See https://github.com/Kentico/kontent-delivery-sdk-ruby#retrieving-content-types
11
- class DeliveryTypeListingResponse < ResponseBase
12
- # Parses the 'pagination' JSON node of the response.
13
- #
14
- # * *Returns*:
15
- # - Kentico::Kontent::Delivery::Pagination
16
- def pagination
17
- @pagination unless @pagination.nil?
18
- @pagination = Pagination.new @response['pagination']
19
- end
20
-
21
- # Parses the 'types' JSON node of the response from a
22
- # Kentico::Kontent::Delivery::DeliveryClient.types call.
23
- #
24
- # * *Returns*:
25
- # - +Array+ The content types as Kentico::Kontent::Delivery::ContentType objects
26
- def types
27
- @types unless @types.nil?
28
- types = []
29
- @response['types'].each do |n|
30
- types << Kentico::Kontent::Delivery::ContentType.new(n)
31
- end
32
- @types = types
33
- end
34
-
35
- def initialize(headers, body)
36
- @response = JSON.parse(body)
37
- super 200,
38
- "Success, #{types.length} types returned",
39
- headers,
40
- JSON.generate(@response)
41
- end
42
- end
43
- end
44
- end
45
- end
46
- end
1
+ require 'delivery/models/content_type'
2
+ require 'delivery/models/pagination'
3
+ require 'delivery/responses/response_base'
4
+
5
+ module Kentico
6
+ module Kontent
7
+ module Delivery
8
+ module Responses
9
+ # The response of a successful query for content types.
10
+ # See https://github.com/Kentico/kontent-delivery-sdk-ruby#retrieving-content-types
11
+ class DeliveryTypeListingResponse < ResponseBase
12
+ # Parses the 'pagination' JSON node of the response.
13
+ #
14
+ # * *Returns*:
15
+ # - Kentico::Kontent::Delivery::Pagination
16
+ def pagination
17
+ @pagination unless @pagination.nil?
18
+ @pagination = Pagination.new @response['pagination']
19
+ end
20
+
21
+ # Parses the 'types' JSON node of the response from a
22
+ # Kentico::Kontent::Delivery::DeliveryClient.types call.
23
+ #
24
+ # * *Returns*:
25
+ # - +Array+ The content types as Kentico::Kontent::Delivery::ContentType objects
26
+ def types
27
+ @types unless @types.nil?
28
+ types = []
29
+ @response['types'].each do |n|
30
+ types << Kentico::Kontent::Delivery::ContentType.new(n)
31
+ end
32
+ @types = types
33
+ end
34
+
35
+ def initialize(headers, body)
36
+ @response = JSON.parse(body)
37
+ super 200,
38
+ "Success, #{types.length} types returned",
39
+ headers,
40
+ JSON.generate(@response)
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -1,32 +1,32 @@
1
- require 'delivery/models/content_type'
2
- require 'delivery/responses/response_base'
3
-
4
- module Kentico
5
- module Kontent
6
- module Delivery
7
- module Responses
8
- # The response of a successful query for a content type.
9
- # See https://github.com/Kentico/kontent-delivery-sdk-ruby#retrieving-content-types
10
- class DeliveryTypeResponse < ResponseBase
11
- # A Kentico::Kontent::Delivery::ContentType object from a
12
- # Kentico::Kontent::Delivery::DeliveryClient.type call.
13
- #
14
- # * *Returns*:
15
- # - Kentico::Kontent::Delivery::ContentType
16
- def type
17
- @type unless @type.nil?
18
- @type = Kentico::Kontent::Delivery::ContentType.new(@response)
19
- end
20
-
21
- def initialize(headers, body)
22
- @response = JSON.parse(body)
23
- super 200,
24
- "Success, type '#{type.system.codename}' returned",
25
- headers,
26
- JSON.generate(@response)
27
- end
28
- end
29
- end
30
- end
31
- end
32
- end
1
+ require 'delivery/models/content_type'
2
+ require 'delivery/responses/response_base'
3
+
4
+ module Kentico
5
+ module Kontent
6
+ module Delivery
7
+ module Responses
8
+ # The response of a successful query for a content type.
9
+ # See https://github.com/Kentico/kontent-delivery-sdk-ruby#retrieving-content-types
10
+ class DeliveryTypeResponse < ResponseBase
11
+ # A Kentico::Kontent::Delivery::ContentType object from a
12
+ # Kentico::Kontent::Delivery::DeliveryClient.type call.
13
+ #
14
+ # * *Returns*:
15
+ # - Kentico::Kontent::Delivery::ContentType
16
+ def type
17
+ @type unless @type.nil?
18
+ @type = Kentico::Kontent::Delivery::ContentType.new(@response)
19
+ end
20
+
21
+ def initialize(headers, body)
22
+ @response = JSON.parse(body)
23
+ super 200,
24
+ "Success, type '#{type.system.codename}' returned",
25
+ headers,
26
+ JSON.generate(@response)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,39 +1,39 @@
1
- module Kentico
2
- module Kontent
3
- module Delivery
4
- module Responses
5
- # Base class for all responses from a
6
- # Kentico::Kontent::Delivery::DeliveryQuery.execute call.
7
- class ResponseBase
8
- attr_accessor :http_code,
9
- :message,
10
- :headers,
11
- :json
12
-
13
- # Constructor.
14
- #
15
- # * *Args*:
16
- # - *http_code* (+integer+) The status code returned by the REST request
17
- # - *message* (+string+) An informative message about the response, visible when calling +to_s+
18
- # - *headers* (+hash+) _optional_ The headers of the REST response
19
- # - *json* (+string+) _optional_ The complete, unmodified JSON response from the server
20
- def initialize(http_code, message, headers = {}, json = '')
21
- self.http_code = http_code
22
- self.message = message
23
- self.headers = headers
24
- self.json = json
25
- end
26
-
27
- # Provides an informative message about the success of the request
28
- # by combining the status code and message.
29
- #
30
- # * *Returns*:
31
- # - +string+
32
- def to_s
33
- "Response is status code #{http_code} with message:\n#{message}"
34
- end
35
- end
36
- end
37
- end
38
- end
39
- end
1
+ module Kentico
2
+ module Kontent
3
+ module Delivery
4
+ module Responses
5
+ # Base class for all responses from a
6
+ # Kentico::Kontent::Delivery::DeliveryQuery.execute call.
7
+ class ResponseBase
8
+ attr_accessor :http_code,
9
+ :message,
10
+ :headers,
11
+ :json
12
+
13
+ # Constructor.
14
+ #
15
+ # * *Args*:
16
+ # - *http_code* (+integer+) The status code returned by the REST request
17
+ # - *message* (+string+) An informative message about the response, visible when calling +to_s+
18
+ # - *headers* (+hash+) _optional_ The headers of the REST response
19
+ # - *json* (+string+) _optional_ The complete, unmodified JSON response from the server
20
+ def initialize(http_code, message, headers = {}, json = '')
21
+ self.http_code = http_code
22
+ self.message = message
23
+ self.headers = headers
24
+ self.json = json
25
+ end
26
+
27
+ # Provides an informative message about the success of the request
28
+ # by combining the status code and message.
29
+ #
30
+ # * *Returns*:
31
+ # - +string+
32
+ def to_s
33
+ "Response is status code #{http_code} with message:\n#{message}"
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end