doorloop 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5a9ac995291e0df7e8b3e3ada12ec0823d5371667ffd79639218058bd2816954
4
+ data.tar.gz: 8793a7c08b2d83d84e81c6dc0a363d76be981ec6a40bc8f6919773c7f9d2605d
5
+ SHA512:
6
+ metadata.gz: ca8cab8bca74f9c3f6f0ecb996996d7595be0da911e5ad44c47596fa27c380e1ffa605f27da9ddcb4d3432601f5727593a6593476cbcb6286710bfffeb83b92d
7
+ data.tar.gz: 0fd1a0b37a43ecf046ec970f8be50ffde32bce40efc6071cb62142685be2b0c56b1054aaa63ef7e4636be2dc2365f66fd4a9b470686aaa9d2a01545e0120572e
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ .idea
13
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 3.1.2
6
+ before_install: gem install bundler -v 2.5.2
data/CHANGELOG.md ADDED
File without changes
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at mezbahalam26@gmai.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in doorloop.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 13.0"
7
+ gem "rspec", "~> 3.0"
data/Gemfile.lock ADDED
@@ -0,0 +1,87 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ doorloop (0.1.0)
5
+ rest-client (~> 2.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.8.6)
11
+ public_suffix (>= 2.0.2, < 6.0)
12
+ ast (2.4.2)
13
+ crack (0.4.5)
14
+ rexml
15
+ diff-lcs (1.5.0)
16
+ domain_name (0.6.20240107)
17
+ hashdiff (1.1.0)
18
+ http-accept (1.7.0)
19
+ http-cookie (1.0.5)
20
+ domain_name (~> 0.5)
21
+ json (2.7.1)
22
+ language_server-protocol (3.17.0.3)
23
+ mime-types (3.5.2)
24
+ mime-types-data (~> 3.2015)
25
+ mime-types-data (3.2023.1205)
26
+ netrc (0.11.0)
27
+ parallel (1.24.0)
28
+ parser (3.3.0.5)
29
+ ast (~> 2.4.1)
30
+ racc
31
+ public_suffix (5.0.4)
32
+ racc (1.7.3)
33
+ rainbow (3.1.1)
34
+ rake (13.0.6)
35
+ regexp_parser (2.9.0)
36
+ rest-client (2.1.0)
37
+ http-accept (>= 1.7.0, < 2.0)
38
+ http-cookie (>= 1.0.2, < 2.0)
39
+ mime-types (>= 1.16, < 4.0)
40
+ netrc (~> 0.8)
41
+ rexml (3.2.6)
42
+ rspec (3.12.0)
43
+ rspec-core (~> 3.12.0)
44
+ rspec-expectations (~> 3.12.0)
45
+ rspec-mocks (~> 3.12.0)
46
+ rspec-core (3.12.2)
47
+ rspec-support (~> 3.12.0)
48
+ rspec-expectations (3.12.3)
49
+ diff-lcs (>= 1.2.0, < 2.0)
50
+ rspec-support (~> 3.12.0)
51
+ rspec-mocks (3.12.6)
52
+ diff-lcs (>= 1.2.0, < 2.0)
53
+ rspec-support (~> 3.12.0)
54
+ rspec-support (3.12.1)
55
+ rubocop (1.60.2)
56
+ json (~> 2.3)
57
+ language_server-protocol (>= 3.17.0)
58
+ parallel (~> 1.10)
59
+ parser (>= 3.3.0.2)
60
+ rainbow (>= 2.2.2, < 4.0)
61
+ regexp_parser (>= 1.8, < 3.0)
62
+ rexml (>= 3.2.5, < 4.0)
63
+ rubocop-ast (>= 1.30.0, < 2.0)
64
+ ruby-progressbar (~> 1.7)
65
+ unicode-display_width (>= 2.4.0, < 3.0)
66
+ rubocop-ast (1.30.0)
67
+ parser (>= 3.2.1.0)
68
+ ruby-progressbar (1.13.0)
69
+ unicode-display_width (2.5.0)
70
+ webmock (3.19.1)
71
+ addressable (>= 2.8.0)
72
+ crack (>= 0.3.2)
73
+ hashdiff (>= 0.4.0, < 2.0.0)
74
+
75
+ PLATFORMS
76
+ arm64-darwin-21
77
+ ruby
78
+
79
+ DEPENDENCIES
80
+ doorloop!
81
+ rake (~> 13.0)
82
+ rspec (~> 3.0)
83
+ rubocop (~> 1.0)
84
+ webmock (~> 3.19.1)
85
+
86
+ BUNDLED WITH
87
+ 2.5.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 MezbahAlam
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # Doorloop
2
+
3
+ Welcome to Doorloop, an API wrapper gem for the Doorloop API. This gem allows you to easily interact with Doorloop’s API using Ruby, providing a simple and intuitive interface for managing your property management needs.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'doorloop'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install doorloop
20
+
21
+ ## Usage
22
+
23
+ To use the Doorloop gem, you need to configure it with your Doorloop API key. You can set it up directly in your code:
24
+
25
+ ```ruby
26
+ require 'doorloop'
27
+
28
+ client = DoorLoop::Client.new('your_api_token')
29
+
30
+ # Example: List all accounts
31
+ response = client.accounts.list
32
+ puts response
33
+ ```
34
+ For detailed usage and API documentation, please refer to the Doorloop API [documentation](https://api.doorloop.com/reference/get-accounts).
35
+
36
+
37
+ ## Development
38
+
39
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
40
+
41
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
42
+
43
+ ## Contributing
44
+
45
+ Bug reports and pull requests are welcome on GitHub at https://github.com/mezbahalam/doorloop. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/doorloop/blob/master/CODE_OF_CONDUCT.md).
46
+
47
+
48
+ ## License
49
+
50
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
51
+
52
+ ## Code of Conduct
53
+
54
+ Everyone interacting in the Doorloop project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/doorloop/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "doorloop"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/doorloop.gemspec ADDED
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/doorloop/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'doorloop'
7
+ spec.version = Doorloop::VERSION
8
+ spec.authors = ['MezbahAlam']
9
+ spec.email = ['mezbahalam26@gmail.com']
10
+
11
+ spec.summary = 'A simple wrapper for the DoorLoop API'
12
+ spec.description = 'A Ruby client for the DoorLoop API, allowing easy access to its resources.'
13
+ spec.homepage = 'https://github.com/mezbahalam/doorloop'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
16
+
17
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
18
+
19
+ spec.metadata['homepage_uri'] = spec.homepage
20
+ spec.metadata['source_code_uri'] = 'https://github.com/mezbahalam/doorloop'
21
+ spec.metadata['changelog_uri'] = 'https://github.com/mezbahalam/doorloop/CHANGELOG.md'
22
+
23
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ end
26
+ spec.bindir = 'exe'
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ['lib']
29
+
30
+ spec.add_dependency 'rest-client', '~> 2.0'
31
+
32
+ spec.add_development_dependency 'rake', '~> 13.0'
33
+ spec.add_development_dependency 'rubocop', '~> 1.0'
34
+ spec.add_development_dependency 'webmock', '~> 3.19.1'
35
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DoorLoop
4
+ class Accounts
5
+ def initialize(client)
6
+ @client = client
7
+ end
8
+
9
+
10
+ def list(options = {})
11
+ @client.get('accounts', options)
12
+ end
13
+
14
+ def create(params)
15
+ @client.post('accounts', params)
16
+ end
17
+
18
+ def retrieve(id)
19
+ @client.get("accounts/#{id}")
20
+ end
21
+
22
+ def update(id, params)
23
+ @client.put("accounts/#{id}", params)
24
+ end
25
+
26
+ def delete(id)
27
+ @client.delete("accounts/#{id}")
28
+ end
29
+ end
30
+ end
31
+
32
+ # Example usage
33
+ # client = DoorLoop::Client.new('your_api_token')
34
+ # response = client.accounts.create({ name: 'New Account', active: true, type: 'ASSET_ACCOUNT' })
35
+ # puts response
36
+ # doorloop.accounts.create("active"=>true, "name"=>"Cable & Internet & Wifi Wifi", "id"=>"658ef10a55e60d0de105d7c9", "type"=>"EXPENSE_EXPENSE", "description"=> "string")
37
+ # "667ab65df65d881f0bef54fb"
38
+ # >> doorloop.accounts.update("667ab65df65d881f0bef54fb",{"name"=>"Cable & Internet & Wifi", "active" => true,"type"=>"EXPENSE_EXPENSE" })
39
+ #
@@ -0,0 +1,205 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rest-client'
4
+ require 'json'
5
+ require 'logger'
6
+ require_relative 'error_handler'
7
+ require_relative 'accounts'
8
+ require_relative 'properties'
9
+ require_relative 'units'
10
+ require_relative 'users'
11
+ require_relative 'leases'
12
+ require_relative 'tenants'
13
+ require_relative 'lease_payments'
14
+ require_relative 'lease_charges'
15
+ require_relative 'lease_returned_payments'
16
+ require_relative 'lease_credits'
17
+ require_relative 'portfolios'
18
+ require_relative 'tasks'
19
+ require_relative 'owners'
20
+ require_relative 'vendors'
21
+ require_relative 'expenses'
22
+ require_relative 'vendor_bills'
23
+ require_relative 'vendor_credits'
24
+ require_relative 'reports'
25
+ require_relative 'communication_logs'
26
+ require_relative 'notes'
27
+ require_relative 'files'
28
+
29
+
30
+ module DoorLoop
31
+ class Client
32
+ attr_accessor :api_token, :api_base_url, :retry_on_rate_limit, :logger
33
+
34
+ def initialize(api_token, api_base_url: 'https://app.doorloop.com/api/', retry_on_rate_limit: false)
35
+ @api_token = api_token
36
+ @api_base_url = api_base_url
37
+ @retry_on_rate_limit = retry_on_rate_limit
38
+ @logger = Logger.new($stdout)
39
+ @error_handler = DoorLoop::ErrorHandler.new(@logger, self)
40
+ end
41
+
42
+ def accounts
43
+ Accounts.new(self)
44
+ end
45
+
46
+ def properties
47
+ Properties.new(self)
48
+ end
49
+
50
+ def units
51
+ Units.new(self)
52
+ end
53
+
54
+ def users
55
+ Users.new(self)
56
+ end
57
+
58
+ def leases
59
+ Leases.new(self)
60
+ end
61
+
62
+ def tenants
63
+ Tenants.new(self)
64
+ end
65
+
66
+ def lease_payments
67
+ LeasePayments.new(self)
68
+ end
69
+
70
+ def lease_returned_payments
71
+ LeaseReturnedPayments.new(self)
72
+ end
73
+
74
+ def lease_charges
75
+ LeaseCharges.new(self)
76
+ end
77
+
78
+ def lease_credits
79
+ LeaseCredits.new(self)
80
+ end
81
+
82
+ def portfolios
83
+ Portfolios.new(self)
84
+ end
85
+
86
+ def tasks
87
+ Tasks.new(self)
88
+ end
89
+
90
+ def owners
91
+ Owners.new(self)
92
+ end
93
+
94
+ def vendors
95
+ Vendors.new(self)
96
+ end
97
+
98
+ def expenses
99
+ Expenses.new(self)
100
+ end
101
+
102
+ def vender_bills
103
+ VendorBills.new(self)
104
+ end
105
+
106
+ def vendor_credits
107
+ VendorCredits.new(self)
108
+ end
109
+
110
+ def reports
111
+ Reports.new(self)
112
+ end
113
+
114
+ def notes
115
+ Notes.new(self)
116
+ end
117
+
118
+ def files
119
+ Files.new(self)
120
+ end
121
+
122
+ def communication_logs
123
+ CommunicationLogs.new(self)
124
+ end
125
+
126
+ def get(path, options = {})
127
+ url = build_url(path, options)
128
+ response = make_request(url)
129
+ parse_response(response)
130
+ end
131
+
132
+ def post(path, payload)
133
+ url = build_url(path)
134
+ response = make_post_request(url, payload)
135
+ parse_response(response)
136
+ end
137
+
138
+ def put(path, payload)
139
+ url = build_url(path)
140
+ response = make_put_request(url, payload)
141
+ parse_response(response)
142
+ end
143
+
144
+ def delete(path)
145
+ url = build_url(path)
146
+ response = make_delete_request(url)
147
+ parse_response(response)
148
+ end
149
+
150
+
151
+ private
152
+
153
+ def headers
154
+ {
155
+ 'Accept' => 'application/json',
156
+ 'Authorization' => "Bearer #{@api_token}",
157
+ 'Content-Type' => 'application/json'
158
+ }
159
+ end
160
+
161
+ def build_url(path, options = {})
162
+ defaults = { page_number: 1, page_size: 50, sort_by: nil, sort_descending: false }
163
+ options = defaults.merge(options)
164
+
165
+ options.delete(:sort_by) if options[:sort_by].nil?
166
+ options.delete(:sort_descending) if options[:sort_descending] == false
167
+
168
+ uri = URI.join(@api_base_url, path)
169
+ uri.query = URI.encode_www_form(options) if options.any?
170
+ uri.to_s
171
+ rescue StandardError => e
172
+ @logger.error("Error building URL: #{e.message}")
173
+ raise DoorLoop::Error, "Error building URL: #{e.message}"
174
+ end
175
+
176
+ def parse_response(response)
177
+ JSON.parse(response.body)
178
+ end
179
+
180
+ def make_request(url)
181
+ RestClient.get(url, headers)
182
+ rescue RestClient::ExceptionWithResponse => e
183
+ @error_handler.handle(e)
184
+ end
185
+
186
+ def make_post_request(url, payload)
187
+ RestClient.post(url, payload.to_json, headers)
188
+ rescue RestClient::ExceptionWithResponse => e
189
+ @error_handler.handle(e)
190
+ end
191
+
192
+ def make_put_request(url, payload)
193
+ RestClient.put(url, payload.to_json, headers)
194
+ rescue RestClient::ExceptionWithResponse => e
195
+ @logger.error("PUT request failed: #{e.response}")
196
+ @error_handler.handle(e)
197
+ end
198
+
199
+ def make_delete_request(url)
200
+ RestClient.delete(url, headers)
201
+ rescue RestClient::ExceptionWithResponse => e
202
+ @error_handler.handle(e)
203
+ end
204
+ end
205
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DoorLoop
4
+ class CommunicationLogs
5
+ def initialize(client)
6
+ @client = client
7
+ end
8
+
9
+ def list(options = {})
10
+ @client.get('communications', options)
11
+ end
12
+
13
+ def create(params)
14
+ @client.post('communications', params)
15
+ end
16
+
17
+ def retrieve(id)
18
+ @client.get("communications/#{id}")
19
+ end
20
+
21
+ def update(id, params)
22
+ @client.put("communications/#{id}", params)
23
+ end
24
+
25
+ def delete(id)
26
+ @client.delete("communications/#{id}")
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DoorLoop
4
+ class ErrorHandler
5
+ def initialize(logger, client)
6
+ @logger = logger
7
+ @client = client
8
+ end
9
+
10
+ def handle(exception)
11
+ case exception.http_code
12
+ when 401
13
+ @logger.error('Unauthorized access')
14
+ raise DoorLoop::UnauthorizedError, 'Unauthorized access'
15
+ when 403
16
+ @logger.error('Forbidden access')
17
+ raise DoorLoop::ForbiddenError, 'Forbidden access'
18
+ when 404
19
+ @logger.error('Resource not found')
20
+ raise DoorLoop::NotFoundError, 'Resource not found'
21
+ when 429
22
+ handle_rate_limit(exception)
23
+ else
24
+ @logger.error("Unexpected error: #{exception}")
25
+ raise DoorLoop::Error, "Unexpected error: #{exception}"
26
+ end
27
+ end
28
+
29
+ def handle_rate_limit(exception)
30
+ retry_after = exception.response.headers[:retry_after].to_i
31
+ if @client.retry_on_rate_limit
32
+ begin
33
+ @logger.warn("Rate limit exceeded, retrying in #{retry_after} seconds...")
34
+ sleep(retry_after)
35
+ rescue DoorLoop::TooManyRequestsError
36
+ retry
37
+ end
38
+ else
39
+ @logger.warn("Rate limit exceeded, retry after #{retry_after} seconds.")
40
+ raise DoorLoop::TooManyRequestsError, 'Rate limit exceeded'
41
+ end
42
+ end
43
+ end
44
+ end