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 +4 -4
- data/.github/workflows/development.yml +39 -0
- data/.ruby-version +1 -0
- data/Gemfile.lock +38 -36
- data/README.md +14 -3
- data/bin/release +36 -0
- data/examples/account.rb +1 -1
- data/examples/ccr_article_and_violation_types.rb +83 -81
- data/examples/property.rb +5 -5
- data/examples/test.rb +1 -1
- data/hoalife.gemspec +2 -2
- data/lib/hoalife/client/base.rb +1 -1
- data/lib/hoalife/concerns/arrayable.rb +30 -0
- data/lib/hoalife/properties/supplemental_mailing_address.rb +18 -0
- data/lib/hoalife/property.rb +3 -0
- data/lib/hoalife/resource.rb +31 -5
- data/lib/hoalife/resources/persistable.rb +6 -0
- data/lib/hoalife/version.rb +1 -1
- data/lib/hoalife.rb +2 -1
- metadata +17 -13
- data/.travis.yml +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 574f6e811f81b395d73ab0fb26366f9b8ef7201fefd98c5a50fc5e3d0f2ec804
|
4
|
+
data.tar.gz: a222efe6f9fa58c5422572139913194f65ba6c1f9914c96c0dd83362d63747b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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.
|
11
|
-
public_suffix (>= 2.0.2, <
|
12
|
-
ast (2.4.
|
13
|
-
crack (0.4.
|
14
|
-
|
15
|
-
ffi (1.
|
16
|
-
hashdiff (1.0.
|
17
|
-
|
18
|
-
|
19
|
-
rb-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
-
|
33
|
-
|
30
|
+
regexp_parser (2.2.1)
|
31
|
+
rexml (3.2.5)
|
32
|
+
rubocop (0.93.1)
|
34
33
|
parallel (~> 1.10)
|
35
|
-
parser (>= 2.
|
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, <
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
unicode-display_width (1.
|
43
|
-
webmock (3.
|
44
|
-
addressable (>= 2.
|
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.
|
49
|
+
zeitwerk (2.5.4)
|
48
50
|
|
49
51
|
PLATFORMS
|
50
52
|
ruby
|
51
53
|
|
52
54
|
DEPENDENCIES
|
53
|
-
bundler (
|
55
|
+
bundler (> 2.3)
|
54
56
|
hoalife!
|
55
57
|
listen (~> 3.1)
|
56
58
|
minitest (~> 5.0)
|
57
|
-
rake (~>
|
59
|
+
rake (~> 13.0)
|
58
60
|
rubocop (~> 0.74)
|
59
61
|
webmock (~> 3.6)
|
60
62
|
|
61
63
|
BUNDLED WITH
|
62
|
-
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 `
|
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/
|
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[
|
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:
|
4
|
-
title:
|
5
|
+
article: 1,
|
6
|
+
title: 'Exterior Maintenance',
|
5
7
|
violation_types_attributes: [
|
6
8
|
{
|
7
|
-
title:
|
8
|
-
resolution_step:
|
9
|
-
days_to_cure:
|
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:
|
13
|
-
resolution_step:
|
14
|
-
days_to_cure:
|
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:
|
18
|
-
resolution_step:
|
19
|
-
days_to_cure:
|
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:
|
23
|
-
resolution_step:
|
24
|
-
days_to_cure:
|
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:
|
28
|
-
resolution_step:
|
29
|
-
days_to_cure:
|
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:
|
33
|
-
resolution_step:
|
34
|
-
days_to_cure:
|
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:
|
38
|
-
resolution_step:
|
39
|
-
days_to_cure:
|
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:
|
43
|
-
resolution_step:
|
44
|
-
days_to_cure:
|
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:
|
48
|
-
resolution_step:
|
49
|
-
days_to_cure:
|
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:
|
55
|
-
title:
|
56
|
+
article: 2,
|
57
|
+
title: 'ARC',
|
56
58
|
violation_types_attributes: [
|
57
59
|
{
|
58
|
-
title:
|
59
|
-
resolution_step:
|
60
|
-
days_to_cure:
|
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:
|
66
|
-
title:
|
67
|
+
article: 3,
|
68
|
+
title: 'Improper Storage',
|
67
69
|
violation_types_attributes: [
|
68
70
|
{
|
69
|
-
title:
|
70
|
-
resolution_step:
|
71
|
-
days_to_cure:
|
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:
|
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:
|
79
|
+
days_to_cure: nil
|
78
80
|
},
|
79
81
|
{
|
80
|
-
title:
|
81
|
-
resolution_step:
|
82
|
-
days_to_cure:
|
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:
|
88
|
-
title:
|
89
|
+
article: 4,
|
90
|
+
title: 'Vehicles',
|
89
91
|
violation_types_attributes: [
|
90
92
|
{
|
91
|
-
title:
|
92
|
-
resolution_step:
|
93
|
-
days_to_cure:
|
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:
|
97
|
-
resolution_step:
|
98
|
-
days_to_cure:
|
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:
|
102
|
-
resolution_step:
|
103
|
-
days_to_cure:
|
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:
|
107
|
-
resolution_step:
|
108
|
-
days_to_cure:
|
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:
|
114
|
-
title:
|
115
|
+
article: 5,
|
116
|
+
title: 'Lawn Maintenance',
|
115
117
|
violation_types_attributes: [
|
116
118
|
{
|
117
|
-
title:
|
118
|
-
resolution_step:
|
119
|
-
days_to_cure:
|
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:
|
123
|
-
resolution_step:
|
124
|
-
days_to_cure:
|
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:
|
128
|
-
resolution_step:
|
129
|
-
days_to_cure:
|
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:
|
133
|
-
resolution_step:
|
134
|
-
days_to_cure:
|
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:
|
138
|
-
resolution_step:
|
139
|
-
days_to_cure:
|
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:
|
143
|
-
resolution_step:
|
144
|
-
days_to_cure:
|
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:
|
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:
|
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 |
|
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[
|
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[
|
40
|
-
emails: row[
|
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[
|
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[
|
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
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', '
|
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', '~>
|
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
|
data/lib/hoalife/client/base.rb
CHANGED
@@ -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
|
data/lib/hoalife/property.rb
CHANGED
data/lib/hoalife/resource.rb
CHANGED
@@ -6,7 +6,11 @@ require 'time'
|
|
6
6
|
require 'forwardable'
|
7
7
|
|
8
8
|
# :nodoc
|
9
|
-
class HOALife::Resource
|
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(
|
40
|
-
@
|
43
|
+
def initialize(attrs = {}, _relationships = {})
|
44
|
+
@attrs = {}
|
41
45
|
|
42
|
-
|
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
|
-
|
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
|
|
data/lib/hoalife/version.rb
CHANGED
data/lib/hoalife.rb
CHANGED
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.
|
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:
|
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.
|
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.
|
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: '
|
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: '
|
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
|
-
- ".
|
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.
|
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: []
|