amocrm 0.5.3 → 0.6.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: b3a5391d4393e98f05990cfeb6fc9bd3b83bc46dc1b78e0095593d6a4783cd26
4
- data.tar.gz: 12ca76dc9c7b54151c8b7a97dbc1d8d28f152df038f2f4d442e5307550fd235e
3
+ metadata.gz: 9a71d810c5ee0f4accfa61d6f925744f7564ddf2e86f3b84a00a29bff529bd3e
4
+ data.tar.gz: 207bd4a58ffbc551c9936380e8b139392dbe4e442bff8185d4ca3ed23fb605a1
5
5
  SHA512:
6
- metadata.gz: 5ddc508445da427dbf30f710541e2d084e13146a1af9dd4e6b4750f60c92b8f611b5a572fbacb0609d2e1644dfb94026d4a1144d55852b6df61335375fb1b536
7
- data.tar.gz: 61ee03c687f3460c72635ac1377e1ee662b4dc056580947d5238d25f766aeb9b66600d677dfb09610e4cdefb4104317985c91cb4207c075a932737d5de48c9aa
6
+ metadata.gz: 060caa4e4c2fb2b878fe5c2e81e7e7d9083462236f2574fefff6df7327550f3faacd69faa409bf0444d69f2c7e7bf158941da0e30ba48b1ec1839927d1602464
7
+ data.tar.gz: 452203e68cf7177a56a4ad5659c4e2be29cd16c332b18128bc2e95e82a5254a0e638366bcaa7527a10592d9ed45528369e4fd30f97195abc9ffa3219efd579e9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.0 (2026-04-30)
4
+
5
+ Full Changelog: [v0.5.4...v0.6.0](https://github.com/Hexlet/amocrm-ruby/compare/v0.5.4...v0.6.0)
6
+
7
+ ### Features
8
+
9
+ * support setting headers via env ([9d3e5cc](https://github.com/Hexlet/amocrm-ruby/commit/9d3e5ccbfb69032008b65d94ea95429ad28e67ae))
10
+
11
+
12
+ ### Chores
13
+
14
+ * **internal:** more robust bootstrap script ([8159023](https://github.com/Hexlet/amocrm-ruby/commit/8159023a5aae2e0345da38e58737a8e8c3ab5c9e))
15
+
16
+ ## 0.5.4 (2026-04-09)
17
+
18
+ Full Changelog: [v0.5.3...v0.5.4](https://github.com/Hexlet/amocrm-ruby/compare/v0.5.3...v0.5.4)
19
+
20
+ ### Bug Fixes
21
+
22
+ * align path encoding with RFC 3986 section 3.3 ([e553b8e](https://github.com/Hexlet/amocrm-ruby/commit/e553b8e0b21dfb819d67c93a63a71009b0f728a8))
23
+ * **internal:** correct multipart form field name encoding ([4975893](https://github.com/Hexlet/amocrm-ruby/commit/4975893b8eb2d4f427e7d40c07a3b7c1413168fb))
24
+ * multipart encoding for file arrays ([6e86c5d](https://github.com/Hexlet/amocrm-ruby/commit/6e86c5d69289bc86c02b5a8f0d441fa5c7bb2ffc))
25
+ * variable name typo ([e8f5466](https://github.com/Hexlet/amocrm-ruby/commit/e8f546639d827bb38a89df2e42465f9c6d019ea4))
26
+
27
+
28
+ ### Chores
29
+
30
+ * **ci:** skip lint on metadata-only changes ([dad96e5](https://github.com/Hexlet/amocrm-ruby/commit/dad96e5408642a9781334f2bb4dbc32cd73872d9))
31
+ * **ci:** support opting out of skipping builds on metadata-only commits ([34c8c04](https://github.com/Hexlet/amocrm-ruby/commit/34c8c04b937d0249fe49073193997e9311228d8f))
32
+ * **internal:** tweak CI branches ([9a3e737](https://github.com/Hexlet/amocrm-ruby/commit/9a3e7375b6cca91433c8732e6fa060ecea85519c))
33
+ * **internal:** update gitignore ([9fb96c7](https://github.com/Hexlet/amocrm-ruby/commit/9fb96c78308d30c29ead727cc05a101cdd1b97d1))
34
+
3
35
  ## 0.5.3 (2026-03-08)
4
36
 
5
37
  Full Changelog: [v0.5.2...v0.5.3](https://github.com/Hexlet/amocrm-ruby/compare/v0.5.2...v0.5.3)
data/README.md CHANGED
@@ -15,7 +15,7 @@ To use this gem, install via Bundler by adding the following to your application
15
15
  <!-- x-release-please-start-version -->
16
16
 
17
17
  ```ruby
18
- gem "amocrm", "~> 0.5.3"
18
+ gem "amocrm", "~> 0.6.0"
19
19
  ```
20
20
 
21
21
  <!-- x-release-please-end -->
data/lib/amocrm/client.rb CHANGED
@@ -172,6 +172,19 @@ module Amocrm
172
172
  raise ArgumentError.new("subdomain is required, and can be set via environ: \"AMOCRM_SUBDOMAIN\"")
173
173
  end
174
174
 
175
+ headers = {}
176
+ custom_headers_env = ENV["AMOCRM_CUSTOM_HEADERS"]
177
+ unless custom_headers_env.nil?
178
+ parsed = {}
179
+ custom_headers_env.split("\n").each do |line|
180
+ colon = line.index(":")
181
+ unless colon.nil?
182
+ parsed[line[0...colon].strip] = line[(colon + 1)..].strip
183
+ end
184
+ end
185
+ headers = parsed.merge(headers)
186
+ end
187
+
175
188
  @token = token.to_s
176
189
  @subdomain = subdomain.to_s
177
190
 
@@ -180,7 +193,8 @@ module Amocrm
180
193
  timeout: timeout,
181
194
  max_retries: max_retries,
182
195
  initial_retry_delay: initial_retry_delay,
183
- max_retry_delay: max_retry_delay
196
+ max_retry_delay: max_retry_delay,
197
+ headers: headers
184
198
  )
185
199
 
186
200
  @account = Amocrm::Resources::Account.new(client: self)
@@ -157,7 +157,7 @@ module Amocrm
157
157
  in Hash | nil => coerced
158
158
  coerced
159
159
  else
160
- message = "Expected a #{Hash} or #{Amocrm::Internal::Type::BaseModel}, got #{data.inspect}"
160
+ message = "Expected a #{Hash} or #{Amocrm::Internal::Type::BaseModel}, got #{input.inspect}"
161
161
  raise ArgumentError.new(message)
162
162
  end
163
163
  end
@@ -237,6 +237,11 @@ module Amocrm
237
237
  end
238
238
  end
239
239
 
240
+ # @type [Regexp]
241
+ #
242
+ # https://www.rfc-editor.org/rfc/rfc3986.html#section-3.3
243
+ RFC_3986_NOT_PCHARS = /[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/
244
+
240
245
  class << self
241
246
  # @api private
242
247
  #
@@ -247,6 +252,15 @@ module Amocrm
247
252
  "#{uri.scheme}://#{uri.host}#{":#{uri.port}" unless uri.port == uri.default_port}"
248
253
  end
249
254
 
255
+ # @api private
256
+ #
257
+ # @param path [String, Integer]
258
+ #
259
+ # @return [String]
260
+ def encode_path(path)
261
+ path.to_s.gsub(Amocrm::Internal::Util::RFC_3986_NOT_PCHARS) { ERB::Util.url_encode(_1) }
262
+ end
263
+
250
264
  # @api private
251
265
  #
252
266
  # @param path [String, Array<String>]
@@ -259,7 +273,7 @@ module Amocrm
259
273
  in []
260
274
  ""
261
275
  in [String => p, *interpolations]
262
- encoded = interpolations.map { ERB::Util.url_encode(_1) }
276
+ encoded = interpolations.map { encode_path(_1) }
263
277
  format(p, *encoded)
264
278
  end
265
279
  end
@@ -573,16 +587,15 @@ module Amocrm
573
587
  y << "Content-Disposition: form-data"
574
588
 
575
589
  unless key.nil?
576
- name = ERB::Util.url_encode(key.to_s)
577
- y << "; name=\"#{name}\""
590
+ y << "; name=\"#{key}\""
578
591
  end
579
592
 
580
593
  case val
581
594
  in Amocrm::FilePart unless val.filename.nil?
582
- filename = ERB::Util.url_encode(val.filename)
595
+ filename = encode_path(val.filename)
583
596
  y << "; filename=\"#{filename}\""
584
597
  in Pathname | IO
585
- filename = ERB::Util.url_encode(::File.basename(val.to_path))
598
+ filename = encode_path(::File.basename(val.to_path))
586
599
  y << "; filename=\"#{filename}\""
587
600
  else
588
601
  end
@@ -599,6 +612,7 @@ module Amocrm
599
612
  #
600
613
  # @return [Array(String, Enumerable<String>)]
601
614
  private def encode_multipart_streaming(body)
615
+ # rubocop:disable Style/CaseEquality
602
616
  # RFC 1521 Section 7.2.1 says we should have 70 char maximum for boundary length
603
617
  boundary = SecureRandom.urlsafe_base64(46)
604
618
 
@@ -608,7 +622,7 @@ module Amocrm
608
622
  in Hash
609
623
  body.each do |key, val|
610
624
  case val
611
- in Array if val.all? { primitive?(_1) }
625
+ in Array if val.all? { primitive?(_1) || Amocrm::Internal::Type::FileInput === _1 }
612
626
  val.each do |v|
613
627
  write_multipart_chunk(y, boundary: boundary, key: key, val: v, closing: closing)
614
628
  end
@@ -624,6 +638,7 @@ module Amocrm
624
638
 
625
639
  fused_io = fused_enum(strio) { closing.each(&:call) }
626
640
  [boundary, fused_io]
641
+ # rubocop:enable Style/CaseEquality
627
642
  end
628
643
 
629
644
  # @api private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Amocrm
4
- VERSION = "0.5.3"
4
+ VERSION = "0.6.0"
5
5
  end
@@ -148,12 +148,20 @@ module Amocrm
148
148
  end
149
149
  end
150
150
 
151
+ # https://www.rfc-editor.org/rfc/rfc3986.html#section-3.3
152
+ RFC_3986_NOT_PCHARS = T.let(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/, Regexp)
153
+
151
154
  class << self
152
155
  # @api private
153
156
  sig { params(uri: URI::Generic).returns(String) }
154
157
  def uri_origin(uri)
155
158
  end
156
159
 
160
+ # @api private
161
+ sig { params(path: T.any(String, Integer)).returns(String) }
162
+ def encode_path(path)
163
+ end
164
+
157
165
  # @api private
158
166
  sig { params(path: T.any(String, T::Array[String])).returns(String) }
159
167
  def interpolate_path(path)
@@ -45,8 +45,12 @@ module Amocrm
45
45
  -> top?
46
46
  } -> top?
47
47
 
48
+ RFC_3986_NOT_PCHARS: Regexp
49
+
48
50
  def self?.uri_origin: (URI::Generic uri) -> String
49
51
 
52
+ def self?.encode_path: (String | Integer path) -> String
53
+
50
54
  def self?.interpolate_path: (String | ::Array[String] path) -> String
51
55
 
52
56
  def self?.decode_query: (String? query) -> ::Hash[String, ::Array[String]]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amocrm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amocrm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-03-16 00:00:00.000000000 Z
11
+ date: 2026-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cgi