tops_connect 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ea51779a7b5f7ab9379772a5723751ca073fef6
4
- data.tar.gz: e52176e589a6f1e81c5bc5c284051c3aacf9c526
3
+ metadata.gz: c12dc89e03b14593d72f2eb5e7d784b39ee2c994
4
+ data.tar.gz: 1432be52961935df235d278c6b068139414c7395
5
5
  SHA512:
6
- metadata.gz: 9afb749f50a162a4f4d2c195c869fe7549b641ea7f6d6dba0c0255a18506e2b811f0edda523810e8684aa2ce727c5681f3fa5420e7ebd7d73d98e96252e54d5e
7
- data.tar.gz: a54e1f8960178dc77bd94b779b649c143e619c1d0fabaa98e3df7f8d5025d0496017513e797d0bd941359ff0203448824b493703c280ba6d6be65858dc458f3c
6
+ metadata.gz: a39e2abd5217e9c3dce0177f67d08a59cf53a35416bf48dc57ae66fec2d66aa0c06b0013e54ab6fe665e2ccd62480ed63c925ff1469f2bb2d94763287e584fa5
7
+ data.tar.gz: 85ebb9698513db3964d6a5c14f3e9b02fe6a1befefa09700c05aa945ac2a88ca219f7933ea980928825bf89de94f5e929d9f73551dc8fd5cbc9fe81a07ca8ea8
data/lib/tops_connect.rb CHANGED
@@ -6,6 +6,9 @@ require 'json'
6
6
  require 'tops_connect/communities'
7
7
  require 'tops_connect/owners'
8
8
 
9
+ require 'tops_connect/base'
10
+ require 'tops_connect/owner'
11
+
9
12
  require 'tops_connect/configuration'
10
13
  require 'tops_connect/client'
11
14
  require 'tops_connect/version'
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+ module TopsConnect
3
+ class Base
4
+ class << self
5
+ attr_accessor :client
6
+ end
7
+
8
+ def get(*args)
9
+ TopsConnect::Base.client.get(*args)
10
+ end
11
+ end
12
+ end
@@ -22,6 +22,8 @@ module TopsConnect
22
22
  )
23
23
 
24
24
  @subscription_key = TopsConnect.configuration.subscription_key
25
+
26
+ TopsConnect::Base.client = self
25
27
  end
26
28
 
27
29
  def get(endpoint, parameters = {})
@@ -0,0 +1,99 @@
1
+ # frozen_string_literal: true
2
+ module TopsConnect
3
+ class Owner < Base
4
+ attr_reader :id
5
+
6
+ def initialize(id, data = nil)
7
+ @id = id.to_i
8
+ @data = data
9
+ end
10
+
11
+ def data
12
+ @data ||= get "/owner/#{@id}"
13
+ end
14
+
15
+ def alternate_mailing_addresses
16
+ [1, 2].map do |n|
17
+ next unless data["AltMailing#{n}AddressLine1"]
18
+
19
+ city = data["AltMailing#{n}City"]
20
+ state = data["AltMailing#{n}State"]
21
+ zip = data["AltMailing#{n}Zip"]
22
+
23
+ lines = [data["AltMailing#{n}AddressLine1"]]
24
+
25
+ if data["AltMailing#{n}AddressLine2"] !~ /[^[:space:]]/
26
+ lines << data["AltMailing#{n}AddressLine2"]
27
+ end
28
+
29
+ lines << "#{city}, #{state} #{zip}"
30
+
31
+ lines.reject(&:blank?).join("\n")
32
+ end.compact
33
+ end
34
+
35
+ def property_id
36
+ data['PropertyKey']
37
+ end
38
+
39
+ def community_id
40
+ data['CommunityKey']
41
+ end
42
+
43
+ def legal_name
44
+ data['LegalName']
45
+ end
46
+
47
+ def alternate_name
48
+ data['AlternateName']
49
+ end
50
+
51
+ def home_phone
52
+ data['PhoneHome']
53
+ end
54
+
55
+ def alternate_phone
56
+ data['PhoneAlt']
57
+ end
58
+
59
+ def fax
60
+ data['PhoneFax']
61
+ end
62
+
63
+ def work_phone
64
+ data['PhoneWork']
65
+ end
66
+
67
+ def updated_at
68
+ DateTime.parse data['Metadata']['ModifiedDate']
69
+ end
70
+
71
+ def owner?
72
+ data['ResidentType'] == 'Owner'
73
+ end
74
+
75
+ def tenant?
76
+ data['ResidentType'] == 'Tenant'
77
+ end
78
+
79
+ def move_out_date
80
+ DateTime.parse data['MoveOutDate'] if data['MoveOutDate']
81
+ end
82
+
83
+ def settlement_date
84
+ DateTime.parse data['SettlementDate'] if data['SettlementDate']
85
+ end
86
+
87
+ # Method: GET
88
+ # Endpoint: Balance_Get
89
+ def balance
90
+ get "/balance/#{@id}"
91
+ end
92
+
93
+ # Method: GET
94
+ # Endpoint: Charge_Get
95
+ def charges
96
+ get "/charge/#{@id}"
97
+ end
98
+ end
99
+ end
@@ -4,7 +4,7 @@ module TopsConnect
4
4
  # Method: GET
5
5
  # Endpoint: Owner_Get
6
6
  def owner(owner_id)
7
- get "/owner/#{owner_id.to_i}"
7
+ TopsConnect::Owner.new owner_id
8
8
  end
9
9
 
10
10
  # Method: GET
@@ -13,13 +13,9 @@ module TopsConnect
13
13
  parameters = {}
14
14
  parameters['PropertyKey'] = property_id.to_i if property_id
15
15
 
16
- get '/owner', parameters
17
- end
18
-
19
- # Method: GET
20
- # Endpoint: Balance_Get
21
- def balance(owner_id)
22
- get "/balance/#{owner_id.to_i}"
16
+ get('/owner', parameters).map do |owner|
17
+ TopsConnect::Owner.new owner['OwnerKey'], owner
18
+ end
23
19
  end
24
20
  end
25
21
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module TopsConnect
3
- VERSION = '0.1.2'
3
+ VERSION = '0.1.3'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tops_connect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Hoffman
@@ -97,9 +97,11 @@ files:
97
97
  - bin/console
98
98
  - bin/setup
99
99
  - lib/tops_connect.rb
100
+ - lib/tops_connect/base.rb
100
101
  - lib/tops_connect/client.rb
101
102
  - lib/tops_connect/communities.rb
102
103
  - lib/tops_connect/configuration.rb
104
+ - lib/tops_connect/owner.rb
103
105
  - lib/tops_connect/owners.rb
104
106
  - lib/tops_connect/version.rb
105
107
  - tops_connect.gemspec