honest_renter 0.0.0 → 1.0.0

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.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.travis.yml +7 -0
  4. data/Gemfile.lock +23 -1
  5. data/LICENSE.txt +22 -0
  6. data/README.md +116 -1
  7. data/Rakefile +11 -0
  8. data/honest_renter.gemspec +6 -1
  9. data/lib/authenticator.rb +76 -0
  10. data/lib/client.rb +11 -0
  11. data/lib/honest_renter.rb +12 -0
  12. data/lib/request.rb +71 -0
  13. data/lib/requests/expandable.rb +10 -0
  14. data/lib/requests/filter.rb +9 -0
  15. data/lib/requests/find_all.rb +27 -0
  16. data/lib/requests/find_all_by_filter.rb +38 -0
  17. data/lib/requests/find_by_id.rb +23 -0
  18. data/lib/requests/post.rb +15 -0
  19. data/lib/requires.rb +18 -0
  20. data/lib/response.rb +30 -0
  21. data/lib/session.rb +20 -0
  22. data/models/applicant.rb +42 -0
  23. data/models/base_model.rb +57 -0
  24. data/models/candidate.rb +31 -0
  25. data/models/child.rb +20 -0
  26. data/models/code.rb +27 -0
  27. data/models/cooccupant.rb +20 -0
  28. data/models/country.rb +16 -0
  29. data/models/email.rb +21 -0
  30. data/models/emergency_contact.rb +20 -0
  31. data/models/ethnicity.rb +16 -0
  32. data/models/failed_login.rb +21 -0
  33. data/models/gender.rb +16 -0
  34. data/models/inbox_filters.rb +26 -0
  35. data/models/invite_settings.rb +23 -0
  36. data/models/member.rb +24 -0
  37. data/models/name.rb +22 -0
  38. data/models/notification.rb +18 -0
  39. data/models/notification_type.rb +19 -0
  40. data/models/organization.rb +23 -0
  41. data/models/participant.rb +21 -0
  42. data/models/person.rb +30 -0
  43. data/models/pet.rb +22 -0
  44. data/models/pet_age_category.rb +18 -0
  45. data/models/pet_size_category.rb +18 -0
  46. data/models/pet_type.rb +18 -0
  47. data/models/phone.rb +24 -0
  48. data/models/phone_type.rb +18 -0
  49. data/models/position.rb +23 -0
  50. data/models/reason_for_archive.rb +18 -0
  51. data/models/reason_for_eviction.rb +18 -0
  52. data/models/reason_for_exclusion.rb +18 -0
  53. data/models/reference.rb +20 -0
  54. data/models/relationship_type.rb +19 -0
  55. data/models/reminder.rb +19 -0
  56. data/models/residence.rb +25 -0
  57. data/models/smoking_status_category.rb +18 -0
  58. data/models/sort_by_option.rb +18 -0
  59. data/models/time_of_day.rb +18 -0
  60. data/models/title.rb +17 -0
  61. data/models/user.rb +20 -0
  62. data/models/vehicle.rb +21 -0
  63. data/modules/requests_unsupported.rb +21 -0
  64. data/modules/unrequestable.rb +23 -0
  65. data/test/fixtures/ethnicities/find_all.json +38 -0
  66. data/test/fixtures/members/find.json +31 -0
  67. data/test/fixtures/titles/find_all_by_filters.json +11 -0
  68. data/test/integration/find_all_by_filters_test.rb +12 -0
  69. data/test/integration/find_all_test.rb +11 -0
  70. data/test/integration/find_test.rb +10 -0
  71. data/test/lib/authenticator_test.rb +75 -0
  72. data/test/lib/requests/filter_test.rb +14 -0
  73. data/test/lib/requests/find_all_by_filter_test.rb +44 -0
  74. data/test/lib/requests/find_all_test.rb +59 -0
  75. data/test/lib/requests/find_by_id_test.rb +30 -0
  76. data/test/lib/requests/post_test.rb +38 -0
  77. data/test/lib/response_test.rb +46 -0
  78. data/test/lib/session_test.rb +45 -0
  79. data/test/models/base_model_test.rb +62 -0
  80. data/test/test_helper.rb +76 -0
  81. data/version.rb +1 -1
  82. metadata +134 -2
@@ -0,0 +1,18 @@
1
+ module HonestRenter
2
+ class ReasonForEviction < BaseModel
3
+ ATTRIBUTES = [
4
+ :id,
5
+ :label
6
+ ].freeze
7
+
8
+ attr_accessor *ATTRIBUTES
9
+
10
+ include Unrequestable
11
+
12
+ class << self
13
+ def attr_name
14
+ 'reasons_for_eviction'
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ module HonestRenter
2
+ class ReasonForExclusion < BaseModel
3
+ ATTRIBUTES = [
4
+ :id,
5
+ :label
6
+ ].freeze
7
+
8
+ attr_accessor *ATTRIBUTES
9
+
10
+ include Unrequestable
11
+
12
+ class << self
13
+ def attr_name
14
+ 'reasons_for_exclusion'
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,20 @@
1
+ module HonestRenter
2
+ class Reference < BaseModel
3
+ ATTRIBUTES = [
4
+ :id,
5
+ :created,
6
+ :person,
7
+ :position,
8
+ :relationship,
9
+ :residence
10
+ ].freeze
11
+
12
+ attr_accessor *ATTRIBUTES
13
+
14
+ class << self
15
+ def attr_name
16
+ 'references'
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,19 @@
1
+ module HonestRenter
2
+ class RelationshipType < BaseModel
3
+ ATTRIBUTES = [
4
+ :id,
5
+ :converse,
6
+ :label
7
+ ].freeze
8
+
9
+ attr_accessor *ATTRIBUTES
10
+
11
+ include Unrequestable
12
+
13
+ class << self
14
+ def attr_name
15
+ 'relationship_types'
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ module HonestRenter
2
+ class Reminder < BaseModel
3
+ ATTRIBUTES = [
4
+ :id,
5
+ :applicant,
6
+ :created,
7
+ :destination,
8
+ :sender
9
+ ].freeze
10
+
11
+ attr_accessor *ATTRIBUTES
12
+
13
+ class << self
14
+ def attr_name
15
+ 'reminders'
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,25 @@
1
+ module HonestRenter
2
+ class Residence < BaseModel
3
+ ATTRIBUTES = [
4
+ :id,
5
+ :address,
6
+ :city,
7
+ :country,
8
+ :candidate,
9
+ :created,
10
+ :reason_for_leaving,
11
+ :references,
12
+ :start_date,
13
+ :state,
14
+ :unit_label
15
+ ].freeze
16
+
17
+ attr_accessor *ATTRIBUTES
18
+
19
+ class << self
20
+ def attr_name
21
+ 'residences'
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,18 @@
1
+ module HonestRenter
2
+ class SmokingStatusCategory < BaseModel
3
+ ATTRIBUTES = [
4
+ :id,
5
+ :label
6
+ ].freeze
7
+
8
+ attr_accessor *ATTRIBUTES
9
+
10
+ include Unrequestable
11
+
12
+ class << self
13
+ def attr_name
14
+ 'smoking_status_categories'
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ module HonestRenter
2
+ class SortByOption < BaseModel
3
+ ATTRIBUTES = [
4
+ :id,
5
+ :label
6
+ ].freeze
7
+
8
+ attr_accessor *ATTRIBUTES
9
+
10
+ include Unrequestable
11
+
12
+ class << self
13
+ def attr_name
14
+ 'sort_by_options'
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ module HonestRenter
2
+ class TimeOfDay < BaseModel
3
+ ATTRIBUTES = [
4
+ :id,
5
+ :label
6
+ ].freeze
7
+
8
+ attr_accessor *ATTRIBUTES
9
+
10
+ include Unrequestable
11
+
12
+ class << self
13
+ def attr_name
14
+ 'times_of_day'
15
+ end
16
+ end
17
+ end
18
+ end
data/models/title.rb ADDED
@@ -0,0 +1,17 @@
1
+ module HonestRenter
2
+ class Title < BaseModel
3
+ ATTRIBUTES = [
4
+ :id,
5
+ :gender,
6
+ :acronym
7
+ ].freeze
8
+
9
+ attr_accessor *ATTRIBUTES
10
+
11
+ class << self
12
+ def attr_name
13
+ 'titles'
14
+ end
15
+ end
16
+ end
17
+ end
data/models/user.rb ADDED
@@ -0,0 +1,20 @@
1
+ module HonestRenter
2
+ class User < BaseModel
3
+ ATTRIBUTES = [
4
+ :id,
5
+ :account,
6
+ :created,
7
+ :removed,
8
+ :member,
9
+ :role
10
+ ].freeze
11
+
12
+ attr_accessor *ATTRIBUTES
13
+
14
+ class << self
15
+ def attr_name
16
+ 'users'
17
+ end
18
+ end
19
+ end
20
+ end
data/models/vehicle.rb ADDED
@@ -0,0 +1,21 @@
1
+ module HonestRenter
2
+ class Vehicle < BaseModel
3
+ ATTRIBUTES = [
4
+ :id,
5
+ :created,
6
+ :license_plate,
7
+ :make,
8
+ :model,
9
+ :owner,
10
+ :year
11
+ ].freeze
12
+
13
+ attr_accessor *ATTRIBUTES
14
+
15
+ class << self
16
+ def attr_name
17
+ 'vehicles'
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ module HonestRenter
2
+ module Unrequestable
3
+ class Unsupported < StandardError; end
4
+
5
+ def self.included(base)
6
+ base.extend(ClassMethods)
7
+ end
8
+
9
+ module ClassMethods
10
+ def find_all(*)
11
+ raise Unsupported, "this model may not use the #{__method__} method."
12
+ end
13
+
14
+ def find(*)
15
+ raise Unsupported, "this model may not use the #{__method__} method."
16
+ end
17
+ end
18
+
19
+ private_constant :Unsupported
20
+ end
21
+ end
@@ -0,0 +1,23 @@
1
+ module HonestRenter
2
+ module Unrequestable
3
+ class Unsupported < StandardError; end
4
+
5
+ def included(base)
6
+ base.extend(ClassMethods)
7
+ end
8
+
9
+ module ClassMethods
10
+ class << self
11
+ def find_all(*)
12
+ raise Unsupported, "this model may not use the #{__method__} method."
13
+ end
14
+
15
+ def find(*)
16
+ raise Unsupported, "this model may not use the #{__method__} method."
17
+ end
18
+ end
19
+ end
20
+
21
+ private_constant :Unsupported
22
+ end
23
+ end
@@ -0,0 +1,38 @@
1
+ {
2
+ "data": [
3
+ {
4
+ "id": 1,
5
+ "label": "White"
6
+ },
7
+ {
8
+ "id": 2,
9
+ "label": "Black"
10
+ },
11
+ {
12
+ "id": 3,
13
+ "label": "Hispanic, Lantino, or Spanish origin"
14
+ },
15
+ {
16
+ "id": 4,
17
+ "label": "Asian"
18
+ },
19
+ {
20
+ "id": 5,
21
+ "label": "Aboriginal"
22
+ },
23
+ {
24
+ "id": 6,
25
+ "label": "Arab"
26
+ },
27
+ {
28
+ "id": 7,
29
+ "label": "Pacific Islander"
30
+ },
31
+ {
32
+ "id": 8,
33
+ "label": "Other"
34
+ }
35
+ ],
36
+ "limit": 100,
37
+ "offset": 0
38
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "data": {
3
+ "id": "TYJH7ptuju",
4
+ "hasPassword": 1,
5
+ "inboxFilters": "TYJH7ptuju",
6
+ "inviteSettings": "TYJH7ptuju",
7
+ "sendReportsByEmail": true,
8
+ "users": [
9
+ "1LXpyPFjYJ"
10
+ ],
11
+ "accountsWithAccess": [
12
+ "qupHjmQzUb"
13
+ ],
14
+ "birthdate": null,
15
+ "created": 1454552715,
16
+ "dateToDeleteIdentifyingInfo": null,
17
+ "ethnicities": [],
18
+ "emails": [
19
+ "ZGU3CSVfwn"
20
+ ],
21
+ "gender": null,
22
+ "name": "TYJH7ptuju",
23
+ "notes": [],
24
+ "notifications": [],
25
+ "otherEthnicity": "",
26
+ "phones": [],
27
+ "positions": null,
28
+ "preferredEmail": null,
29
+ "preferredPhone": null
30
+ }
31
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "data": [
3
+ {
4
+ "id": 3,
5
+ "gender": 2,
6
+ "acronym": "Mrs."
7
+ }
8
+ ],
9
+ "limit": 100,
10
+ "offset": 0
11
+ }
@@ -0,0 +1,12 @@
1
+ require_relative '../test_helper'
2
+
3
+ class FindAllByFiltersTest < WebMockingTest
4
+ def test_find_all_titles_by_filters
5
+ session = test_session
6
+ filters = [HonestRenter::Filter.new(:id, TEST_TITLES_ID)]
7
+ titles = HonestRenter::Title.find_all_by_filters(filters, session)
8
+ assert_equal(Array, titles.class)
9
+ assert_equal(true,
10
+ titles.all? { |e| e.class == HonestRenter::Title })
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+ require_relative '../test_helper'
2
+
3
+ class FindAllTest < WebMockingTest
4
+ def test_find_all_ethnicities
5
+ session = test_session
6
+ ethnicities = HonestRenter::Ethnicity.find_all(session)
7
+ assert_equal(Array, ethnicities.class)
8
+ assert_equal(true,
9
+ ethnicities.all? { |e| e.class == HonestRenter::Ethnicity })
10
+ end
11
+ end
@@ -0,0 +1,10 @@
1
+ require_relative '../test_helper'
2
+
3
+ class FindTest < WebMockingTest
4
+ def test_find_member
5
+ session = test_session
6
+ member = HonestRenter::Member.find(TEST_MEMBER_ID, session)
7
+ assert_equal(HonestRenter::Member, member.class)
8
+ assert_equal(TEST_MEMBER_ID, member.id)
9
+ end
10
+ end
@@ -0,0 +1,75 @@
1
+ require_relative '../test_helper'
2
+ require_relative '../../lib/authenticator'
3
+
4
+ module HonestRenter
5
+ class AuthenticatorTest < MiniTest::Unit::TestCase
6
+ def test_from_secret_key_member_id
7
+ secret_key = 'secret_key'
8
+ member_id = 1234
9
+ authenticator = Authenticator.from_secret_key_member_id(secret_key, member_id)
10
+
11
+ assert_equal(authenticator.class, SecretKeyMemberIdAuthenticator)
12
+ assert_equal(authenticator.instance_variable_get(:@secret_key), secret_key)
13
+ assert_equal(authenticator.instance_variable_get(:@member_id), member_id)
14
+ end
15
+
16
+ def test_from_address_and_password
17
+ address = 'address'
18
+ password = 'a password'
19
+ authenticator = Authenticator.from_address_and_password(address, password)
20
+
21
+ assert_equal(authenticator.class, AddressPasswordAuthenticator)
22
+ assert_equal(authenticator.instance_variable_get(:@address), address)
23
+ assert_equal(authenticator.instance_variable_get(:@password), password)
24
+ end
25
+
26
+ def test_secret_key_build_session
27
+ secret_key = 'secret_key'
28
+ member_id = 1234
29
+ authenticator = Authenticator.from_secret_key_member_id(secret_key, member_id)
30
+
31
+ assert_equal(authenticator.session.class, HonestRenter::Session)
32
+ end
33
+
34
+ def test_address_and_password_session
35
+ address = 'address'
36
+ password = 'a password'
37
+ authenticator = Authenticator.from_address_and_password(address, password)
38
+ allow(HonestRenter::Post).to receive_message_chain(:new, :call) do
39
+ instance_double(HonestRenter::Response, headers: {})
40
+ end
41
+
42
+ assert_equal(authenticator.session.class, HonestRenter::Session)
43
+ end
44
+
45
+ def test_secret_key_raw_hash_keys
46
+ secret_key = 'secret_key'
47
+ member_id = 1234
48
+ authenticator = Authenticator.from_secret_key_member_id(secret_key, member_id)
49
+ hash = authenticator.raw_hash
50
+ expected_keys = [
51
+ :apiKey,
52
+ :authorization,
53
+ :expires,
54
+ :person,
55
+ :renewableUntil
56
+ ]
57
+
58
+ assert_equal(authenticator.raw_hash.keys, expected_keys)
59
+ end
60
+
61
+ def test_renew!
62
+ allow(HonestRenter::Post).to receive_message_chain(:new, :call) do
63
+ instance_double(HonestRenter::Response, headers: {})
64
+ end
65
+
66
+ address = 'address'
67
+ password = 'a password'
68
+ authenticator = Authenticator.from_address_and_password(address, password)
69
+
70
+ assert_equal(authenticator.instance_variable_get(:@session).nil?, true)
71
+ authenticator.renew!
72
+ assert_equal(authenticator.instance_variable_get(:@session).nil?, false)
73
+ end
74
+ end
75
+ end