monday_ruby 1.1.0 → 1.2.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.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.env +1 -1
  3. data/.rubocop.yml +2 -1
  4. data/CHANGELOG.md +14 -0
  5. data/CONTRIBUTING.md +104 -0
  6. data/README.md +146 -142
  7. data/docs/.vitepress/config.mjs +255 -0
  8. data/docs/.vitepress/theme/index.js +4 -0
  9. data/docs/.vitepress/theme/style.css +43 -0
  10. data/docs/README.md +80 -0
  11. data/docs/explanation/architecture.md +507 -0
  12. data/docs/explanation/best-practices/errors.md +478 -0
  13. data/docs/explanation/best-practices/performance.md +1084 -0
  14. data/docs/explanation/best-practices/rate-limiting.md +630 -0
  15. data/docs/explanation/best-practices/testing.md +820 -0
  16. data/docs/explanation/column-values.md +857 -0
  17. data/docs/explanation/design.md +795 -0
  18. data/docs/explanation/graphql.md +356 -0
  19. data/docs/explanation/migration/v1.md +808 -0
  20. data/docs/explanation/pagination.md +447 -0
  21. data/docs/guides/advanced/batch.md +1274 -0
  22. data/docs/guides/advanced/complex-queries.md +1114 -0
  23. data/docs/guides/advanced/errors.md +818 -0
  24. data/docs/guides/advanced/pagination.md +934 -0
  25. data/docs/guides/advanced/rate-limiting.md +981 -0
  26. data/docs/guides/authentication.md +286 -0
  27. data/docs/guides/boards/create.md +386 -0
  28. data/docs/guides/boards/delete.md +405 -0
  29. data/docs/guides/boards/duplicate.md +511 -0
  30. data/docs/guides/boards/query.md +530 -0
  31. data/docs/guides/boards/update.md +453 -0
  32. data/docs/guides/columns/create.md +452 -0
  33. data/docs/guides/columns/metadata.md +492 -0
  34. data/docs/guides/columns/query.md +455 -0
  35. data/docs/guides/columns/update-multiple.md +459 -0
  36. data/docs/guides/columns/update-values.md +509 -0
  37. data/docs/guides/files/add-to-column.md +40 -0
  38. data/docs/guides/files/add-to-update.md +37 -0
  39. data/docs/guides/files/clear-column.md +33 -0
  40. data/docs/guides/first-request.md +285 -0
  41. data/docs/guides/folders/manage.md +750 -0
  42. data/docs/guides/groups/items.md +626 -0
  43. data/docs/guides/groups/manage.md +501 -0
  44. data/docs/guides/installation.md +169 -0
  45. data/docs/guides/items/create.md +493 -0
  46. data/docs/guides/items/delete.md +514 -0
  47. data/docs/guides/items/query.md +605 -0
  48. data/docs/guides/items/subitems.md +483 -0
  49. data/docs/guides/items/update.md +699 -0
  50. data/docs/guides/updates/manage.md +619 -0
  51. data/docs/guides/use-cases/dashboard.md +1421 -0
  52. data/docs/guides/use-cases/import.md +1962 -0
  53. data/docs/guides/use-cases/task-management.md +1381 -0
  54. data/docs/guides/workspaces/manage.md +502 -0
  55. data/docs/index.md +69 -0
  56. data/docs/package-lock.json +2468 -0
  57. data/docs/package.json +13 -0
  58. data/docs/reference/client.md +540 -0
  59. data/docs/reference/configuration.md +586 -0
  60. data/docs/reference/errors.md +693 -0
  61. data/docs/reference/resources/account.md +208 -0
  62. data/docs/reference/resources/activity-log.md +369 -0
  63. data/docs/reference/resources/board-view.md +359 -0
  64. data/docs/reference/resources/board.md +393 -0
  65. data/docs/reference/resources/column.md +543 -0
  66. data/docs/reference/resources/file.md +236 -0
  67. data/docs/reference/resources/folder.md +386 -0
  68. data/docs/reference/resources/group.md +507 -0
  69. data/docs/reference/resources/item.md +348 -0
  70. data/docs/reference/resources/subitem.md +267 -0
  71. data/docs/reference/resources/update.md +259 -0
  72. data/docs/reference/resources/workspace.md +213 -0
  73. data/docs/reference/response.md +560 -0
  74. data/docs/tutorial/first-integration.md +713 -0
  75. data/lib/monday/client.rb +24 -0
  76. data/lib/monday/configuration.rb +5 -0
  77. data/lib/monday/request.rb +15 -0
  78. data/lib/monday/resources/base.rb +4 -0
  79. data/lib/monday/resources/file.rb +56 -0
  80. data/lib/monday/util.rb +1 -0
  81. data/lib/monday/version.rb +1 -1
  82. metadata +87 -4
data/lib/monday/client.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "uri"
4
4
  require "net/http"
5
+ require "net/http/post/multipart"
5
6
  require "json"
6
7
 
7
8
  require_relative "configuration"
@@ -37,6 +38,18 @@ module Monday
37
38
  handle_response(Response.new(response))
38
39
  end
39
40
 
41
+ def make_file_request(query, variables)
42
+ response = Request.post_multipart(
43
+ files_uri,
44
+ { query: query, variables: variables },
45
+ request_multipart_headers,
46
+ open_timeout: @config.open_timeout,
47
+ read_timeout: @config.read_timeout
48
+ )
49
+
50
+ handle_response(Response.new(response))
51
+ end
52
+
40
53
  private
41
54
 
42
55
  def configure(config_args)
@@ -49,6 +62,10 @@ module Monday
49
62
  URI(@config.host)
50
63
  end
51
64
 
65
+ def files_uri
66
+ URI(@config.files_host)
67
+ end
68
+
52
69
  def request_headers
53
70
  {
54
71
  "Content-Type": "application/json",
@@ -56,6 +73,13 @@ module Monday
56
73
  }
57
74
  end
58
75
 
76
+ def request_multipart_headers
77
+ {
78
+ "Content-Type": "multipart/form-data",
79
+ Authorization: @config.token
80
+ }
81
+ end
82
+
59
83
  def handle_response(response)
60
84
  return response if response.success?
61
85
 
@@ -7,8 +7,10 @@ module Monday
7
7
  #
8
8
  # token: used to authenticate the requests
9
9
  # host: defaults to https://api.monday.com/v2
10
+ # files_host: defaults to https://api.monday.com/v2/files
10
11
  class Configuration
11
12
  DEFAULT_HOST = "https://api.monday.com/v2"
13
+ DEFAULT_FILES_HOST = "#{DEFAULT_HOST}/file"
12
14
  DEFAULT_TOKEN = nil
13
15
  DEFAULT_VERSION = "2023-07"
14
16
  DEFAULT_OPEN_TIMEOUT = 10
@@ -17,6 +19,7 @@ module Monday
17
19
  CONFIGURATION_FIELDS = %i[
18
20
  token
19
21
  host
22
+ files_host
20
23
  version
21
24
  open_timeout
22
25
  read_timeout
@@ -29,6 +32,7 @@ module Monday
29
32
  raise ArgumentError, "Unknown arguments: #{invalid_keys}" unless invalid_keys.empty?
30
33
 
31
34
  @host = DEFAULT_HOST
35
+ @files_host = DEFAULT_FILES_HOST
32
36
  @token = DEFAULT_TOKEN
33
37
  @version = DEFAULT_VERSION
34
38
  @open_timeout = DEFAULT_OPEN_TIMEOUT
@@ -42,6 +46,7 @@ module Monday
42
46
  def reset
43
47
  @token = DEFAULT_TOKEN
44
48
  @host = DEFAULT_HOST
49
+ @files_host = DEFAULT_FILES_HOST
45
50
  @version = DEFAULT_VERSION
46
51
  @open_timeout = DEFAULT_OPEN_TIMEOUT
47
52
  @read_timeout = DEFAULT_READ_TIMEOUT
@@ -18,5 +18,20 @@ module Monday
18
18
 
19
19
  http.request(request)
20
20
  end
21
+
22
+ def self.post_multipart(uri, body, headers, open_timeout: 10, read_timeout: 30)
23
+ http = Net::HTTP.new(uri.host, uri.port)
24
+ http.use_ssl = true
25
+ http.open_timeout = open_timeout
26
+ http.read_timeout = read_timeout
27
+
28
+ params = {
29
+ "query" => body[:query],
30
+ "variables[file]" => body[:variables][:file]
31
+ }
32
+
33
+ request = Net::HTTP::Post::Multipart.new(uri.request_uri, params, headers)
34
+ http.request(request)
35
+ end
21
36
  end
22
37
  end
@@ -12,6 +12,10 @@ module Monday
12
12
 
13
13
  protected
14
14
 
15
+ def make_file_request(query, variables)
16
+ client.make_file_request(query, variables)
17
+ end
18
+
15
19
  def make_request(query)
16
20
  client.make_request(query)
17
21
  end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Monday
4
+ module Resources
5
+ # Represents Monday.com's file asset resource.
6
+ class File < Base
7
+ DEFAULT_SELECT = %w[id].freeze
8
+
9
+ # Adds a file to a file type column for an item.
10
+ #
11
+ # Allows customizing the column update using the args option.
12
+ # Allows customizing the values to retrieve using the select option.
13
+ # By default, The ID is retrieved.
14
+ def add_file_to_column(args: {}, select: DEFAULT_SELECT)
15
+ cloned_args = args.clone
16
+ variables = { file: cloned_args.delete(:file) }
17
+ cloned_args.merge!(file: "$file")
18
+ query = <<~QUERY
19
+ mutation add_file($file: File!) {
20
+ add_file_to_column#{Util.format_args(cloned_args)} {#{Util.format_select(select)}}
21
+ }
22
+ QUERY
23
+ make_file_request(query, variables)
24
+ end
25
+
26
+ # Adds a file to an update for an item.
27
+ #
28
+ # Allows customizing the update creation using the args option.
29
+ # Allows customizing the values to retrieve using the select option.
30
+ # By default, The ID is retrieved.
31
+ def add_file_to_update(args: {}, select: DEFAULT_SELECT)
32
+ cloned_args = args.clone
33
+ variables = { file: cloned_args.delete(:file) }
34
+ cloned_args.merge!(file: "$file")
35
+ query = <<~QUERY
36
+ mutation ($file: File!) {
37
+ add_file_to_update#{Util.format_args(cloned_args)} {#{Util.format_select(select)}}
38
+ }
39
+ QUERY
40
+ make_file_request(query, variables)
41
+ end
42
+
43
+ # Clear an item's files column. This is a helper method for files
44
+ # and you could also use the column.change_value to clear the column as well.
45
+ #
46
+ # Allows customizing the update creation using the args option.
47
+ # Allows customizing the values to retrieve using the select option.
48
+ # By default, ID is retrieved.
49
+ def clear_file_column(args: {}, select: DEFAULT_SELECT)
50
+ merged_args = args.merge(value: '{\"clear_all\": true}')
51
+ query = "mutation { change_column_value#{Util.format_args(merged_args)} {#{Util.format_select(select)}}}"
52
+ make_request(query)
53
+ end
54
+ end
55
+ end
56
+ end
data/lib/monday/util.rb CHANGED
@@ -108,6 +108,7 @@ module Monday
108
108
 
109
109
  def formatted_args_value(value)
110
110
  return value if value.is_a?(Symbol)
111
+ return value if value.to_s.include?("$") # GraphQL query variable
111
112
  return value.to_json.to_json if value.is_a?(Hash)
112
113
  return value if integer?(value)
113
114
  return "[#{value.map { |v| formatted_args_value(v) }.join(", ")}]" if value.is_a?(Array)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Monday
4
- VERSION = "1.1.0"
4
+ VERSION = "1.2.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monday_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sanif Himani
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.3.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: multipart-post
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.4'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.4'
27
41
  description: A Gem to easily interact with monday.com API using native Ruby
28
42
  email:
29
43
  - sanifhimani92@gmail.com
@@ -43,6 +57,74 @@ files:
43
57
  - LICENSE
44
58
  - README.md
45
59
  - Rakefile
60
+ - docs/.vitepress/config.mjs
61
+ - docs/.vitepress/theme/index.js
62
+ - docs/.vitepress/theme/style.css
63
+ - docs/README.md
64
+ - docs/explanation/architecture.md
65
+ - docs/explanation/best-practices/errors.md
66
+ - docs/explanation/best-practices/performance.md
67
+ - docs/explanation/best-practices/rate-limiting.md
68
+ - docs/explanation/best-practices/testing.md
69
+ - docs/explanation/column-values.md
70
+ - docs/explanation/design.md
71
+ - docs/explanation/graphql.md
72
+ - docs/explanation/migration/v1.md
73
+ - docs/explanation/pagination.md
74
+ - docs/guides/advanced/batch.md
75
+ - docs/guides/advanced/complex-queries.md
76
+ - docs/guides/advanced/errors.md
77
+ - docs/guides/advanced/pagination.md
78
+ - docs/guides/advanced/rate-limiting.md
79
+ - docs/guides/authentication.md
80
+ - docs/guides/boards/create.md
81
+ - docs/guides/boards/delete.md
82
+ - docs/guides/boards/duplicate.md
83
+ - docs/guides/boards/query.md
84
+ - docs/guides/boards/update.md
85
+ - docs/guides/columns/create.md
86
+ - docs/guides/columns/metadata.md
87
+ - docs/guides/columns/query.md
88
+ - docs/guides/columns/update-multiple.md
89
+ - docs/guides/columns/update-values.md
90
+ - docs/guides/files/add-to-column.md
91
+ - docs/guides/files/add-to-update.md
92
+ - docs/guides/files/clear-column.md
93
+ - docs/guides/first-request.md
94
+ - docs/guides/folders/manage.md
95
+ - docs/guides/groups/items.md
96
+ - docs/guides/groups/manage.md
97
+ - docs/guides/installation.md
98
+ - docs/guides/items/create.md
99
+ - docs/guides/items/delete.md
100
+ - docs/guides/items/query.md
101
+ - docs/guides/items/subitems.md
102
+ - docs/guides/items/update.md
103
+ - docs/guides/updates/manage.md
104
+ - docs/guides/use-cases/dashboard.md
105
+ - docs/guides/use-cases/import.md
106
+ - docs/guides/use-cases/task-management.md
107
+ - docs/guides/workspaces/manage.md
108
+ - docs/index.md
109
+ - docs/package-lock.json
110
+ - docs/package.json
111
+ - docs/reference/client.md
112
+ - docs/reference/configuration.md
113
+ - docs/reference/errors.md
114
+ - docs/reference/resources/account.md
115
+ - docs/reference/resources/activity-log.md
116
+ - docs/reference/resources/board-view.md
117
+ - docs/reference/resources/board.md
118
+ - docs/reference/resources/column.md
119
+ - docs/reference/resources/file.md
120
+ - docs/reference/resources/folder.md
121
+ - docs/reference/resources/group.md
122
+ - docs/reference/resources/item.md
123
+ - docs/reference/resources/subitem.md
124
+ - docs/reference/resources/update.md
125
+ - docs/reference/resources/workspace.md
126
+ - docs/reference/response.md
127
+ - docs/tutorial/first-integration.md
46
128
  - lib/monday/client.rb
47
129
  - lib/monday/configuration.rb
48
130
  - lib/monday/deprecation.rb
@@ -55,6 +137,7 @@ files:
55
137
  - lib/monday/resources/board.rb
56
138
  - lib/monday/resources/board_view.rb
57
139
  - lib/monday/resources/column.rb
140
+ - lib/monday/resources/file.rb
58
141
  - lib/monday/resources/folder.rb
59
142
  - lib/monday/resources/group.rb
60
143
  - lib/monday/resources/item.rb
@@ -70,8 +153,8 @@ licenses:
70
153
  - MIT
71
154
  metadata:
72
155
  homepage_uri: https://github.com/sanifhimani/monday_ruby
73
- documentation_uri: https://monday-ruby.gitbook.io/docs/
74
- changelog_uri: https://github.com/sanifhimani/monday_ruby/blob/v1.1.0/CHANGELOG.md
156
+ documentation_uri: https://sanifhimani.github.io/monday_ruby/
157
+ changelog_uri: https://github.com/sanifhimani/monday_ruby/blob/v1.2.0/CHANGELOG.md
75
158
  rubygems_mfa_required: 'true'
76
159
  rdoc_options: []
77
160
  require_paths:
@@ -87,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
170
  - !ruby/object:Gem::Version
88
171
  version: '0'
89
172
  requirements: []
90
- rubygems_version: 3.6.9
173
+ rubygems_version: 3.7.2
91
174
  specification_version: 4
92
175
  summary: Ruby bindings to use the monday.com API
93
176
  test_files: []