Sha256: 44053ed7844357ae317ab1b3dd9900b909dc9eb31547171b48543cff22675dfd

Contents?: true

Size: 1.5 KB

Versions: 1

Compression:

Stored size: 1.5 KB

Contents

# frozen_string_literal: true

module Monday
  module Resources
    # Represents Monday.com's workspace resource.
    module Workspace
      DEFAULT_SELECT = %w[id name description].freeze

      # Retrieves all the workspaces.
      #
      # Allows filtering workspaces using the args option.
      # Allows customizing the values to retrieve using the select option.
      # By default, ID, name and description fields are retrieved.
      def workspaces(args: {}, select: DEFAULT_SELECT)
        query = "query { workspaces#{Util.format_args(args)} {#{Util.format_select(select)}}}"

        make_request(query)
      end

      # Creates a new workspaces.
      #
      # Allows customizing creating a workspace using the args option.
      # Allows customizing the values to retrieve using the select option.
      # By default, ID, name and description fields are retrieved.
      def create_workspace(args: {}, select: DEFAULT_SELECT)
        query = "mutation { create_workspace#{Util.format_args(args)} {#{Util.format_select(select)}}}"

        make_request(query)
      end

      # Deletes a workspace.
      #
      # Requires workspace_id to delete the workspace.
      # Allows customizing the values to retrieve using the select option.
      # By default, returns the ID of the workspace deleted.
      def delete_workspace(workspace_id, select: ["id"])
        query = "mutation { delete_workspace(workspace_id: #{workspace_id}) {#{Util.format_select(select)}}}"

        make_request(query)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
monday_ruby-0.6.2 lib/monday/resources/workspace.rb