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.
- checksums.yaml +4 -4
- data/LICENSE.md +21 -21
- data/README.md +480 -461
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/lib/delivery-sdk-ruby.rb +17 -17
- data/lib/delivery/builders/image_transformation_builder.rb +143 -141
- data/lib/delivery/builders/url_builder.rb +75 -73
- data/lib/delivery/client/delivery_client.rb +87 -85
- data/lib/delivery/client/delivery_query.rb +190 -188
- data/lib/delivery/models/content_item.rb +98 -96
- data/lib/delivery/models/content_type.rb +28 -26
- data/lib/delivery/models/pagination.rb +15 -13
- data/lib/delivery/models/taxonomy_group.rb +26 -24
- data/lib/delivery/query_parameters/filters.rb +89 -87
- data/lib/delivery/query_parameters/parameter_base.rb +32 -30
- data/lib/delivery/query_parameters/query_string.rb +51 -49
- data/lib/delivery/resolvers/content_link_resolver.rb +64 -62
- data/lib/delivery/resolvers/inline_content_item_resolver.rb +52 -50
- data/lib/delivery/resolvers/linked_item_resolver.rb +30 -28
- data/lib/delivery/responses/delivery_element_response.rb +25 -23
- data/lib/delivery/responses/delivery_item_listing_response.rb +41 -39
- data/lib/delivery/responses/delivery_item_response.rb +31 -29
- data/lib/delivery/responses/delivery_taxonomy_listing_response.rb +34 -32
- data/lib/delivery/responses/delivery_taxonomy_response.rb +24 -22
- data/lib/delivery/responses/delivery_type_listing_response.rb +33 -31
- data/lib/delivery/responses/delivery_type_response.rb +23 -21
- data/lib/delivery/responses/response_base.rb +22 -20
- data/lib/delivery/version.rb +5 -3
- metadata +13 -14
@@ -1,23 +1,25 @@
|
|
1
|
-
require 'delivery/responses/response_base'
|
2
|
-
|
3
|
-
module
|
4
|
-
module
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
JSON.
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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
|
6
|
-
module
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
items
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
@
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
6
|
-
module
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
taxonomies
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
6
|
-
module
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
types
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|