dato 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,80 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'dato/site/repo/base'
3
- require 'dato/site/paginator'
4
- require 'active_support/core_ext/hash/except'
5
- require 'active_support/core_ext/hash/keys'
6
-
7
- module Dato
8
- module Site
9
- module Repo
10
- class Item < Base
11
- def create(resource_attributes)
12
- body = JsonApiSerializer.new(
13
- type: :item,
14
- attributes: resource_attributes.keys - [:item_type, :id],
15
- relationships: {
16
- item_type: { collection: false, type: 'item_type' }
17
- },
18
- required_relationships: %i(item_type)
19
- ).serialize(resource_attributes)
20
-
21
- post_request '/items', body
22
- end
23
-
24
- def update(item_id, resource_attributes)
25
- resource_attributes = resource_attributes.except(
26
- :id,
27
- :updated_at,
28
- :created_at,
29
- :is_valid,
30
- :item_type,
31
- :published_version,
32
- :current_version
33
- )
34
-
35
- body = JsonApiSerializer.new(
36
- type: :item,
37
- attributes: resource_attributes.keys
38
- ).serialize(resource_attributes, item_id)
39
-
40
- put_request "/items/#{item_id}", body
41
- end
42
-
43
- def publish(item_id)
44
- put_request "/items/#{item_id}/publish", {}
45
- end
46
-
47
- def unpublish(item_id)
48
- put_request "/items/#{item_id}/unpublish", {}
49
- end
50
-
51
- def all(filters = {}, options = {})
52
- options.symbolize_keys!
53
-
54
- deserialize_response = options.fetch(:deserialize_response, true)
55
- all_pages = options.fetch(:all_pages, false)
56
-
57
- response = if all_pages
58
- Paginator.new(client, '/items', filters).response
59
- else
60
- client.request(:get, '/items', filters)
61
- end
62
-
63
- if deserialize_response
64
- JsonApiDeserializer.new.deserialize(response)
65
- else
66
- response
67
- end
68
- end
69
-
70
- def find(item_id)
71
- get_request "/items/#{item_id}"
72
- end
73
-
74
- def destroy(item_id)
75
- delete_request "/items/#{item_id}"
76
- end
77
- end
78
- end
79
- end
80
- end
@@ -1,50 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'dato/site/repo/base'
3
-
4
- module Dato
5
- module Site
6
- module Repo
7
- class ItemType < Base
8
- def create(resource_attributes)
9
- body = JsonApiSerializer.new(
10
- type: :item_type,
11
- attributes: %i(api_key modular_block name ordering_direction singleton sortable tree draft_mode_active),
12
- relationships: { ordering_field: { collection: false, type: :field } },
13
- required_attributes: %i(api_key modular_block name ordering_direction singleton sortable tree draft_mode_active),
14
- required_relationships: %i(ordering_field)
15
- ).serialize(resource_attributes)
16
-
17
- post_request '/item-types', body
18
- end
19
-
20
- def update(item_type_id, resource_attributes)
21
- body = JsonApiSerializer.new(
22
- type: :item_type,
23
- attributes: %i(api_key modular_block name ordering_direction singleton sortable tree draft_mode_active),
24
- relationships: { ordering_field: { collection: false, type: :field } },
25
- required_attributes: %i(api_key modular_block name ordering_direction singleton sortable tree draft_mode_active),
26
- required_relationships: %i(ordering_field)
27
- ).serialize(resource_attributes, item_type_id)
28
-
29
- put_request "/item-types/#{item_type_id}", body
30
- end
31
-
32
- def all
33
- get_request '/item-types'
34
- end
35
-
36
- def find(item_type_id)
37
- get_request "/item-types/#{item_type_id}"
38
- end
39
-
40
- def duplicate(item_type_id)
41
- post_request "/item-types/#{item_type_id}/duplicate"
42
- end
43
-
44
- def destroy(item_type_id)
45
- delete_request "/item-types/#{item_type_id}"
46
- end
47
- end
48
- end
49
- end
50
- end
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'dato/site/repo/base'
3
-
4
- module Dato
5
- module Site
6
- module Repo
7
- class MenuItem < Base
8
- def create(resource_attributes)
9
- body = JsonApiSerializer.new(
10
- type: :menu_item,
11
- attributes: %i(label position),
12
- relationships: { item_type: { collection: false, type: :item_type }, parent: { collection: false, type: :menu_item } },
13
- required_attributes: %i(label position)
14
- ).serialize(resource_attributes)
15
-
16
- post_request '/menu-items', body
17
- end
18
-
19
- def update(menu_item_id, resource_attributes)
20
- body = JsonApiSerializer.new(
21
- type: :menu_item,
22
- attributes: %i(label position),
23
- relationships: { item_type: { collection: false, type: :item_type }, parent: { collection: false, type: :menu_item } },
24
- required_attributes: %i(label position)
25
- ).serialize(resource_attributes, menu_item_id)
26
-
27
- put_request "/menu-items/#{menu_item_id}", body
28
- end
29
-
30
- def all
31
- get_request '/menu-items'
32
- end
33
-
34
- def find(menu_item_id)
35
- get_request "/menu-items/#{menu_item_id}"
36
- end
37
-
38
- def destroy(menu_item_id)
39
- delete_request "/menu-items/#{menu_item_id}"
40
- end
41
- end
42
- end
43
- end
44
- end
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'dato/site/repo/base'
3
-
4
- module Dato
5
- module Site
6
- module Repo
7
- class Role < Base
8
- def create(resource_attributes)
9
- body = JsonApiSerializer.new(
10
- type: :role,
11
- attributes: %i(can_edit_favicon can_edit_schema can_edit_site can_manage_access_tokens can_manage_users can_perform_site_search can_publish_to_production can_publish_to_staging name negative_item_type_permissions positive_item_type_permissions),
12
- required_attributes: %i(can_edit_favicon can_edit_schema can_edit_site can_manage_access_tokens can_manage_users can_perform_site_search can_publish_to_production can_publish_to_staging name negative_item_type_permissions positive_item_type_permissions)
13
- ).serialize(resource_attributes)
14
-
15
- post_request '/roles', body
16
- end
17
-
18
- def update(role_id, resource_attributes)
19
- body = JsonApiSerializer.new(
20
- type: :role,
21
- attributes: %i(can_edit_favicon can_edit_schema can_edit_site can_manage_access_tokens can_manage_users can_perform_site_search can_publish_to_production can_publish_to_staging name negative_item_type_permissions positive_item_type_permissions),
22
- required_attributes: %i(can_edit_favicon can_edit_schema can_edit_site can_manage_access_tokens can_manage_users can_perform_site_search can_publish_to_production can_publish_to_staging name negative_item_type_permissions positive_item_type_permissions)
23
- ).serialize(resource_attributes, role_id)
24
-
25
- put_request "/roles/#{role_id}", body
26
- end
27
-
28
- def all
29
- get_request '/roles'
30
- end
31
-
32
- def find(role_id)
33
- get_request "/roles/#{role_id}"
34
- end
35
-
36
- def destroy(role_id)
37
- delete_request "/roles/#{role_id}"
38
- end
39
- end
40
- end
41
- end
42
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'dato/site/repo/base'
3
-
4
- module Dato
5
- module Site
6
- module Repo
7
- class SearchResult < Base
8
- def all
9
- get_request '/search-results'
10
- end
11
- end
12
- end
13
- end
14
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'dato/site/repo/base'
3
-
4
- module Dato
5
- module Site
6
- module Repo
7
- class Site < Base
8
- def find
9
- get_request '/site'
10
- end
11
-
12
- def update(resource_attributes)
13
- body = JsonApiSerializer.new(
14
- type: :site,
15
- attributes: %i(favicon global_seo locales name no_index production_deploy_adapter production_deploy_settings production_frontend_url production_spider_enabled require_2fa ssg staging_deploy_adapter staging_deploy_settings staging_frontend_url staging_spider_enabled theme timezone)
16
- ).serialize(resource_attributes)
17
-
18
- put_request '/site', body
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,59 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'dato/site/repo/base'
3
- require 'dato/site/paginator'
4
- require 'active_support/core_ext/hash/except'
5
- require 'active_support/core_ext/hash/keys'
6
-
7
- module Dato
8
- module Site
9
- module Repo
10
- class Upload < Base
11
- def create(resource_attributes)
12
- body = JsonApiSerializer.new(
13
- type: :upload,
14
- attributes: %i(alt format height path size title width),
15
- required_attributes: %i(format path size)
16
- ).serialize(resource_attributes)
17
-
18
- post_request '/uploads', body
19
- end
20
-
21
- def all(filters = {}, options = {})
22
- options.symbolize_keys!
23
-
24
- deserialize_response = options.fetch(:deserialize_response, true)
25
- all_pages = options.fetch(:all_pages, false)
26
-
27
- response = if all_pages
28
- Paginator.new(client, '/uploads', filters).response
29
- else
30
- client.request(:get, '/uploads', filters)
31
- end
32
-
33
- if deserialize_response
34
- JsonApiDeserializer.new.deserialize(response)
35
- else
36
- response
37
- end
38
- end
39
-
40
- def find(upload_id)
41
- get_request "/uploads/#{upload_id}"
42
- end
43
-
44
- def destroy(upload_id)
45
- delete_request "/uploads/#{upload_id}"
46
- end
47
-
48
- def update(upload_id, resource_attributes)
49
- body = JsonApiSerializer.new(
50
- type: :upload,
51
- attributes: %i(alt title)
52
- ).serialize(resource_attributes, upload_id)
53
-
54
- put_request "/uploads/#{upload_id}", body
55
- end
56
- end
57
- end
58
- end
59
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'dato/site/repo/base'
3
-
4
- module Dato
5
- module Site
6
- module Repo
7
- class UploadRequest < Base
8
- def create(resource_attributes)
9
- body = JsonApiSerializer.new(
10
- type: :upload_request,
11
- attributes: %i(filename)
12
- ).serialize(resource_attributes)
13
-
14
- post_request '/upload-requests', body
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'dato/site/repo/base'
3
-
4
- module Dato
5
- module Site
6
- module Repo
7
- class User < Base
8
- def create(resource_attributes)
9
- body = JsonApiSerializer.new(
10
- type: :user,
11
- attributes: %i(email first_name last_name),
12
- relationships: { role: { collection: false, type: :role } },
13
- required_attributes: %i(email first_name last_name),
14
- required_relationships: %i(role)
15
- ).serialize(resource_attributes)
16
-
17
- post_request '/users', body
18
- end
19
-
20
- def all
21
- get_request '/users'
22
- end
23
-
24
- def find(user_id)
25
- get_request "/users/#{user_id}"
26
- end
27
-
28
- def reset_password(resource_attributes)
29
- body = JsonApiSerializer.new(
30
- type: :user,
31
- attributes: %i(email),
32
- required_attributes: %i(email)
33
- ).serialize(resource_attributes)
34
-
35
- post_request '/users/reset_password', body
36
- end
37
-
38
- def destroy(user_id)
39
- delete_request "/users/#{user_id}"
40
- end
41
- end
42
- end
43
- end
44
- end