monday_ruby 0.6.2 → 1.1.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/.rspec +0 -1
- data/.rubocop.yml +18 -0
- data/.simplecov +1 -0
- data/CHANGELOG.md +55 -0
- data/CONTRIBUTING.md +61 -0
- data/README.md +97 -51
- data/lib/monday/client.rb +30 -12
- data/lib/monday/configuration.rb +8 -0
- data/lib/monday/deprecation.rb +23 -0
- data/lib/monday/error.rb +5 -2
- data/lib/monday/request.rb +4 -1
- 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 +71 -17
- data/lib/monday/resources/board_view.rb +6 -4
- data/lib/monday/resources/column.rb +28 -20
- data/lib/monday/resources/folder.rb +55 -0
- data/lib/monday/resources/group.rb +84 -16
- data/lib/monday/resources/item.rb +77 -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 +33 -1
- data/lib/monday/version.rb +1 -1
- data/lib/monday_ruby.rb +1 -0
- metadata +22 -48
- 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
- data/monday_ruby.gemspec +0 -37
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fca12fa6b3f49d85bea9353e7621904cbe773f69fc9b4b18afc641a7c25318a0
|
|
4
|
+
data.tar.gz: 738fa89ae3732c0bf6afe22c314d7dcc42bae2990bfc313e640ce8aee7183755
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 843ba4a79d3a53b75b8ddfc8eb545d442600fe3b5b90df4f01ced08dd1516c8e9aab4755180b094d7c8fa94a2c330497dbee0b86ecc04071101deb0e236d2d6c
|
|
7
|
+
data.tar.gz: e6a6b8a7c1b912aee79a55f3da44372cf4d35eed207c7e061f131e6385ed9c48475c87c5722162dbdbf259058eaf13f7acf0e990a765dbc3b33299662120d8ef
|
data/.env
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
token="
|
|
1
|
+
token="eyJhbGciOiJIUzI1NiJ9.eyJ0aWQiOjU3ODczMzkyMiwiYWFpIjoxMSwidWlkIjo5NDg5NDgxMywiaWFkIjoiMjAyNS0xMC0yN1QwMToyMToxMy44NDFaIiwicGVyIjoibWU6d3JpdGUiLCJhY3RpZCI6MzIxODc3OTQsInJnbiI6InVzZTEifQ.SgPS-m2FEMHjitKC0SYTYsiQ8vAHZ7ynjDmMwQInneE"
|
data/.rspec
CHANGED
data/.rubocop.yml
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
|
+
plugins:
|
|
2
|
+
- rubocop-rake
|
|
3
|
+
- rubocop-rspec
|
|
4
|
+
|
|
1
5
|
AllCops:
|
|
2
6
|
TargetRubyVersion: 2.7
|
|
3
7
|
NewCops: enable
|
|
8
|
+
SuggestExtensions: false
|
|
9
|
+
Exclude:
|
|
10
|
+
- "spec/support/**/*.rb"
|
|
11
|
+
- "vendor/**/*"
|
|
4
12
|
|
|
5
13
|
Style/StringLiterals:
|
|
6
14
|
Enabled: true
|
|
@@ -20,3 +28,13 @@ Metrics/BlockLength:
|
|
|
20
28
|
Metrics/MethodLength:
|
|
21
29
|
Exclude:
|
|
22
30
|
- "lib/monday/util.rb"
|
|
31
|
+
|
|
32
|
+
Metrics/ParameterLists:
|
|
33
|
+
Exclude:
|
|
34
|
+
- "lib/monday/resources/group.rb"
|
|
35
|
+
|
|
36
|
+
RSpec/NestedGroups:
|
|
37
|
+
Max: 5
|
|
38
|
+
|
|
39
|
+
RSpec/MultipleMemoizedHelpers:
|
|
40
|
+
Max: 10
|
data/.simplecov
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,58 @@
|
|
|
1
|
+
## v1.1.0 (October 27, 2025)
|
|
2
|
+
|
|
3
|
+
### Added
|
|
4
|
+
|
|
5
|
+
- **Cursor-based pagination for items**:
|
|
6
|
+
- Added `items_page` method to `Board` resource for paginated item retrieval
|
|
7
|
+
- Added `items_page` method to `Group` resource for paginated group items
|
|
8
|
+
- Added `items_page` method to `Item` resource for paginated item queries
|
|
9
|
+
- Support for cursor-based pagination with customizable limits (up to 500 items per page)
|
|
10
|
+
- Support for filtered queries using `query_params` with rules and operators
|
|
11
|
+
|
|
12
|
+
- **Deprecation warning system**:
|
|
13
|
+
- Added `Deprecation` module for issuing deprecation warnings
|
|
14
|
+
- Marked `delete_subscribers` method for deprecation in v2.0.0
|
|
15
|
+
- Provides clear migration paths for deprecated methods
|
|
16
|
+
|
|
17
|
+
- **Configurable request timeouts**:
|
|
18
|
+
- Added `open_timeout` configuration option (default: 10 seconds)
|
|
19
|
+
- Added `read_timeout` configuration option (default: 30 seconds)
|
|
20
|
+
- Configurable at both global and client instance levels
|
|
21
|
+
|
|
22
|
+
- **Documentation improvements**:
|
|
23
|
+
- Added CONTRIBUTING.md with development guidelines
|
|
24
|
+
- Added VCR testing guide in pull request template
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- Updated Ruby version support matrix in CI (added Ruby 3.3 and 3.4)
|
|
29
|
+
- Updated base64 gem dependency to ~> 0.3.0
|
|
30
|
+
- Improved RuboCop configuration and fixed linting issues
|
|
31
|
+
|
|
32
|
+
### Fixed
|
|
33
|
+
|
|
34
|
+
- CI workflow improvements and linting configurations
|
|
35
|
+
|
|
36
|
+
## v1.0.0 (July 30, 2024)
|
|
37
|
+
|
|
38
|
+
### Changed
|
|
39
|
+
|
|
40
|
+
- **Refactor: Flat API replaced by Resource Classes**
|
|
41
|
+
- The client now uses a modular approach with resource classes instead of a flat API.
|
|
42
|
+
- Introduced a `Base` class for resources to encapsulate common functionality.
|
|
43
|
+
- All resource-specific logic is now encapsulated within individual resource classes (e.g., `Account`, `Board`).
|
|
44
|
+
|
|
45
|
+
### Added
|
|
46
|
+
|
|
47
|
+
- Support for enums
|
|
48
|
+
|
|
49
|
+
### Breaking Changes
|
|
50
|
+
|
|
51
|
+
- **Accessing Resources**:
|
|
52
|
+
- The way resources are accessed has changed.
|
|
53
|
+
- **Old**: `client.account`, `client.create_board`
|
|
54
|
+
- **New**: `client.accounts.query`, `client.board.create`
|
|
55
|
+
|
|
1
56
|
## v0.6.2 (April 21, 2024)
|
|
2
57
|
|
|
3
58
|
### Bug Fixes
|
data/CONTRIBUTING.md
CHANGED
|
@@ -16,6 +16,67 @@ Please follow these steps to have your contribution considered:
|
|
|
16
16
|
2. Follow the [commit guidelines](#commit-message-guidelines).
|
|
17
17
|
3. After you submit your pull request, verify that all the status checks are passing.
|
|
18
18
|
|
|
19
|
+
## Testing Guidelines
|
|
20
|
+
|
|
21
|
+
This project uses [VCR](https://github.com/vcr/vcr) to record HTTP interactions for tests. This means you **do not need a Monday.com API token** to run most tests or contribute to the project.
|
|
22
|
+
|
|
23
|
+
### Running Tests
|
|
24
|
+
|
|
25
|
+
To run the test suite:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
bundle exec rake spec
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
All tests will use pre-recorded VCR cassettes stored in `spec/fixtures/vcr_cassettes/`.
|
|
32
|
+
|
|
33
|
+
### Working with VCR Cassettes
|
|
34
|
+
|
|
35
|
+
**For most contributions, you won't need to modify VCR cassettes.** The existing cassettes cover the current API functionality.
|
|
36
|
+
|
|
37
|
+
#### When You Need to Record New Cassettes
|
|
38
|
+
|
|
39
|
+
You only need to record new VCR cassettes when:
|
|
40
|
+
- Adding support for a **new API endpoint** that doesn't have existing test coverage
|
|
41
|
+
- Modifying an existing API call that changes the request/response structure
|
|
42
|
+
|
|
43
|
+
To record new cassettes:
|
|
44
|
+
|
|
45
|
+
1. Set your Monday.com API token as an environment variable:
|
|
46
|
+
```bash
|
|
47
|
+
export MONDAY_TOKEN="your_token_here"
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
2. Delete the old cassette file (if updating an existing test):
|
|
51
|
+
```bash
|
|
52
|
+
rm spec/fixtures/vcr_cassettes/your_cassette_name.yml
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
3. Run the specific test to generate a new cassette:
|
|
56
|
+
```bash
|
|
57
|
+
bundle exec rspec spec/path/to/your_spec.rb
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
4. **Important:** Before committing, verify the cassette doesn't contain sensitive data:
|
|
61
|
+
- VCR automatically filters the `Authorization` header
|
|
62
|
+
- Check for any other sensitive information in the cassette file
|
|
63
|
+
- Cassettes are committed to the repository
|
|
64
|
+
|
|
65
|
+
#### Testing New Features Without API Access
|
|
66
|
+
|
|
67
|
+
If you're adding a new feature but don't have API access to record cassettes:
|
|
68
|
+
1. Write your implementation and tests
|
|
69
|
+
2. Create a pull request noting that cassettes need to be recorded
|
|
70
|
+
3. A maintainer with API access will record the cassettes for you
|
|
71
|
+
|
|
72
|
+
### Code Quality
|
|
73
|
+
|
|
74
|
+
Run RuboCop to ensure code style compliance:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
bundle exec rake rubocop
|
|
78
|
+
```
|
|
79
|
+
|
|
19
80
|
## Commit message guidelines
|
|
20
81
|
|
|
21
82
|
* Use present tense ("Add feature" not "Added feature")
|
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"
|
|
@@ -81,6 +58,25 @@ Monday.configure do |config|
|
|
|
81
58
|
end
|
|
82
59
|
```
|
|
83
60
|
|
|
61
|
+
You can also configure request timeouts (new in v1.1.0):
|
|
62
|
+
|
|
63
|
+
```ruby
|
|
64
|
+
require "monday_ruby"
|
|
65
|
+
|
|
66
|
+
Monday.configure do |config|
|
|
67
|
+
config.token = "<AUTH_TOKEN>"
|
|
68
|
+
config.open_timeout = 10 # seconds (default: 10)
|
|
69
|
+
config.read_timeout = 30 # seconds (default: 30)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Or configure per client
|
|
73
|
+
client = Monday::Client.new(
|
|
74
|
+
token: "<AUTH_TOKEN>",
|
|
75
|
+
open_timeout: 15,
|
|
76
|
+
read_timeout: 45
|
|
77
|
+
)
|
|
78
|
+
```
|
|
79
|
+
|
|
84
80
|
### Accessing a response object
|
|
85
81
|
|
|
86
82
|
Get access to response objects by initializing a client and using the appropriate action you want to perform:
|
|
@@ -89,35 +85,33 @@ Get access to response objects by initializing a client and using the appropriat
|
|
|
89
85
|
client = Monday::Client.new(token: "<AUTH_TOKEN>")
|
|
90
86
|
response = client.boards
|
|
91
87
|
|
|
88
|
+
puts response.success?
|
|
92
89
|
puts response.body
|
|
93
90
|
```
|
|
94
91
|
|
|
95
92
|
### Use cases
|
|
96
93
|
|
|
97
|
-
Here are some common
|
|
94
|
+
Here are some common use cases for the API client.
|
|
98
95
|
|
|
99
96
|
#### Fetching all the boards
|
|
100
97
|
|
|
101
|
-
Initialize the client with the auth token and call the `boards`
|
|
98
|
+
Initialize the client with the auth token and call the `boards` method.
|
|
102
99
|
|
|
103
100
|
```ruby
|
|
104
101
|
client = Monday::Client.new(token: <AUTH_TOKEN>)
|
|
105
102
|
|
|
106
|
-
response = client.boards
|
|
107
|
-
# => <Monday::Response ...>
|
|
103
|
+
response = client.boards # => <Monday::Response ...>
|
|
108
104
|
|
|
109
105
|
# To check if the request was successful
|
|
110
|
-
response.success?
|
|
111
|
-
# => true
|
|
106
|
+
response.success? # => true
|
|
112
107
|
|
|
113
108
|
# To get the boards from the response
|
|
114
|
-
response.dig("data", "boards")
|
|
115
|
-
# => [...]
|
|
109
|
+
response.body.dig("data", "boards") # => [...]
|
|
116
110
|
```
|
|
117
111
|
|
|
118
112
|
#### Creating a new board
|
|
119
113
|
|
|
120
|
-
Initialize the client with the auth token and call the `create_board`
|
|
114
|
+
Initialize the client with the auth token and call the `create_board` method.
|
|
121
115
|
|
|
122
116
|
```ruby
|
|
123
117
|
client = Monday::Client.new(token: <AUTH_TOKEN>)
|
|
@@ -128,21 +122,19 @@ args = {
|
|
|
128
122
|
description: "Test board description"
|
|
129
123
|
}
|
|
130
124
|
|
|
131
|
-
response = client.create_board(args: args)
|
|
132
125
|
# => <Monday::Response ...>
|
|
126
|
+
response = client.create_board(args: args)
|
|
133
127
|
|
|
134
128
|
# To check if the request was successful
|
|
135
|
-
response.success?
|
|
136
|
-
# => true
|
|
129
|
+
response.success? # => true
|
|
137
130
|
|
|
138
131
|
# To get the created board from the response
|
|
139
|
-
response.dig("data", "create_board")
|
|
140
|
-
# => { ... }
|
|
132
|
+
response.body.dig("data", "create_board") # => { ... }
|
|
141
133
|
```
|
|
142
134
|
|
|
143
135
|
#### Creating a new item on board
|
|
144
136
|
|
|
145
|
-
Initialize the client with the auth token and call the `create_item`
|
|
137
|
+
Initialize the client with the auth token and call the `create_item` method.
|
|
146
138
|
|
|
147
139
|
```ruby
|
|
148
140
|
client = Monday::Client.new(token: <AUTH_TOKEN>)
|
|
@@ -160,35 +152,89 @@ args = {
|
|
|
160
152
|
}
|
|
161
153
|
}
|
|
162
154
|
|
|
163
|
-
response = client.create_item(args: args)
|
|
164
155
|
# => <Monday::Response ...>
|
|
156
|
+
response = client.create_item(args: args)
|
|
165
157
|
|
|
166
158
|
# To check if the request was successful
|
|
167
|
-
response.success?
|
|
168
|
-
# => true
|
|
159
|
+
response.success? # => true
|
|
169
160
|
|
|
170
161
|
# To get the created item from the response
|
|
171
|
-
response.dig("data", "create_item")
|
|
172
|
-
|
|
162
|
+
response.body.dig("data", "create_item") # => { ... }
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
#### Fetching items with pagination (New in v1.1.0)
|
|
166
|
+
|
|
167
|
+
The library now supports efficient cursor-based pagination for retrieving large numbers of items. This is the recommended approach for working with boards, groups, or items that contain many records.
|
|
168
|
+
|
|
169
|
+
```ruby
|
|
170
|
+
client = Monday::Client.new(token: <AUTH_TOKEN>)
|
|
171
|
+
|
|
172
|
+
# Fetch first page of items from a board (up to 500 items per page)
|
|
173
|
+
response = client.board.items_page(
|
|
174
|
+
board_ids: <BOARD_ID>,
|
|
175
|
+
limit: 100
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
# Extract items and cursor from response
|
|
179
|
+
items = response.body.dig("data", "boards", 0, "items_page", "items")
|
|
180
|
+
cursor = response.body.dig("data", "boards", 0, "items_page", "cursor")
|
|
181
|
+
|
|
182
|
+
# Fetch next page using cursor
|
|
183
|
+
if cursor
|
|
184
|
+
next_response = client.board.items_page(
|
|
185
|
+
board_ids: <BOARD_ID>,
|
|
186
|
+
limit: 100,
|
|
187
|
+
cursor: cursor
|
|
188
|
+
)
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
# You can also filter items using query_params
|
|
192
|
+
response = client.board.items_page(
|
|
193
|
+
board_ids: <BOARD_ID>,
|
|
194
|
+
limit: 50,
|
|
195
|
+
query_params: {
|
|
196
|
+
rules: [{ column_id: "status", compare_value: [1] }],
|
|
197
|
+
operator: :and
|
|
198
|
+
}
|
|
199
|
+
)
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Pagination is also available for groups and items:
|
|
203
|
+
|
|
204
|
+
```ruby
|
|
205
|
+
# Fetch paginated items from a group
|
|
206
|
+
response = client.group.items_page(
|
|
207
|
+
board_ids: <BOARD_ID>,
|
|
208
|
+
group_ids: "group_id",
|
|
209
|
+
limit: 100
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
# Fetch paginated items with custom query
|
|
213
|
+
response = client.item.items_page(
|
|
214
|
+
limit: 100,
|
|
215
|
+
query_params: {
|
|
216
|
+
rules: [{ column_id: "status", compare_value: [5] }]
|
|
217
|
+
}
|
|
218
|
+
)
|
|
173
219
|
```
|
|
174
220
|
|
|
175
221
|
## Development
|
|
176
222
|
|
|
177
223
|
Run all tests:
|
|
178
224
|
|
|
179
|
-
```
|
|
225
|
+
```bash
|
|
180
226
|
bundle exec rake spec
|
|
181
227
|
```
|
|
182
228
|
|
|
183
229
|
Run linter:
|
|
184
230
|
|
|
185
|
-
```
|
|
231
|
+
```bash
|
|
186
232
|
bundle exec rake rubocop
|
|
187
233
|
```
|
|
188
234
|
|
|
189
235
|
## Contributing
|
|
190
236
|
|
|
191
|
-
Bug reports and pull requests are welcome on GitHub
|
|
237
|
+
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
238
|
|
|
193
239
|
## License
|
|
194
240
|
|
data/lib/monday/client.rb
CHANGED
|
@@ -15,20 +15,31 @@ 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(
|
|
30
|
+
uri,
|
|
31
|
+
body,
|
|
32
|
+
request_headers,
|
|
33
|
+
open_timeout: @config.open_timeout,
|
|
34
|
+
read_timeout: @config.read_timeout
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
handle_response(Response.new(response))
|
|
27
38
|
end
|
|
28
39
|
|
|
29
40
|
private
|
|
30
41
|
|
|
31
|
-
def
|
|
42
|
+
def configure(config_args)
|
|
32
43
|
return Monday.config if config_args.empty?
|
|
33
44
|
|
|
34
45
|
Configuration.new(**config_args)
|
|
@@ -45,12 +56,6 @@ module Monday
|
|
|
45
56
|
}
|
|
46
57
|
end
|
|
47
58
|
|
|
48
|
-
def make_request(body)
|
|
49
|
-
response = Request.post(uri, body, request_headers)
|
|
50
|
-
|
|
51
|
-
handle_response(Response.new(response))
|
|
52
|
-
end
|
|
53
|
-
|
|
54
59
|
def handle_response(response)
|
|
55
60
|
return response if response.success?
|
|
56
61
|
|
|
@@ -58,13 +63,13 @@ module Monday
|
|
|
58
63
|
end
|
|
59
64
|
|
|
60
65
|
def raise_errors(response)
|
|
61
|
-
raise default_exception(response) unless
|
|
66
|
+
raise default_exception(response) unless successful_response?(response.status)
|
|
62
67
|
|
|
63
68
|
raise response_exception(response)
|
|
64
69
|
end
|
|
65
70
|
|
|
66
71
|
def response_exception(response)
|
|
67
|
-
error_code = response
|
|
72
|
+
error_code = response_error_code(response)
|
|
68
73
|
|
|
69
74
|
return Error.new(response: response) if error_code.nil?
|
|
70
75
|
|
|
@@ -72,8 +77,21 @@ module Monday
|
|
|
72
77
|
exception_klass.new(message: error_code, response: response, code: code)
|
|
73
78
|
end
|
|
74
79
|
|
|
80
|
+
def response_error_code(response)
|
|
81
|
+
error_code = response.body["error_code"]
|
|
82
|
+
return error_code unless error_code.nil?
|
|
83
|
+
|
|
84
|
+
return unless response.body["errors"].is_a?(Array) && !response.body["errors"].empty?
|
|
85
|
+
|
|
86
|
+
response.body.dig("errors", 0, "extensions", "code") || response.body.dig("errors", 0, "extensions", "error_code")
|
|
87
|
+
end
|
|
88
|
+
|
|
75
89
|
def default_exception(response)
|
|
76
90
|
Util.status_code_exceptions_mapping(response.status).new(response: response)
|
|
77
91
|
end
|
|
92
|
+
|
|
93
|
+
def successful_response?(status)
|
|
94
|
+
(200..299).cover?(status)
|
|
95
|
+
end
|
|
78
96
|
end
|
|
79
97
|
end
|
data/lib/monday/configuration.rb
CHANGED
|
@@ -11,11 +11,15 @@ module Monday
|
|
|
11
11
|
DEFAULT_HOST = "https://api.monday.com/v2"
|
|
12
12
|
DEFAULT_TOKEN = nil
|
|
13
13
|
DEFAULT_VERSION = "2023-07"
|
|
14
|
+
DEFAULT_OPEN_TIMEOUT = 10
|
|
15
|
+
DEFAULT_READ_TIMEOUT = 30
|
|
14
16
|
|
|
15
17
|
CONFIGURATION_FIELDS = %i[
|
|
16
18
|
token
|
|
17
19
|
host
|
|
18
20
|
version
|
|
21
|
+
open_timeout
|
|
22
|
+
read_timeout
|
|
19
23
|
].freeze
|
|
20
24
|
|
|
21
25
|
attr_accessor(*CONFIGURATION_FIELDS)
|
|
@@ -27,6 +31,8 @@ module Monday
|
|
|
27
31
|
@host = DEFAULT_HOST
|
|
28
32
|
@token = DEFAULT_TOKEN
|
|
29
33
|
@version = DEFAULT_VERSION
|
|
34
|
+
@open_timeout = DEFAULT_OPEN_TIMEOUT
|
|
35
|
+
@read_timeout = DEFAULT_READ_TIMEOUT
|
|
30
36
|
|
|
31
37
|
config_args.each do |key, value|
|
|
32
38
|
public_send("#{key}=", value)
|
|
@@ -37,6 +43,8 @@ module Monday
|
|
|
37
43
|
@token = DEFAULT_TOKEN
|
|
38
44
|
@host = DEFAULT_HOST
|
|
39
45
|
@version = DEFAULT_VERSION
|
|
46
|
+
@open_timeout = DEFAULT_OPEN_TIMEOUT
|
|
47
|
+
@read_timeout = DEFAULT_READ_TIMEOUT
|
|
40
48
|
end
|
|
41
49
|
end
|
|
42
50
|
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Monday
|
|
4
|
+
# Utility module for handling deprecation warnings
|
|
5
|
+
module Deprecation
|
|
6
|
+
# Issues a deprecation warning to stderr
|
|
7
|
+
#
|
|
8
|
+
# @param method_name [String] The name of the deprecated method
|
|
9
|
+
# @param removal_version [String] The version in which the method will be removed
|
|
10
|
+
# @param alternative [String, nil] The recommended alternative method
|
|
11
|
+
#
|
|
12
|
+
# @example
|
|
13
|
+
# Deprecation.warn(method_name: "items", removal_version: "2.0.0", alternative: "items_page")
|
|
14
|
+
# # => [DEPRECATION] `items` is deprecated and will be removed in v2.0.0. Use `items_page` instead.
|
|
15
|
+
def self.warn(method_name:, removal_version:, alternative: nil)
|
|
16
|
+
message = "[DEPRECATION] `#{method_name}` is deprecated and will be removed in v#{removal_version}."
|
|
17
|
+
message += " Use `#{alternative}` instead." if alternative
|
|
18
|
+
|
|
19
|
+
# Output to stderr so it doesn't interfere with normal output
|
|
20
|
+
Kernel.warn message
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
data/lib/monday/error.rb
CHANGED
|
@@ -56,13 +56,16 @@ module Monday
|
|
|
56
56
|
# AuthorizationError is raised when the request returns
|
|
57
57
|
# a 401 or 403 status code.
|
|
58
58
|
#
|
|
59
|
-
# It is also raised when the body returns the following
|
|
60
|
-
# UserUnauthorizedException
|
|
59
|
+
# It is also raised when the body returns the following error_codes:
|
|
60
|
+
# UserUnauthorizedException, USER_UNAUTHORIZED
|
|
61
61
|
class AuthorizationError < Error
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
# RateLimitError is raised when the request returns
|
|
65
65
|
# a 429 status code.
|
|
66
|
+
#
|
|
67
|
+
# It is also raised when the body returns the following error_codes:
|
|
68
|
+
# ComplexityException, COMPLEXITY_BUDGET_EXHAUSTED
|
|
66
69
|
class RateLimitError < Error
|
|
67
70
|
end
|
|
68
71
|
|
data/lib/monday/request.rb
CHANGED
|
@@ -4,9 +4,12 @@ module Monday
|
|
|
4
4
|
# Defines the HTTP request methods.
|
|
5
5
|
class Request
|
|
6
6
|
# Performs a POST request
|
|
7
|
-
def self.post(uri, query, headers)
|
|
7
|
+
def self.post(uri, query, headers, open_timeout: 10, read_timeout: 30)
|
|
8
8
|
http = Net::HTTP.new(uri.host, uri.port)
|
|
9
9
|
http.use_ssl = true
|
|
10
|
+
http.open_timeout = open_timeout
|
|
11
|
+
http.read_timeout = read_timeout
|
|
12
|
+
|
|
10
13
|
request = Net::HTTP::Post.new(uri.request_uri, headers)
|
|
11
14
|
|
|
12
15
|
request.body = {
|
|
@@ -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
|