castle-rb 8.0.0 → 8.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/castle/api/list_items/archive.rb +23 -0
- data/lib/castle/api/list_items/count.rb +22 -0
- data/lib/castle/api/list_items/create.rb +22 -0
- data/lib/castle/api/list_items/get.rb +22 -0
- data/lib/castle/api/list_items/query.rb +22 -0
- data/lib/castle/api/list_items/unarchive.rb +22 -0
- data/lib/castle/api/list_items/update.rb +22 -0
- data/lib/castle/api/lists/create.rb +23 -0
- data/lib/castle/api/lists/delete.rb +22 -0
- data/lib/castle/api/lists/get.rb +22 -0
- data/lib/castle/api/lists/get_all.rb +22 -0
- data/lib/castle/api/lists/query.rb +22 -0
- data/lib/castle/api/lists/update.rb +22 -0
- data/lib/castle/client.rb +3 -0
- data/lib/castle/client_actions/list_items.rb +44 -0
- data/lib/castle/client_actions/lists.rb +39 -0
- data/lib/castle/commands/list_items/archive.rb +24 -0
- data/lib/castle/commands/list_items/count.rb +23 -0
- data/lib/castle/commands/list_items/create.rb +22 -0
- data/lib/castle/commands/list_items/get.rb +23 -0
- data/lib/castle/commands/list_items/query.rb +24 -0
- data/lib/castle/commands/list_items/unarchive.rb +23 -0
- data/lib/castle/commands/list_items/update.rb +22 -0
- data/lib/castle/commands/lists/create.rb +21 -0
- data/lib/castle/commands/lists/delete.rb +20 -0
- data/lib/castle/commands/lists/get.rb +20 -0
- data/lib/castle/commands/lists/get_all.rb +17 -0
- data/lib/castle/commands/lists/query.rb +21 -0
- data/lib/castle/commands/lists/update.rb +22 -0
- data/lib/castle/version.rb +1 -1
- data/lib/castle.rb +28 -0
- data/spec/lib/castle/api/approve_device_spec.rb +1 -1
- data/spec/lib/castle/api/authenticate_spec.rb +1 -1
- data/spec/lib/castle/api/end_impersonation_spec.rb +1 -1
- data/spec/lib/castle/api/filter_spec.rb +1 -1
- data/spec/lib/castle/api/get_device_spec.rb +1 -1
- data/spec/lib/castle/api/get_devices_for_user_spec.rb +1 -1
- data/spec/lib/castle/api/list_items/archive_spec.rb +18 -0
- data/spec/lib/castle/api/list_items/count_spec.rb +21 -0
- data/spec/lib/castle/api/list_items/create_spec.rb +22 -0
- data/spec/lib/castle/api/list_items/get_spec.rb +18 -0
- data/spec/lib/castle/api/list_items/query_spec.rb +21 -0
- data/spec/lib/castle/api/list_items/unarchive_spec.rb +18 -0
- data/spec/lib/castle/api/list_items/update_spec.rb +22 -0
- data/spec/lib/castle/api/lists/create_spec.rb +21 -0
- data/spec/lib/castle/api/lists/delete_spec.rb +17 -0
- data/spec/lib/castle/api/lists/get_all_spec.rb +17 -0
- data/spec/lib/castle/api/lists/get_spec.rb +17 -0
- data/spec/lib/castle/api/lists/query_spec.rb +21 -0
- data/spec/lib/castle/api/lists/update_spec.rb +21 -0
- data/spec/lib/castle/api/log_spec.rb +1 -1
- data/spec/lib/castle/api/report_device_spec.rb +1 -1
- data/spec/lib/castle/api/risk_spec.rb +1 -1
- data/spec/lib/castle/api/start_impersonation_spec.rb +1 -1
- data/spec/lib/castle/api/track_spec.rb +1 -1
- data/spec/lib/castle/api_spec.rb +1 -1
- data/spec/lib/castle/client_id/extract_spec.rb +1 -1
- data/spec/lib/castle/client_spec.rb +6 -1
- data/spec/lib/castle/command_spec.rb +1 -1
- data/spec/lib/castle/commands/approve_device_spec.rb +1 -1
- data/spec/lib/castle/commands/authenticate_spec.rb +1 -1
- data/spec/lib/castle/commands/end_impersonation_spec.rb +1 -1
- data/spec/lib/castle/commands/filter_spec.rb +1 -1
- data/spec/lib/castle/commands/get_device_spec.rb +1 -1
- data/spec/lib/castle/commands/get_devices_for_user_spec.rb +1 -1
- data/spec/lib/castle/commands/list_items/archive_spec.rb +21 -0
- data/spec/lib/castle/commands/list_items/count_spec.rb +21 -0
- data/spec/lib/castle/commands/list_items/create_spec.rb +22 -0
- data/spec/lib/castle/commands/list_items/get_spec.rb +21 -0
- data/spec/lib/castle/commands/list_items/query_spec.rb +27 -0
- data/spec/lib/castle/commands/list_items/unarchive_spec.rb +21 -0
- data/spec/lib/castle/commands/list_items/update_spec.rb +21 -0
- data/spec/lib/castle/commands/lists/create_spec.rb +33 -0
- data/spec/lib/castle/commands/lists/delete_spec.rb +21 -0
- data/spec/lib/castle/commands/lists/get_all_spec.rb +11 -0
- data/spec/lib/castle/commands/lists/get_spec.rb +21 -0
- data/spec/lib/castle/commands/lists/query_spec.rb +27 -0
- data/spec/lib/castle/commands/lists/update_spec.rb +29 -0
- data/spec/lib/castle/commands/log_spec.rb +1 -1
- data/spec/lib/castle/commands/report_device_spec.rb +1 -1
- data/spec/lib/castle/commands/risk_spec.rb +1 -1
- data/spec/lib/castle/commands/start_impersonation_spec.rb +1 -1
- data/spec/lib/castle/commands/track_spec.rb +1 -1
- data/spec/lib/castle/configuration_spec.rb +1 -1
- data/spec/lib/castle/context/get_default_spec.rb +1 -1
- data/spec/lib/castle/context/merge_spec.rb +1 -1
- data/spec/lib/castle/context/prepare_spec.rb +1 -1
- data/spec/lib/castle/context/sanitize_spec.rb +1 -1
- data/spec/lib/castle/core/get_connection_spec.rb +1 -1
- data/spec/lib/castle/core/process_response_spec.rb +1 -1
- data/spec/lib/castle/core/process_webhook_spec.rb +1 -1
- data/spec/lib/castle/core/send_request_spec.rb +1 -1
- data/spec/lib/castle/failover/strategy_spec.rb +1 -1
- data/spec/lib/castle/headers/extract_spec.rb +1 -1
- data/spec/lib/castle/headers/filter_spec.rb +1 -1
- data/spec/lib/castle/headers/format_spec.rb +1 -1
- data/spec/lib/castle/ips/extract_spec.rb +1 -1
- data/spec/lib/castle/logger_spec.rb +1 -1
- data/spec/lib/castle/payload/prepare_spec.rb +1 -1
- data/spec/lib/castle/secure_mode_spec.rb +1 -1
- data/spec/lib/castle/session_spec.rb +1 -1
- data/spec/lib/castle/singleton_configuration_spec.rb +1 -1
- data/spec/lib/castle/utils/clean_invalid_chars_spec.rb +1 -1
- data/spec/lib/castle/utils/clone_spec.rb +1 -1
- data/spec/lib/castle/utils/deep_symbolize_keys_spec.rb +1 -1
- data/spec/lib/castle/utils/get_timestamp_spec.rb +1 -1
- data/spec/lib/castle/utils/merge_spec.rb +1 -1
- data/spec/lib/castle/validators/not_supported_spec.rb +1 -1
- data/spec/lib/castle/validators/present_spec.rb +1 -1
- data/spec/lib/castle/verdict_spec.rb +1 -1
- data/spec/lib/castle/version_spec.rb +1 -1
- data/spec/lib/castle/webhooks/verify_spec.rb +1 -1
- data/spec/lib/castle_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -0
- data/spec/support/shared_examples/list_items.rb +52 -0
- data/spec/support/shared_examples/lists.rb +45 -0
- metadata +87 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f571bda5aa4075f18ef7c64173155401d822ced4fe66fe7c4ceaf4c7c6c6c6e
|
4
|
+
data.tar.gz: 15709ff2d5bbdf57063bdd0c1f3eb492f78beff5b1e2b8c61a848f3a2af1d32d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5186002c86cef93deb33c8c03c95ffc81adaa7b59b032a06f2f81ff1423d0cd247d198e0a7fce2a15e2a1ab6a76a986c524644c4f4338be5a7e16ec45ba6cdca
|
7
|
+
data.tar.gz: a9c63ce6293981630ed431471ceb0ffb70fe990b68784f70088dba28140a63e7ff012286604d8da9a79f5b93486ba4cb8e3318c93ee3617c29f6f981ef737d86
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Castle
|
4
|
+
module API
|
5
|
+
# Namespace for the list items API ednpoints
|
6
|
+
module ListItems
|
7
|
+
# Sends DELETE /lists/:list_id/items/:item_id request
|
8
|
+
module Archive
|
9
|
+
class << self
|
10
|
+
# @param options [Hash]
|
11
|
+
# @return [Hash]
|
12
|
+
def call(options = {})
|
13
|
+
options = Castle::Utils::DeepSymbolizeKeys.call(options || {})
|
14
|
+
http = options.delete(:http)
|
15
|
+
config = options.delete(:config) || Castle.config
|
16
|
+
|
17
|
+
Castle::API.call(Castle::Commands::ListItems::Archive.build(options), {}, http, config)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Castle
|
4
|
+
module API
|
5
|
+
module ListItems
|
6
|
+
# Sends POST /lists/:list_id/items request
|
7
|
+
module Count
|
8
|
+
class << self
|
9
|
+
# @param options [Hash]
|
10
|
+
# @return [Hash]
|
11
|
+
def call(options = {})
|
12
|
+
options = Castle::Utils::DeepSymbolizeKeys.call(options || {})
|
13
|
+
http = options.delete(:http)
|
14
|
+
config = options.delete(:config) || Castle.config
|
15
|
+
|
16
|
+
Castle::API.call(Castle::Commands::ListItems::Count.build(options), {}, http, config)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Castle
|
4
|
+
module API
|
5
|
+
module ListItems
|
6
|
+
# Sends POST /lists/:list_id/items request
|
7
|
+
module Create
|
8
|
+
class << self
|
9
|
+
# @param options [Hash]
|
10
|
+
# @return [Hash]
|
11
|
+
def call(options = {})
|
12
|
+
options = Castle::Utils::DeepSymbolizeKeys.call(options || {})
|
13
|
+
http = options.delete(:http)
|
14
|
+
config = options.delete(:config) || Castle.config
|
15
|
+
|
16
|
+
Castle::API.call(Castle::Commands::ListItems::Create.build(options), {}, http, config)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Castle
|
4
|
+
module API
|
5
|
+
module ListItems
|
6
|
+
# Sends GET /lists/:list_id/items/:item_id request
|
7
|
+
module Get
|
8
|
+
class << self
|
9
|
+
# @param options [Hash]
|
10
|
+
# @return [Hash]
|
11
|
+
def call(options = {})
|
12
|
+
options = Castle::Utils::DeepSymbolizeKeys.call(options || {})
|
13
|
+
http = options.delete(:http)
|
14
|
+
config = options.delete(:config) || Castle.config
|
15
|
+
|
16
|
+
Castle::API.call(Castle::Commands::ListItems::Get.build(options), {}, http, config)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Castle
|
4
|
+
module API
|
5
|
+
module ListItems
|
6
|
+
# Sends POST /lists/:list_id/items/query request
|
7
|
+
module Query
|
8
|
+
class << self
|
9
|
+
# @param options [Hash]
|
10
|
+
# @return [Hash]
|
11
|
+
def call(options = {})
|
12
|
+
options = Castle::Utils::DeepSymbolizeKeys.call(options || {})
|
13
|
+
http = options.delete(:http)
|
14
|
+
config = options.delete(:config) || Castle.config
|
15
|
+
|
16
|
+
Castle::API.call(Castle::Commands::ListItems::Query.build(options), {}, http, config)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Castle
|
4
|
+
module API
|
5
|
+
module ListItems
|
6
|
+
# Sends PUT /lists/:list_id/items/:item_id/unarchive request
|
7
|
+
module Unarchive
|
8
|
+
class << self
|
9
|
+
# @param options [Hash]
|
10
|
+
# @return [Hash]
|
11
|
+
def call(options = {})
|
12
|
+
options = Castle::Utils::DeepSymbolizeKeys.call(options || {})
|
13
|
+
http = options.delete(:http)
|
14
|
+
config = options.delete(:config) || Castle.config
|
15
|
+
|
16
|
+
Castle::API.call(Castle::Commands::ListItems::Unarchive.build(options), {}, http, config)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Castle
|
4
|
+
module API
|
5
|
+
module ListItems
|
6
|
+
# Sends PUT /lists/:list_id/items/:item_id request
|
7
|
+
module Update
|
8
|
+
class << self
|
9
|
+
# @param options [Hash]
|
10
|
+
# @return [Hash]
|
11
|
+
def call(options = {})
|
12
|
+
options = Castle::Utils::DeepSymbolizeKeys.call(options || {})
|
13
|
+
http = options.delete(:http)
|
14
|
+
config = options.delete(:config) || Castle.config
|
15
|
+
|
16
|
+
Castle::API.call(Castle::Commands::ListItems::Update.build(options), {}, http, config)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Castle
|
4
|
+
module API
|
5
|
+
# Namespace for the lists API ednpoints
|
6
|
+
module Lists
|
7
|
+
# Sends POST /lists request
|
8
|
+
module Create
|
9
|
+
class << self
|
10
|
+
# @param options [Hash]
|
11
|
+
# @return [Hash]
|
12
|
+
def call(options = {})
|
13
|
+
options = Castle::Utils::DeepSymbolizeKeys.call(options || {})
|
14
|
+
http = options.delete(:http)
|
15
|
+
config = options.delete(:config) || Castle.config
|
16
|
+
|
17
|
+
Castle::API.call(Castle::Commands::Lists::Create.build(options), {}, http, config)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Castle
|
4
|
+
module API
|
5
|
+
module Lists
|
6
|
+
# Sends DELETE /lists/:list_id request
|
7
|
+
module Delete
|
8
|
+
class << self
|
9
|
+
# @param options [Hash]
|
10
|
+
# @return [Hash]
|
11
|
+
def call(options = {})
|
12
|
+
options = Castle::Utils::DeepSymbolizeKeys.call(options || {})
|
13
|
+
http = options.delete(:http)
|
14
|
+
config = options.delete(:config) || Castle.config
|
15
|
+
|
16
|
+
Castle::API.call(Castle::Commands::Lists::Delete.build(options), {}, http, config)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Castle
|
4
|
+
module API
|
5
|
+
module Lists
|
6
|
+
# Sends GET /lists/:list_id request
|
7
|
+
module Get
|
8
|
+
class << self
|
9
|
+
# @param options [Hash]
|
10
|
+
# @return [Hash]
|
11
|
+
def call(options = {})
|
12
|
+
options = Castle::Utils::DeepSymbolizeKeys.call(options || {})
|
13
|
+
http = options.delete(:http)
|
14
|
+
config = options.delete(:config) || Castle.config
|
15
|
+
|
16
|
+
Castle::API.call(Castle::Commands::Lists::Get.build(options), {}, http, config)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Castle
|
4
|
+
module API
|
5
|
+
module Lists
|
6
|
+
# Sends GET /lists request
|
7
|
+
module GetAll
|
8
|
+
class << self
|
9
|
+
# @param options [Hash]
|
10
|
+
# @return [Hash]
|
11
|
+
def call(options = {})
|
12
|
+
options = Castle::Utils::DeepSymbolizeKeys.call(options || {})
|
13
|
+
http = options.delete(:http)
|
14
|
+
config = options.delete(:config) || Castle.config
|
15
|
+
|
16
|
+
Castle::API.call(Castle::Commands::Lists::GetAll.build, {}, http, config)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Castle
|
4
|
+
module API
|
5
|
+
module Lists
|
6
|
+
# Sends POST /lists/query request
|
7
|
+
module Query
|
8
|
+
class << self
|
9
|
+
# @param options [Hash]
|
10
|
+
# @return [Hash]
|
11
|
+
def call(options = {})
|
12
|
+
options = Castle::Utils::DeepSymbolizeKeys.call(options || {})
|
13
|
+
http = options.delete(:http)
|
14
|
+
config = options.delete(:config) || Castle.config
|
15
|
+
|
16
|
+
Castle::API.call(Castle::Commands::Lists::Query.build(options), {}, http, config)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Castle
|
4
|
+
module API
|
5
|
+
module Lists
|
6
|
+
# Sends PUT /lists/:list_id request
|
7
|
+
module Update
|
8
|
+
class << self
|
9
|
+
# @param options [Hash]
|
10
|
+
# @return [Hash]
|
11
|
+
def call(options = {})
|
12
|
+
options = Castle::Utils::DeepSymbolizeKeys.call(options || {})
|
13
|
+
http = options.delete(:http)
|
14
|
+
config = options.delete(:config) || Castle.config
|
15
|
+
|
16
|
+
Castle::API.call(Castle::Commands::Lists::Update.build(options), {}, http, config)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/castle/client.rb
CHANGED
@@ -3,6 +3,9 @@
|
|
3
3
|
module Castle
|
4
4
|
# Castle's client.
|
5
5
|
class Client
|
6
|
+
include Castle::ClientActions::ListItems
|
7
|
+
include Castle::ClientActions::Lists
|
8
|
+
|
6
9
|
class << self
|
7
10
|
def from_request(request, options = {})
|
8
11
|
new(options.merge(context: Castle::Context::Prepare.call(request, options)))
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Castle
|
4
|
+
# Namesapce for client actions
|
5
|
+
module ClientActions
|
6
|
+
# Client actions for list items
|
7
|
+
module ListItems
|
8
|
+
# @param options [Hash]
|
9
|
+
def archive_list_item(options = {})
|
10
|
+
Castle::API::ListItems::Archive.call(options)
|
11
|
+
end
|
12
|
+
|
13
|
+
# @param options [Hash]
|
14
|
+
def count_list_items(options = {})
|
15
|
+
Castle::API::ListItems::Count.call(options)
|
16
|
+
end
|
17
|
+
|
18
|
+
# @param options [Hash]
|
19
|
+
def create_list_item(options = {})
|
20
|
+
Castle::API::ListItems::Create.call(options)
|
21
|
+
end
|
22
|
+
|
23
|
+
# @param options [Hash]
|
24
|
+
def get_list_item(options = {})
|
25
|
+
Castle::API::ListItems::Get.call(options)
|
26
|
+
end
|
27
|
+
|
28
|
+
# @param options [Hash]
|
29
|
+
def query_list_items(options = {})
|
30
|
+
Castle::API::ListItems::Query.call(options)
|
31
|
+
end
|
32
|
+
|
33
|
+
# @param options [Hash]
|
34
|
+
def unarchive_list_item(options)
|
35
|
+
Castle::API::ListItems::Unarchive.call(options)
|
36
|
+
end
|
37
|
+
|
38
|
+
# @param options [Hash]
|
39
|
+
def update_list_item(options = {})
|
40
|
+
Castle::API::ListItems::Update.call(options)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Castle
|
4
|
+
# Namespace for client actions
|
5
|
+
module ClientActions
|
6
|
+
# Client actions for lists
|
7
|
+
module Lists
|
8
|
+
# @param options [Hash]
|
9
|
+
def create_list(options = {})
|
10
|
+
Castle::API::Lists::Create.call(options)
|
11
|
+
end
|
12
|
+
|
13
|
+
# @param options [Hash]
|
14
|
+
def delete_list(options = {})
|
15
|
+
Castle::API::Lists::Delete.call(options)
|
16
|
+
end
|
17
|
+
|
18
|
+
# @param options [Hash]
|
19
|
+
def get_all_lists(options = {})
|
20
|
+
Castle::API::Lists::GetAll.call(options)
|
21
|
+
end
|
22
|
+
|
23
|
+
# @param options [Hash]
|
24
|
+
def get_list(options = {})
|
25
|
+
Castle::API::Lists::Get.call(options)
|
26
|
+
end
|
27
|
+
|
28
|
+
# @param options [Hash]
|
29
|
+
def query_lists(options = {})
|
30
|
+
Castle::API::Lists::Query.call(options)
|
31
|
+
end
|
32
|
+
|
33
|
+
# @param options [Hash]
|
34
|
+
def update_list(options = {})
|
35
|
+
Castle::API::Lists::Update.call(options)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Castle
|
4
|
+
module Commands
|
5
|
+
# Commands for list items endpoints
|
6
|
+
module ListItems
|
7
|
+
# Generates the payload for the DELETE /lists/:list_id/items/:item_id/archive request
|
8
|
+
class Archive
|
9
|
+
class << self
|
10
|
+
# @param options [Hash]
|
11
|
+
# @return [Castle::Command]
|
12
|
+
def build(options = {})
|
13
|
+
Castle::Validators::Present.call(options, %i[list_id list_item_id])
|
14
|
+
|
15
|
+
list_id = options.delete(:list_id)
|
16
|
+
list_item_id = options.delete(:list_item_id)
|
17
|
+
|
18
|
+
Castle::Command.new("lists/#{list_id}/items/#{list_item_id}/archive", nil, :delete)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Castle
|
4
|
+
module Commands
|
5
|
+
module ListItems
|
6
|
+
# Generates the payload for the POST /lists/:list_id/items/count request
|
7
|
+
class Count
|
8
|
+
class << self
|
9
|
+
# @param options [Hash]
|
10
|
+
# @return [Castle::Command]
|
11
|
+
def build(options = {})
|
12
|
+
Castle::Validators::Present.call(options, %i[list_id])
|
13
|
+
options[:filters]&.each { |f| Castle::Validators::Present.call(f, %i[field op value]) }
|
14
|
+
|
15
|
+
list_id = options.delete(:list_id)
|
16
|
+
|
17
|
+
Castle::Command.new("lists/#{list_id}/items/count", options, :post)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Castle
|
4
|
+
module Commands
|
5
|
+
module ListItems
|
6
|
+
# Builds the command to create a list item
|
7
|
+
class Create
|
8
|
+
class << self
|
9
|
+
# @param options [Hash]
|
10
|
+
# @return [Castle::Command]
|
11
|
+
def build(options = {})
|
12
|
+
Castle::Validators::Present.call(options, %i[list_id author primary_value])
|
13
|
+
|
14
|
+
list_id = options.delete(:list_id)
|
15
|
+
|
16
|
+
Castle::Command.new("lists/#{list_id}/items", options, :post)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Castle
|
4
|
+
module Commands
|
5
|
+
module ListItems
|
6
|
+
# Builds the command to get a list item
|
7
|
+
class Get
|
8
|
+
class << self
|
9
|
+
# @param options [Hash]
|
10
|
+
# @return [Castle::Command]
|
11
|
+
def build(options = {})
|
12
|
+
Castle::Validators::Present.call(options, %i[list_id list_item_id])
|
13
|
+
|
14
|
+
list_id = options.delete(:list_id)
|
15
|
+
list_item_id = options.delete(:list_item_id)
|
16
|
+
|
17
|
+
Castle::Command.new("lists/#{list_id}/items/#{list_item_id}", nil, :get)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Castle
|
4
|
+
module Commands
|
5
|
+
module ListItems
|
6
|
+
# Builds the command to query list items
|
7
|
+
class Query
|
8
|
+
class << self
|
9
|
+
# @param options [Hash]
|
10
|
+
# @return [Castle::Command]
|
11
|
+
def build(options = {})
|
12
|
+
Castle::Validators::Present.call(options, %i[list_id])
|
13
|
+
options[:filters]&.each { |f| Castle::Validators::Present.call(f, %i[field op value]) }
|
14
|
+
Castle::Validators::Present.call(options[:sort], %i[field order]) if options[:sort]
|
15
|
+
|
16
|
+
list_id = options.delete(:list_id)
|
17
|
+
|
18
|
+
Castle::Command.new("lists/#{list_id}/items/query", options, :post)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Castle
|
4
|
+
module Commands
|
5
|
+
module ListItems
|
6
|
+
# Builds the command to unarchive a list item
|
7
|
+
class Unarchive
|
8
|
+
class << self
|
9
|
+
# @param options [Hash]
|
10
|
+
# @return [Castle::Command]
|
11
|
+
def build(options = {})
|
12
|
+
Castle::Validators::Present.call(options, %i[list_id list_item_id])
|
13
|
+
|
14
|
+
list_id = options.delete(:list_id)
|
15
|
+
list_item_id = options.delete(:list_item_id)
|
16
|
+
|
17
|
+
Castle::Command.new("lists/#{list_id}/items/#{list_item_id}/unarchive", nil, :put)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Castle
|
4
|
+
module Commands
|
5
|
+
module ListItems
|
6
|
+
# Builds the command to update a list item
|
7
|
+
class Update
|
8
|
+
class << self
|
9
|
+
# @param options [Hash]
|
10
|
+
# @return [Castle::Command]
|
11
|
+
def build(options = {})
|
12
|
+
Castle::Validators::Present.call(options, %i[list_id list_item_id comment])
|
13
|
+
list_id = options.delete(:list_id)
|
14
|
+
list_item_id = options.delete(:list_item_id)
|
15
|
+
|
16
|
+
Castle::Command.new("lists/#{list_id}/items/#{list_item_id}", options, :put)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Castle
|
4
|
+
module Commands
|
5
|
+
# Commands for lists endpoints
|
6
|
+
module Lists
|
7
|
+
# Builds the command to create a list
|
8
|
+
class Create
|
9
|
+
class << self
|
10
|
+
# @param options [Hash]
|
11
|
+
# @return [Castle::Command]
|
12
|
+
def build(options = {})
|
13
|
+
Castle::Validators::Present.call(options, %i[name color primary_field])
|
14
|
+
|
15
|
+
Castle::Command.new('lists', options, :post)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Castle
|
4
|
+
module Commands
|
5
|
+
module Lists
|
6
|
+
# Builds the command to delete a list
|
7
|
+
class Delete
|
8
|
+
class << self
|
9
|
+
# @param options [Hash]
|
10
|
+
# @return [Castle::Command]
|
11
|
+
def build(options = {})
|
12
|
+
Castle::Validators::Present.call(options, %i[list_id])
|
13
|
+
|
14
|
+
Castle::Command.new("lists/#{options[:list_id]}", nil, :delete)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Castle
|
4
|
+
module Commands
|
5
|
+
module Lists
|
6
|
+
# Builds the command to get a list
|
7
|
+
class Get
|
8
|
+
class << self
|
9
|
+
# @param options [Hash]
|
10
|
+
# @return [Castle::Command]
|
11
|
+
def build(options = {})
|
12
|
+
Castle::Validators::Present.call(options, %i[list_id])
|
13
|
+
|
14
|
+
Castle::Command.new("lists/#{options[:list_id]}", nil, :get)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Castle
|
4
|
+
module Commands
|
5
|
+
module Lists
|
6
|
+
# Builds the command to get all lists
|
7
|
+
class GetAll
|
8
|
+
class << self
|
9
|
+
# @return [Castle::Command]
|
10
|
+
def build
|
11
|
+
Castle::Command.new('lists', nil, :get)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|