Class: Amocrm::Client
Constant Summary
collapse
- DEFAULT_MAX_RETRIES =
Default max number of retries to attempt after a failed retryable request.
2
- DEFAULT_TIMEOUT_IN_SECONDS =
Default per-request timeout.
60.0
- DEFAULT_INITIAL_RETRY_DELAY =
Default initial retry delay in seconds. Overall delay is calculated using exponential backoff + jitter.
0.5
- DEFAULT_MAX_RETRY_DELAY =
Default max retry delay in seconds.
8.0
Internal::Transport::BaseClient::MAX_REDIRECTS, Internal::Transport::BaseClient::PLATFORM_HEADERS
Instance Attribute Summary collapse
#base_url, #headers, #idempotency_header, #initial_retry_delay, #max_retries, #max_retry_delay, #requester, #timeout
Instance Method Summary
collapse
follow_redirect, #inspect, reap_connection!, #request, #send_request, should_retry?, validate!
#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type
Constructor Details
#initialize(token: ENV["AMOCRM_AUTH_TOKEN"], subdomain: ENV["AMOCRM_SUBDOMAIN"], base_url: ENV["AMOCRM_BASE_URL"], max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY) ⇒ Client
Creates and returns a new client for interacting with the API.
‘“api.example.com/v2/”`. Defaults to `ENV`
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
# File 'lib/amocrm/client.rb', line 157
def initialize(
token: ENV["AMOCRM_AUTH_TOKEN"],
subdomain: ENV["AMOCRM_SUBDOMAIN"],
base_url: ENV["AMOCRM_BASE_URL"],
max_retries: self.class::DEFAULT_MAX_RETRIES,
timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS,
initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY,
max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY
)
base_url ||= "https://#{subdomain}.amocrm.ru"
if token.nil?
raise ArgumentError.new("token is required, and can be set via environ: \"AMOCRM_AUTH_TOKEN\"")
end
if subdomain.nil?
raise ArgumentError.new("subdomain is required, and can be set via environ: \"AMOCRM_SUBDOMAIN\"")
end
@token = token.to_s
@subdomain = subdomain.to_s
super(
base_url: base_url,
timeout: timeout,
max_retries: max_retries,
initial_retry_delay: initial_retry_delay,
max_retry_delay: max_retry_delay
)
@account = Amocrm::Resources::Account.new(client: self)
@calls = Amocrm::Resources::Calls.new(client: self)
@catalog_elements = Amocrm::Resources::CatalogElements.new(client: self)
@catalogs = Amocrm::Resources::Catalogs.new(client: self)
@companies = Amocrm::Resources::Companies.new(client: self)
@contact_chats = Amocrm::Resources::ContactChats.new(client: self)
@contacts = Amocrm::Resources::Contacts.new(client: self)
@custom_field_groups = Amocrm::Resources::CustomFieldGroups.new(client: self)
@custom_fields = Amocrm::Resources::CustomFields.new(client: self)
@customer_bonus_points = Amocrm::Resources::CustomerBonusPoints.new(client: self)
@customer_segments = Amocrm::Resources::CustomerSegments.new(client: self)
@customer_statuses = Amocrm::Resources::CustomerStatuses.new(client: self)
@customer_transactions = Amocrm::Resources::CustomerTransactions.new(client: self)
@customers = Amocrm::Resources::Customers.new(client: self)
@customers_mode = Amocrm::Resources::CustomersMode.new(client: self)
@entity_followers = Amocrm::Resources::EntityFollowers.new(client: self)
@entity_links = Amocrm::Resources::EntityLinks.new(client: self)
@entity_notes = Amocrm::Resources::EntityNotes.new(client: self)
@entity_notes_by_parent = Amocrm::Resources::EntityNotesByParent.new(client: self)
@events = Amocrm::Resources::Events.new(client: self)
@leads = Amocrm::Resources::Leads.new(client: self)
@pipeline_statuses = Amocrm::Resources::PipelineStatuses.new(client: self)
@pipelines = Amocrm::Resources::Pipelines.new(client: self)
@roles = Amocrm::Resources::Roles.new(client: self)
@salesbot = Amocrm::Resources::Salesbot.new(client: self)
@short_links = Amocrm::Resources::ShortLinks.new(client: self)
@sources = Amocrm::Resources::Sources.new(client: self)
@tags = Amocrm::Resources::Tags.new(client: self)
@talks = Amocrm::Resources::Talks.new(client: self)
@tasks = Amocrm::Resources::Tasks.new(client: self)
@unsorted_leads = Amocrm::Resources::UnsortedLeads.new(client: self)
@users = Amocrm::Resources::Users.new(client: self)
@webhooks = Amocrm::Resources::Webhooks.new(client: self)
@website_buttons = Amocrm::Resources::WebsiteButtons.new(client: self)
@widget_bot_continue = Amocrm::Resources::WidgetBotContinue.new(client: self)
@widgets = Amocrm::Resources::Widgets.new(client: self)
end
|
Instance Attribute Details
25
26
27
|
# File 'lib/amocrm/client.rb', line 25
def account
@account
end
|
28
29
30
|
# File 'lib/amocrm/client.rb', line 28
def calls
@calls
end
|
31
32
33
|
# File 'lib/amocrm/client.rb', line 31
def catalog_elements
@catalog_elements
end
|
34
35
36
|
# File 'lib/amocrm/client.rb', line 34
def catalogs
@catalogs
end
|
37
38
39
|
# File 'lib/amocrm/client.rb', line 37
def companies
@companies
end
|
40
41
42
|
# File 'lib/amocrm/client.rb', line 40
def contact_chats
@contact_chats
end
|
43
44
45
|
# File 'lib/amocrm/client.rb', line 43
def contacts
@contacts
end
|
46
47
48
|
# File 'lib/amocrm/client.rb', line 46
def custom_field_groups
@custom_field_groups
end
|
49
50
51
|
# File 'lib/amocrm/client.rb', line 49
def custom_fields
@custom_fields
end
|
52
53
54
|
# File 'lib/amocrm/client.rb', line 52
def customer_bonus_points
@customer_bonus_points
end
|
55
56
57
|
# File 'lib/amocrm/client.rb', line 55
def customer_segments
@customer_segments
end
|
58
59
60
|
# File 'lib/amocrm/client.rb', line 58
def customer_statuses
@customer_statuses
end
|
61
62
63
|
# File 'lib/amocrm/client.rb', line 61
def customer_transactions
@customer_transactions
end
|
64
65
66
|
# File 'lib/amocrm/client.rb', line 64
def customers
@customers
end
|
67
68
69
|
# File 'lib/amocrm/client.rb', line 67
def customers_mode
@customers_mode
end
|
70
71
72
|
# File 'lib/amocrm/client.rb', line 70
def entity_followers
@entity_followers
end
|
73
74
75
|
# File 'lib/amocrm/client.rb', line 73
def entity_links
@entity_links
end
|
76
77
78
|
# File 'lib/amocrm/client.rb', line 76
def entity_notes
@entity_notes
end
|
79
80
81
|
# File 'lib/amocrm/client.rb', line 79
def entity_notes_by_parent
@entity_notes_by_parent
end
|
82
83
84
|
# File 'lib/amocrm/client.rb', line 82
def events
@events
end
|
85
86
87
|
# File 'lib/amocrm/client.rb', line 85
def leads
@leads
end
|
88
89
90
|
# File 'lib/amocrm/client.rb', line 88
def pipeline_statuses
@pipeline_statuses
end
|
91
92
93
|
# File 'lib/amocrm/client.rb', line 91
def pipelines
@pipelines
end
|
94
95
96
|
# File 'lib/amocrm/client.rb', line 94
def roles
@roles
end
|
97
98
99
|
# File 'lib/amocrm/client.rb', line 97
def salesbot
@salesbot
end
|
100
101
102
|
# File 'lib/amocrm/client.rb', line 100
def short_links
@short_links
end
|
103
104
105
|
# File 'lib/amocrm/client.rb', line 103
def sources
@sources
end
|
#subdomain ⇒ String
22
23
24
|
# File 'lib/amocrm/client.rb', line 22
def subdomain
@subdomain
end
|
106
107
108
|
# File 'lib/amocrm/client.rb', line 106
def tags
@tags
end
|
109
110
111
|
# File 'lib/amocrm/client.rb', line 109
def talks
@talks
end
|
112
113
114
|
# File 'lib/amocrm/client.rb', line 112
def tasks
@tasks
end
|
#token ⇒ String
19
20
21
|
# File 'lib/amocrm/client.rb', line 19
def token
@token
end
|
115
116
117
|
# File 'lib/amocrm/client.rb', line 115
def unsorted_leads
@unsorted_leads
end
|
118
119
120
|
# File 'lib/amocrm/client.rb', line 118
def users
@users
end
|
121
122
123
|
# File 'lib/amocrm/client.rb', line 121
def webhooks
@webhooks
end
|
124
125
126
|
# File 'lib/amocrm/client.rb', line 124
def website_buttons
@website_buttons
end
|
127
128
129
|
# File 'lib/amocrm/client.rb', line 127
def widget_bot_continue
@widget_bot_continue
end
|
130
131
132
|
# File 'lib/amocrm/client.rb', line 130
def widgets
@widgets
end
|