tops_connect 0.2.0 → 0.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5867e71a798feb5d737263d749fb3b4dd009a19f
4
- data.tar.gz: b5510fb2c07a486eac402485f78fdbba12f02134
3
+ metadata.gz: 4848a6dc16bda8501057fd0279bfe1b4422c6f5d
4
+ data.tar.gz: 9deec64df62077a039d0c5d70f4632d15538e3e0
5
5
  SHA512:
6
- metadata.gz: 80f5fb0f17b286f461ad626600ad4555693955a6b2dd7b1d3c30ab728766ac2c005c86a5335f2c86f068b5bed496c96d22c29c345101ffc8b1adb8bb70ecd589
7
- data.tar.gz: 1a57806bd996195daba9aa889c64644558c949f53283f167b21135928d5375c9c4b20edae8a529ea63d2eb6d8c559ee93b2157ec69a217279ba20daa0a966cd5
6
+ metadata.gz: 9a100cdb062f92be4e637447cd1bda59a8a7be1327b2a88c8daffb9ed2ee894e6702d1162403119a495ee48648e21978161f8152d838849bb6482d338a701962
7
+ data.tar.gz: 7754b43cc9ce16ea0509023f0d4db2ee9e0620513ef733cf1902c5aeb6c739b22872b1de0dc3953b658ef0d6dba69aeb7e14e71d5a8400881a739f1004ff5a17
@@ -4,6 +4,7 @@ module TopsConnect
4
4
  include HTTParty
5
5
  include TopsConnect::Communities
6
6
  include TopsConnect::Owners
7
+ include TopsConnect::Properties
7
8
 
8
9
  attr_reader :community_id, :community_api_key
9
10
 
@@ -3,16 +3,31 @@ module TopsConnect
3
3
  module Communities
4
4
  # Method: GET
5
5
  # Endpoint: Community_GetList
6
- # Returns: Array<Hash>
6
+ # Returns: Array<TopsConnect::Community>
7
7
  def communities
8
- get('/community')
8
+ get('/community').map do |community_data|
9
+ TopsConnect::Community.new community_data
10
+ end
9
11
  end
10
12
 
11
13
  # Method: GET
12
14
  # Endpoint: Community_Get
13
15
  # Returns: TopsConnect::Community
14
16
  def community
15
- TopsConnect::Community.new self
17
+ TopsConnect::Community.new get("/community/#{@community_id}")
18
+ end
19
+
20
+ # Method: GET
21
+ # Endpoint: ChargeCode_GetList
22
+ # Returns: Array<Hash>
23
+ def charge_codes
24
+ get('/chargecode').map do |charge_code|
25
+ {
26
+ key: charge_code['ChargeCodeKey'],
27
+ code: charge_code['Code'],
28
+ description: charge_code['Description']
29
+ }
30
+ end
16
31
  end
17
32
  end
18
33
  end
@@ -1,21 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
  module TopsConnect
3
- class Community < Base
4
- attr_reader :id
3
+ class Community
4
+ attr_reader :data
5
5
 
6
- def initialize(client, data = nil)
6
+ def initialize(data)
7
7
  @data = data
8
-
9
- super client
10
- end
11
-
12
- def data
13
- @data || reload!
14
8
  end
15
9
 
16
- def reload!
17
- @data = get "/community/#{@client.community_id}"
10
+ def id
11
+ data['CommunityKey']
18
12
  end
13
+ alias community_key id
19
14
 
20
15
  def code
21
16
  data['CommunityID']
@@ -42,21 +37,10 @@ module TopsConnect
42
37
  end
43
38
 
44
39
  def updated_at
45
- return nil unless data['Metadata']['ModifiedDate']
40
+ return unless data['Metadata']['ModifiedDate']
46
41
 
47
42
  DateTime.parse data['Metadata']['ModifiedDate']
48
43
  end
49
-
50
- # Method: GET
51
- # Endpoint: ChargeCode_GetList
52
- def charge_codes
53
- get('/chargecode').map do |charge_code|
54
- {
55
- key: charge_code['ChargeCodeKey'],
56
- code: charge_code['Code'],
57
- description: charge_code['Description']
58
- }
59
- end
60
- end
44
+ alias modified_date updated_at
61
45
  end
62
46
  end
@@ -1,22 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
  module TopsConnect
3
- class Owner < Base
4
- attr_reader :id
3
+ class Owner
4
+ attr_reader :data
5
5
 
6
- def initialize(client, id, data = nil)
7
- @id = id.to_i
6
+ def initialize(data)
8
7
  @data = data
9
-
10
- super client
11
- end
12
-
13
- def data
14
- @data || reload!
15
8
  end
16
9
 
17
- def reload!
18
- @data = get "/owner/#{@id}"
10
+ def id
11
+ data['OwnerKey']
19
12
  end
13
+ alias owner_key id
20
14
 
21
15
  def alternate_mailing_addresses
22
16
  [1, 2].map do |n|
@@ -71,6 +65,8 @@ module TopsConnect
71
65
  end
72
66
 
73
67
  def updated_at
68
+ return unless data['Metadata']['ModifiedDate']
69
+
74
70
  DateTime.parse data['Metadata']['ModifiedDate']
75
71
  end
76
72
 
@@ -83,23 +79,15 @@ module TopsConnect
83
79
  end
84
80
 
85
81
  def move_out_date
86
- DateTime.parse data['MoveOutDate'] if data['MoveOutDate']
87
- end
82
+ return unless data['MoveOutDate']
88
83
 
89
- def settlement_date
90
- DateTime.parse data['SettlementDate'] if data['SettlementDate']
84
+ DateTime.parse data['MoveOutDate']
91
85
  end
92
86
 
93
- # Method: GET
94
- # Endpoint: Balance_Get
95
- def balance
96
- get "/balance/#{@id}"
97
- end
87
+ def settlement_date
88
+ return unless data['SettlementDate']
98
89
 
99
- # Method: GET
100
- # Endpoint: Charge_Get
101
- def charges
102
- get "/charge/#{@id}"
90
+ DateTime.parse data['SettlementDate']
103
91
  end
104
92
  end
105
93
  end
@@ -1,21 +1,37 @@
1
1
  # frozen_string_literal: true
2
2
  module TopsConnect
3
3
  module Owners
4
+ # Method: GET
5
+ # Endpoint: Owner_GetList
6
+ # Returns: Array<TopsConnect::Owner>
7
+ def owners(property_key = nil)
8
+ query = {}
9
+ query['PropertyKey'] = property_key.to_i if property_key
10
+
11
+ get('/owner', query: query).map do |owner_data|
12
+ TopsConnect::Owner.new owner_data
13
+ end
14
+ end
15
+
4
16
  # Method: GET
5
17
  # Endpoint: Owner_Get
6
- def owner(owner_id)
7
- TopsConnect::Owner.new self, owner_id, get("/owner/#{owner_id}")
18
+ # Returns: TopsConnect::Owner
19
+ def owner(owner_key)
20
+ TopsConnect::Owner.new get("/owner/#{owner_key}")
8
21
  end
9
22
 
10
23
  # Method: GET
11
- # Endpoint: Owner_GetList
12
- def owners(property_id = nil)
13
- query = {}
14
- query['PropertyKey'] = property_id.to_i if property_id
24
+ # Endpoint: Balance_Get
25
+ # Returns: Hash
26
+ def balance(owner_key)
27
+ get "/balance/#{owner_key}"
28
+ end
15
29
 
16
- get('/owner', query: query).map do |owner|
17
- TopsConnect::Owner.new self, owner['OwnerKey'], owner
18
- end
30
+ # Method: GET
31
+ # Endpoint: Charge_Get
32
+ # Returns: Hash
33
+ def charges(owner_key)
34
+ get "/charge/#{owner_key}"
19
35
  end
20
36
  end
21
37
  end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+ module TopsConnect
3
+ module Properties
4
+ # Method: GET
5
+ # Endpoint: Property_GetList
6
+ # Returns: Array<TopsConnect::Property>
7
+ def properties
8
+ get('/property').map do |property_data|
9
+ TopsConnect::Property.new property_data
10
+ end
11
+ end
12
+
13
+ # Method: GET
14
+ # Endpoint: Property_Get
15
+ # Returns: TopsConnect::Property
16
+ def property(property_key)
17
+ TopsConnect::Property.new get("/property/#{property_key}")
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+ module TopsConnect
3
+ class Property
4
+ attr_reader :data
5
+
6
+ def initialize(data)
7
+ @data = data
8
+ end
9
+
10
+ def id
11
+ data['PropertyKey']
12
+ end
13
+ alias property_key id
14
+
15
+ def account_number
16
+ data['AccountNumber']
17
+ end
18
+
19
+ def address
20
+ "#{data['AddressNumber']} #{data['Street']}"
21
+ end
22
+
23
+ def city
24
+ data['City']
25
+ end
26
+
27
+ def state
28
+ data['State']
29
+ end
30
+
31
+ def address_number
32
+ data['AddressNumber']
33
+ end
34
+
35
+ def street
36
+ data['Street']
37
+ end
38
+
39
+ def zip
40
+ data['Zip']
41
+ end
42
+
43
+ def community_key
44
+ data['CommunityKey']
45
+ end
46
+
47
+ def updated_at
48
+ return unless data['Metadata']['ModifiedDate']
49
+
50
+ DateTime.parse data['Metadata']['ModifiedDate']
51
+ end
52
+ alias modified_date updated_at
53
+ end
54
+ end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module TopsConnect
3
- VERSION = '0.2.0'
3
+ VERSION = '0.3.0'
4
4
  end
data/lib/tops_connect.rb CHANGED
@@ -5,10 +5,12 @@ require 'json'
5
5
 
6
6
  require 'tops_connect/communities'
7
7
  require 'tops_connect/owners'
8
+ require 'tops_connect/properties'
8
9
 
9
10
  require 'tops_connect/base'
10
11
  require 'tops_connect/community'
11
12
  require 'tops_connect/owner'
13
+ require 'tops_connect/property'
12
14
 
13
15
  require 'tops_connect/configuration'
14
16
  require 'tops_connect/client'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tops_connect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Hoffman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-24 00:00:00.000000000 Z
11
+ date: 2016-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -97,13 +97,14 @@ files:
97
97
  - bin/console
98
98
  - bin/setup
99
99
  - lib/tops_connect.rb
100
- - lib/tops_connect/base.rb
101
100
  - lib/tops_connect/client.rb
102
101
  - lib/tops_connect/communities.rb
103
102
  - lib/tops_connect/community.rb
104
103
  - lib/tops_connect/configuration.rb
105
104
  - lib/tops_connect/owner.rb
106
105
  - lib/tops_connect/owners.rb
106
+ - lib/tops_connect/properties.rb
107
+ - lib/tops_connect/property.rb
107
108
  - lib/tops_connect/version.rb
108
109
  - tops_connect.gemspec
109
110
  homepage: https://github.com/ValenciaMgmt/tops_connect
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
- module TopsConnect
3
- class Base
4
- def initialize(client)
5
- @client = client
6
- end
7
-
8
- def get(*args)
9
- @client.get(*args)
10
- end
11
- end
12
- end