kontent-delivery-sdk-ruby 2.0.18 → 2.0.24

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.md +21 -21
  3. data/README.md +603 -576
  4. data/bin/console +14 -14
  5. data/bin/setup +8 -8
  6. data/lib/delivery/builders/image_transformation_builder.rb +272 -271
  7. data/lib/delivery/builders/url_builder.rb +123 -120
  8. data/lib/delivery/client/delivery_client.rb +184 -176
  9. data/lib/delivery/client/delivery_query.rb +302 -302
  10. data/lib/delivery/client/request_manager.rb +126 -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/language.rb +29 -0
  14. data/lib/delivery/models/pagination.rb +22 -22
  15. data/lib/delivery/models/taxonomy_group.rb +39 -39
  16. data/lib/delivery/query_parameters/filters.rb +201 -158
  17. data/lib/delivery/query_parameters/parameter_base.rb +56 -46
  18. data/lib/delivery/query_parameters/query_string.rb +78 -78
  19. data/lib/delivery/resolvers/content_link_resolver.rb +102 -102
  20. data/lib/delivery/resolvers/inline_content_item_resolver.rb +75 -75
  21. data/lib/delivery/resolvers/linked_item_resolver.rb +43 -37
  22. data/lib/delivery/responses/delivery_element_response.rb +34 -34
  23. data/lib/delivery/responses/delivery_item_listing_response.rb +54 -54
  24. data/lib/delivery/responses/delivery_item_response.rb +40 -40
  25. data/lib/delivery/responses/delivery_items_feed_response.rb +58 -58
  26. data/lib/delivery/responses/delivery_language_listing_response.rb +44 -0
  27. data/lib/delivery/responses/delivery_taxonomy_listing_response.rb +47 -47
  28. data/lib/delivery/responses/delivery_taxonomy_response.rb +33 -33
  29. data/lib/delivery/responses/delivery_type_listing_response.rb +46 -46
  30. data/lib/delivery/responses/delivery_type_response.rb +32 -32
  31. data/lib/delivery/responses/response_base.rb +39 -39
  32. data/lib/delivery/tests/401.json +5 -5
  33. data/lib/delivery/tests/429.json +4 -4
  34. data/lib/delivery/tests/fake_responder.rb +99 -110
  35. data/lib/delivery/tests/filtering/items_with_count.json +5385 -4986
  36. data/lib/delivery/tests/filtering/{pagination_about_us.json → pagination.json} +761 -646
  37. data/lib/delivery/tests/generic/items.json +5383 -4984
  38. data/lib/delivery/tests/generic/items/about_us.json +276 -227
  39. data/lib/delivery/tests/generic/items/aeropress_filters.json +155 -138
  40. data/lib/delivery/tests/generic/items/coffee_processing_techniques.json +565 -168
  41. data/lib/delivery/tests/generic/items/where_does_coffee_come_from_.json +599 -621
  42. data/lib/delivery/tests/generic/languages.json +24 -0
  43. data/lib/delivery/tests/generic/taxonomies.json +203 -126
  44. data/lib/delivery/tests/generic/taxonomies/manufacturer.json +30 -0
  45. data/lib/delivery/tests/generic/types.json +836 -781
  46. data/lib/delivery/tests/generic/types/brewer.json +89 -0
  47. data/lib/delivery/tests/generic/types/brewer/elements/product_status.json +5 -5
  48. data/lib/delivery/tests/items_feed/articles_feed_1.json +39 -39
  49. data/lib/delivery/tests/items_feed/articles_feed_2.json +78 -78
  50. data/lib/delivery/tests/items_feed/articles_feed_3.json +104 -104
  51. data/lib/kontent-delivery-sdk-ruby.rb +22 -20
  52. metadata +30 -29
  53. data/lib/delivery/tests/filtering/items_gt.json +0 -566
  54. data/lib/delivery/tests/filtering/multiple.json +0 -283
  55. 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
@@ -0,0 +1,44 @@
1
+ require 'delivery/models/language'
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 project languages.
9
+ class DeliveryLanguageListingResponse < ResponseBase
10
+ # Parses the 'pagination' JSON node of the response.
11
+ #
12
+ # * *Returns*:
13
+ # - Kentico::Kontent::Delivery::Pagination
14
+ def pagination
15
+ @pagination unless @pagination.nil?
16
+ @pagination = Pagination.new @response['pagination']
17
+ end
18
+
19
+ # Parses the 'languages' JSON node of the response from a
20
+ # Kentico::Kontent::Delivery::DeliveryClient.languages call.
21
+ #
22
+ # * *Returns*:
23
+ # - +Array+ The content types as Kentico::Kontent::Delivery::Language objects
24
+ def languages
25
+ @languages unless @languages.nil?
26
+ languages = []
27
+ @response['languages'].each do |n|
28
+ languages << Kentico::Kontent::Delivery::Language.new(n)
29
+ end
30
+ @languages = languages
31
+ end
32
+
33
+ def initialize(headers, body)
34
+ @response = JSON.parse(body)
35
+ super 200,
36
+ "Success, #{languages.length} languages returned",
37
+ headers,
38
+ JSON.generate(@response)
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ 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