Class: REIformslive::UserTemplate
- Inherits:
-
Object
- Object
- REIformslive::UserTemplate
- Defined in:
- lib/reiformslive/user_template.rb
Constant Summary collapse
- PATH =
'/user-templates'.freeze
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Class Method Summary collapse
Instance Method Summary collapse
- #agency_id ⇒ Object
- #created_at ⇒ Object
- #finalised? ⇒ Boolean
- #full_name ⇒ Object
- #given_name ⇒ Object
- #id ⇒ Object
-
#initialize(data: '{}') ⇒ UserTemplate
constructor
A new instance of UserTemplate.
- #name ⇒ Object
- #original_template_code ⇒ Object
- #original_template_name ⇒ Object
- #private? ⇒ Boolean
- #surname ⇒ Object
- #template? ⇒ Boolean
- #template_cost ⇒ Object
- #template_id ⇒ Object
- #template_version_id ⇒ Object
- #updated_at ⇒ Object
- #user_id ⇒ Object
Constructor Details
#initialize(data: '{}') ⇒ UserTemplate
Returns a new instance of UserTemplate.
7 8 9 |
# File 'lib/reiformslive/user_template.rb', line 7 def initialize data: '{}' @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
5 6 7 |
# File 'lib/reiformslive/user_template.rb', line 5 def data @data end |
Class Method Details
.all ⇒ Object
79 80 81 82 83 84 |
# File 'lib/reiformslive/user_template.rb', line 79 def self.all REIformslive::Session .get(path: PATH) .parse_json .map{|data| self.new data: data } end |
.find(id) ⇒ Object
86 87 88 89 90 91 |
# File 'lib/reiformslive/user_template.rb', line 86 def self.find id self.new data: REIformslive::Session .get(path: "#{PATH}/#{id}") .parse_json end |
Instance Method Details
#agency_id ⇒ Object
19 20 21 |
# File 'lib/reiformslive/user_template.rb', line 19 def agency_id data['agency_id'].to_i end |
#created_at ⇒ Object
43 44 45 |
# File 'lib/reiformslive/user_template.rb', line 43 def created_at Time.at data['created'].to_i end |
#finalised? ⇒ Boolean
35 36 37 |
# File 'lib/reiformslive/user_template.rb', line 35 def finalised? data['finalised'].to_s == 'true' end |
#full_name ⇒ Object
59 60 61 |
# File 'lib/reiformslive/user_template.rb', line 59 def full_name "#{given_name} #{surname}" end |
#given_name ⇒ Object
51 52 53 |
# File 'lib/reiformslive/user_template.rb', line 51 def given_name data['given_name'] end |
#id ⇒ Object
11 12 13 |
# File 'lib/reiformslive/user_template.rb', line 11 def id data['id'].to_i end |
#name ⇒ Object
27 28 29 |
# File 'lib/reiformslive/user_template.rb', line 27 def name data['name'] end |
#original_template_code ⇒ Object
75 76 77 |
# File 'lib/reiformslive/user_template.rb', line 75 def original_template_code data['template_code'] end |
#original_template_name ⇒ Object
71 72 73 |
# File 'lib/reiformslive/user_template.rb', line 71 def original_template_name data['template_name'] end |
#private? ⇒ Boolean
39 40 41 |
# File 'lib/reiformslive/user_template.rb', line 39 def private? data['private'].to_s == 'true' end |
#surname ⇒ Object
55 56 57 |
# File 'lib/reiformslive/user_template.rb', line 55 def surname data['surname'] end |
#template? ⇒ Boolean
31 32 33 |
# File 'lib/reiformslive/user_template.rb', line 31 def template? data['template'].to_s == 'true' end |
#template_cost ⇒ Object
63 64 65 |
# File 'lib/reiformslive/user_template.rb', line 63 def template_cost data['template_cost'].to_i end |
#template_id ⇒ Object
67 68 69 |
# File 'lib/reiformslive/user_template.rb', line 67 def template_id data['template_id'].to_i end |
#template_version_id ⇒ Object
15 16 17 |
# File 'lib/reiformslive/user_template.rb', line 15 def template_version_id data['template_version_id'].to_i end |
#updated_at ⇒ Object
47 48 49 |
# File 'lib/reiformslive/user_template.rb', line 47 def updated_at Time.at data['updated'].to_i end |
#user_id ⇒ Object
23 24 25 |
# File 'lib/reiformslive/user_template.rb', line 23 def user_id data['user_id'].to_i end |