rentlinx 0.3.1 → 0.3.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: 3819098a7b8edb089697d87f6302b298b3529f56
4
- data.tar.gz: 5c392001f17b5c750ad0cd3c81cf336363bd070b
3
+ metadata.gz: 3b5b566cfebed779111d78efd37f82571407bf98
4
+ data.tar.gz: e941ff23098e8a4634836a0d7083fcaf3667185c
5
5
  SHA512:
6
- metadata.gz: 529234a86df627dd0beea23cd00e49d921b1594bc160fcf362f3e98de4a84615c5592df1a948c8eeb02b01b1ac2b4ee4ec3d9ee761cf5333ff8f313ddaaa2126
7
- data.tar.gz: a75cd39c0fa79d5fd8e52c98deb04c17b3c1442a62cc309b77da6f2d43925fa97cd7d230e82f7a20f05abd26ec640126e28da1c7d3b78517d132391210eeee78
6
+ metadata.gz: 799d668a581182b0a1d7204b964c8d4bfb405627442dda8de9771da23f18eea6ab19279c5673a1690855f5f44adcd5e77ffffcfd94e9f101f71b70f7dde04988
7
+ data.tar.gz: c65076091494c0da9eb34638f52fe660e4dcae8952c03acf8334267f74fa951dfa8d46361f14692b38129310137a1edaa6603f6d9530d701a22f9012c8bb1287
@@ -111,7 +111,7 @@ module Rentlinx
111
111
  nil # don't attempt to JSON parse emptystring
112
112
  when 400
113
113
  body = JSON.parse(response.body)
114
- raise Rentlinx::BadRequest, body['details']
114
+ raise Rentlinx::BadRequest, response, body['details']
115
115
  when 403
116
116
  raise Rentlinx::Forbidden, response
117
117
  when 404
@@ -30,8 +30,8 @@ module Rentlinx
30
30
  end
31
31
 
32
32
  class BadRequest < HTTPError
33
- def initialize(response)
34
- super(response, 'The request sent to the server was invalid.')
33
+ def initialize(response, message = nil)
34
+ super(response, message || 'The request sent to the server was invalid.')
35
35
  end
36
36
  end
37
37
 
@@ -49,21 +49,15 @@ module Rentlinx
49
49
  end
50
50
 
51
51
  def valid?
52
- required_attributes.all? do |at|
53
- !send(at).nil? && send(at) != ''
54
- end
52
+ required_attributes.none? { |at| blank?(send(at)) }
55
53
  end
56
54
 
57
55
  def valid_for_post?
58
- required_attributes_for_post.all? do |at|
59
- !send(at).nil? && send(at) != ''
60
- end
56
+ required_attributes_for_post.none? { |at| blank?(send(at)) }
61
57
  end
62
58
 
63
59
  def missing_attributes
64
- missing = required_attributes.select do |at|
65
- send(at).nil? || send(at) == ''
66
- end
60
+ missing = required_attributes.select { |at| blank?(send(at)) }
67
61
 
68
62
  "Missing required attributes: #{missing.join(', ')}"
69
63
  end
@@ -77,5 +71,9 @@ module Rentlinx
77
71
  def self.type
78
72
  name.split('::').last.downcase.to_sym
79
73
  end
74
+
75
+ def blank?(str)
76
+ str.nil? || str == ''
77
+ end
80
78
  end
81
79
  end
@@ -1,3 +1,3 @@
1
1
  module Rentlinx
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.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.3.1
4
+ version: 0.3.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-06-26 00:00:00.000000000 Z
11
+ date: 2015-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient