teleflow 2.0.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.
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ # TODO: add rubocop back to default task once all offenses are corrected
13
+ task default: %i[spec]
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Teleflow
4
+ class Api
5
+ # Module Teleflow::Api::Blueprints provides an API for managing templated for notifications that are sent out in the Teleflow application.
6
+ #
7
+ # This module includes methods for retrieving blueprints by templateID and grouping blueprints by category.
8
+ #
9
+ # For more information on the Teleflow Blueprint API, see https://docs.teleflow.khulnasoft.com/api/get-messages/.
10
+ module Blueprints
11
+ # Returns the details of a particular template
12
+ #
13
+ # @pathParams
14
+ # @param `template_id` [String]
15
+ #
16
+ # @return [Hash] The list of properties that pertains to the template e.g. _id, name, description, active, draft, preferenceSettings, and many others.
17
+ # @return [number] status
18
+ # - Returns 200 if successful
19
+ def get_blueprint(template_id)
20
+ get("/blueprints/#{template_id}")
21
+ end
22
+
23
+ # Get V1blueprintsgroup by Category
24
+ def group_blueprints_by_category
25
+ get("/blueprints/group-by-category")
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Teleflow
4
+ class Api
5
+ # Module Teleflow::Api::Changes provides an API for managing changes in the Teleflow application.
6
+ #
7
+ # This module includes methods for retrieving, count, and applying bulk changes.
8
+ #
9
+ # For more information on the Teleflow API(https://api-teleflow.khulnasoft.com/api#/Changes), see https://docs.teleflow.khulnasoft.com/api/get-changes/.
10
+ module Changes
11
+ # Returns a list of changes that can be paginated using the `page` query parameter
12
+ #
13
+ # @queryparams:
14
+ # @param `page` [Integer(optional)] Number of page for the pagination.
15
+ # @param `limit` [Integer(optional)]
16
+ # @param `promoted` [String]
17
+ #
18
+ # @return [Hash] The list of changes that match the criteria of the query params are successfully returned.
19
+ # @return [number] status
20
+ # - Returns 200 if successful
21
+ def changes(query = {})
22
+ get("/changes", query: query)
23
+ end
24
+
25
+ # Returns changes count
26
+ #
27
+ # @return [Hash] changes count
28
+ # @return [number] status
29
+ # - Returns 200 if successful
30
+ def count_changes
31
+ get("/changes/count")
32
+ end
33
+
34
+ # Apply Bulk Change
35
+ #
36
+ # @bodyParams
37
+ # @param changeIds [Array] The list of environment IDs to apply changes to.
38
+ # @return [Hash] updated change.
39
+ # @return [number] status
40
+ # - Returns 201 if the bulk change has been updated correctly.
41
+ def apply_bulk_changes(changeIds)
42
+ post("/changes/bulk/apply", body: changeIds)
43
+ end
44
+
45
+ # Apply change
46
+ #
47
+ # @pathparams:
48
+ # @param `change_id` [Integer] The ID of the change to update.
49
+ #
50
+ # @return [Hash] updated change.
51
+ # @return [number] status
52
+ # - Returns 201 if the change with the change_id provided has been updated correctly.
53
+ def apply_change(change_id)
54
+ post("/changes/#{change_id}/apply")
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Teleflow
4
+ class Api
5
+ module Connection
6
+
7
+ def get(path, options = {})
8
+ request :get, path, options
9
+ end
10
+
11
+ def post(path, options = {})
12
+ request :post, path, options
13
+ end
14
+
15
+ def put(path, options = {})
16
+ request :put, path, options
17
+ end
18
+
19
+ def patch(path, options = {})
20
+ request :patch, path, options
21
+ end
22
+
23
+ def delete(path, options = {})
24
+ request :delete, path, options
25
+ end
26
+
27
+ private
28
+
29
+ # Send API Request
30
+ #
31
+ # It applies exponential backoff strategy (if enabled) for failed requests.
32
+ # It also performs an idempotent request to safely retry requests without having duplication operations.
33
+ #
34
+ def request(http_method, path, options)
35
+
36
+ if http_method.to_s == 'post' || http_method.to_s == 'patch'
37
+ self.class.default_options[:headers].merge!({ "Idempotency-Key" => "#{@idempotency_key.to_s.strip}" })
38
+ end
39
+
40
+ response = self.class.send(http_method, path, options)
41
+
42
+ if ! [401, 403, 409, 500, 502, 503, 504].include?(response.code) && ! @enable_retry
43
+ response
44
+ elsif @enable_retry
45
+
46
+ if @retry_attempts < @max_retries
47
+ @retry_attempts += 1
48
+
49
+ @backoff.intervals.each do |interval|
50
+ sleep(interval)
51
+ request(http_method, path, options)
52
+ end
53
+ else
54
+ raise StandardError, "Max retry attempts reached"
55
+ end
56
+ else
57
+ response
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,91 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Teleflow
4
+ class Api
5
+ # Module Teleflow::Api::Environments provides an API for managing environments in the Teleflow application.
6
+ #
7
+ # This module includes methods for creating, retrieving, and updating environments.
8
+ # It also includes methods for getting and regenerating the api keys also for updatation of widget settings .
9
+ #
10
+ # For more information on the Teleflow API(https://api-teleflow.khulnasoft.com/api#/Environments), see https://docs.teleflow.khulnasoft.com/api/get-current-environment/.
11
+ module Environments
12
+ # Retrieves the current environment
13
+ #
14
+ # @return [Hash] The retrieved environment.
15
+ # @return [number] status
16
+ # - Returns 200 if successful
17
+ def current_environment
18
+ get("/environments/me")
19
+ end
20
+
21
+ # Creates a new environment.
22
+ #
23
+ # @bodyparams:
24
+ # @param `name` [String]
25
+ # @param `parentId` [String(optional)]
26
+ #
27
+ # @return [Hash] The created environment entity.
28
+ # @return [number] status - The status code. Returns 201 if the environment has been successfully created.
29
+ def create_environment(body)
30
+ post("/environments", body: body)
31
+ end
32
+
33
+ # Returns a list of environments
34
+ #
35
+ # @return [Hash] The list of environments.
36
+ # @return [number] status
37
+ # - Returns 200 if successful
38
+ def environments
39
+ get("/environments")
40
+ end
41
+
42
+ # Update the environment.
43
+ #
44
+ # @pathparams:
45
+ # @param `environment_id` [String] The ID of the environment to update.
46
+ #
47
+ # @bodyparams
48
+ # @param `name` [String(optional)]
49
+ # @param `identifier` [String(optional)]
50
+ # @param `parentId` [String(optional)]
51
+ # @param `dns` [Hash]
52
+ #
53
+ # @return [Hash] The updated environment.
54
+ # @return [number] status
55
+ # - Returns 200 if the environment with the environment_id provided has been updated correctly.
56
+ def update_environment(environment_id, body)
57
+ put("/environments/#{environment_id}", body: body)
58
+ end
59
+
60
+ # Returns a list of api keys
61
+ #
62
+ # @return [Hash] The list of api keys.
63
+ # @return [number] status
64
+ # - Returns 200 if successful
65
+ def api_keys
66
+ get("/environments/api-keys")
67
+ end
68
+
69
+ # Return regenerated api keys
70
+ #
71
+ # @return [Hash] Api keys.
72
+ # @return [number] status
73
+ # - Returns 200 if successful
74
+ def regenerate_api_keys
75
+ post("/environments/api-keys/regenerate")
76
+ end
77
+
78
+ # Update the widget settings.
79
+ #
80
+ # @bodyparams
81
+ # @param `notificationCenterEncryption` [Boolean]
82
+ #
83
+ # @return [Hash] The updated environment entity.
84
+ # @return [number] status
85
+ # - Returns 200 if the environment entity updated.
86
+ def update_widget_settings(body)
87
+ put("/environments/widget/settings", body: body)
88
+ end
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Teleflow
4
+ class Api
5
+ # Module Teleflow::Api::Events provides an API for managing events in the Teleflow application.
6
+ #
7
+ # This module includes methods for trigger, bulk trigger, broadcast and cancel events.
8
+ #
9
+ # For more information on the Teleflow API(https://api-teleflow.khulnasoft.com/api#/Events), see https://docs.teleflow.khulnasoft.com/api/trigger-event/.
10
+ module Events
11
+ # Trigger event is the main (and the only) way to send notification to subscribers.
12
+ # The trigger identifier is used to match the particular template associated with it.
13
+ # Additional information can be passed according the body interface below
14
+ #
15
+ # @bodyparams:
16
+ # @param `name` [String] The trigger identifier of the template you wish to send. This identifier can be found on the template page.
17
+ # @param `payload` [Hash] The payload object is used to pass additional custom information that could be used to render the template, or perform routing rules based on it. This data will also be available when fetching the notifications feed from the API to display certain parts of the UI.
18
+ # @param `overrides` [Hash(optional)] This could be used to override provider specific configurations.
19
+ # @param `to` [Hash] The recipients list of people who will receive the notification.
20
+ # @param `transactionId` [String(optional)] A unique identifier for this transaction, we will generated a UUID if not provided.
21
+ # @param `actor` [Hash(optional)] It is used to display the Avatar of the provided actor's subscriber id or actor object. If a new actor object is provided, we will create a new subscriber in our system
22
+ #
23
+ # @return [Hash]
24
+ # - acknowledged [Boolean] - If trigger was acknowledged or not
25
+ # - status [String] - Status for trigger
26
+ # - error [Array(optional)] - In case of an error, this field will contain the error message
27
+ # - transactionId [String(optional)] - Transaction id for trigger
28
+ # @return [number] status - The status code. Returns 201 if the event has been successfully triggered.
29
+ def trigger_event(body)
30
+ post("/events/trigger", body: body)
31
+ end
32
+
33
+ # Using this endpoint you can trigger multiple events at once, to avoid multiple calls to the API.
34
+ # The bulk API is limited to 100 events per request.
35
+ #
36
+ # @bodyparams:
37
+ # @param `events` [Array[event]]
38
+ # @event : event structure
39
+ # @param `name` [String] The trigger identifier of the template you wish to send. This identifier can be found on the template page.
40
+ # @param `payload` [Hash] The payload object is used to pass additional custom information that could be used to render the template, or perform routing rules based on it. This data will also be available when fetching the notifications feed from the API to display certain parts of the UI.
41
+ # @param `overrides` [Hash(optional)] This could be used to override provider specific configurations.
42
+ # @param `to` [Hash] The recipients list of people who will receive the notification.
43
+ # @param `transactionId` [String(optional)] A unique identifier for this transaction, we will generated a UUID if not provided.
44
+ # @param `actor` [Hash(optional)] It is used to display the Avatar of the provided actor's subscriber id or actor object. If a new actor object is provided, we will create a new subscriber in our system
45
+ #
46
+ # @return [Hash]
47
+ # - acknowledged [Boolean] - If trigger was acknowledged or not
48
+ # - status [String] - Status for trigger
49
+ # - error [Array(optional)] - In case of an error, this field will contain the error message
50
+ # - transactionId [String(optional)] - Transaction id for trigger
51
+ # @return [number] status - The status code. Returns 201 if the event has been successfully triggered.
52
+ def trigger_bulk_event(body)
53
+ post("/events/trigger/bulk", body: body.to_json, headers: {'Content-Type': 'application/json'})
54
+ end
55
+
56
+ # Trigger a broadcast event to all existing subscribers, could be used to send announcements, etc.
57
+ # In the future could be used to trigger events to a subset of subscribers based on defined filters.
58
+ #
59
+ # @bodyparams:
60
+ # @param `name` [String] The trigger identifier associated for the template you wish to send. This identifier can be found on the template page.
61
+ # @param `payload` [Hash] The payload object is used to pass additional custom information that could be used to render the template, or perform routing rules based on it. This data will also be available when fetching the notifications feed from the API to display certain parts of the UI
62
+ # @param `overrides` [Hash(optional)] This could be used to override provider specific configurations.
63
+ # @param `transactionId` [String(optional)] A unique identifier for this transaction, we will generated a UUID if not provided.
64
+ # @param `actor` [Hash(optional)] It is used to display the Avatar of the provided actor's subscriber id or actor object. If a new actor object is provided, we will create a new subscriber in our system
65
+ #
66
+ # @return [Hash]
67
+ # - acknowledged [Boolean] - If trigger was acknowledged or not
68
+ # - status [String] - Status for trigger
69
+ # - error [Array(optional)] - In case of an error, this field will contain the error message
70
+ # - transactionId [String(optional)] - Transaction id for trigger
71
+ # @return [number] status - The status code. Returns 201 if the event has been successfully broadcast to all existing subscribers.
72
+ def broadcast_event(body)
73
+ post("/events/trigger/broadcast", body: body)
74
+ end
75
+
76
+ # Using a previously generated transactionId during the event trigger, will cancel any active or pending workflows.
77
+ # This is useful to cancel active digests, delays etc...
78
+ #
79
+ # @pathparams:
80
+ # @param `transactionId` [String] - transaction id of the event
81
+ #
82
+ # @return [number] status - The status code. Returns 200 if the event has been successfully cancelled.
83
+ def cancel_triggered_event(transaction_id)
84
+ delete("/events/trigger/#{transaction_id}")
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Teleflow
4
+ class Api
5
+ # Module Teleflow::Api::ExecutionDetails provides an API for managing execution details in the Teleflow application.
6
+ #
7
+ # This module includes method for retrieving execution details.
8
+ #
9
+ # For more information on the Teleflow API(https://api-teleflow.khulnasoft.com/api#/Execution%20Details), see https://docs.teleflow.khulnasoft.com/api/get-execution-details/.
10
+ module ExecutionDetails
11
+ # Returns a list of execution details
12
+ #
13
+ # @queryparams:
14
+ # @param `notificationId` [String]
15
+ # @param `subscriberId` [String]
16
+ #
17
+ # @return [Hash] The list of execution details that match the criteria of the query params are successfully returned.
18
+ # @return [number] status
19
+ # - Returns 200 if successful
20
+ def execution_details(query = {})
21
+ get("/execution-details", query: query)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Teleflow
4
+ class Api
5
+ # Module Teleflow::Api::Feeds provides an API for managing feeds in the Teleflow application.
6
+ #
7
+ # This module includes methods for creating, retrieving, and deleting feeds.
8
+ #
9
+ # For more information on the Teleflow API(https://api-teleflow.khulnasoft.com/api#/Feeds), see https://docs.teleflow.khulnasoft.com/api/create-feed/.
10
+ module Feeds
11
+ # Creates a new feed.
12
+ #
13
+ # @bodyparams:
14
+ # @param `name` [String]
15
+ #
16
+ # @return [Hash] Feed entity.
17
+ # @return [number] status - The status code. Returns 201 if the feed has been successfully created.
18
+ def create_feed(body)
19
+ post("/feeds", body: body)
20
+ end
21
+
22
+ # Returns a list of feeds
23
+ #
24
+ # @return [Hash] list of feeds
25
+ # @return [number] status
26
+ # - Returns 200 if successful
27
+ def feeds
28
+ get("/feeds")
29
+ end
30
+
31
+ # Execute a soft delete of a feed given a certain ID.
32
+ #
33
+ # @pathparams:
34
+ # @param `feed_id` [String] The ID of the feed to delete.
35
+ #
36
+ # @return [Hash] The retrieved feed.
37
+ # @return [number] status
38
+ # - Returns 204 if the feed has been deleted correctly.
39
+ def delete_feed(feed_id)
40
+ delete("/feeds/#{feed_id}")
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Teleflow
4
+ class Api
5
+ # Module Teleflow::Api::InboundParse provides an API for managing inbound-parse in the Teleflow application.
6
+ #
7
+ # This module includes method for retrieving inbound-parse.
8
+ #
9
+ # For more information on the Teleflow API(https://api-teleflow.khulnasoft.com/api#/inbound-parse), see https://docs.teleflow.khulnasoft.com/api/overview/.
10
+ module InboundParse
11
+ # Validate the mx record setup for the inbound parse functionality
12
+ def validate_mx_record_setup_for_inbound_parse
13
+ get("/inbound-parse/mx/status")
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,116 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Teleflow
4
+ class Api
5
+ # Module Teleflow::Api::Integrations provides an API for managing integrations in the Teleflow application.
6
+ #
7
+ # This module includes methods for creating, retrieving, updating, and deleting integrations.
8
+ # It also includes methods for retrieving channel limit, in-app status, webhook provider status.
9
+ #
10
+ # For more information on the Teleflow API(https://api-teleflow.khulnasoft.com/api#/Integrations), see https://docs.teleflow.khulnasoft.com/api/get-integrations/.
11
+ module Integrations
12
+ # Returns a list of integrations
13
+ #
14
+ # @return [Hash] The list of integrations.
15
+ # @return [number] status
16
+ # - Returns 200 if successful
17
+ def integrations
18
+ get("/integrations")
19
+ end
20
+
21
+ # Creates a new integration.
22
+ #
23
+ # @bodyparams:
24
+ # @param `providerId` [String]
25
+ # @param `channel` [String]
26
+ # @param `credentials` [Hash]
27
+ # @param `active` [Boolean]
28
+ # @param `check` [Boolean]
29
+ #
30
+ # @return [Hash] The created integration entity.
31
+ # @return [number] status - The status code. Returns 201 if the intgration has been successfully created.
32
+ def create_integration(body)
33
+ post("/integrations", body: body)
34
+ end
35
+
36
+ # Returns a list of active integrations
37
+ #
38
+ # @return [Hash] The list of active integrations.
39
+ # @return [number] status
40
+ # - Returns 200 if successful
41
+ def active_integrations
42
+ get("/integrations/active")
43
+ end
44
+
45
+ # Get webhook support status for provider
46
+ #
47
+ # @pathparams
48
+ # @param `provider_id` [String]
49
+ #
50
+ # @return [number] status
51
+ # - Returns 200 if successful
52
+ def webhook_provider_status(provider_id)
53
+ get("/integrations/webhook/provider/#{provider_id}/status")
54
+ end
55
+
56
+ # Update the credentials of a integration.
57
+ #
58
+ # @pathparams:
59
+ # @param `integration_id` [Integer] The ID of the integration to update.
60
+ #
61
+ # @bodyparams
62
+ # @param `active` [Boolean]
63
+ # @param `credentials` [Hash]
64
+ # @param `check` [Boolean]
65
+ #
66
+ # @return [Hash] The updated intgration.
67
+ # @return [number] status
68
+ # - Returns 200 if the integration with the integrationId provided has been updated correctly.
69
+ def update_integration(integration_id, body)
70
+ put("/integrations/#{integration_id}", body: body)
71
+ end
72
+
73
+ # Execute a soft delete of a integration given a certain ID.
74
+ #
75
+ # @pathparams:
76
+ # @param `integration_id` [Integer] The ID of the integration to delete.
77
+ #
78
+ # @return [Hash] The retrieved integration.
79
+ # @return [number] status
80
+ # - Returns 200 if the integration has been deleted correctly.
81
+ def delete_integration(integration_id)
82
+ delete("/integrations/#{integration_id}")
83
+ end
84
+
85
+ # Returns a channel limit
86
+ #
87
+ # @pathparams
88
+ # @param `channel_type` [String]
89
+ #
90
+ # @return [number] status
91
+ # - Returns 200 if successful
92
+ def channel_limit(channel_type)
93
+ get("/integrations/#{channel_type}/limit")
94
+ end
95
+
96
+ # Returns in-app status
97
+ #
98
+ # @return [number] status
99
+ # - Returns 200 if successful
100
+ def in_app_status
101
+ get("/integrations/in-app/status")
102
+ end
103
+
104
+ # Set integration as primary
105
+ #
106
+ # @pathparams
107
+ # @param `integration_id` [String]
108
+ #
109
+ # @return [number] status
110
+ # - Returns 200 if successful
111
+ def set_integration_as_primary(integration_id)
112
+ post("/integrations/#{integration_id}/set-primary")
113
+ end
114
+ end
115
+ end
116
+ end
@@ -0,0 +1,106 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Teleflow
4
+ class Api
5
+ # Module Teleflow::Api::Layouts provides an API for managing layouts in the Teleflow application.
6
+ #
7
+ # This module includes methods for creating, retrieving, updating, and deleting layouts.
8
+ # It also includes methods for setting and getting the default layout.
9
+ #
10
+ # For more information on the Teleflow API(https://api-teleflow.khulnasoft.com/api#/Layouts), see https://docs.teleflow.khulnasoft.com/api/layout-creation/.
11
+ module Layouts
12
+ # Creates a new layout.
13
+ #
14
+ # @bodyparams:
15
+ # @param `name` [String] User defined custom name and provided by the user that will name the Layout created.
16
+ # @param `content` [String] User defined content for the layout.
17
+ # @param `description` [String(optional)] User description of the layout.
18
+ # @param `variables` [Array(optional)] User defined variables to render in the layout placeholders.
19
+ # @param `isDefault` [Boolean(optional)] User defined variables to render in the layout placeholders.
20
+ #
21
+ # @return [_id: "_id"] The created layout id.
22
+ # @return [number] status - The status code. Returns 201 if the layout has been successfully created.
23
+ def create_layout(body)
24
+ post("/layouts", body: body)
25
+ end
26
+
27
+ # Returns a list of layouts that can be paginated using the `page` query parameter and
28
+ # filtered by the environment where it is executed from the organization the user belongs to.
29
+ #
30
+ # @queryparams:
31
+ # @param `page` [Integer(optional)] Number of page for the pagination.
32
+ # @param `pageSize` [Integer(optional)] Size of page for the pagination.
33
+ # @param `sortBy` [String(optional)] Sort field. Currently only supported `createdAt`.
34
+ # @param `orderBy` [Integer(optional)] Direction of the sorting query param. Either ascending (1) or descending (-1).
35
+ #
36
+ # @return [Hash] The list of layouts that match the criteria of the query params are successfully returned.
37
+ # @return [number] status
38
+ # - Returns 200 if successful
39
+ # - Returns 400 if Page size can not be larger than the page size limit.
40
+ def layouts(query = {})
41
+ get("/layouts", query: query)
42
+ end
43
+
44
+ # Retrieves the layout with the given ID.
45
+ #
46
+ # @pathparams
47
+ # @param `layout_id` [Integer] The ID of the layout to retrieve.
48
+ #
49
+ # @return [Hash] The retrieved layout.
50
+ # @return [number] status
51
+ # - Returns 200 if the layout with the layoutId provided exists in the database.
52
+ # - Returns 404 The layout with the layoutId provided does not exist in the database.
53
+ def layout(layout_id)
54
+ get("/layouts/#{layout_id}")
55
+ end
56
+
57
+ # Execute a soft delete of a layout given a certain ID.
58
+ #
59
+ # @pathparams:
60
+ # @param `layout_id` [Integer] The ID of the layout to delete.
61
+ #
62
+ # @return [Hash] The retrieved layout.
63
+ # @return [number] status
64
+ # - Returns 204 if the layout has been deleted correctly.
65
+ # - Returns 404 if the layout with the layoutId provided does not exist in the database so it can not be deleted.
66
+ # - Returns 409 if either you are trying to delete a layout that is being used or a layout that is the default in the environment.
67
+ def delete_layout(layout_id)
68
+ delete("/layouts/#{layout_id}")
69
+ end
70
+
71
+ # Update the name, content and variables of a layout. Also change it to be default or no.
72
+ #
73
+ # @pathparams:
74
+ # @param `layout_id` [Integer] The ID of the layout to update.
75
+ #
76
+ # @bodyparams
77
+ # @param `name` [String(optional)] User defined custom name and provided by the user that will name the Layout updated.
78
+ # @param `description` [String(optional)] User defined description of the layout.
79
+ # @param `content` [String(optional)] User defined content for the layout.
80
+ # @param `variables` [Array(optional)] User defined variables to render in the layout placeholders.
81
+ # @param `isDefault` [Boolean(optional)] Variable that defines if the layout is chosen as default when creating a layout.
82
+ #
83
+ # @return [Hash] The updated layout.
84
+ # @return [number] status
85
+ # - Returns 200 if the layout with the layoutId provided has been updated correctly.
86
+ # - Returns 400 if the payload provided or the URL param are not right.
87
+ # - Returns 404 if the layout with the layoutId provided does not exist in the database so it can not be updated.
88
+ # - Returns 409 if one default layout is needed. If you are trying to turn a default layout as not default, you should turn a different layout as default first and automatically it will be done by the system.
89
+ def update_layout(layout_id, body)
90
+ patch("/layouts/#{layout_id}", body: body)
91
+ end
92
+
93
+ # Sets the default layout for the environment and updates to non default to the existing default layout (if any).
94
+ #
95
+ # @pathparams:
96
+ # @param `layout_id` [Integer] The ID of the layout to set the default.
97
+ #
98
+ # @return [number] status
99
+ # - Returns 204 if the selected layout has been set as the default for the environment.
100
+ # - Returns 404 if the layout with the layoutId provided does not exist in the database so it can not be set as the default for the environment.
101
+ def make_default_layout(layout_id)
102
+ post("/layouts/#{layout_id}/default")
103
+ end
104
+ end
105
+ end
106
+ end