delivery-sdk-ruby 0.15.0 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.md +21 -21
  3. data/README.md +480 -461
  4. data/bin/console +14 -14
  5. data/bin/setup +8 -8
  6. data/lib/delivery-sdk-ruby.rb +17 -17
  7. data/lib/delivery/builders/image_transformation_builder.rb +143 -141
  8. data/lib/delivery/builders/url_builder.rb +75 -73
  9. data/lib/delivery/client/delivery_client.rb +87 -85
  10. data/lib/delivery/client/delivery_query.rb +190 -188
  11. data/lib/delivery/models/content_item.rb +98 -96
  12. data/lib/delivery/models/content_type.rb +28 -26
  13. data/lib/delivery/models/pagination.rb +15 -13
  14. data/lib/delivery/models/taxonomy_group.rb +26 -24
  15. data/lib/delivery/query_parameters/filters.rb +89 -87
  16. data/lib/delivery/query_parameters/parameter_base.rb +32 -30
  17. data/lib/delivery/query_parameters/query_string.rb +51 -49
  18. data/lib/delivery/resolvers/content_link_resolver.rb +64 -62
  19. data/lib/delivery/resolvers/inline_content_item_resolver.rb +52 -50
  20. data/lib/delivery/resolvers/linked_item_resolver.rb +30 -28
  21. data/lib/delivery/responses/delivery_element_response.rb +25 -23
  22. data/lib/delivery/responses/delivery_item_listing_response.rb +41 -39
  23. data/lib/delivery/responses/delivery_item_response.rb +31 -29
  24. data/lib/delivery/responses/delivery_taxonomy_listing_response.rb +34 -32
  25. data/lib/delivery/responses/delivery_taxonomy_response.rb +24 -22
  26. data/lib/delivery/responses/delivery_type_listing_response.rb +33 -31
  27. data/lib/delivery/responses/delivery_type_response.rb +23 -21
  28. data/lib/delivery/responses/response_base.rb +22 -20
  29. data/lib/delivery/version.rb +5 -3
  30. metadata +13 -14
@@ -1,23 +1,25 @@
1
- require 'delivery/responses/response_base'
2
-
3
- module Delivery
4
- module Responses
5
- # Returned by DeliveryClient.element containing a single element
6
- class DeliveryElementResponse < ResponseBase
7
- def element
8
- @element unless @element.nil?
9
- @element = JSON.parse(
10
- JSON.generate(@response),
11
- object_class: OpenStruct
12
- )
13
- end
14
-
15
- def initialize(response)
16
- @response = response
17
- super 200,
18
- "Success, '#{element.codename}' returned",
19
- JSON.generate(@response)
20
- end
21
- end
22
- end
23
- end
1
+ require 'delivery/responses/response_base'
2
+
3
+ module KenticoCloud
4
+ module Delivery
5
+ module Responses
6
+ # Returned by DeliveryClient.element containing a single element
7
+ class DeliveryElementResponse < ResponseBase
8
+ def element
9
+ @element unless @element.nil?
10
+ @element = JSON.parse(
11
+ JSON.generate(@response),
12
+ object_class: OpenStruct
13
+ )
14
+ end
15
+
16
+ def initialize(response)
17
+ @response = response
18
+ super 200,
19
+ "Success, '#{element.codename}' returned",
20
+ JSON.generate(@response)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,39 +1,41 @@
1
- require 'delivery/models/content_item'
2
- require 'delivery/models/pagination'
3
- require 'delivery/responses/response_base'
4
-
5
- module Delivery
6
- module Responses
7
- # Returned by DeliveryClient.items with an enumerable of ContentItems
8
- class DeliveryItemListingResponse < ResponseBase
9
- def pagination
10
- @pagination unless @pagination.nil?
11
- @pagination = Pagination.new @response['pagination']
12
- end
13
-
14
- def items
15
- @items unless @items.nil?
16
- linked_items_resolver = LinkedItemResolver.new @response['modular_content'], @content_link_url_resolver, @inline_content_item_resolver
17
- items = []
18
- @response['items'].each do |n|
19
- items << Delivery::ContentItem.new(
20
- n,
21
- @content_link_url_resolver,
22
- @inline_content_item_resolver,
23
- linked_items_resolver
24
- )
25
- end
26
- @items = items
27
- end
28
-
29
- def initialize(response, content_link_url_resolver, inline_content_item_resolver)
30
- @response = response
31
- @content_link_url_resolver = content_link_url_resolver
32
- @inline_content_item_resolver = inline_content_item_resolver
33
- super 200,
34
- "Success, #{items.length} items returned",
35
- JSON.generate(@response)
36
- end
37
- end
38
- end
39
- end
1
+ require 'delivery/models/content_item'
2
+ require 'delivery/models/pagination'
3
+ require 'delivery/responses/response_base'
4
+
5
+ module KenticoCloud
6
+ module Delivery
7
+ module Responses
8
+ # Returned by DeliveryClient.items with an enumerable of ContentItems
9
+ class DeliveryItemListingResponse < ResponseBase
10
+ def pagination
11
+ @pagination unless @pagination.nil?
12
+ @pagination = Pagination.new @response['pagination']
13
+ end
14
+
15
+ def items
16
+ @items unless @items.nil?
17
+ linked_items_resolver = LinkedItemResolver.new @response['modular_content'], @content_link_url_resolver, @inline_content_item_resolver
18
+ items = []
19
+ @response['items'].each do |n|
20
+ items << KenticoCloud::Delivery::ContentItem.new(
21
+ n,
22
+ @content_link_url_resolver,
23
+ @inline_content_item_resolver,
24
+ linked_items_resolver
25
+ )
26
+ end
27
+ @items = items
28
+ end
29
+
30
+ def initialize(response, content_link_url_resolver, inline_content_item_resolver)
31
+ @response = response
32
+ @content_link_url_resolver = content_link_url_resolver
33
+ @inline_content_item_resolver = inline_content_item_resolver
34
+ super 200,
35
+ "Success, #{items.length} items returned",
36
+ JSON.generate(@response)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -1,29 +1,31 @@
1
- require 'delivery/models/content_item'
2
- require 'delivery/responses/response_base'
3
-
4
- module Delivery
5
- module Responses
6
- # Returned by DeliveryClient.item containing a single ContentItem
7
- class DeliveryItemResponse < ResponseBase
8
- def item
9
- @item unless @item.nil?
10
- linked_items_resolver = LinkedItemResolver.new @response['modular_content'], @content_link_url_resolver, @inline_content_item_resolver
11
- @item = Delivery::ContentItem.new(
12
- @response,
13
- @content_link_url_resolver,
14
- @inline_content_item_resolver,
15
- linked_items_resolver
16
- )
17
- end
18
-
19
- def initialize(response, content_link_url_resolver, inline_content_item_resolver)
20
- @response = response
21
- @content_link_url_resolver = content_link_url_resolver
22
- @inline_content_item_resolver = inline_content_item_resolver
23
- super 200,
24
- "Success, '#{item.system.code_name}' returned",
25
- JSON.generate(@response)
26
- end
27
- end
28
- end
29
- end
1
+ require 'delivery/models/content_item'
2
+ require 'delivery/responses/response_base'
3
+
4
+ module KenticoCloud
5
+ module Delivery
6
+ module Responses
7
+ # Returned by DeliveryClient.item containing a single ContentItem
8
+ class DeliveryItemResponse < ResponseBase
9
+ def item
10
+ @item unless @item.nil?
11
+ linked_items_resolver = LinkedItemResolver.new @response['modular_content'], @content_link_url_resolver, @inline_content_item_resolver
12
+ @item = KenticoCloud::Delivery::ContentItem.new(
13
+ @response,
14
+ @content_link_url_resolver,
15
+ @inline_content_item_resolver,
16
+ linked_items_resolver
17
+ )
18
+ end
19
+
20
+ def initialize(response, content_link_url_resolver, inline_content_item_resolver)
21
+ @response = response
22
+ @content_link_url_resolver = content_link_url_resolver
23
+ @inline_content_item_resolver = inline_content_item_resolver
24
+ super 200,
25
+ "Success, '#{item.system.code_name}' returned",
26
+ JSON.generate(@response)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -1,32 +1,34 @@
1
- require 'delivery/models/taxonomy_group'
2
- require 'delivery/models/pagination'
3
- require 'delivery/responses/response_base'
4
-
5
- module Delivery
6
- module Responses
7
- # Returned by DeliveryClient.taxonomies with an enumerable of TaxonomyGroups
8
- class DeliveryTaxonomyListingResponse < ResponseBase
9
- def pagination
10
- @pagination unless @pagination.nil?
11
- @pagination = Pagination.new @response['pagination']
12
- end
13
-
14
- def taxonomies
15
- @taxonomies unless @taxonomies.nil?
16
- taxonomies = []
17
- @response['taxonomies'].each do |n|
18
- taxonomies << Delivery::TaxonomyGroup.new(n)
19
- end
20
- @taxonomies = taxonomies
21
- end
22
-
23
- def initialize(response)
24
- @response = response
25
-
26
- super 200,
27
- "Success, #{taxonomies.length} taxonomies returned",
28
- JSON.generate(@response)
29
- end
30
- end
31
- end
32
- end
1
+ require 'delivery/models/taxonomy_group'
2
+ require 'delivery/models/pagination'
3
+ require 'delivery/responses/response_base'
4
+
5
+ module KenticoCloud
6
+ module Delivery
7
+ module Responses
8
+ # Returned by DeliveryClient.taxonomies with an enumerable of TaxonomyGroups
9
+ class DeliveryTaxonomyListingResponse < ResponseBase
10
+ def pagination
11
+ @pagination unless @pagination.nil?
12
+ @pagination = Pagination.new @response['pagination']
13
+ end
14
+
15
+ def taxonomies
16
+ @taxonomies unless @taxonomies.nil?
17
+ taxonomies = []
18
+ @response['taxonomies'].each do |n|
19
+ taxonomies << KenticoCloud::Delivery::TaxonomyGroup.new(n)
20
+ end
21
+ @taxonomies = taxonomies
22
+ end
23
+
24
+ def initialize(response)
25
+ @response = response
26
+
27
+ super 200,
28
+ "Success, #{taxonomies.length} taxonomies returned",
29
+ JSON.generate(@response)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1,22 +1,24 @@
1
- require 'delivery/models/taxonomy_group'
2
- require 'delivery/responses/response_base'
3
-
4
- module Delivery
5
- module Responses
6
- # Returned by DeliveryClient.taxonomy containing a single TaxonomyGroup
7
- class DeliveryTaxonomyResponse < ResponseBase
8
- def taxonomy
9
- @taxonomy unless @taxonomy.nil?
10
- @taxonomy = Delivery::TaxonomyGroup.new(@response)
11
- end
12
-
13
- def initialize(response)
14
- @response = response
15
-
16
- super 200,
17
- "Success, '#{taxonomy.system.codename}' returned",
18
- JSON.generate(@response)
19
- end
20
- end
21
- end
22
- end
1
+ require 'delivery/models/taxonomy_group'
2
+ require 'delivery/responses/response_base'
3
+
4
+ module KenticoCloud
5
+ module Delivery
6
+ module Responses
7
+ # Returned by DeliveryClient.taxonomy containing a single TaxonomyGroup
8
+ class DeliveryTaxonomyResponse < ResponseBase
9
+ def taxonomy
10
+ @taxonomy unless @taxonomy.nil?
11
+ @taxonomy = KenticoCloud::Delivery::TaxonomyGroup.new(@response)
12
+ end
13
+
14
+ def initialize(response)
15
+ @response = response
16
+
17
+ super 200,
18
+ "Success, '#{taxonomy.system.codename}' returned",
19
+ JSON.generate(@response)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,31 +1,33 @@
1
- require 'delivery/models/content_type'
2
- require 'delivery/models/pagination'
3
- require 'delivery/responses/response_base'
4
-
5
- module Delivery
6
- module Responses
7
- # Returned by DeliveryClient.types with an enumerable of ContentTypes
8
- class DeliveryTypeListingResponse < ResponseBase
9
- def pagination
10
- @pagination unless @pagination.nil?
11
- @pagination = Pagination.new @response['pagination']
12
- end
13
-
14
- def types
15
- @types unless @types.nil?
16
- types = []
17
- @response['types'].each do |n|
18
- types << Delivery::ContentType.new(n)
19
- end
20
- @types = types
21
- end
22
-
23
- def initialize(response)
24
- @response = response
25
- super 200,
26
- "Success, #{types.length} types returned",
27
- JSON.generate(@response)
28
- end
29
- end
30
- end
31
- end
1
+ require 'delivery/models/content_type'
2
+ require 'delivery/models/pagination'
3
+ require 'delivery/responses/response_base'
4
+
5
+ module KenticoCloud
6
+ module Delivery
7
+ module Responses
8
+ # Returned by DeliveryClient.types with an enumerable of ContentTypes
9
+ class DeliveryTypeListingResponse < ResponseBase
10
+ def pagination
11
+ @pagination unless @pagination.nil?
12
+ @pagination = Pagination.new @response['pagination']
13
+ end
14
+
15
+ def types
16
+ @types unless @types.nil?
17
+ types = []
18
+ @response['types'].each do |n|
19
+ types << KenticoCloud::Delivery::ContentType.new(n)
20
+ end
21
+ @types = types
22
+ end
23
+
24
+ def initialize(response)
25
+ @response = response
26
+ super 200,
27
+ "Success, #{types.length} types returned",
28
+ JSON.generate(@response)
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,21 +1,23 @@
1
- require 'delivery/models/content_type'
2
- require 'delivery/responses/response_base'
3
-
4
- module Delivery
5
- module Responses
6
- # Returned by DeliveryClient.types with an enumerable of ContentTypes
7
- class DeliveryTypeResponse < ResponseBase
8
- def type
9
- @type unless @type.nil?
10
- @type = Delivery::ContentType.new(@response)
11
- end
12
-
13
- def initialize(response)
14
- @response = response
15
- super 200,
16
- "Success, type '#{type.system.codename}' returned",
17
- JSON.generate(@response)
18
- end
19
- end
20
- end
21
- end
1
+ require 'delivery/models/content_type'
2
+ require 'delivery/responses/response_base'
3
+
4
+ module KenticoCloud
5
+ module Delivery
6
+ module Responses
7
+ # Returned by DeliveryClient.types with an enumerable of ContentTypes
8
+ class DeliveryTypeResponse < ResponseBase
9
+ def type
10
+ @type unless @type.nil?
11
+ @type = KenticoCloud::Delivery::ContentType.new(@response)
12
+ end
13
+
14
+ def initialize(response)
15
+ @response = response
16
+ super 200,
17
+ "Success, type '#{type.system.codename}' returned",
18
+ JSON.generate(@response)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,20 +1,22 @@
1
- module Delivery
2
- module Responses
3
- # Base class for all responses from DeliveryQuery.execute
4
- class ResponseBase
5
- attr_accessor :http_code,
6
- :message,
7
- :json
8
-
9
- def initialize(http_code, message, json = '')
10
- self.http_code = http_code
11
- self.message = message
12
- self.json = json
13
- end
14
-
15
- def to_s
16
- "Response is status code #{http_code} with message:\n#{message}"
17
- end
18
- end
19
- end
20
- end
1
+ module KenticoCloud
2
+ module Delivery
3
+ module Responses
4
+ # Base class for all responses from DeliveryQuery.execute
5
+ class ResponseBase
6
+ attr_accessor :http_code,
7
+ :message,
8
+ :json
9
+
10
+ def initialize(http_code, message, json = '')
11
+ self.http_code = http_code
12
+ self.message = message
13
+ self.json = json
14
+ end
15
+
16
+ def to_s
17
+ "Response is status code #{http_code} with message:\n#{message}"
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end