rentlinx 0.7.0 → 0.7.1

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: 3e9c6235c8891f0be05e492ba4811f8ea49caefb
4
- data.tar.gz: 68324208bc855cc495a4f9e7abc74748b7f26b68
3
+ metadata.gz: ef85bce9f2ff14a271f922916dbd8c3698204df4
4
+ data.tar.gz: 31f3863df3a5104030ea8e978e193bb57e5104c7
5
5
  SHA512:
6
- metadata.gz: 2f2e8c07d583ad39c97f246f01c9b0a953509f56e2d37140afee8b88d43fa9d49930265889a38156efc0fb6cdb2d211da27e27a4ffb385e8675ecc94669e970d
7
- data.tar.gz: 7bec813c58aac658c954d38fba18440a5772b0a6c2cf06e3ff615725e0a641f19879f255899ffb912057901ea34aede345527384ed66a594733c58465c27d848
6
+ metadata.gz: efbd029b6d1463d9e321949507141bf4b6f2b895d96bb68fc2ca3cfce82759a3b6d2adba6db81376ca1604e2885ed5b64bc5b96a11e62aa0b1b394707aaa4581
7
+ data.tar.gz: bd45c674674e197bc7c6227fdf51fcdb9587471b5065e57a34acd057c56f5525fca36a421feed553909ffbd4e5997f5d3ad20b35801191b83b78a1e934a99ea8
@@ -20,6 +20,12 @@ module Rentlinx
20
20
  end
21
21
  end
22
22
 
23
+ class IncompatibleGroupOfObjectsForPost < RentlinxError
24
+ def initialize(property)
25
+ super("These objects cannot be grouped together ('#{property}' differ).")
26
+ end
27
+ end
28
+
23
29
  class HTTPError < RentlinxError
24
30
  attr_reader :response
25
31
 
@@ -10,4 +10,4 @@ module Rentlinx
10
10
  { url: url, title: title }
11
11
  end
12
12
  end
13
- end
13
+ end
@@ -6,4 +6,4 @@ module Rentlinx
6
6
 
7
7
  attr_accessor(*ATTRIBUTES)
8
8
  end
9
- end
9
+ end
@@ -1,8 +1,10 @@
1
1
  module Rentlinx
2
2
  module AmenityClientMethods
3
3
  def post_amenities(amenities)
4
- raise Rentlinx::InvalidObject, amenities.find { |a| !a.valid? } unless amenities.all?(&:valid?)
5
- raise Rentlinx::InvalidObject, amenities unless amenities.all? { |p| p.propertyID == amenities.first.propertyID }
4
+ return if amenities.nil?
5
+ raise(Rentlinx::InvalidObject, amenities.find { |a| !a.valid? }) unless amenities.all?(&:valid?)
6
+ raise(Rentlinx::IncompatibleGroupOfObjectsForPost, 'propertyID') unless amenities.all? { |p| p.propertyID == amenities.first.propertyID }
7
+
6
8
  property_amenities = amenities.select { |p| p.class == Rentlinx::PropertyAmenity }
7
9
  unit_amenities = amenities - property_amenities
8
10
 
@@ -1,8 +1,11 @@
1
1
  module Rentlinx
2
2
  module LinkClientMethods
3
3
  def post_links(links)
4
- raise Rentlinx::InvalidObject, links.find { |a| !a.valid? } unless links.all?(&:valid?)
5
- raise Rentlinx::InvalidObject, links unless links.all? { |p| p.propertyID == links.first.propertyID }
4
+ return if links.nil?
5
+
6
+ raise(Rentlinx::InvalidObject, links.find { |a| !a.valid? }) unless links.all?(&:valid?)
7
+ raise(Rentlinx::IncompatibleGroupOfObjectsForPost, 'propertyID') unless links.all? { |p| p.propertyID == links.first.propertyID }
8
+
6
9
  property_links = links.select { |l| l.class == Rentlinx::PropertyLink }
7
10
  unit_links = links - property_links
8
11
 
@@ -26,17 +29,17 @@ module Rentlinx
26
29
 
27
30
  def get_links_for_unit(unit)
28
31
  links = get_links_for_property_id(unit.propertyID)
29
- links.select { |a| defined? a.unitID && a.unitID == unit.unitID }
32
+ links.select { |link| defined? link.unitID && link.unitID == unit.unitID }
30
33
  end
31
34
 
32
35
  def unpost_link(link)
33
36
  case link
34
- when Rentlinx::UnitLink
35
- unpost_unit_link(link.unitID, link.url)
36
- when Rentlinx::PropertyLink
37
- unpost_property_link(link.propertyID, link.url)
38
- else
39
- raise TypeError, "Invalid type: #{link.class}"
37
+ when Rentlinx::UnitLink
38
+ unpost_unit_link(link.unitID, link.url)
39
+ when Rentlinx::PropertyLink
40
+ unpost_property_link(link.propertyID, link.url)
41
+ else
42
+ raise TypeError, "Invalid type: #{link.class}"
40
43
  end
41
44
  end
42
45
 
@@ -62,11 +65,11 @@ module Rentlinx
62
65
  end
63
66
 
64
67
  def unpost_property_link(id, url)
65
- request('DELETE', URI.encode("properties/#{id}/links/"), { url: url })
68
+ request('DELETE', URI.encode("properties/#{id}/links/"), url: url)
66
69
  end
67
70
 
68
71
  def unpost_unit_link(id, url)
69
- request('DELETE', URI.encode("units/#{id}/links/"), { url: url })
72
+ request('DELETE', URI.encode("units/#{id}/links/"), url: url)
70
73
  end
71
74
  end
72
- end
75
+ end
@@ -10,9 +10,7 @@ module Rentlinx
10
10
  end
11
11
 
12
12
  def links
13
- return @links if @links
14
-
15
- @links =
13
+ @links ||=
16
14
  if defined? unitID
17
15
  Rentlinx.client.get_links_for_unit(self)
18
16
  else
@@ -1,8 +1,10 @@
1
1
  module Rentlinx
2
2
  module PhotoClientMethods
3
3
  def post_photos(photos)
4
- return false unless photos.all?(&:valid?)
5
- return false unless photos.all? { |p| p.propertyID == photos.first.propertyID }
4
+ return if photos.nil?
5
+ raise(Rentlinx::InvalidObject, photos.find { |p| !p.valid? }) unless photos.all?(&:valid?)
6
+ raise(Rentlinx::IncompatibleGroupOfObjectsForPost, 'propertyID') unless photos.all? { |p| p.propertyID == photos.first.propertyID }
7
+
6
8
  property_photos = photos.select { |p| p.class == Rentlinx::PropertyPhoto }
7
9
  unit_photos = photos - property_photos
8
10
 
@@ -1,3 +1,3 @@
1
1
  module Rentlinx
2
- VERSION = '0.7.0'
2
+ VERSION = '0.7.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rentlinx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - AppFolio, Inc.