Class: Dotloop::Loop
Constant Summary
collapse
- STATUS_MAP =
{
private_listing: 1,
active_listing: 2,
under_contract: 3,
sold: 4,
leased: 5,
archived: 6,
pre_listing: 7,
pre_offer: 8
}.freeze
QueryParamHelpers::BATCH_SIZE, QueryParamHelpers::MAX_LOOPS
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(client:) ⇒ Loop
Returns a new instance of Loop.
17
18
19
|
# File 'lib/dotloop/loop.rb', line 17
def initialize(client:)
@client = client
end
|
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
4
5
6
|
# File 'lib/dotloop/loop.rb', line 4
def client
@client
end
|
Class Method Details
.statuses ⇒ Object
56
57
58
|
# File 'lib/dotloop/loop.rb', line 56
def self.statuses
STATUS_MAP.keys
end
|
Instance Method Details
#all(options = {}) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/dotloop/loop.rb', line 21
def all(options = {})
loops = []
options[:batch_size] = BATCH_SIZE
(1..MAX_LOOPS).each do |i|
options[:batch_number] = i
current_batch = batch(options)
loops += current_batch
break if current_batch.size < options[:batch_size]
end
loops
end
|
#batch(options = {}) ⇒ Object
33
34
35
36
37
38
39
40
|
# File 'lib/dotloop/loop.rb', line 33
def batch(options = {})
@client.get("/profile/#{profile_id(options)}/loop", query_params(options)).map do |attrs|
lp = Dotloop::Models::Loop.new(attrs)
lp.client = client
lp.profile_id = profile_id(options)
lp
end
end
|
#detail(profile_id:, loop_view_id:) ⇒ Object
50
51
52
53
54
|
# File 'lib/dotloop/loop.rb', line 50
def detail(profile_id:, loop_view_id:)
loop_detail = @client.get("/profile/#{profile_id.to_i}/loop/#{loop_view_id.to_i}/detail")
loop_detail[:sections] = Dotloop::Section.new(loop_detail[:sections]).sections if loop_detail[:sections]
Dotloop::Models::LoopDetail.new(loop_detail)
end
|
#find(profile_id:, loop_view_id:) ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/dotloop/loop.rb', line 42
def find(profile_id:, loop_view_id:)
loop_data = @client.get("/profile/#{profile_id.to_i}/loop/#{loop_view_id.to_i}")
lp = Dotloop::Models::Loop.new(loop_data)
lp.client = client
lp.profile_id = profile_id.to_i
lp
end
|
#statuses ⇒ Object
60
61
62
|
# File 'lib/dotloop/loop.rb', line 60
def statuses
self.class.statuses
end
|