dotloop-ruby 0.1.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.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.rspec +2 -0
  4. data/CODE_OF_CONDUCT.md +74 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +386 -0
  8. data/Rakefile +6 -0
  9. data/bin/console +14 -0
  10. data/bin/setup +8 -0
  11. data/dotloop-ruby.gemspec +46 -0
  12. data/lib/.DS_Store +0 -0
  13. data/lib/dotloop-ruby.rb +45 -0
  14. data/lib/dotloop/.DS_Store +0 -0
  15. data/lib/dotloop/authenticate.rb +92 -0
  16. data/lib/dotloop/client.rb +160 -0
  17. data/lib/dotloop/contact.rb +70 -0
  18. data/lib/dotloop/document.rb +72 -0
  19. data/lib/dotloop/exceptions.rb +10 -0
  20. data/lib/dotloop/folder.rb +60 -0
  21. data/lib/dotloop/loop.rb +157 -0
  22. data/lib/dotloop/loop_detail.rb +38 -0
  23. data/lib/dotloop/models/.DS_Store +0 -0
  24. data/lib/dotloop/models/contact.rb +22 -0
  25. data/lib/dotloop/models/document.rb +27 -0
  26. data/lib/dotloop/models/folder.rb +19 -0
  27. data/lib/dotloop/models/loop.rb +45 -0
  28. data/lib/dotloop/models/loop_detail.rb +22 -0
  29. data/lib/dotloop/models/loop_details/contact.rb +28 -0
  30. data/lib/dotloop/models/loop_details/contract_dates.rb +13 -0
  31. data/lib/dotloop/models/loop_details/contract_info.rb +13 -0
  32. data/lib/dotloop/models/loop_details/financials.rb +20 -0
  33. data/lib/dotloop/models/loop_details/geographic_description.rb +22 -0
  34. data/lib/dotloop/models/loop_details/listing_information.rb +25 -0
  35. data/lib/dotloop/models/loop_details/offer_dates.rb +15 -0
  36. data/lib/dotloop/models/loop_details/property.rb +18 -0
  37. data/lib/dotloop/models/loop_details/property_address.rb +21 -0
  38. data/lib/dotloop/models/loop_details/referral.rb +13 -0
  39. data/lib/dotloop/models/participant.rb +17 -0
  40. data/lib/dotloop/models/profile.rb +36 -0
  41. data/lib/dotloop/models/task.rb +18 -0
  42. data/lib/dotloop/models/tasklist.rb +31 -0
  43. data/lib/dotloop/models/template.rb +18 -0
  44. data/lib/dotloop/participant.rb +66 -0
  45. data/lib/dotloop/profile.rb +26 -0
  46. data/lib/dotloop/query_param_helpers.rb +36 -0
  47. data/lib/dotloop/task.rb +32 -0
  48. data/lib/dotloop/tasklist.rb +30 -0
  49. data/lib/dotloop/template.rb +28 -0
  50. data/lib/dotloop/version.rb +3 -0
  51. metadata +276 -0
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dotloop
4
+ module Models
5
+ class LoopDetail
6
+ include Virtus.model
7
+ attribute :contract_dates, Dotloop::Models::LoopDetails::ContractDates
8
+ attribute :contract_info, Dotloop::Models::LoopDetails::ContractInfo
9
+ attribute :financials, Dotloop::Models::LoopDetails::Financials
10
+ attribute :geographic_description, Dotloop::Models::LoopDetails::GeographicDescription
11
+ attribute :listing_information, Dotloop::Models::LoopDetails::ListingInformation
12
+ attribute :offer_dates, Dotloop::Models::LoopDetails::OfferDates
13
+ attribute :property_address, Dotloop::Models::LoopDetails::PropertyAddress
14
+ attribute :property, Dotloop::Models::LoopDetails::Property
15
+ attribute :referral, Dotloop::Models::LoopDetails::Referral
16
+ attribute :contacts, Array[Dotloop::Models::LoopDetails::Contact]
17
+
18
+ attr_accessor :profile_id
19
+ attr_accessor :loop_id
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dotloop
4
+ module Models
5
+ module LoopDetails
6
+ class Contact
7
+ include Virtus.model
8
+ attribute :role
9
+ attribute :cell_phone
10
+ attribute :city
11
+ attribute :company_name
12
+ attribute :country
13
+ attribute :email
14
+ attribute :fax
15
+ attribute :id
16
+ attribute :license
17
+ attribute :marital_status
18
+ attribute :name
19
+ attribute :phone
20
+ attribute :state_prov
21
+ attribute :street_name
22
+ attribute :street_number
23
+ attribute :unit_number
24
+ attribute :zip_or_postal_code
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dotloop
4
+ module Models
5
+ module LoopDetails
6
+ class ContractDates
7
+ include Virtus.model
8
+ attribute :contract_agreement_date
9
+ attribute :closing_date
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dotloop
4
+ module Models
5
+ module LoopDetails
6
+ class ContractInfo
7
+ include Virtus.model
8
+ attribute :transaction_number
9
+ attribute :type
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dotloop
4
+ module Models
5
+ module LoopDetails
6
+ class Financials
7
+ include Virtus.model
8
+ attribute :sale_commission_rate
9
+ attribute :earnest_money_held_by
10
+ attribute :purchase_sale_price
11
+ attribute :earnest_money_amount
12
+ attribute :sale_commission_total
13
+ attribute :sale_commission_split_percent_buy_side
14
+ attribute :sale_commission_split_percent_sell_side
15
+ attribute :sale_commission_split_doller_buy_side
16
+ attribute :sale_commission_split_doller_sell_side
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dotloop
4
+ module Models
5
+ module LoopDetails
6
+ class GeographicDescription
7
+ include Virtus.model
8
+
9
+ attribute :addition
10
+ attribute :block
11
+ attribute :deed_book
12
+ attribute :deed_page
13
+ attribute :lot
14
+ attribute :map_grid
15
+ attribute :mls_area
16
+ attribute :mls_legal_description
17
+ attribute :section
18
+ attribute :subdivision
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dotloop
4
+ module Models
5
+ module LoopDetails
6
+ class ListingInformation
7
+ include Virtus.model
8
+ attribute :property_excludes
9
+ attribute :description_of_other_liens
10
+ attribute :expiration_date
11
+ attribute :listing_date
12
+ attribute :total_encumbrances
13
+ attribute :property_includes
14
+ attribute :remarks
15
+ attribute :current_price
16
+ attribute :first_mortgage_balance
17
+ attribute :homeowners_association
18
+ attribute :second_mortgage_balance
19
+ attribute :original_price
20
+ attribute :other_liens
21
+ attribute :homeowners_association_dues
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dotloop
4
+ module Models
5
+ module LoopDetails
6
+ class OfferDates
7
+ include Virtus.model
8
+ attribute :offer_date
9
+ attribute :inspection_date
10
+ attribute :occupancy_date
11
+ attribute :offer_expiration_date
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dotloop
4
+ module Models
5
+ module LoopDetails
6
+ class Property
7
+ include Virtus.model
8
+ attribute :bedrooms
9
+ attribute :year_built
10
+ attribute :square_footage
11
+ attribute :type
12
+ attribute :bathrooms
13
+ attribute :school_district
14
+ attribute :lot_size
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dotloop
4
+ module Models
5
+ module LoopDetails
6
+ class PropertyAddress
7
+ include Virtus.model
8
+ attribute :city
9
+ attribute :county
10
+ attribute :country
11
+ attribute :mls_number
12
+ attribute :parcel_tax_id
13
+ attribute :state_prov
14
+ attribute :street_name
15
+ attribute :street_number
16
+ attribute :unit_number
17
+ attribute :zip_postal_code
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dotloop
4
+ module Models
5
+ module LoopDetails
6
+ class Referral
7
+ include Virtus.model
8
+ attribute :referral_source
9
+ attribute :referral_percent
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dotloop
4
+ module Models
5
+ class Participant
6
+ include Virtus.model
7
+ attribute :email
8
+ attribute :full_name
9
+ attribute :id, Integer
10
+ attribute :role
11
+
12
+ attr_accessor :client
13
+ attr_accessor :profile_id
14
+ attr_accessor :loop_id
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dotloop
4
+ module Models
5
+ class Profile
6
+ include Virtus.model
7
+
8
+ attribute :address
9
+ attribute :city
10
+ attribute :company
11
+ attribute :default, Boolean
12
+ attribute :fax
13
+ attribute :id, Integer
14
+ attribute :name
15
+ attribute :phone
16
+ attribute :requires_template, Boolean
17
+ attribute :state
18
+ attribute :type
19
+ attribute :zip_code
20
+
21
+ attr_accessor :client
22
+
23
+ def loops
24
+ client.Loop.all(profile_id: id)
25
+ end
26
+
27
+ def create_loop(data)
28
+ client.Loop.create(profile_id: id, params: data)
29
+ end
30
+
31
+ def loop_it(data)
32
+ client.Loop.loop_it(profile_id: id, params: data)
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dotloop
4
+ module Models
5
+ class Task
6
+ include Virtus.model
7
+ attribute :name
8
+ attribute :completed
9
+ attribute :due
10
+ attribute :id, Integer
11
+
12
+ attr_accessor :client
13
+ attr_accessor :profile_id
14
+ attr_accessor :loop_id
15
+ attr_accessor :task_list_id
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dotloop
4
+ module Models
5
+ class Tasklist
6
+ include Virtus.model
7
+ attribute :name
8
+ attribute :id, Integer
9
+
10
+ attr_accessor :profile_id
11
+ attr_accessor :loop_id
12
+ attr_accessor :client
13
+
14
+ def tasks
15
+ client.Task.all(
16
+ profile_id: profile_id,
17
+ loop_id: loop_id,
18
+ task_list_id: id
19
+ )
20
+ end
21
+
22
+ def get
23
+ client.Tasklist.get(
24
+ profile_id: profile_id,
25
+ loop_id: loop_id,
26
+ task_list_id: id
27
+ )
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dotloop
4
+ module Models
5
+ class Template
6
+ include Virtus.model
7
+ attribute :name
8
+ attribute :id, Integer
9
+ attribute :profile_id, Integer
10
+ attribute :transaction_type
11
+ attribute :shared, Boolean
12
+ attribute :global, Boolean
13
+
14
+ attr_accessor :profile_id
15
+ attr_accessor :client
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dotloop
4
+ class Participant
5
+ attr_accessor :client
6
+
7
+ PARTICIPANT_FIELDS = %w[fullName email role].freeze
8
+
9
+ def initialize(client:)
10
+ @client = client
11
+ end
12
+
13
+ def all(profile_id:, loop_id:)
14
+ @client.get("/profile/#{profile_id.to_i}/loop/#{loop_id.to_i}/participant")[:data].map do |participant_attrs|
15
+ participant = Dotloop::Models::Participant.new(participant_attrs)
16
+ participant.client = client
17
+ participant.profile_id = profile_id.to_i
18
+ participant.loop_id = loop_id.to_i
19
+ participant
20
+ end
21
+ end
22
+
23
+ def find(profile_id:, loop_id:, participant_id:)
24
+ participant_data = @client.get("/profile/#{profile_id.to_i}/loop/#{loop_id.to_i}/participant/#{participant_id.to_i}")[:data]
25
+ participant = Dotloop::Models::Participant.new(participant_data)
26
+ participant.client = client
27
+ participant.profile_id = profile_id.to_i
28
+ participant.loop_id = loop_id.to_i
29
+ participant
30
+ end
31
+
32
+ def create(profile_id:, loop_id:, params: {})
33
+ data = {}
34
+ params.each do |key, value|
35
+ PARTICIPANT_FIELDS.include?(key.to_s) || next
36
+ data[key] = value.to_s
37
+ end
38
+
39
+ participant_data = @client.post("/profile/#{profile_id.to_i}/loop/#{loop_id.to_i}/participant", data)[:data]
40
+ participant = Dotloop::Models::Participant.new(participant_data)
41
+ participant.client = client
42
+ participant.profile_id = profile_id.to_i
43
+ participant.loop_id = loop_id.to_i
44
+ participant
45
+ end
46
+
47
+ def update(profile_id:, loop_id:, participant_id:, params: {})
48
+ data = {}
49
+ params.each do |key, value|
50
+ PARTICIPANT_FIELDS.include?(key.to_s) || next
51
+ data[key] = value.to_s
52
+ end
53
+
54
+ participant_data = @client.patch("/profile/#{profile_id.to_i}/loop/#{loop_id.to_i}/participant/#{participant_id.to_i}", data)[:data]
55
+ participant = Dotloop::Models::Participant.new(participant_data)
56
+ participant.client = client
57
+ participant.profile_id = profile_id.to_i
58
+ participant.loop_id = loop_id.to_i
59
+ participant
60
+ end
61
+
62
+ def delete(profile_id:, loop_id:, participant_id:)
63
+ @client.delete("/profile/#{profile_id.to_i}/loop/#{loop_id.to_i}/participant/#{participant_id.to_i}")
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dotloop
4
+ class Profile
5
+ attr_accessor :client
6
+
7
+ def initialize(client:)
8
+ @client = client
9
+ end
10
+
11
+ def all
12
+ @client.get('/profile')[:data].map do |profile_attrs|
13
+ profile = Dotloop::Models::Profile.new(profile_attrs)
14
+ profile.client = client
15
+ profile
16
+ end
17
+ end
18
+
19
+ def find(profile_id:)
20
+ profile_attrs = @client.get("/profile/#{profile_id.to_i}")[:data]
21
+ profile = Dotloop::Models::Profile.new(profile_attrs)
22
+ profile.client = client
23
+ profile
24
+ end
25
+ end
26
+ end