Skip to content

Commit f34a4cf

Browse files
authored
Merge pull request #6 from Hexlet/release-please--branches--main--changes--next
release: 0.2.0
2 parents 94f2de5 + d9b81f4 commit f34a4cf

11 files changed

Lines changed: 102 additions & 39 deletions

File tree

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.1.2"
2+
".": "0.2.0"
33
}

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 3
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hexlet%2Famocrm-1e3996435299c13cb597cf42c7be5e8083535346edd559ce68ab44beb754751a.yml
3-
openapi_spec_hash: ec32cbb57936365b46a2daf7626590d5
4-
config_hash: e01761a134b02efe7127582e0ad9cc0d
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hexlet%2Famocrm-800f4ed7083bc38fd4ddc3fdb0b975c2ad3f95b7e0375ff64d31690a3a0d5d34.yml
3+
openapi_spec_hash: ee149ec82a8a54b8ba43f99fa8a53004
4+
config_hash: 217a521823c76d5a758440ebbe1fbf4b

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## 0.2.0 (2026-02-06)
4+
5+
Full Changelog: [v0.1.2...v0.2.0](https://github.com/Hexlet/amocrm-ruby/compare/v0.1.2...v0.2.0)
6+
7+
### Features
8+
9+
* **api:** api update ([c47313c](https://github.com/Hexlet/amocrm-ruby/commit/c47313c8d4d72d7fa64f8ae3492f1474287132e6))
10+
311
## 0.1.2 (2026-02-04)
412

513
Full Changelog: [v0.1.1...v0.1.2](https://github.com/Hexlet/amocrm-ruby/compare/v0.1.1...v0.1.2)

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ GIT
1111
PATH
1212
remote: .
1313
specs:
14-
amocrm (0.1.2)
14+
amocrm (0.2.0)
1515
cgi
1616
connection_pool
1717

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ To use this gem, install via Bundler by adding the following to your application
1515
<!-- x-release-please-start-version -->
1616

1717
```ruby
18-
gem "amocrm", "~> 0.1.2"
18+
gem "amocrm", "~> 0.2.0"
1919
```
2020

2121
<!-- x-release-please-end -->
@@ -26,7 +26,7 @@ gem "amocrm", "~> 0.1.2"
2626
require "bundler/setup"
2727
require "amocrm"
2828

29-
amocrm = Amocrm::Client.new(api_key: "My API Key")
29+
amocrm = Amocrm::Client.new(token: "My Token", subdomain: "My-Subdomain")
3030

3131
response = amocrm.v4.leads.unsorted.create_forms(
3232
body: [{metadata: {}, source_name: "source_name", source_uid: "source_uid"}]
@@ -83,7 +83,8 @@ You can use the `max_retries` option to configure or disable this:
8383
# Configure the default for all requests:
8484
amocrm = Amocrm::Client.new(
8585
max_retries: 0, # default is 2
86-
api_key: "My API Key"
86+
token: "My Token",
87+
subdomain: "My-Subdomain"
8788
)
8889

8990
# Or, configure per-request:
@@ -101,7 +102,8 @@ By default, requests will time out after 60 seconds. You can use the timeout opt
101102
# Configure the default for all requests:
102103
amocrm = Amocrm::Client.new(
103104
timeout: nil, # default is 60
104-
api_key: "My API Key"
105+
token: "My Token",
106+
subdomain: "My-Subdomain"
105107
)
106108

107109
# Or, configure per-request:

lib/amocrm/client.rb

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,19 @@ class Client < Amocrm::Internal::Transport::BaseClient
1616
DEFAULT_MAX_RETRY_DELAY = 8.0
1717

1818
# @return [String]
19-
attr_reader :api_key
19+
attr_reader :token
20+
21+
# @return [String]
22+
attr_reader :subdomain
2023

2124
# @return [Amocrm::Resources::V4]
2225
attr_reader :v4
2326

2427
# Creates and returns a new client for interacting with the API.
2528
#
26-
# @param api_key [String, nil] Defaults to `ENV["AMOCRM_API_KEY"]`
29+
# @param token [String, nil] Defaults to `ENV["AMOCRM_AUTH_TOKEN"]`
30+
#
31+
# @param subdomain [String, nil] Defaults to `ENV["AMOCRM_SUBDOMAIN"]`
2732
#
2833
# @param base_url [String, nil] Override the default base URL for the API, e.g.,
2934
# `"https://api.example.com/v2/"`. Defaults to `ENV["AMOCRM_BASE_URL"]`
@@ -36,20 +41,25 @@ class Client < Amocrm::Internal::Transport::BaseClient
3641
#
3742
# @param max_retry_delay [Float]
3843
def initialize(
39-
api_key: ENV["AMOCRM_API_KEY"],
44+
token: ENV["AMOCRM_AUTH_TOKEN"],
45+
subdomain: ENV["AMOCRM_SUBDOMAIN"],
4046
base_url: ENV["AMOCRM_BASE_URL"],
4147
max_retries: self.class::DEFAULT_MAX_RETRIES,
4248
timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS,
4349
initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY,
4450
max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY
4551
)
46-
base_url ||= "https://{subdomain}.amocrm.ru"
52+
base_url ||= "https://#{subdomain}.amocrm.ru"
4753

48-
if api_key.nil?
49-
raise ArgumentError.new("api_key is required, and can be set via environ: \"AMOCRM_API_KEY\"")
54+
if token.nil?
55+
raise ArgumentError.new("token is required, and can be set via environ: \"AMOCRM_AUTH_TOKEN\"")
56+
end
57+
if subdomain.nil?
58+
raise ArgumentError.new("subdomain is required, and can be set via environ: \"AMOCRM_SUBDOMAIN\"")
5059
end
5160

52-
@api_key = api_key.to_s
61+
@token = token.to_s
62+
@subdomain = subdomain.to_s
5363

5464
super(
5565
base_url: base_url,

lib/amocrm/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module Amocrm
4-
VERSION = "0.1.2"
4+
VERSION = "0.2.0"
55
end

rbi/amocrm/client.rbi

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,19 @@ module Amocrm
1111
DEFAULT_MAX_RETRY_DELAY = T.let(8.0, Float)
1212

1313
sig { returns(String) }
14-
attr_reader :api_key
14+
attr_reader :token
15+
16+
sig { returns(String) }
17+
attr_reader :subdomain
1518

1619
sig { returns(Amocrm::Resources::V4) }
1720
attr_reader :v4
1821

1922
# Creates and returns a new client for interacting with the API.
2023
sig do
2124
params(
22-
api_key: T.nilable(String),
25+
token: T.nilable(String),
26+
subdomain: T.nilable(String),
2327
base_url: T.nilable(String),
2428
max_retries: Integer,
2529
timeout: Float,
@@ -28,8 +32,10 @@ module Amocrm
2832
).returns(T.attached_class)
2933
end
3034
def self.new(
31-
# Defaults to `ENV["AMOCRM_API_KEY"]`
32-
api_key: ENV["AMOCRM_API_KEY"],
35+
# Defaults to `ENV["AMOCRM_AUTH_TOKEN"]`
36+
token: ENV["AMOCRM_AUTH_TOKEN"],
37+
# Defaults to `ENV["AMOCRM_SUBDOMAIN"]`
38+
subdomain: ENV["AMOCRM_SUBDOMAIN"],
3339
# Override the default base URL for the API, e.g.,
3440
# `"https://api.example.com/v2/"`. Defaults to `ENV["AMOCRM_BASE_URL"]`
3541
base_url: ENV["AMOCRM_BASE_URL"],

sig/amocrm/client.rbs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ module Amocrm
88

99
DEFAULT_MAX_RETRY_DELAY: Float
1010

11-
attr_reader api_key: String
11+
attr_reader token: String
12+
13+
attr_reader subdomain: String
1214

1315
attr_reader v4: Amocrm::Resources::V4
1416

1517
def initialize: (
16-
?api_key: String?,
18+
?token: String?,
19+
?subdomain: String?,
1720
?base_url: String?,
1821
?max_retries: Integer,
1922
?timeout: Float,

test/amocrm/client_test.rb

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def test_raises_on_missing_non_nullable_opts
3737
def test_client_default_request_default_retry_attempts
3838
stub_request(:post, "http://localhost/api/v4/leads/unsorted/forms").to_return_json(status: 500, body: {})
3939

40-
amocrm = Amocrm::Client.new(base_url: "http://localhost", api_key: "My API Key")
40+
amocrm = Amocrm::Client.new(base_url: "http://localhost", token: "My Token", subdomain: "My-Subdomain")
4141

4242
assert_raises(Amocrm::Errors::InternalServerError) do
4343
amocrm.v4.leads.unsorted.create_forms(
@@ -51,7 +51,13 @@ def test_client_default_request_default_retry_attempts
5151
def test_client_given_request_default_retry_attempts
5252
stub_request(:post, "http://localhost/api/v4/leads/unsorted/forms").to_return_json(status: 500, body: {})
5353

54-
amocrm = Amocrm::Client.new(base_url: "http://localhost", api_key: "My API Key", max_retries: 3)
54+
amocrm =
55+
Amocrm::Client.new(
56+
base_url: "http://localhost",
57+
token: "My Token",
58+
subdomain: "My-Subdomain",
59+
max_retries: 3
60+
)
5561

5662
assert_raises(Amocrm::Errors::InternalServerError) do
5763
amocrm.v4.leads.unsorted.create_forms(
@@ -65,7 +71,7 @@ def test_client_given_request_default_retry_attempts
6571
def test_client_default_request_given_retry_attempts
6672
stub_request(:post, "http://localhost/api/v4/leads/unsorted/forms").to_return_json(status: 500, body: {})
6773

68-
amocrm = Amocrm::Client.new(base_url: "http://localhost", api_key: "My API Key")
74+
amocrm = Amocrm::Client.new(base_url: "http://localhost", token: "My Token", subdomain: "My-Subdomain")
6975

7076
assert_raises(Amocrm::Errors::InternalServerError) do
7177
amocrm.v4.leads.unsorted.create_forms(
@@ -80,7 +86,13 @@ def test_client_default_request_given_retry_attempts
8086
def test_client_given_request_given_retry_attempts
8187
stub_request(:post, "http://localhost/api/v4/leads/unsorted/forms").to_return_json(status: 500, body: {})
8288

83-
amocrm = Amocrm::Client.new(base_url: "http://localhost", api_key: "My API Key", max_retries: 3)
89+
amocrm =
90+
Amocrm::Client.new(
91+
base_url: "http://localhost",
92+
token: "My Token",
93+
subdomain: "My-Subdomain",
94+
max_retries: 3
95+
)
8496

8597
assert_raises(Amocrm::Errors::InternalServerError) do
8698
amocrm.v4.leads.unsorted.create_forms(
@@ -99,7 +111,13 @@ def test_client_retry_after_seconds
99111
body: {}
100112
)
101113

102-
amocrm = Amocrm::Client.new(base_url: "http://localhost", api_key: "My API Key", max_retries: 1)
114+
amocrm =
115+
Amocrm::Client.new(
116+
base_url: "http://localhost",
117+
token: "My Token",
118+
subdomain: "My-Subdomain",
119+
max_retries: 1
120+
)
103121

104122
assert_raises(Amocrm::Errors::InternalServerError) do
105123
amocrm.v4.leads.unsorted.create_forms(
@@ -118,7 +136,13 @@ def test_client_retry_after_date
118136
body: {}
119137
)
120138

121-
amocrm = Amocrm::Client.new(base_url: "http://localhost", api_key: "My API Key", max_retries: 1)
139+
amocrm =
140+
Amocrm::Client.new(
141+
base_url: "http://localhost",
142+
token: "My Token",
143+
subdomain: "My-Subdomain",
144+
max_retries: 1
145+
)
122146

123147
assert_raises(Amocrm::Errors::InternalServerError) do
124148
Thread.current.thread_variable_set(:time_now, Time.now)
@@ -139,7 +163,13 @@ def test_client_retry_after_ms
139163
body: {}
140164
)
141165

142-
amocrm = Amocrm::Client.new(base_url: "http://localhost", api_key: "My API Key", max_retries: 1)
166+
amocrm =
167+
Amocrm::Client.new(
168+
base_url: "http://localhost",
169+
token: "My Token",
170+
subdomain: "My-Subdomain",
171+
max_retries: 1
172+
)
143173

144174
assert_raises(Amocrm::Errors::InternalServerError) do
145175
amocrm.v4.leads.unsorted.create_forms(
@@ -154,7 +184,7 @@ def test_client_retry_after_ms
154184
def test_retry_count_header
155185
stub_request(:post, "http://localhost/api/v4/leads/unsorted/forms").to_return_json(status: 500, body: {})
156186

157-
amocrm = Amocrm::Client.new(base_url: "http://localhost", api_key: "My API Key")
187+
amocrm = Amocrm::Client.new(base_url: "http://localhost", token: "My Token", subdomain: "My-Subdomain")
158188

159189
assert_raises(Amocrm::Errors::InternalServerError) do
160190
amocrm.v4.leads.unsorted.create_forms(
@@ -170,7 +200,7 @@ def test_retry_count_header
170200
def test_omit_retry_count_header
171201
stub_request(:post, "http://localhost/api/v4/leads/unsorted/forms").to_return_json(status: 500, body: {})
172202

173-
amocrm = Amocrm::Client.new(base_url: "http://localhost", api_key: "My API Key")
203+
amocrm = Amocrm::Client.new(base_url: "http://localhost", token: "My Token", subdomain: "My-Subdomain")
174204

175205
assert_raises(Amocrm::Errors::InternalServerError) do
176206
amocrm.v4.leads.unsorted.create_forms(
@@ -187,7 +217,7 @@ def test_omit_retry_count_header
187217
def test_overwrite_retry_count_header
188218
stub_request(:post, "http://localhost/api/v4/leads/unsorted/forms").to_return_json(status: 500, body: {})
189219

190-
amocrm = Amocrm::Client.new(base_url: "http://localhost", api_key: "My API Key")
220+
amocrm = Amocrm::Client.new(base_url: "http://localhost", token: "My Token", subdomain: "My-Subdomain")
191221

192222
assert_raises(Amocrm::Errors::InternalServerError) do
193223
amocrm.v4.leads.unsorted.create_forms(
@@ -210,7 +240,7 @@ def test_client_redirect_307
210240
headers: {"location" => "/redirected"}
211241
)
212242

213-
amocrm = Amocrm::Client.new(base_url: "http://localhost", api_key: "My API Key")
243+
amocrm = Amocrm::Client.new(base_url: "http://localhost", token: "My Token", subdomain: "My-Subdomain")
214244

215245
assert_raises(Amocrm::Errors::APIConnectionError) do
216246
amocrm.v4.leads.unsorted.create_forms(
@@ -242,7 +272,7 @@ def test_client_redirect_303
242272
headers: {"location" => "/redirected"}
243273
)
244274

245-
amocrm = Amocrm::Client.new(base_url: "http://localhost", api_key: "My API Key")
275+
amocrm = Amocrm::Client.new(base_url: "http://localhost", token: "My Token", subdomain: "My-Subdomain")
246276

247277
assert_raises(Amocrm::Errors::APIConnectionError) do
248278
amocrm.v4.leads.unsorted.create_forms(
@@ -269,7 +299,7 @@ def test_client_redirect_auth_keep_same_origin
269299
headers: {"location" => "/redirected"}
270300
)
271301

272-
amocrm = Amocrm::Client.new(base_url: "http://localhost", api_key: "My API Key")
302+
amocrm = Amocrm::Client.new(base_url: "http://localhost", token: "My Token", subdomain: "My-Subdomain")
273303

274304
assert_raises(Amocrm::Errors::APIConnectionError) do
275305
amocrm.v4.leads.unsorted.create_forms(
@@ -299,7 +329,7 @@ def test_client_redirect_auth_strip_cross_origin
299329
headers: {"location" => "https://example.com/redirected"}
300330
)
301331

302-
amocrm = Amocrm::Client.new(base_url: "http://localhost", api_key: "My API Key")
332+
amocrm = Amocrm::Client.new(base_url: "http://localhost", token: "My Token", subdomain: "My-Subdomain")
303333

304334
assert_raises(Amocrm::Errors::APIConnectionError) do
305335
amocrm.v4.leads.unsorted.create_forms(
@@ -317,7 +347,7 @@ def test_client_redirect_auth_strip_cross_origin
317347
def test_default_headers
318348
stub_request(:post, "http://localhost/api/v4/leads/unsorted/forms").to_return_json(status: 200, body: {})
319349

320-
amocrm = Amocrm::Client.new(base_url: "http://localhost", api_key: "My API Key")
350+
amocrm = Amocrm::Client.new(base_url: "http://localhost", token: "My Token", subdomain: "My-Subdomain")
321351

322352
amocrm.v4.leads.unsorted.create_forms(
323353
body: [{metadata: {}, source_name: "source_name", source_uid: "source_uid"}]

0 commit comments

Comments
 (0)