dotloop 0.1.2

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 (50) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.gitignore +9 -0
  5. data/.rspec +2 -0
  6. data/.rubocop.yml +44 -0
  7. data/.travis.yml +8 -0
  8. data/Gemfile +4 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +109 -0
  11. data/Rakefile +6 -0
  12. data/bin/console +10 -0
  13. data/bin/setup +8 -0
  14. data/certs/shanedavies.pem +21 -0
  15. data/dotloop.gemspec +42 -0
  16. data/lib/dotloop.rb +42 -0
  17. data/lib/dotloop/admin.rb +24 -0
  18. data/lib/dotloop/client.rb +89 -0
  19. data/lib/dotloop/document.rb +26 -0
  20. data/lib/dotloop/document_activity.rb +24 -0
  21. data/lib/dotloop/employee.rb +14 -0
  22. data/lib/dotloop/folder.rb +14 -0
  23. data/lib/dotloop/loop.rb +62 -0
  24. data/lib/dotloop/loop_activity.rb +24 -0
  25. data/lib/dotloop/models/admin.rb +13 -0
  26. data/lib/dotloop/models/buying_brokerage.rb +15 -0
  27. data/lib/dotloop/models/document.rb +17 -0
  28. data/lib/dotloop/models/document_activity.rb +9 -0
  29. data/lib/dotloop/models/employee.rb +15 -0
  30. data/lib/dotloop/models/financials.rb +13 -0
  31. data/lib/dotloop/models/folder.rb +14 -0
  32. data/lib/dotloop/models/listing_brokerage.rb +15 -0
  33. data/lib/dotloop/models/loop.rb +15 -0
  34. data/lib/dotloop/models/loop_activity.rb +9 -0
  35. data/lib/dotloop/models/loop_detail.rb +9 -0
  36. data/lib/dotloop/models/participant.rb +12 -0
  37. data/lib/dotloop/models/person.rb +19 -0
  38. data/lib/dotloop/models/profile.rb +28 -0
  39. data/lib/dotloop/models/property_address.rb +16 -0
  40. data/lib/dotloop/models/section.rb +11 -0
  41. data/lib/dotloop/models/tag.rb +11 -0
  42. data/lib/dotloop/models/task.rb +16 -0
  43. data/lib/dotloop/participant.rb +15 -0
  44. data/lib/dotloop/person.rb +29 -0
  45. data/lib/dotloop/profile.rb +17 -0
  46. data/lib/dotloop/query_param_helpers.rb +59 -0
  47. data/lib/dotloop/task.rb +14 -0
  48. data/lib/dotloop/version.rb +3 -0
  49. metadata +294 -0
  50. metadata.gz.sig +0 -0
@@ -0,0 +1,26 @@
1
+ module Dotloop
2
+ class Document
3
+ attr_accessor :client
4
+
5
+ def initialize(client:)
6
+ @client = client
7
+ end
8
+
9
+ def all(profile_id:, loop_view_id:)
10
+ @client.get("/profile/#{profile_id.to_i}/loop/#{loop_view_id.to_i}/document").map do |document_attrs|
11
+ doc = Dotloop::Models::Document.new(document_attrs)
12
+ doc.client = client
13
+ doc
14
+ end
15
+ end
16
+
17
+ def get(profile_id:, loop_view_id:, document_id:, document_name:)
18
+ document_name = CGI.escape(document_name)
19
+ StringIO.new(
20
+ @client.raw(
21
+ "/profile/#{profile_id.to_i}/loop/#{loop_view_id.to_i}/document/#{document_id}/#{document_name}.pdf"
22
+ )
23
+ )
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,24 @@
1
+ module Dotloop
2
+ class DocumentActivity
3
+ include Dotloop::QueryParamHelpers
4
+ attr_accessor :client
5
+
6
+ def initialize(client:)
7
+ @client = client
8
+ end
9
+
10
+ def all(options = {})
11
+ activities = []
12
+ url = "/profile/#{profile_id(options)}/document/#{document_id(options)}/activity"
13
+ (1..MAX_LOOPS).each do |i|
14
+ options[:batch_number] = i
15
+ current_activity = @client.get(url, query_params(options)).map do |act_attrs|
16
+ Dotloop::Models::DocumentActivity.new(act_attrs)
17
+ end
18
+ activities += current_activity
19
+ break if current_activity.size < BATCH_SIZE
20
+ end
21
+ activities
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,14 @@
1
+ module Dotloop
2
+ class Employee
3
+ attr_accessor :client
4
+
5
+ def initialize(client:)
6
+ @client = client
7
+ end
8
+
9
+ def all(profile_id:)
10
+ url = "/profile/#{profile_id.to_i}/employee"
11
+ @client.get(url).map { |employee_attrs| Dotloop::Models::Employee.new(employee_attrs) }
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ module Dotloop
2
+ class Folder
3
+ attr_accessor :client
4
+
5
+ def initialize(client:)
6
+ @client = client
7
+ end
8
+
9
+ def all(profile_id:, loop_view_id:)
10
+ url = "/profile/#{profile_id.to_i}/loop/#{loop_view_id.to_i}/folder"
11
+ @client.get(url).map { |folder_attrs| Dotloop::Models::Folder.new(folder_attrs) }
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,62 @@
1
+ module Dotloop
2
+ class Loop
3
+ include Dotloop::QueryParamHelpers
4
+ attr_accessor :client
5
+
6
+ def initialize(client:)
7
+ @client = client
8
+ end
9
+
10
+ def all(options = {})
11
+ loops = []
12
+ options[:batch_size] = BATCH_SIZE
13
+ (1..MAX_LOOPS).each do |i|
14
+ options[:batch_number] = i
15
+ current_batch = batch(options)
16
+ loops += current_batch
17
+ break if current_batch.size < options[:batch_size]
18
+ end
19
+ loops
20
+ end
21
+
22
+ def batch(options = {})
23
+ @client.get("/profile/#{profile_id(options)}/loop", query_params(options)).map do |attrs|
24
+ Dotloop::Models::Loop.new(attrs)
25
+ end
26
+ end
27
+
28
+ def find(profile_id:, loop_view_id:)
29
+ loop_data = @client.get("/profile/#{profile_id.to_i}/loop/#{loop_view_id.to_i}")
30
+ Dotloop::Models::Loop.new(loop_data)
31
+ end
32
+
33
+ def detail(profile_id:, loop_view_id:)
34
+ loop_detail = @client.get("/profile/#{profile_id.to_i}/loop/#{loop_view_id.to_i}/detail")
35
+ loop_detail[:sections] = fixed_sections(loop_detail[:sections])
36
+ Dotloop::Models::LoopDetail.new(loop_detail)
37
+ end
38
+
39
+ private
40
+
41
+ def fixed_sections(sections)
42
+ return unless sections
43
+ sections.each_with_object({}) do |item, memo|
44
+ memo[item[0].to_s.downcase.tr(' ', '_')] = item[1]
45
+ end
46
+ end
47
+
48
+ def query_params(options)
49
+ {
50
+ batchNumber: batch_number(options),
51
+ batchSize: batch_size(options),
52
+ statusIds: status_ids(options),
53
+ complianceStatusIds: compliance_status_ids(options),
54
+ tagIds: tag_ids(options),
55
+ sortBy: options[:sort_by],
56
+ searchQuery: options[:search_query],
57
+ tagNames: options[:tag_names],
58
+ createdByMe: created_by_me(options)
59
+ }.delete_if { |_, v| should_delete(v) }
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,24 @@
1
+ module Dotloop
2
+ class LoopActivity
3
+ include Dotloop::QueryParamHelpers
4
+ attr_accessor :client
5
+
6
+ def initialize(client:)
7
+ @client = client
8
+ end
9
+
10
+ def all(options = {})
11
+ activities = []
12
+ url = "/profile/#{profile_id(options)}/loop/#{loop_view_id(options)}/activity"
13
+ (1..MAX_LOOPS).each do |i|
14
+ options[:batch_number] = i
15
+ current_activity = @client.get(url, query_params(options)).map do |act_attrs|
16
+ Dotloop::Models::LoopActivity.new(act_attrs)
17
+ end
18
+ activities += current_activity
19
+ break if current_activity.size < BATCH_SIZE
20
+ end
21
+ activities
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,13 @@
1
+ module Dotloop
2
+ module Models
3
+ class Admin
4
+ include Virtus.model
5
+ attribute :email_address
6
+ attribute :first_name
7
+ attribute :is_admin, Boolean
8
+ attribute :last_name
9
+ attribute :member_id, Integer
10
+ attribute :status
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ module Dotloop
2
+ module Models
3
+ class BuyingBrokerage
4
+ include Virtus.model
5
+
6
+ attribute :city
7
+ attribute :name
8
+ attribute :postal_code
9
+ attribute :state_or_province
10
+ attribute :street_name
11
+ attribute :street_number
12
+ attribute :suite
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,17 @@
1
+ module Dotloop
2
+ module Models
3
+ class Document
4
+ include Virtus.model
5
+ attribute :created_by, Integer
6
+ attribute :created_date, DateTime
7
+ attribute :document_id, Integer
8
+ attribute :document_name
9
+ attribute :folder_name
10
+ attribute :last_modified_date, DateTime
11
+ attribute :loop_id, Integer
12
+ attribute :shared_with, Array[Integer]
13
+ attribute :signature_verfication_link
14
+ attr_accessor :client
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ module Dotloop
2
+ module Models
3
+ class DocumentActivity
4
+ include Virtus.model
5
+ attribute :activity_date, DateTime
6
+ attribute :message
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,15 @@
1
+ module Dotloop
2
+ module Models
3
+ class Employee
4
+ include Virtus.model
5
+ attribute :email_address
6
+ attribute :first_name
7
+ attribute :is_admin, Boolean
8
+ attribute :last_name
9
+ attribute :loops_created, Integer
10
+ attribute :member_id, Integer
11
+ attribute :status
12
+ attribute :total_loops, Integer
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ module Dotloop
2
+ module Models
3
+ class Financials
4
+ include Virtus.model
5
+
6
+ attribute :comission_rate
7
+ attribute :current_price
8
+ attribute :earnest_money_held_by
9
+ attribute :original_listing_price
10
+ attribute :purchase_price
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ module Dotloop
2
+ module Models
3
+ class Folder
4
+ include Virtus.model
5
+ attribute :archived, Boolean
6
+ attribute :folder_email_name
7
+ attribute :folder_id, Integer
8
+ attribute :last_updated_date_iso, DateTime
9
+ attribute :minimized, Boolean
10
+ attribute :name
11
+ attribute :view_id, Integer
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ module Dotloop
2
+ module Models
3
+ class ListingBrokerage
4
+ include Virtus.model
5
+
6
+ attribute :city
7
+ attribute :name
8
+ attribute :office_phone
9
+ attribute :postal_code
10
+ attribute :state_or_province
11
+ attribute :street_name
12
+ attribute :street_number
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Dotloop
2
+ module Models
3
+ class Loop
4
+ include Virtus.model
5
+ attribute :created_by, Integer
6
+ attribute :last_updated, DateTime
7
+ attribute :loop_id, Integer
8
+ attribute :loop_name
9
+ attribute :loop_status
10
+ attribute :loop_tags, Array
11
+ attribute :loop_view_id, Integer
12
+ attribute :transaction_type
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,9 @@
1
+ module Dotloop
2
+ module Models
3
+ class LoopActivity
4
+ include Virtus.model
5
+ attribute :activity_date, DateTime
6
+ attribute :message
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Dotloop
2
+ module Models
3
+ class LoopDetail
4
+ include Virtus.model
5
+ attribute :loop_id, Integer
6
+ attribute :sections, Dotloop::Models::Section
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,12 @@
1
+ module Dotloop
2
+ module Models
3
+ class Participant
4
+ include Virtus.model
5
+ attribute :email
6
+ attribute :member_of_my_team
7
+ attribute :name, Boolean
8
+ attribute :participant_id, Integer
9
+ attribute :role
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,19 @@
1
+ module Dotloop
2
+ module Models
3
+ class Person
4
+ include Virtus.model
5
+ attribute :city
6
+ attribute :email
7
+ attribute :fax
8
+ attribute :first_name
9
+ attribute :homephone
10
+ attribute :last_name
11
+ attribute :officephone
12
+ attribute :person_id, Integer
13
+ attribute :state_or_prov
14
+ attribute :street_address01
15
+ attribute :zip_or_postal_code
16
+ attr_accessor :client
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,28 @@
1
+ module Dotloop
2
+ module Models
3
+ class Profile
4
+ include Virtus.model
5
+
6
+ attribute :active, Boolean
7
+ attribute :address1
8
+ attribute :address2
9
+ attribute :city
10
+ attribute :company_name
11
+ attribute :deleted, Boolean
12
+ attribute :fax_number
13
+ attribute :name
14
+ attribute :phone_number
15
+ attribute :profile_id, Integer
16
+ attribute :profile_type
17
+ attribute :state
18
+ attribute :suite
19
+ attribute :zipcode
20
+
21
+ attr_accessor :client
22
+
23
+ def loops
24
+ client.Loop.all(profile_id: profile_id)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,16 @@
1
+ module Dotloop
2
+ module Models
3
+ class PropertyAddress
4
+ include Virtus.model
5
+
6
+ attribute :city
7
+ attribute :country
8
+ attribute :mls_number
9
+ attribute :postal_code
10
+ attribute :property_address_country
11
+ attribute :state_or_province
12
+ attribute :street_name
13
+ attribute :street_number
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,11 @@
1
+ module Dotloop
2
+ module Models
3
+ class Section
4
+ include Virtus.model
5
+ attribute :buying_brokerage, Dotloop::Models::BuyingBrokerage
6
+ attribute :financials, Dotloop::Models::Financials
7
+ attribute :listing_brokerage, Dotloop::Models::ListingBrokerage
8
+ attribute :property_address, Dotloop::Models::PropertyAddress
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dotloop
2
+ module Models
3
+ class Tag
4
+ include Virtus.model
5
+
6
+ attribute :profile_id, Integer
7
+ attribute :tag_id, Integer
8
+ attribute :tag_name, String
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,16 @@
1
+ module Dotloop
2
+ module Models
3
+ class Task
4
+ include Virtus.model
5
+ attribute :completion_status
6
+ attribute :created_by, Integer
7
+ attribute :created_date, DateTime
8
+ attribute :due_date, DateTime
9
+ attribute :due_date_type, DateTime
10
+ attribute :list_id, Integer
11
+ attribute :list_name
12
+ attribute :locked_status
13
+ attribute :name
14
+ end
15
+ end
16
+ end