amocrm 0.2.0 → 0.3.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: dc9a0148aba6bb8e96a07ae3d3d3fe63dc3c62b0c97947e05dd0fbcababa02ce
4
- data.tar.gz: 5de4295ae87953e229c059b56cea3d19e6b00a764a9af29d57f7ac6a75436631
3
+ metadata.gz: 953688e737dbd47ad20302d617670f8e6e719896ebc97174d0d1e90388008fcd
4
+ data.tar.gz: 858c425ffcc05c3c2f61b75f4d0481fb0f3daa27461eb9b47ebccca47338a0d0
5
5
  SHA512:
6
- metadata.gz: f721ec018a7c082b983c613337e8fc64acb374a111d83507944dfb939ad001b90b482c53c75ffafdf5618bc620f2ce3a777cd6637f627c4e0ac998dc1bfae051
7
- data.tar.gz: 954adf1b791e7f37556266752e1a3e183f99d1fcbbd96e9d106aa01f5d68b31c877508bdb18631427b6f55de8f295100378981c301138aca377b81b8623cc7d3
6
+ metadata.gz: 9ade2d543faf32eef73ff10de52644776f4a01fff2ab270d2d8587dc38edc0421e5b9a48cae999b0ce340e0119272a448ef5b4298d22f873311162265a49476e
7
+ data.tar.gz: 751aed99a3da0659b98129161b649d5a76ec158a766b0a2e9eaed33a0242f6a72707c530683201c2d90b38382fcbe0aa5447033a177502db97ae3ce6ac9ad0b5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.0 (2026-02-06)
4
+
5
+ Full Changelog: [v0.2.0...v0.3.0](https://github.com/Hexlet/amocrm-ruby/compare/v0.2.0...v0.3.0)
6
+
7
+ ### Features
8
+
9
+ * **api:** api update ([63b728e](https://github.com/Hexlet/amocrm-ruby/commit/63b728e195a95b6116d954797cd4224626c3fd28))
10
+
3
11
  ## 0.2.0 (2026-02-06)
4
12
 
5
13
  Full Changelog: [v0.1.2...v0.2.0](https://github.com/Hexlet/amocrm-ruby/compare/v0.1.2...v0.2.0)
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.2.0"
18
+ gem "amocrm", "~> 0.3.0"
19
19
  ```
20
20
 
21
21
  <!-- x-release-please-end -->
@@ -26,7 +26,10 @@ gem "amocrm", "~> 0.2.0"
26
26
  require "bundler/setup"
27
27
  require "amocrm"
28
28
 
29
- amocrm = Amocrm::Client.new(token: "My Token", subdomain: "My-Subdomain")
29
+ amocrm = Amocrm::Client.new(
30
+ token: ENV["AMOCRM_AUTH_TOKEN"], # This is the default and can be omitted
31
+ subdomain: "My-Subdomain"
32
+ )
30
33
 
31
34
  response = amocrm.v4.leads.unsorted.create_forms(
32
35
  body: [{metadata: {}, source_name: "source_name", source_uid: "source_uid"}]
@@ -83,7 +86,6 @@ You can use the `max_retries` option to configure or disable this:
83
86
  # Configure the default for all requests:
84
87
  amocrm = Amocrm::Client.new(
85
88
  max_retries: 0, # default is 2
86
- token: "My Token",
87
89
  subdomain: "My-Subdomain"
88
90
  )
89
91
 
@@ -102,7 +104,6 @@ By default, requests will time out after 60 seconds. You can use the timeout opt
102
104
  # Configure the default for all requests:
103
105
  amocrm = Amocrm::Client.new(
104
106
  timeout: nil, # default is 60
105
- token: "My Token",
106
107
  subdomain: "My-Subdomain"
107
108
  )
108
109
 
data/lib/amocrm/client.rb CHANGED
@@ -24,6 +24,15 @@ module Amocrm
24
24
  # @return [Amocrm::Resources::V4]
25
25
  attr_reader :v4
26
26
 
27
+ # @api private
28
+ #
29
+ # @return [Hash{String=>String}]
30
+ private def auth_headers
31
+ return {} if @token.nil?
32
+
33
+ {"authorization" => "Bearer #{@token}"}
34
+ end
35
+
27
36
  # Creates and returns a new client for interacting with the API.
28
37
  #
29
38
  # @param token [String, nil] Defaults to `ENV["AMOCRM_AUTH_TOKEN"]`
@@ -215,6 +215,11 @@ module Amocrm
215
215
  @max_retry_delay = max_retry_delay
216
216
  end
217
217
 
218
+ # @api private
219
+ #
220
+ # @return [Hash{String=>String}]
221
+ private def auth_headers = {}
222
+
218
223
  # @api private
219
224
  #
220
225
  # @return [String]
@@ -271,6 +276,7 @@ module Amocrm
271
276
 
272
277
  headers = Amocrm::Internal::Util.normalized_headers(
273
278
  @headers,
279
+ auth_headers,
274
280
  req[:headers].to_h,
275
281
  opts[:extra_headers].to_h
276
282
  )
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Amocrm
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
@@ -19,6 +19,11 @@ module Amocrm
19
19
  sig { returns(Amocrm::Resources::V4) }
20
20
  attr_reader :v4
21
21
 
22
+ # @api private
23
+ sig { override.returns(T::Hash[String, String]) }
24
+ private def auth_headers
25
+ end
26
+
22
27
  # Creates and returns a new client for interacting with the API.
23
28
  sig do
24
29
  params(
@@ -171,6 +171,11 @@ module Amocrm
171
171
  )
172
172
  end
173
173
 
174
+ # @api private
175
+ sig { overridable.returns(T::Hash[String, String]) }
176
+ private def auth_headers
177
+ end
178
+
174
179
  # @api private
175
180
  sig { returns(String) }
176
181
  private def user_agent
@@ -14,6 +14,8 @@ module Amocrm
14
14
 
15
15
  attr_reader v4: Amocrm::Resources::V4
16
16
 
17
+ private def auth_headers: -> ::Hash[String, String]
18
+
17
19
  def initialize: (
18
20
  ?token: String?,
19
21
  ?subdomain: String?,
@@ -85,6 +85,8 @@ module Amocrm
85
85
  ?idempotency_header: String?
86
86
  ) -> void
87
87
 
88
+ private def auth_headers: -> ::Hash[String, String]
89
+
88
90
  private def user_agent: -> String
89
91
 
90
92
  private def generate_idempotency_key: -> String
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amocrm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amocrm