rentlinx 0.7.1 → 0.7.2

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: ef85bce9f2ff14a271f922916dbd8c3698204df4
4
- data.tar.gz: 31f3863df3a5104030ea8e978e193bb57e5104c7
3
+ metadata.gz: 10267302edef4619d3c54cdfd38a2ac28f30888f
4
+ data.tar.gz: a8249200c41e54bbdcf5447520396b5fab742e97
5
5
  SHA512:
6
- metadata.gz: efbd029b6d1463d9e321949507141bf4b6f2b895d96bb68fc2ca3cfce82759a3b6d2adba6db81376ca1604e2885ed5b64bc5b96a11e62aa0b1b394707aaa4581
7
- data.tar.gz: bd45c674674e197bc7c6227fdf51fcdb9587471b5065e57a34acd057c56f5525fca36a421feed553909ffbd4e5997f5d3ad20b35801191b83b78a1e934a99ea8
6
+ metadata.gz: 378d358c7340a32907bf5ea61a7dcedc2db181d5436c7c1454b2c927a43a8383693b6bda3e8d7165612b90be3173b3568e05da3bc18c3cacfcfadd022700cdc5
7
+ data.tar.gz: 136bb509dad0430b9b6f1fc1ec6e46897ae738d4db1d10950431bacdc6568d479113d1796e59f6ee1b6533fce23a926adb197db406a4b4fdba45c20cba97c190
@@ -21,7 +21,7 @@ module Rentlinx
21
21
  Rentlinx.password.nil? ||
22
22
  Rentlinx.site_url.nil?
23
23
 
24
- @url_prefix = (Rentlinx.site_url + '/').freeze # Extra slashes are fine
24
+ @url_prefix = (Rentlinx.site_url + '/').freeze # Extra slashes are fine
25
25
  @api_token ||= authenticate(Rentlinx.username, Rentlinx.password)
26
26
  end
27
27
 
@@ -12,6 +12,17 @@ module Rentlinx
12
12
  post_unit_amenities(unit_amenities) unless unit_amenities.empty?
13
13
  end
14
14
 
15
+ def unpost_amenities_for(object)
16
+ case object
17
+ when Rentlinx::Unit
18
+ post_amenities_for_unit_id(object.unitID, [])
19
+ when Rentlinx::Property
20
+ post_amenities_for_property_id(object.propertyID, [])
21
+ else
22
+ raise TypeError, "Type not permitted: #{object.class}"
23
+ end
24
+ end
25
+
15
26
  def get_amenities_for_property_id(id)
16
27
  data = request('GET', "properties/#{id}/amenities")['data']
17
28
  data.map do |amenity_data|
@@ -47,7 +58,11 @@ module Rentlinx
47
58
  # post_amenities should only be called from property or unit, so we don't need
48
59
  # to handle multiple properties
49
60
  def post_property_amenities(amenities)
50
- request('PUT', "properties/#{amenities.first.propertyID}/amenities", amenities.map(&:to_hash))
61
+ post_amenities_for_property_id(amenities.first.propertyID, amenities)
62
+ end
63
+
64
+ def post_amenities_for_property_id(id, amenities)
65
+ request('PUT', "properties/#{id}/amenities", amenities.map(&:to_hash))
51
66
  end
52
67
 
53
68
  def post_unit_amenities(amenities)
@@ -61,10 +76,14 @@ module Rentlinx
61
76
  end
62
77
 
63
78
  hash.each do |unitID, unit_amenities|
64
- request('PUT', "units/#{unitID}/amenities", unit_amenities.map(&:to_hash))
79
+ post_amenities_for_unit_id(unitID, unit_amenities)
65
80
  end
66
81
  end
67
82
 
83
+ def post_amenities_for_unit_id(id, amenities)
84
+ request('PUT', "units/#{id}/amenities", amenities.map(&:to_hash))
85
+ end
86
+
68
87
  def unpost_property_amenity(id, name)
69
88
  request('DELETE', URI.encode("properties/#{id}/amenities/#{name}"))
70
89
  end
@@ -6,7 +6,13 @@ module Rentlinx
6
6
  end
7
7
 
8
8
  def post_amenities
9
- Rentlinx.client.post_amenities(@amenities)
9
+ return if @amenities.nil?
10
+
11
+ if @amenities.length == 0
12
+ Rentlinx.client.unpost_amenities_for(self)
13
+ else
14
+ Rentlinx.client.post_amenities(@amenities)
15
+ end
10
16
  end
11
17
 
12
18
  def amenities
@@ -13,6 +13,17 @@ module Rentlinx
13
13
  post_unit_links(unit_links) unless unit_links.empty?
14
14
  end
15
15
 
16
+ def unpost_links_for(object)
17
+ case object
18
+ when Rentlinx::Unit
19
+ post_links_for_unit_id(object.unitID, [])
20
+ when Rentlinx::Property
21
+ post_links_for_property_id(object.propertyID, [])
22
+ else
23
+ raise TypeError, 'Type not permitted: #{object.class}'
24
+ end
25
+ end
26
+
16
27
  def get_links_for_property_id(id)
17
28
  data = request('GET', "properties/#{id}/links")['data']
18
29
  data.map do |link_data|
@@ -46,7 +57,11 @@ module Rentlinx
46
57
  private
47
58
 
48
59
  def post_property_links(links)
49
- request('PUT', "properties/#{links.first.propertyID}/links", links.map(&:to_hash))
60
+ post_links_for_property_id(links.first.propertyID, links)
61
+ end
62
+
63
+ def post_links_for_property_id(id, links)
64
+ request('PUT', "properties/#{id}/links", links.map(&:to_hash))
50
65
  end
51
66
 
52
67
  def post_unit_links(links)
@@ -60,10 +75,14 @@ module Rentlinx
60
75
  end
61
76
 
62
77
  hash.each do |unitID, unit_links|
63
- request('PUT', "units/#{unitID}/links", unit_links.map(&:to_hash))
78
+ post_links_for_unit_id(unitID, unit_links)
64
79
  end
65
80
  end
66
81
 
82
+ def post_links_for_unit_id(id, links)
83
+ request('PUT', "units/#{id}/links", links.map(&:to_hash))
84
+ end
85
+
67
86
  def unpost_property_link(id, url)
68
87
  request('DELETE', URI.encode("properties/#{id}/links/"), url: url)
69
88
  end
@@ -6,7 +6,13 @@ module Rentlinx
6
6
  end
7
7
 
8
8
  def post_links
9
- Rentlinx.client.post_links(@links)
9
+ return if @links.nil?
10
+
11
+ if @links.length == 0
12
+ Rentlinx.client.unpost_links_for(self)
13
+ else
14
+ Rentlinx.client.post_links(@links)
15
+ end
10
16
  end
11
17
 
12
18
  def links
@@ -12,6 +12,17 @@ module Rentlinx
12
12
  post_unit_photos(unit_photos) unless unit_photos.empty?
13
13
  end
14
14
 
15
+ def unpost_photos_for(object)
16
+ case object
17
+ when Rentlinx::Unit
18
+ post_photos_for_unit_id(object.unitID, [])
19
+ when Rentlinx::Property
20
+ post_photos_for_property_id(object.propertyID, [])
21
+ else
22
+ raise TypeError, "Type not permitted: #{object.class}"
23
+ end
24
+ end
25
+
15
26
  def get_photos_for_property_id(id)
16
27
  data = request('GET', "properties/#{id}/photos")['data']
17
28
  data.map do |photo_data|
@@ -40,7 +51,11 @@ module Rentlinx
40
51
  # post_photos should only be called from property or unit, so we don't need
41
52
  # to handle multiple properties
42
53
  def post_property_photos(photos)
43
- request('PUT', "properties/#{photos.first.propertyID}/photos", photos.map(&:to_hash))
54
+ post_photos_for_property_id(photos.first.propertyID, photos)
55
+ end
56
+
57
+ def post_photos_for_property_id(id, photos)
58
+ request('PUT', "properties/#{id}/photos", photos.map(&:to_hash))
44
59
  end
45
60
 
46
61
  def post_unit_photos(photos)
@@ -54,10 +69,14 @@ module Rentlinx
54
69
  end
55
70
 
56
71
  hash.each do |unitID, unit_photos|
57
- request('PUT', "units/#{unitID}/photos", unit_photos.map(&:to_hash))
72
+ post_photos_for_unit_id(unitID, unit_photos)
58
73
  end
59
74
  end
60
75
 
76
+ def post_photos_for_unit_id(id, photos)
77
+ request('PUT', "units/#{id}/photos", photos.map(&:to_hash))
78
+ end
79
+
61
80
  def unpost_property_photo(id, url)
62
81
  request('DELETE', "properties/#{id}/photos", url: url)
63
82
  end
@@ -6,7 +6,13 @@ module Rentlinx
6
6
  end
7
7
 
8
8
  def post_photos
9
- Rentlinx.client.post_photos(@photos)
9
+ return if @photos.nil?
10
+
11
+ if @photos.length == 0
12
+ Rentlinx.client.unpost_photos_for(self)
13
+ else
14
+ Rentlinx.client.post_photos(@photos)
15
+ end
10
16
  end
11
17
 
12
18
  def photos
@@ -1,3 +1,3 @@
1
1
  module Rentlinx
2
- VERSION = '0.7.1'
2
+ VERSION = '0.7.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rentlinx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - AppFolio, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-04 00:00:00.000000000 Z
11
+ date: 2015-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient