vimaly 1.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0a5b2991366fa54ec8d160b894d4393236d24362d8e659b7bdb2222be9001a9
4
- data.tar.gz: 200257d646a0a01284c5d26dae3be16c1c3f31e92fb5e3c9704223b00c8584a6
3
+ metadata.gz: 7e67a18552b8d4a3c3bf527a2bb4fb859a15b8c59e0fded3fc7f5138df00d375
4
+ data.tar.gz: 5a1c9269b2556e45fe0eb867f4ad31f4fa73b11bd581da743ea5dc15eca2717c
5
5
  SHA512:
6
- metadata.gz: 529972ff9c59f81cf30ea2f0fcc81e09a51a8a8479b3e0a79929ce806001f3004b98368ef56953489d0721fe68462e74d1ce23f84d4a2df573c5525fdea4859f
7
- data.tar.gz: 78d667532eb197842526a3e9a51584c07d8fef4530fff79a4c4f2124645760d3d0e5057a4c99c242b5812d3f07e9715627aea8ef73f62e7427ea17429373c26e
6
+ metadata.gz: 610de2b9dac4235222006ab0361a3d62f0c42ff6c6a67e5c6173ddb700ba19608a17f51e6d06c7d07bdf10b3791f3a88fe9dd98bf52a3cd6f355fb227a474142
7
+ data.tar.gz: a58e11c17157e1192383164018457b11502f6b284582432c6d04224bdbd7365f2a322847cfd7eebb8176f713a5025098276683bcee79277a9b6294d487741c4d
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.5.3
1
+ 2.6.5
data/.travis.yml CHANGED
@@ -2,4 +2,5 @@ sudo: false
2
2
  language: ruby
3
3
  rvm:
4
4
  - 2.5.3
5
+ - 2.6.3
5
6
  before_install: gem install bundler
data/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.2.0
4
+
5
+ * add support for more than 500 bins, refactored and options added [#21](https://github.com/sharesight/vimaly/pull/21)
6
+
7
+ ## 1.1.1
8
+
9
+ * add support for more than 500 bins [#20](https://github.com/sharesight/vimaly/pull/20)
10
+
11
+ ## 1.1.0
12
+
13
+ * add support for searching tickets [#19](https://github.com/sharesight/vimaly/pull/19)
14
+
15
+ ## 1.0.2
16
+
17
+ * Fix unfriendly filenames not attaching to Vimaly tickets [#17](https://github.com/sharesight/vimaly/pull/17)
18
+
19
+ ## 1.0.1
20
+
21
+ * Update for Ruby 2.6.3 compatibility.
22
+
3
23
  ## 1.0.0
4
24
 
5
25
  * allow adding attachments with providing a content-type [#15](https://github.com/sharesight/vimaly/pull/15)
data/lib/vimaly/client.rb CHANGED
@@ -54,8 +54,17 @@ module Vimaly
54
54
  end
55
55
  end
56
56
 
57
+ def search_tickets(query_string, state: 'active')
58
+ ticket_type_map = Hash[ticket_types.map { |t| [t.id, t] }]
59
+ bin_map = Hash[bins.map { |b| [b.id, b] }]
60
+
61
+ get("/ticket-search?text=#{query_string}&state=#{state}").map do |ticket_data|
62
+ Ticket.from_vimaly(ticket_data, ticket_type_map, bin_map, custom_fields)
63
+ end
64
+ end
65
+
57
66
  def add_attachment(ticket_id, file_name, file_content, request_options={})
58
- response = post("/tickets/#{ticket_id}/attachments?name=#{file_name}", file_content, request_options)
67
+ response = post("/tickets/#{ticket_id}/attachments?name=#{CGI.escape(file_name)}", file_content, request_options)
59
68
  case response.status
60
69
  when 200..299
61
70
  true
@@ -75,10 +84,25 @@ module Vimaly
75
84
  end
76
85
  end
77
86
 
78
- def bins
87
+ def bins(options={})
79
88
  @bins ||= begin
80
- get('/bins?max-results=500').map do |bin_data|
81
- Bin.new(bin_data['_id'], bin_data['name'])
89
+ # 500 is the vimaly limit
90
+ bins_per_request = options[:bins_per_request] || 500
91
+ # 5000 is just a random value here; hopefully we never reach this limit
92
+ max_number_of_bins = options[:max_number_of_bins] || 5000
93
+
94
+ bins = []
95
+ current_page = 0
96
+ while bins.size < max_number_of_bins
97
+ # those request parameters are not documented, maybe this gets added at some
98
+ # point to https://vimaly.com/public/rest-help.html#Bins
99
+ chunk_of_bins = get("/bins?max-results=#{bins_per_request}&page-token=#{current_page * bins_per_request}")
100
+ current_page += 1
101
+ bins += chunk_of_bins
102
+ break if chunk_of_bins.size < bins_per_request
103
+ end
104
+ bins.map do |bin|
105
+ Bin.new(bin['_id'], bin['name'])
82
106
  end
83
107
  end
84
108
  end
@@ -113,7 +137,6 @@ module Vimaly
113
137
  get("/tickets?bin_id=#{bin_id}").map do |ticket_data|
114
138
  Ticket.from_vimaly(ticket_data, ticket_type_map, bin_map, custom_fields)
115
139
  end
116
-
117
140
  end
118
141
 
119
142
  def matching_tickets_in_named_bin(bin_name, title_matcher)
@@ -1,3 +1,3 @@
1
1
  module Vimaly
2
- VERSION = "1.0.0".freeze
2
+ VERSION = "1.2.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vimaly
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thorsten Boettger
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-21 00:00:00.000000000 Z
11
+ date: 2021-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -166,7 +166,7 @@ homepage: https://github.com/sharesight/vimaly
166
166
  licenses:
167
167
  - MIT
168
168
  metadata: {}
169
- post_install_message:
169
+ post_install_message:
170
170
  rdoc_options: []
171
171
  require_paths:
172
172
  - lib
@@ -181,8 +181,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
181
  - !ruby/object:Gem::Version
182
182
  version: '0'
183
183
  requirements: []
184
- rubygems_version: 3.0.2
185
- signing_key:
184
+ rubygems_version: 3.2.17
185
+ signing_key:
186
186
  specification_version: 4
187
187
  summary: Wrapper for the Vimaly API
188
188
  test_files: []