hoalife 0.1.2 → 0.1.7

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
  SHA256:
3
- metadata.gz: 6e9fe73cbcf41218fdb70092c76c53d2d246d6e7602bc5626e6bb886064c7ca5
4
- data.tar.gz: f946d9c751278d2d03b5312c4106a4bd9a962a1c2f25b81dd2cd275cc38ac704
3
+ metadata.gz: 574f6e811f81b395d73ab0fb26366f9b8ef7201fefd98c5a50fc5e3d0f2ec804
4
+ data.tar.gz: a222efe6f9fa58c5422572139913194f65ba6c1f9914c96c0dd83362d63747b4
5
5
  SHA512:
6
- metadata.gz: e1dc7e64648516ad16b4c93876956026a604bfc5d43100dfc359ab2baed6472dd1f94e27e6ce8091d36b00dd1ad44244bc4f78e273efad0b1ebf3ea9bb93cc44
7
- data.tar.gz: efb95de9498777594e79e054afe876f22cdd3a7bab80749b35438dd9610fb070b00f7d3b1543d737f411293b00156f953adbb03735cc06f34393d2c43fd80709
6
+ metadata.gz: '06099ee7c8213063c3e86552c6199e21ca6fdd43b09267fa12723a9d69ce03fb4812092d8c421493578df56db17a8f22b82dae3ea75982b54988b659d2a560bb'
7
+ data.tar.gz: be7e0a035ccda0f45ce974e4752db649d80415b50d7036e4b75c5353461a3bf91a5d0d9936f43c9d172045a696ca23fc9b4dcdf4db648d81dbe351b5cf866ff0
@@ -0,0 +1,39 @@
1
+ name: Development
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ name: ${{matrix.ruby}} on ${{matrix.os}}
8
+ runs-on: ${{matrix.os}}-latest
9
+ continue-on-error: ${{matrix.experimental}}
10
+
11
+ strategy:
12
+ matrix:
13
+ os:
14
+ - ubuntu
15
+
16
+ ruby:
17
+ - "2.6"
18
+ - "2.7"
19
+ - "3.0"
20
+ - "3.1"
21
+
22
+ experimental: [false]
23
+ env: [""]
24
+
25
+ include:
26
+ - os: ubuntu
27
+ ruby: head
28
+ experimental: true
29
+
30
+ steps:
31
+ - uses: actions/checkout@v2
32
+ - uses: ruby/setup-ruby@v1
33
+ with:
34
+ ruby-version: ${{matrix.ruby}}
35
+ bundler-cache: true
36
+
37
+ - name: Run tests
38
+ timeout-minutes: 5
39
+ run: ${{matrix.env}} bundle exec rake test
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.7.3
data/Gemfile.lock CHANGED
@@ -1,62 +1,64 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hoalife (0.1.2)
4
+ hoalife (0.1.7)
5
5
  zeitwerk (~> 2.1)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- addressable (2.6.0)
11
- public_suffix (>= 2.0.2, < 4.0)
12
- ast (2.4.0)
13
- crack (0.4.3)
14
- safe_yaml (~> 1.0.0)
15
- ffi (1.11.1)
16
- hashdiff (1.0.0)
17
- jaro_winkler (1.5.3)
18
- listen (3.1.5)
19
- rb-fsevent (~> 0.9, >= 0.9.4)
20
- rb-inotify (~> 0.9, >= 0.9.7)
21
- ruby_dep (~> 1.2)
22
- minitest (5.11.3)
23
- parallel (1.17.0)
24
- parser (2.6.3.0)
25
- ast (~> 2.4.0)
26
- public_suffix (3.1.1)
27
- rainbow (3.0.0)
28
- rake (10.5.0)
29
- rb-fsevent (0.10.3)
30
- rb-inotify (0.10.0)
10
+ addressable (2.8.0)
11
+ public_suffix (>= 2.0.2, < 5.0)
12
+ ast (2.4.2)
13
+ crack (0.4.5)
14
+ rexml
15
+ ffi (1.15.5)
16
+ hashdiff (1.0.1)
17
+ listen (3.7.1)
18
+ rb-fsevent (~> 0.10, >= 0.10.3)
19
+ rb-inotify (~> 0.9, >= 0.9.10)
20
+ minitest (5.15.0)
21
+ parallel (1.21.0)
22
+ parser (3.1.1.0)
23
+ ast (~> 2.4.1)
24
+ public_suffix (4.0.6)
25
+ rainbow (3.1.1)
26
+ rake (13.0.6)
27
+ rb-fsevent (0.11.1)
28
+ rb-inotify (0.10.1)
31
29
  ffi (~> 1.0)
32
- rubocop (0.74.0)
33
- jaro_winkler (~> 1.5.1)
30
+ regexp_parser (2.2.1)
31
+ rexml (3.2.5)
32
+ rubocop (0.93.1)
34
33
  parallel (~> 1.10)
35
- parser (>= 2.6)
34
+ parser (>= 2.7.1.5)
36
35
  rainbow (>= 2.2.2, < 4.0)
36
+ regexp_parser (>= 1.8)
37
+ rexml
38
+ rubocop-ast (>= 0.6.0)
37
39
  ruby-progressbar (~> 1.7)
38
- unicode-display_width (>= 1.4.0, < 1.7)
39
- ruby-progressbar (1.10.1)
40
- ruby_dep (1.5.0)
41
- safe_yaml (1.0.5)
42
- unicode-display_width (1.6.0)
43
- webmock (3.6.2)
44
- addressable (>= 2.3.6)
40
+ unicode-display_width (>= 1.4.0, < 2.0)
41
+ rubocop-ast (1.16.0)
42
+ parser (>= 3.1.1.0)
43
+ ruby-progressbar (1.11.0)
44
+ unicode-display_width (1.8.0)
45
+ webmock (3.14.0)
46
+ addressable (>= 2.8.0)
45
47
  crack (>= 0.3.2)
46
48
  hashdiff (>= 0.4.0, < 2.0.0)
47
- zeitwerk (2.1.10)
49
+ zeitwerk (2.5.4)
48
50
 
49
51
  PLATFORMS
50
52
  ruby
51
53
 
52
54
  DEPENDENCIES
53
- bundler (~> 2.0)
55
+ bundler (> 2.3)
54
56
  hoalife!
55
57
  listen (~> 3.1)
56
58
  minitest (~> 5.0)
57
- rake (~> 10.0)
59
+ rake (~> 13.0)
58
60
  rubocop (~> 0.74)
59
61
  webmock (~> 3.6)
60
62
 
61
63
  BUNDLED WITH
62
- 2.0.2
64
+ 2.3.8
data/README.md CHANGED
@@ -29,6 +29,8 @@ Or install it yourself as:
29
29
  Configure the client with your credentials in your code.
30
30
 
31
31
  ```ruby
32
+ require 'hoalife'
33
+
32
34
  HOALife.config do |config|
33
35
  config.api_key = 'sk_YOURSUPERSECRETKEY'
34
36
  config.signing_secret = 'ss_YOURSIGNINGSECRET'
@@ -42,7 +44,7 @@ HOALife.signing_secret = 'ss_YOURSIGNINGSECRET'
42
44
  HOALife.sleep_when_rate_limited = 10.0 # Optional
43
45
  ```
44
46
 
45
- Alternatively, you can specify the `api_key`, and `signing_secret` with environmental variables.
47
+ Alternatively, you can specify the `HOALIFE_API_KEY`, and `HOALIFE_SIGNING_SECRET` environmental variables to automatically configure the client.
46
48
 
47
49
  ```sh
48
50
  HOALIFE_API_KEY=sk_YOURSUPERSECRETKEY
@@ -51,6 +53,16 @@ HOALIFE_SIGNING_SECRET=ss_YOURSIGNINGSECRET
51
53
  echo $HOALIFE_API_KEY # => sk_YOURSUPERSECRETKEY
52
54
  echo $HOALIFE_SIGNING_SECRET # => ss_YOURSIGNINGSECRET
53
55
  ```
56
+ resulting in
57
+ ```ruby
58
+ require 'hoalife'
59
+
60
+ ENV['HOALIFE_API_KEY'] # => 'sk_YOURSUPERSECRETKEY'
61
+ ENV['HOALIFE_SIGNING_SECRET'] # => 'ss_YOURSIGNINGSECRET'
62
+
63
+ HOALife.api_key # => 'sk_YOURSUPERSECRETKEY'
64
+ HOALife.signing_secret # => 'ss_YOURSIGNINGSECRET'
65
+ ```
54
66
 
55
67
  ### Rate Limits
56
68
 
@@ -211,11 +223,10 @@ account.destroy # => true
211
223
 
212
224
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
213
225
 
214
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
215
226
 
216
227
  ## Contributing
217
228
 
218
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/hoalife.
229
+ Bug reports and pull requests are welcome on GitHub at https://github.com/hoalife/hoalife-ruby.
219
230
 
220
231
  ## License
221
232
 
data/bin/release ADDED
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ release_version = case ARGV[0]
5
+ when 'major'
6
+ 'major'
7
+ when 'minor'
8
+ 'minor'
9
+ when 'pre'
10
+ 'pre'
11
+ when /\d+\.\d+\.\d+$/
12
+ ARGV[0]
13
+ else
14
+ 'patch'
15
+ end
16
+
17
+ version = `gem bump --no-commit --version #{release_version} | awk '{ print $4 }' | head -n 1`.strip
18
+
19
+ system('bundle')
20
+
21
+ system('git add lib/hoalife/version.rb')
22
+ system('git add Gemfile.lock')
23
+
24
+ system("git commit -m \"Bump HOALife to #{version}\"")
25
+
26
+ system("git tag v#{version}")
27
+ system('git push')
28
+ system('git push --tags')
29
+
30
+ system('gem build hoalife')
31
+
32
+ puts 'OTP Code:'
33
+ code = gets.strip
34
+ system("gem push --otp #{code} --key hoalife_rubygems_api_key hoalife-#{version}.gem")
35
+
36
+ system("rm hoalife-#{version}.gem")
data/examples/account.rb CHANGED
@@ -8,7 +8,7 @@ parent = HOALife::Account.where(organizational: true).first
8
8
 
9
9
  csv = CSV.read(File.expand_path('properties.csv', __dir__), headers: true)
10
10
 
11
- associations = csv.collect { |row| row["association_name"] }.uniq
11
+ associations = csv.collect { |row| row['association_name'] }.uniq
12
12
 
13
13
  associations.each.with_index do |association, i|
14
14
  attrs = {
@@ -1,158 +1,160 @@
1
+ # frozen_string_literal: true
2
+
1
3
  articles = [
2
4
  {
3
- article: 1,
4
- title: "Exterior Maintenance",
5
+ article: 1,
6
+ title: 'Exterior Maintenance',
5
7
  violation_types_attributes: [
6
8
  {
7
- title: "Mildew on home",
8
- resolution_step: "Please pressure wash your home in the next 20 days",
9
- days_to_cure: 20
9
+ title: 'Mildew on home',
10
+ resolution_step: 'Please pressure wash your home in the next 20 days',
11
+ days_to_cure: 20
10
12
  },
11
13
  {
12
- title: "Faded shutters",
13
- resolution_step: "Please paint your shutters in the next 20 days",
14
- days_to_cure: 20
14
+ title: 'Faded shutters',
15
+ resolution_step: 'Please paint your shutters in the next 20 days',
16
+ days_to_cure: 20
15
17
  },
16
18
  {
17
- title: "Siding damaged",
18
- resolution_step: "Please repair/replace the damaged siding in the next 20 day",
19
- days_to_cure: 20
19
+ title: 'Siding damaged',
20
+ resolution_step: 'Please repair/replace the damaged siding in the next 20 day',
21
+ days_to_cure: 20
20
22
  },
21
23
  {
22
- title: "Shutter(s) missing/damaged",
23
- resolution_step: "Please repair/replace the missing/damaged shutter(s) in the next 20 days",
24
- days_to_cure: 20
24
+ title: 'Shutter(s) missing/damaged',
25
+ resolution_step: 'Please repair/replace the missing/damaged shutter(s) in the next 20 days',
26
+ days_to_cure: 20
25
27
  },
26
28
  {
27
- title: "Mailbox is damaged",
28
- resolution_step: "Please repair/replace the damaged mailbox in the next 20 days",
29
- days_to_cure: 20
29
+ title: 'Mailbox is damaged',
30
+ resolution_step: 'Please repair/replace the damaged mailbox in the next 20 days',
31
+ days_to_cure: 20
30
32
  },
31
33
  {
32
- title: "Mailbox needs to be painted",
33
- resolution_step: "Please paint your mailbox in the next 20 days",
34
- days_to_cure: 20
34
+ title: 'Mailbox needs to be painted',
35
+ resolution_step: 'Please paint your mailbox in the next 20 days',
36
+ days_to_cure: 20
35
37
  },
36
38
  {
37
- title: "Garage door damaged",
38
- resolution_step: "Please repair/replace the garage door in the next 20 days",
39
- days_to_cure: 20
39
+ title: 'Garage door damaged',
40
+ resolution_step: 'Please repair/replace the garage door in the next 20 days',
41
+ days_to_cure: 20
40
42
  },
41
43
  {
42
- title: "Fence damaged",
43
- resolution_step: "Please repair the damaged fence in the next 20 days",
44
- days_to_cure: 20
44
+ title: 'Fence damaged',
45
+ resolution_step: 'Please repair the damaged fence in the next 20 days',
46
+ days_to_cure: 20
45
47
  },
46
48
  {
47
- title: "Trim on home needs to be painted",
48
- resolution_step: "Please paint the trim on your home in the next 20 days",
49
- days_to_cure: 20
49
+ title: 'Trim on home needs to be painted',
50
+ resolution_step: 'Please paint the trim on your home in the next 20 days',
51
+ days_to_cure: 20
50
52
  }
51
53
  ]
52
54
  },
53
55
  {
54
- article: 2,
55
- title: "ARC",
56
+ article: 2,
57
+ title: 'ARC',
56
58
  violation_types_attributes: [
57
59
  {
58
- title: "Unapproved structure",
59
- resolution_step: "Please submit an ARC form in the next 10 days",
60
- days_to_cure: 10
60
+ title: 'Unapproved structure',
61
+ resolution_step: 'Please submit an ARC form in the next 10 days',
62
+ days_to_cure: 10
61
63
  }
62
64
  ]
63
65
  },
64
66
  {
65
- article: 3,
66
- title: "Improper Storage",
67
+ article: 3,
68
+ title: 'Improper Storage',
67
69
  violation_types_attributes: [
68
70
  {
69
- title: "Basketball goal",
70
- resolution_step: "Please properly store your basketball goal when not in use",
71
- days_to_cure: nil
71
+ title: 'Basketball goal',
72
+ resolution_step: 'Please properly store your basketball goal when not in use',
73
+ days_to_cure: nil
72
74
  },
73
75
  {
74
- title: "Garbage can(s) in view from street",
76
+ title: 'Garbage can(s) in view from street',
75
77
  resolution_step: "Please store your garbage can(s) from the view of the street on days not \
76
78
  deemed for pickup",
77
- days_to_cure: nil
79
+ days_to_cure: nil
78
80
  },
79
81
  {
80
- title: "Improperly stored item(s) around home",
81
- resolution_step: "Please properly store all item(s) in the next 5 days",
82
- days_to_cure: 5
82
+ title: 'Improperly stored item(s) around home',
83
+ resolution_step: 'Please properly store all item(s) in the next 5 days',
84
+ days_to_cure: 5
83
85
  }
84
86
  ]
85
87
  },
86
88
  {
87
- article: 4,
88
- title: "Vehicles",
89
+ article: 4,
90
+ title: 'Vehicles',
89
91
  violation_types_attributes: [
90
92
  {
91
- title: "Vehicle(s) parked in grass",
92
- resolution_step: "Please refrain from parking in the grassy areas of the community",
93
- days_to_cure: nil
93
+ title: 'Vehicle(s) parked in grass',
94
+ resolution_step: 'Please refrain from parking in the grassy areas of the community',
95
+ days_to_cure: nil
94
96
  },
95
97
  {
96
- title: "Inoperable vehicle at residence",
97
- resolution_step: "Please repair/properly register your vehicle in the next 10 days",
98
- days_to_cure: 10
98
+ title: 'Inoperable vehicle at residence',
99
+ resolution_step: 'Please repair/properly register your vehicle in the next 10 days',
100
+ days_to_cure: 10
99
101
  },
100
102
  {
101
- title: "Trailer at residence",
102
- resolution_step: "Please remove the trailer from the community in the next 5 days",
103
- days_to_cure: 5
103
+ title: 'Trailer at residence',
104
+ resolution_step: 'Please remove the trailer from the community in the next 5 days',
105
+ days_to_cure: 5
104
106
  },
105
107
  {
106
- title: "Boat at residence",
107
- resolution_step: "Please remove the boat from the community in the next 5 days",
108
- days_to_cure: 5
108
+ title: 'Boat at residence',
109
+ resolution_step: 'Please remove the boat from the community in the next 5 days',
110
+ days_to_cure: 5
109
111
  }
110
112
  ]
111
113
  },
112
114
  {
113
- article: 5,
114
- title: "Lawn Maintenance",
115
+ article: 5,
116
+ title: 'Lawn Maintenance',
115
117
  violation_types_attributes: [
116
118
  {
117
- title: "High grass",
118
- resolution_step: "Please mow your lawn in the next 7 days",
119
- days_to_cure: 7
119
+ title: 'High grass',
120
+ resolution_step: 'Please mow your lawn in the next 7 days',
121
+ days_to_cure: 7
120
122
  },
121
123
  {
122
- title: "Weeds in lawn",
123
- resolution_step: "Please treat the weeds in your lawn in the next 15 days",
124
- days_to_cure: 15
124
+ title: 'Weeds in lawn',
125
+ resolution_step: 'Please treat the weeds in your lawn in the next 15 days',
126
+ days_to_cure: 15
125
127
  },
126
128
  {
127
- title: "Weeds in landscaping bed(s)",
128
- resolution_step: "Please treat the weeds in your landscaping bed(s) in the next 15 days",
129
- days_to_cure: 15
129
+ title: 'Weeds in landscaping bed(s)',
130
+ resolution_step: 'Please treat the weeds in your landscaping bed(s) in the next 15 days',
131
+ days_to_cure: 15
130
132
  },
131
133
  {
132
- title: "Bare spot(s) in lawn",
133
- resolution_step: "Please treat the bare spot(s) in your lawn in the next 15 days",
134
- days_to_cure: 15
134
+ title: 'Bare spot(s) in lawn',
135
+ resolution_step: 'Please treat the bare spot(s) in your lawn in the next 15 days',
136
+ days_to_cure: 15
135
137
  },
136
138
  {
137
- title: "Rut in lawn",
138
- resolution_step: "Please fill in the rut in your lawn in the next 15 days",
139
- days_to_cure: 15
139
+ title: 'Rut in lawn',
140
+ resolution_step: 'Please fill in the rut in your lawn in the next 15 days',
141
+ days_to_cure: 15
140
142
  },
141
143
  {
142
- title: "Overgrown Shrub(s)",
143
- resolution_step: "Please trim your shrub(s) in the next 10 days",
144
- days_to_cure: 10
144
+ title: 'Overgrown Shrub(s)',
145
+ resolution_step: 'Please trim your shrub(s) in the next 10 days',
146
+ days_to_cure: 10
145
147
  }
146
148
  ]
147
149
  }
148
150
  ]
149
151
 
150
152
  parent = HOALife::Account.where(organizational: true).first
151
- account = HOALife::Account.create(name: "Article & VT test", parent_id: parent.id)
153
+ account = HOALife::Account.create(name: 'Article & VT test', parent_id: parent.id)
152
154
 
153
155
  articles.each do |article|
154
156
  record = HOALife::CCRArticle.create(
155
- article: article[:article], title: article[:title], description: "Description here!",
157
+ article: article[:article], title: article[:title], description: 'Description here!',
156
158
  account_id: account.id
157
159
  )
158
160
 
@@ -165,7 +167,7 @@ articles.each do |article|
165
167
  article_violation_types = HOALife::CCRViolationType.where(ccr_article_id: record.id).tap(&:all)
166
168
  assert_equal article[:violation_types_attributes].size, article_violation_types.count
167
169
 
168
- article[:violation_types_attributes].each.with_index do |vt, i|
170
+ article[:violation_types_attributes].each.with_index do |_vt, i|
169
171
  violation_type = HOALife::CCRViolationType.where(external_id: i).first
170
172
  assert(violation_type.destroy)
171
173
  end
data/examples/property.rb CHANGED
@@ -33,11 +33,11 @@ def create_account(name)
33
33
  end
34
34
 
35
35
  csv.each do |row|
36
- association = find_or_create_account(row["association_name"])
36
+ association = find_or_create_account(row['association_name'])
37
37
 
38
38
  attrs = row.to_h.merge(
39
- account_id: association.id, phone_numbers: row["phone_numbers"].split("|"),
40
- emails: row["emails"].split("|"),
39
+ account_id: association.id, phone_numbers: row['phone_numbers'].split('|'),
40
+ emails: row['emails'].split('|')
41
41
  )
42
42
 
43
43
  property = HOALife::Property.create(attrs)
@@ -48,12 +48,12 @@ end
48
48
  refute_equal(original_size, HOALife::Property.reload.count)
49
49
 
50
50
  csv.each do |row|
51
- find_by_external_id = HOALife::Property.where(external_id: row["external_id"])
51
+ find_by_external_id = HOALife::Property.where(external_id: row['external_id'])
52
52
  assert_equal 1, find_by_external_id.count
53
53
 
54
54
  found = find_by_external_id.first
55
55
 
56
- new_external_id = row["external_id"] + "WithAChange"
56
+ new_external_id = row['external_id'] + 'WithAChange'
57
57
  found.external_id = new_external_id
58
58
  assert(found.save)
59
59
 
data/examples/test.rb CHANGED
@@ -18,7 +18,7 @@ def assert(bool)
18
18
  print "\e[32m.\e[0m"
19
19
  else
20
20
  puts "\e[31m"
21
- puts "FAILED"
21
+ puts 'FAILED'
22
22
  puts caller
23
23
  print "\e[0m"
24
24
  end
data/hoalife.gemspec CHANGED
@@ -33,10 +33,10 @@ Gem::Specification.new do |spec|
33
33
 
34
34
  spec.add_dependency 'zeitwerk', '~> 2.1'
35
35
 
36
- spec.add_development_dependency 'bundler', '~> 2.0'
36
+ spec.add_development_dependency 'bundler', '> 2.3'
37
37
  spec.add_development_dependency 'listen', '~> 3.1'
38
38
  spec.add_development_dependency 'minitest', '~> 5.0'
39
- spec.add_development_dependency 'rake', '~> 10.0'
39
+ spec.add_development_dependency 'rake', '~> 13.0'
40
40
  spec.add_development_dependency 'rubocop', '~> 0.74'
41
41
  spec.add_development_dependency 'webmock', '~> 3.6'
42
42
  end
@@ -101,7 +101,7 @@ class HOALife::Client::Base
101
101
  def api_version
102
102
  return nil if HOALife.api_version.nil?
103
103
 
104
- "version=#{HOALife.api_version}"
104
+ "application/vnd.api+json; version=#{HOALife.api_version}"
105
105
  end
106
106
 
107
107
  def authorization_header
@@ -0,0 +1,30 @@
1
+ # Pass a string, have it split with the given separator
2
+ module HOALife::Arrayable
3
+ BLANK_RE = /\A[[:space:]]*\z/
4
+
5
+ def as_array(method_name, separator: /,|\||;|\s&\s|\sand\s|\s\s+/, joiner: ",")
6
+ define_method("#{method_name}=") do |value|
7
+ case value
8
+ when String
9
+ super(value.split(separator).collect(&:strip).uniq)
10
+ when Array
11
+ super(
12
+ value.reject do |sub_val|
13
+ sub_val.nil? || sub_val.empty? || sub_val.to_s.match?(BLANK_RE)
14
+ end.collect do |sub_val|
15
+ case sub_val
16
+ when String
17
+ sub_val.split(separator).collect(&:strip)
18
+ else
19
+ sub_val
20
+ end
21
+ end.flatten.uniq
22
+ )
23
+ when nil
24
+ super([])
25
+ else
26
+ super(value)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nodoc
4
+ class HOALife::Properties::SupplementalMailingAddress < HOALife::Resource
5
+ include HOALife::Resources::Persistable
6
+
7
+ self.base_path = '/properties/supplemental_mailing_addresses'
8
+
9
+ def as_json
10
+ h = super
11
+
12
+ h.dig('data', 'relationships').merge!(
13
+ 'property' => { 'data' => { 'id' => property_id } }
14
+ )
15
+
16
+ h
17
+ end
18
+ end
@@ -4,6 +4,9 @@
4
4
  class HOALife::Property < HOALife::Resource
5
5
  include HOALife::Resources::Persistable
6
6
 
7
+ as_array :emails
8
+ as_array :phone_numbers
9
+
7
10
  self.base_path = '/properties'
8
11
 
9
12
  def as_json
@@ -6,7 +6,11 @@ require 'time'
6
6
  require 'forwardable'
7
7
 
8
8
  # :nodoc
9
- class HOALife::Resource < OpenStruct
9
+ class HOALife::Resource
10
+ extend HOALife::Arrayable
11
+
12
+ attr_reader :attrs
13
+
10
14
  class << self
11
15
  extend Forwardable
12
16
 
@@ -36,10 +40,12 @@ class HOALife::Resource < OpenStruct
36
40
  end
37
41
  end
38
42
 
39
- def initialize(obj = {}, _relationships = {})
40
- @obj = cast_attrs(obj)
43
+ def initialize(attrs = {}, _relationships = {})
44
+ @attrs = {}
41
45
 
42
- super(obj)
46
+ cast_attrs(attrs.transform_keys(&:to_sym)).each do |k, v|
47
+ send("#{k}=".to_sym, v)
48
+ end
43
49
  end
44
50
 
45
51
  def as_json
@@ -50,7 +56,7 @@ class HOALife::Resource < OpenStruct
50
56
  }
51
57
  }
52
58
 
53
- each_pair do |k, _v|
59
+ @attrs.each do |k, _v|
54
60
  h['data']['attributes'][k] = send(k)
55
61
  end
56
62
 
@@ -61,6 +67,26 @@ class HOALife::Resource < OpenStruct
61
67
  JSON.generate as_json
62
68
  end
63
69
 
70
+ def method_missing(method_name, *args, &blk)
71
+ if method_name.match(/\=$/)
72
+ @attrs[method_name.to_s.gsub(/\=$/, "").to_sym] = args.first
73
+ elsif @attrs.key?(method_name)
74
+ @attrs[method_name]
75
+ else
76
+ super
77
+ end
78
+ end
79
+
80
+ def respond_to?(method_name, include_private = false)
81
+ !@attrs[method_name] ||
82
+ method_name.match(/\=$/) ||
83
+ super
84
+ end
85
+
86
+ def ==(other)
87
+ @attrs == other.attrs
88
+ end
89
+
64
90
  private
65
91
 
66
92
  # rubocop:disable Style/RescueModifier
@@ -5,12 +5,18 @@ module HOALife::Resources::Persistable
5
5
  include HOALife::Resources::Requestable
6
6
  extend HOALife::Concern
7
7
 
8
+ attr_accessor :errors
9
+
8
10
  class_methods do
9
11
  def create(attrs = {})
10
12
  new(attrs).tap(&:save)
11
13
  end
12
14
  end
13
15
 
16
+ def id
17
+ attrs[:id]
18
+ end
19
+
14
20
  def save
15
21
  self.errors = nil
16
22
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HOALife
4
- VERSION = '0.1.2'
4
+ VERSION = '0.1.7'
5
5
  end
data/lib/hoalife.rb CHANGED
@@ -21,7 +21,8 @@ end
21
21
 
22
22
  loader.setup
23
23
 
24
- require 'hoalife/error'
24
+ require "hoalife/error"
25
+ require "hoalife/concerns/arrayable"
25
26
 
26
27
  # :nodoc
27
28
  module HOALife
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hoalife
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Westendorf
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-11 00:00:00.000000000 Z
11
+ date: 2022-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.0'
33
+ version: '2.3'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">"
39
39
  - !ruby/object:Gem::Version
40
- version: '2.0'
40
+ version: '2.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: listen
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '10.0'
75
+ version: '13.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '10.0'
82
+ version: '13.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rubocop
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -115,15 +115,17 @@ executables: []
115
115
  extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
+ - ".github/workflows/development.yml"
118
119
  - ".gitignore"
119
120
  - ".rubocop.yml"
120
- - ".travis.yml"
121
+ - ".ruby-version"
121
122
  - Gemfile
122
123
  - Gemfile.lock
123
124
  - LICENSE.txt
124
125
  - README.md
125
126
  - Rakefile
126
127
  - bin/console
128
+ - bin/release
127
129
  - bin/setup
128
130
  - examples/account.rb
129
131
  - examples/ccr_article_and_violation_types.rb
@@ -142,9 +144,11 @@ files:
142
144
  - lib/hoalife/client/post.rb
143
145
  - lib/hoalife/client/put.rb
144
146
  - lib/hoalife/concern.rb
147
+ - lib/hoalife/concerns/arrayable.rb
145
148
  - lib/hoalife/error.rb
146
149
  - lib/hoalife/escalation.rb
147
150
  - lib/hoalife/inspection.rb
151
+ - lib/hoalife/properties/supplemental_mailing_address.rb
148
152
  - lib/hoalife/property.rb
149
153
  - lib/hoalife/resource.rb
150
154
  - lib/hoalife/resources/collection.rb
@@ -163,7 +167,7 @@ metadata:
163
167
  homepage_uri: https://docs.hoalife.com
164
168
  source_code_uri: https://github.com/hoalife/hoalife-ruby
165
169
  changelog_uri: https://github.com/hoalife/hoalife-ruby/master/CHANGELOG.md
166
- post_install_message:
170
+ post_install_message:
167
171
  rdoc_options: []
168
172
  require_paths:
169
173
  - lib
@@ -178,8 +182,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
182
  - !ruby/object:Gem::Version
179
183
  version: '0'
180
184
  requirements: []
181
- rubygems_version: 3.0.3
182
- signing_key:
185
+ rubygems_version: 3.1.6
186
+ signing_key:
183
187
  specification_version: 4
184
188
  summary: Ruby API Client for the HOALife.com API
185
189
  test_files: []
data/.travis.yml DELETED
@@ -1,9 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.5.0
7
- - 2.6.0
8
- - 2.7.0
9
- before_install: gem install bundler -v 2.0.2