monday_ruby 0.6.2 → 1.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.
- checksums.yaml +4 -4
- data/.env +1 -1
- data/CHANGELOG.md +20 -0
- data/README.md +22 -51
- data/lib/monday/client.rb +14 -11
- data/lib/monday/resources/account.rb +6 -4
- data/lib/monday/resources/activity_log.rb +7 -5
- data/lib/monday/resources/base.rb +20 -0
- data/lib/monday/resources/board.rb +19 -17
- data/lib/monday/resources/board_view.rb +6 -4
- data/lib/monday/resources/column.rb +22 -20
- data/lib/monday/resources/group.rb +18 -16
- data/lib/monday/resources/item.rb +15 -13
- data/lib/monday/resources/subitem.rb +8 -6
- data/lib/monday/resources/update.rb +13 -11
- data/lib/monday/resources/workspace.rb +10 -8
- data/lib/monday/resources.rb +16 -20
- data/lib/monday/util.rb +1 -0
- data/lib/monday/version.rb +1 -1
- data/monday_ruby.gemspec +2 -0
- metadata +19 -43
- data/docs/README.md +0 -13
- data/docs/SUMMARY.md +0 -40
- data/docs/client.md +0 -15
- data/docs/configuration.md +0 -40
- data/docs/error-handling.md +0 -71
- data/docs/getting-started.md +0 -25
- data/docs/quick-start.md +0 -269
- data/docs/resources/README.md +0 -27
- data/docs/resources/account/README.md +0 -9
- data/docs/resources/account/accounts.md +0 -82
- data/docs/resources/activity-log/README.md +0 -9
- data/docs/resources/activity-log/activity_logs.md +0 -95
- data/docs/resources/board/README.md +0 -21
- data/docs/resources/board/archive_board.md +0 -79
- data/docs/resources/board/boards.md +0 -96
- data/docs/resources/board/create_board.md +0 -95
- data/docs/resources/board/delete_board.md +0 -79
- data/docs/resources/board/delete_board_subscribers.md +0 -87
- data/docs/resources/board/duplicate_board.md +0 -94
- data/docs/resources/board/update_board.md +0 -91
- data/docs/resources/board-view/README.md +0 -9
- data/docs/resources/board-view/board_views.md +0 -88
- data/docs/resources/column/README.md +0 -25
- data/docs/resources/column/change_column_metadata.md +0 -70
- data/docs/resources/column/change_column_title.md +0 -68
- data/docs/resources/column/change_column_value.md +0 -73
- data/docs/resources/column/change_multiple_column_value.md +0 -81
- data/docs/resources/column/change_simple_column_value.md +0 -69
- data/docs/resources/column/column_values.md +0 -115
- data/docs/resources/column/columns.md +0 -117
- data/docs/resources/column/create_column.md +0 -70
- data/docs/resources/column/delete_column.md +0 -58
- data/docs/resources/item/README.md +0 -17
- data/docs/resources/item/archive_item.md +0 -80
- data/docs/resources/item/create_item.md +0 -105
- data/docs/resources/item/delete_item.md +0 -80
- data/docs/resources/item/duplicate_item.md +0 -87
- data/docs/resources/item/items.md +0 -95
- data/docs/response.md +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e8164389fc7acb67d40bee3bf79a9768e1256833268e5ef8002c6d9392a5b75
|
4
|
+
data.tar.gz: 29165f3538b8658267944fd2ea91f2bbdf11c916c7967e17cfe55e27397959c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f21b44ba54e5c14513cd7f39b6709126fe1a5e54a00468da76fc2275230d9a01e7cf4844ae5035bf8777dacd8153ee7571a8a53a3491b6bf4366b47ea324d6ce
|
7
|
+
data.tar.gz: bbaee28c405107767469f7a9386c7d2b991b4e877ccc3b476a360837ca25bb776aee2d05579ef4aa641b74b747cafe2fb73dc72836dd6b8264f61d4982b36729
|
data/.env
CHANGED
@@ -1 +1 @@
|
|
1
|
-
token="
|
1
|
+
token="eyJhbGciOiJIUzI1NiJ9.eyJ0aWQiOjM4MTE3NTY1MywiYWFpIjoxMSwidWlkIjo2MzEzMDMxMiwiaWFkIjoiMjAyNC0wNy0wN1QxMzo0OTo0Mi4wMzJaIiwicGVyIjoibWU6d3JpdGUiLCJhY3RpZCI6MjQzMDgwODMsInJnbiI6InVzZTEifQ.AKgwPueXJkzm9d0I9y4DzSKBwJ3Vi3t8IsOc2hpyDtk"
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
## v1.0.0 (July 30, 2024)
|
2
|
+
|
3
|
+
### Changed
|
4
|
+
|
5
|
+
- **Refactor: Flat API replaced by Resource Classes**
|
6
|
+
- The client now uses a modular approach with resource classes instead of a flat API.
|
7
|
+
- Introduced a `Base` class for resources to encapsulate common functionality.
|
8
|
+
- All resource-specific logic is now encapsulated within individual resource classes (e.g., `Account`, `Board`).
|
9
|
+
|
10
|
+
### Added
|
11
|
+
|
12
|
+
- Support for enums
|
13
|
+
|
14
|
+
### Breaking Changes
|
15
|
+
|
16
|
+
- **Accessing Resources**:
|
17
|
+
- The way resources are accessed has changed.
|
18
|
+
- **Old**: `client.account`, `client.create_board`
|
19
|
+
- **New**: `client.accounts.query`, `client.board.create`
|
20
|
+
|
1
21
|
## v0.6.2 (April 21, 2024)
|
2
22
|
|
3
23
|
### Bug Fixes
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
[](https://badge.fury.io/rb/monday_ruby)
|
5
5
|
[](https://coveralls.io/github/sanifhimani/monday_ruby?branch=main)
|
6
6
|
|
7
|
-
This library provides convenient access to the monday.com API from the application written in
|
7
|
+
This library provides convenient access to the monday.com API from the application written in Ruby.
|
8
8
|
|
9
9
|
The library provides:
|
10
10
|
|
@@ -12,39 +12,17 @@ The library provides:
|
|
12
12
|
2. Easy configuration path for fast setup and use.
|
13
13
|
3. Easy error handling.
|
14
14
|
|
15
|
-
**
|
15
|
+
**Check out the [Wiki](https://github.com/sanifhimani/monday_ruby/wiki) for detailed documentation on how to use the library.**
|
16
16
|
|
17
17
|
## Installation
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
```sh
|
19
|
+
```bash
|
22
20
|
gem install monday_ruby
|
23
21
|
```
|
24
22
|
|
25
|
-
If you want to build the gem from source:
|
26
|
-
|
27
|
-
```sh
|
28
|
-
gem build monday_ruby.gemspec
|
29
|
-
```
|
30
|
-
|
31
|
-
### Requirements
|
32
|
-
|
33
|
-
* Ruby 2.7+
|
34
|
-
|
35
|
-
### Bundler
|
36
|
-
|
37
|
-
If you are installing via bundler, you should be sure to use the https rubygems source in your Gemfile, as any gems fetched over http could potentially be compromised in transit and alter the code of gems fetched securely over https:
|
38
|
-
|
39
|
-
```ruby
|
40
|
-
source "https://rubygems.org"
|
41
|
-
|
42
|
-
gem "monday_ruby"
|
43
|
-
```
|
44
|
-
|
45
23
|
## Usage
|
46
24
|
|
47
|
-
***Complete list of
|
25
|
+
***Complete list of resources along with examples are provided in the [Wiki](https://github.com/sanifhimani/monday_ruby/wiki).***
|
48
26
|
|
49
27
|
The library needs to be configured with your account's authentication token which is available on the Admin tab on monday.com. Elaborate documentation can be found [here](https://developer.monday.com/api-reference/docs/authentication).
|
50
28
|
|
@@ -60,7 +38,6 @@ require "monday_ruby"
|
|
60
38
|
Monday.configure do |config|
|
61
39
|
config.token = "<AUTH_TOKEN>"
|
62
40
|
end
|
63
|
-
|
64
41
|
```
|
65
42
|
|
66
43
|
#### Client specific config
|
@@ -70,7 +47,7 @@ require "monday_ruby"
|
|
70
47
|
client = Monday::Client.new(token: "<AUTH_TOKEN>")
|
71
48
|
```
|
72
49
|
|
73
|
-
|
50
|
+
The version configuration field allows you to optionally pass in the version of the API you want to use. By default, the latest stable version is used.
|
74
51
|
|
75
52
|
```ruby
|
76
53
|
require "monday_ruby"
|
@@ -89,35 +66,33 @@ Get access to response objects by initializing a client and using the appropriat
|
|
89
66
|
client = Monday::Client.new(token: "<AUTH_TOKEN>")
|
90
67
|
response = client.boards
|
91
68
|
|
69
|
+
puts response.success?
|
92
70
|
puts response.body
|
93
71
|
```
|
94
72
|
|
95
73
|
### Use cases
|
96
74
|
|
97
|
-
Here are some common
|
75
|
+
Here are some common use cases for the API client.
|
98
76
|
|
99
77
|
#### Fetching all the boards
|
100
78
|
|
101
|
-
Initialize the client with the auth token and call the `boards`
|
79
|
+
Initialize the client with the auth token and call the `boards` method.
|
102
80
|
|
103
81
|
```ruby
|
104
82
|
client = Monday::Client.new(token: <AUTH_TOKEN>)
|
105
83
|
|
106
|
-
response = client.boards
|
107
|
-
# => <Monday::Response ...>
|
84
|
+
response = client.boards # => <Monday::Response ...>
|
108
85
|
|
109
86
|
# To check if the request was successful
|
110
|
-
response.success?
|
111
|
-
# => true
|
87
|
+
response.success? # => true
|
112
88
|
|
113
89
|
# To get the boards from the response
|
114
|
-
response.dig("data", "boards")
|
115
|
-
# => [...]
|
90
|
+
response.dig("data", "boards") # => [...]
|
116
91
|
```
|
117
92
|
|
118
93
|
#### Creating a new board
|
119
94
|
|
120
|
-
Initialize the client with the auth token and call the `create_board`
|
95
|
+
Initialize the client with the auth token and call the `create_board` method.
|
121
96
|
|
122
97
|
```ruby
|
123
98
|
client = Monday::Client.new(token: <AUTH_TOKEN>)
|
@@ -128,21 +103,19 @@ args = {
|
|
128
103
|
description: "Test board description"
|
129
104
|
}
|
130
105
|
|
131
|
-
response = client.create_board(args: args)
|
132
106
|
# => <Monday::Response ...>
|
107
|
+
response = client.create_board(args: args)
|
133
108
|
|
134
109
|
# To check if the request was successful
|
135
|
-
response.success?
|
136
|
-
# => true
|
110
|
+
response.success? # => true
|
137
111
|
|
138
112
|
# To get the created board from the response
|
139
|
-
response.dig("data", "create_board")
|
140
|
-
# => { ... }
|
113
|
+
response.dig("data", "create_board") # => { ... }
|
141
114
|
```
|
142
115
|
|
143
116
|
#### Creating a new item on board
|
144
117
|
|
145
|
-
Initialize the client with the auth token and call the `create_item`
|
118
|
+
Initialize the client with the auth token and call the `create_item` method.
|
146
119
|
|
147
120
|
```ruby
|
148
121
|
client = Monday::Client.new(token: <AUTH_TOKEN>)
|
@@ -160,35 +133,33 @@ args = {
|
|
160
133
|
}
|
161
134
|
}
|
162
135
|
|
163
|
-
response = client.create_item(args: args)
|
164
136
|
# => <Monday::Response ...>
|
137
|
+
response = client.create_item(args: args)
|
165
138
|
|
166
139
|
# To check if the request was successful
|
167
|
-
response.success?
|
168
|
-
# => true
|
140
|
+
response.success? # => true
|
169
141
|
|
170
142
|
# To get the created item from the response
|
171
|
-
response.dig("data", "create_item")
|
172
|
-
# => { ... }
|
143
|
+
response.dig("data", "create_item") # => { ... }
|
173
144
|
```
|
174
145
|
|
175
146
|
## Development
|
176
147
|
|
177
148
|
Run all tests:
|
178
149
|
|
179
|
-
```
|
150
|
+
```bash
|
180
151
|
bundle exec rake spec
|
181
152
|
```
|
182
153
|
|
183
154
|
Run linter:
|
184
155
|
|
185
|
-
```
|
156
|
+
```bash
|
186
157
|
bundle exec rake rubocop
|
187
158
|
```
|
188
159
|
|
189
160
|
## Contributing
|
190
161
|
|
191
|
-
Bug reports and pull requests are welcome on GitHub
|
162
|
+
Bug reports and pull requests are welcome on [GitHub](https://github.com/sanifhimani/monday_ruby). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/sanifhimani/monday_ruby/blob/main/CODE_OF_CONDUCT.md).
|
192
163
|
|
193
164
|
## License
|
194
165
|
|
data/lib/monday/client.rb
CHANGED
@@ -15,20 +15,25 @@ module Monday
|
|
15
15
|
# Client executes requests against the monday.com's API and
|
16
16
|
# allows a user to mutate and retrieve resources.
|
17
17
|
class Client
|
18
|
-
include Resources
|
19
|
-
|
20
18
|
JSON_CONTENT_TYPE = "application/json"
|
21
19
|
private_constant :JSON_CONTENT_TYPE
|
22
20
|
|
23
21
|
attr_reader :config
|
24
22
|
|
25
23
|
def initialize(config_args = {})
|
26
|
-
@config =
|
24
|
+
@config = configure(config_args)
|
25
|
+
Resources.initialize(self)
|
26
|
+
end
|
27
|
+
|
28
|
+
def make_request(body)
|
29
|
+
response = Request.post(uri, body, request_headers)
|
30
|
+
|
31
|
+
handle_response(Response.new(response))
|
27
32
|
end
|
28
33
|
|
29
34
|
private
|
30
35
|
|
31
|
-
def
|
36
|
+
def configure(config_args)
|
32
37
|
return Monday.config if config_args.empty?
|
33
38
|
|
34
39
|
Configuration.new(**config_args)
|
@@ -45,12 +50,6 @@ module Monday
|
|
45
50
|
}
|
46
51
|
end
|
47
52
|
|
48
|
-
def make_request(body)
|
49
|
-
response = Request.post(uri, body, request_headers)
|
50
|
-
|
51
|
-
handle_response(Response.new(response))
|
52
|
-
end
|
53
|
-
|
54
53
|
def handle_response(response)
|
55
54
|
return response if response.success?
|
56
55
|
|
@@ -58,7 +57,7 @@ module Monday
|
|
58
57
|
end
|
59
58
|
|
60
59
|
def raise_errors(response)
|
61
|
-
raise default_exception(response) unless
|
60
|
+
raise default_exception(response) unless successful_response?(response.status)
|
62
61
|
|
63
62
|
raise response_exception(response)
|
64
63
|
end
|
@@ -75,5 +74,9 @@ module Monday
|
|
75
74
|
def default_exception(response)
|
76
75
|
Util.status_code_exceptions_mapping(response.status).new(response: response)
|
77
76
|
end
|
77
|
+
|
78
|
+
def successful_response?(status)
|
79
|
+
(200..299).cover?(status)
|
80
|
+
end
|
78
81
|
end
|
79
82
|
end
|
@@ -1,19 +1,21 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative "base"
|
4
|
+
|
3
5
|
module Monday
|
4
6
|
module Resources
|
5
7
|
# Represents Monday.com's account resource.
|
6
|
-
|
8
|
+
class Account < Base
|
7
9
|
DEFAULT_SELECT = %w[id name].freeze
|
8
10
|
|
9
11
|
# Retrieves the users account.
|
10
12
|
#
|
11
13
|
# Allows customizing the values to retrieve using the select option.
|
12
14
|
# By default, ID and name are retrieved.
|
13
|
-
def
|
14
|
-
|
15
|
+
def query(select: DEFAULT_SELECT)
|
16
|
+
request_query = "query{users{account {#{Util.format_select(select)}}}}"
|
15
17
|
|
16
|
-
make_request(
|
18
|
+
make_request(request_query)
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
@@ -1,9 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative "base"
|
4
|
+
|
3
5
|
module Monday
|
4
6
|
module Resources
|
5
7
|
# Represents Monday.com's activity log resource.
|
6
|
-
|
8
|
+
class ActivityLog < Base
|
7
9
|
DEFAULT_SELECT = %w[id event data].freeze
|
8
10
|
|
9
11
|
# Retrieves the activity logs for boards.
|
@@ -12,11 +14,11 @@ module Monday
|
|
12
14
|
# Allows filtering activity logs using the args option.
|
13
15
|
# Allows customizing the values to retrieve using the select option.
|
14
16
|
# By default, ID, event and data are retrieved.
|
15
|
-
def
|
16
|
-
|
17
|
-
|
17
|
+
def query(board_ids, args: {}, select: DEFAULT_SELECT)
|
18
|
+
request_query = "query{boards(ids: #{board_ids})" \
|
19
|
+
"{activity_logs#{Util.format_args(args)}{#{Util.format_select(select)}}}}"
|
18
20
|
|
19
|
-
make_request(
|
21
|
+
make_request(request_query)
|
20
22
|
end
|
21
23
|
end
|
22
24
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Monday
|
4
|
+
module Resources
|
5
|
+
# Base class for all resources.
|
6
|
+
class Base
|
7
|
+
attr_reader :client
|
8
|
+
|
9
|
+
def initialize(client)
|
10
|
+
@client = client
|
11
|
+
end
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
def make_request(query)
|
16
|
+
client.make_request(query)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,9 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative "base"
|
4
|
+
|
3
5
|
module Monday
|
4
6
|
module Resources
|
5
7
|
# Represents Monday.com's board resource.
|
6
|
-
|
8
|
+
class Board < Base
|
7
9
|
DEFAULT_SELECT = %w[id name description].freeze
|
8
10
|
|
9
11
|
# Retrieves all the boards.
|
@@ -11,10 +13,10 @@ module Monday
|
|
11
13
|
# Allows filtering boards using the args option.
|
12
14
|
# Allows customizing the values to retrieve using the select option.
|
13
15
|
# By default, ID, name and description fields are retrieved.
|
14
|
-
def
|
15
|
-
|
16
|
+
def query(args: {}, select: DEFAULT_SELECT)
|
17
|
+
request_query = "query{boards#{Util.format_args(args)}{#{Util.format_select(select)}}}"
|
16
18
|
|
17
|
-
make_request(
|
19
|
+
make_request(request_query)
|
18
20
|
end
|
19
21
|
|
20
22
|
# Creates a new boards.
|
@@ -22,8 +24,8 @@ module Monday
|
|
22
24
|
# Allows customizing creating a board using the args option.
|
23
25
|
# Allows customizing the values to retrieve using the select option.
|
24
26
|
# By default, ID, name and description fields are retrieved.
|
25
|
-
def
|
26
|
-
query = "mutation
|
27
|
+
def create(args: {}, select: DEFAULT_SELECT)
|
28
|
+
query = "mutation{create_board#{Util.format_args(args)}{#{Util.format_select(select)}}}"
|
27
29
|
|
28
30
|
make_request(query)
|
29
31
|
end
|
@@ -33,8 +35,8 @@ module Monday
|
|
33
35
|
# Allows customizing duplicating the board using the args option.
|
34
36
|
# Allows customizing the values to retrieve using the select option.
|
35
37
|
# By default, ID, name and description fields are retrieved.
|
36
|
-
def
|
37
|
-
query = "mutation
|
38
|
+
def duplicate(args: {}, select: DEFAULT_SELECT)
|
39
|
+
query = "mutation{duplicate_board#{Util.format_args(args)}{board{#{Util.format_select(select)}}}}"
|
38
40
|
|
39
41
|
make_request(query)
|
40
42
|
end
|
@@ -43,8 +45,8 @@ module Monday
|
|
43
45
|
#
|
44
46
|
# Allows customizing updating the board using the args option.
|
45
47
|
# Returns the ID of the updated board.
|
46
|
-
def
|
47
|
-
query = "mutation
|
48
|
+
def update(args: {})
|
49
|
+
query = "mutation{update_board#{Util.format_args(args)}}"
|
48
50
|
|
49
51
|
make_request(query)
|
50
52
|
end
|
@@ -54,8 +56,8 @@ module Monday
|
|
54
56
|
# Requires board_id to archive board.
|
55
57
|
# Allows customizing the values to retrieve using the select option.
|
56
58
|
# By default, returns the ID of the board archived.
|
57
|
-
def
|
58
|
-
query = "mutation
|
59
|
+
def archive(board_id, select: ["id"])
|
60
|
+
query = "mutation{archive_board(board_id: #{board_id}){#{Util.format_select(select)}}}"
|
59
61
|
|
60
62
|
make_request(query)
|
61
63
|
end
|
@@ -65,8 +67,8 @@ module Monday
|
|
65
67
|
# Requires board_id to delete the board.
|
66
68
|
# Allows customizing the values to retrieve using the select option.
|
67
69
|
# By default, returns the ID of the board deleted.
|
68
|
-
def
|
69
|
-
query = "mutation
|
70
|
+
def delete(board_id, select: ["id"])
|
71
|
+
query = "mutation{delete_board(board_id: #{board_id}){#{Util.format_select(select)}}}"
|
70
72
|
|
71
73
|
make_request(query)
|
72
74
|
end
|
@@ -76,9 +78,9 @@ module Monday
|
|
76
78
|
# Requires board_id and user_ids to delete subscribers.
|
77
79
|
# Allows customizing the values to retrieve using the select option.
|
78
80
|
# By default, returns the deleted subscriber IDs.
|
79
|
-
def
|
80
|
-
query = "mutation
|
81
|
-
"board_id: #{board_id}, user_ids: #{user_ids})
|
81
|
+
def delete_subscribers(board_id, user_ids, select: ["id"])
|
82
|
+
query = "mutation{delete_subscribers_from_board(" \
|
83
|
+
"board_id: #{board_id}, user_ids: #{user_ids}){#{Util.format_select(select)}}}"
|
82
84
|
|
83
85
|
make_request(query)
|
84
86
|
end
|
@@ -1,9 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative "base"
|
4
|
+
|
3
5
|
module Monday
|
4
6
|
module Resources
|
5
7
|
# Represents Monday.com's board view resource.
|
6
|
-
|
8
|
+
class BoardView < Base
|
7
9
|
DEFAULT_SELECT = %w[id name type].freeze
|
8
10
|
|
9
11
|
# Retrieves board views from a specific board.
|
@@ -11,10 +13,10 @@ module Monday
|
|
11
13
|
# Allows filtering views using the args option.
|
12
14
|
# Allows customizing the values to retrieve using the select option.
|
13
15
|
# By default, ID, name and type fields are retrieved.
|
14
|
-
def
|
15
|
-
|
16
|
+
def query(args: {}, select: DEFAULT_SELECT)
|
17
|
+
request_query = "query{boards#{Util.format_args(args)}{views{#{Util.format_select(select)}}}}"
|
16
18
|
|
17
|
-
make_request(
|
19
|
+
make_request(request_query)
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
@@ -1,9 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative "base"
|
4
|
+
|
3
5
|
module Monday
|
4
6
|
module Resources
|
5
7
|
# Represents Monday.com's column resource.
|
6
|
-
|
8
|
+
class Column < Base
|
7
9
|
DEFAULT_SELECT = %w[id title description].freeze
|
8
10
|
|
9
11
|
# Retrieves all the columns for the boards.
|
@@ -11,10 +13,10 @@ module Monday
|
|
11
13
|
# Allows filtering columns using the args option.
|
12
14
|
# Allows customizing the values to retrieve using the select option.
|
13
15
|
# By default, ID, title and description fields are retrieved.
|
14
|
-
def
|
15
|
-
|
16
|
+
def query(args: {}, select: DEFAULT_SELECT)
|
17
|
+
request_query = "query{boards#{Util.format_args(args)}{columns{#{Util.format_select(select)}}}}"
|
16
18
|
|
17
|
-
make_request(
|
19
|
+
make_request(request_query)
|
18
20
|
end
|
19
21
|
|
20
22
|
# Retrieves metadata about one or a collection of columns.
|
@@ -25,8 +27,8 @@ module Monday
|
|
25
27
|
def column_values(board_ids = [], item_ids = [], select: DEFAULT_SELECT)
|
26
28
|
board_args = board_ids.empty? ? "" : "ids: #{board_ids}"
|
27
29
|
item_args = item_ids.empty? ? "" : "ids: #{item_ids}"
|
28
|
-
query = "query
|
29
|
-
"{
|
30
|
+
query = "query{boards(#{board_args}){items(#{item_args})" \
|
31
|
+
"{column_values{#{Util.format_select(select)}}}}}"
|
30
32
|
|
31
33
|
make_request(query)
|
32
34
|
end
|
@@ -36,8 +38,8 @@ module Monday
|
|
36
38
|
# Allows customizing the column creation using the args option.
|
37
39
|
# Allows customizing the values to retrieve using the select option.
|
38
40
|
# By default, ID, title and description fields are retrieved.
|
39
|
-
def
|
40
|
-
query = "mutation
|
41
|
+
def create(args: {}, select: DEFAULT_SELECT)
|
42
|
+
query = "mutation{create_column#{Util.format_args(args)}{#{Util.format_select(select)}}}"
|
41
43
|
|
42
44
|
make_request(query)
|
43
45
|
end
|
@@ -47,8 +49,8 @@ module Monday
|
|
47
49
|
# Allows customizing the update using the args option.
|
48
50
|
# Allows customizing the values to retrieve using the select option.
|
49
51
|
# By default, ID, title and description fields are retrieved.
|
50
|
-
def
|
51
|
-
query = "mutation
|
52
|
+
def change_title(args: {}, select: DEFAULT_SELECT)
|
53
|
+
query = "mutation{change_column_title#{Util.format_args(args)}{#{Util.format_select(select)}}}"
|
52
54
|
|
53
55
|
make_request(query)
|
54
56
|
end
|
@@ -58,8 +60,8 @@ module Monday
|
|
58
60
|
# Allows customizing the update using the args option.
|
59
61
|
# Allows customizing the values to retrieve using the select option.
|
60
62
|
# By default, ID, title and description fields are retrieved.
|
61
|
-
def
|
62
|
-
query = "mutation
|
63
|
+
def change_metadata(args: {}, select: DEFAULT_SELECT)
|
64
|
+
query = "mutation{change_column_metadata#{Util.format_args(args)}{#{Util.format_select(select)}}}"
|
63
65
|
|
64
66
|
make_request(query)
|
65
67
|
end
|
@@ -69,8 +71,8 @@ module Monday
|
|
69
71
|
# Allows customizing the update using the args option.
|
70
72
|
# Allows customizing the item values to retrieve using the select option.
|
71
73
|
# By default, ID, and name fields are retrieved.
|
72
|
-
def
|
73
|
-
query = "mutation
|
74
|
+
def change_value(args: {}, select: %w[id name])
|
75
|
+
query = "mutation{change_column_value#{Util.format_args(args)}{#{Util.format_select(select)}}}"
|
74
76
|
|
75
77
|
make_request(query)
|
76
78
|
end
|
@@ -80,8 +82,8 @@ module Monday
|
|
80
82
|
# Allows customizing the update using the args option.
|
81
83
|
# Allows customizing the item values to retrieve using the select option.
|
82
84
|
# By default, ID, and name fields are retrieved.
|
83
|
-
def
|
84
|
-
query = "mutation
|
85
|
+
def change_simple_value(args: {}, select: %w[id name])
|
86
|
+
query = "mutation{change_simple_column_value#{Util.format_args(args)}{#{Util.format_select(select)}}}"
|
85
87
|
|
86
88
|
make_request(query)
|
87
89
|
end
|
@@ -91,8 +93,8 @@ module Monday
|
|
91
93
|
# Allows customizing the update using the args option.
|
92
94
|
# Allows customizing the item values to retrieve using the select option.
|
93
95
|
# By default, ID, and name fields are retrieved.
|
94
|
-
def
|
95
|
-
query = "mutation
|
96
|
+
def change_multiple_values(args: {}, select: %w[id name])
|
97
|
+
query = "mutation{change_multiple_column_values#{Util.format_args(args)}{#{Util.format_select(select)}}}"
|
96
98
|
|
97
99
|
make_request(query)
|
98
100
|
end
|
@@ -102,8 +104,8 @@ module Monday
|
|
102
104
|
# Requires board_id and column_id to delete.
|
103
105
|
# Allows customizing the values to retrieve using the select option.
|
104
106
|
# By default, ID is retrieved.
|
105
|
-
def
|
106
|
-
query = "mutation
|
107
|
+
def delete(board_id, column_id, select: %w[id])
|
108
|
+
query = "mutation{delete_column(board_id: #{board_id}, column_id: \"#{column_id}\")" \
|
107
109
|
"{#{Util.format_select(select)}}}"
|
108
110
|
|
109
111
|
make_request(query)
|