Class: Kentaa::Api::Resources::User

Inherits:
Resource show all
Defined in:
lib/kentaa/api/resources/user.rb

Instance Attribute Summary

Attributes inherited from Resource

#id

Attributes inherited from Base

#config, #endpoint_path, #options, #resource_class

Instance Method Summary collapse

Methods inherited from Resource

#create, #created_at, #delete, #initialize, #load, #save, #updated_at

Methods inherited from Base

attribute_key, #initialize, #load, #loaded?

Constructor Details

This class inherits a constructor from Kentaa::Api::Resources::Resource

Instance Method Details

#actionsObject



113
114
115
# File 'lib/kentaa/api/resources/user.rb', line 113

def actions
  @actions ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::Action, endpoint_path: "/users/#{id}/actions")
end

#addressObject



45
46
47
# File 'lib/kentaa/api/resources/user.rb', line 45

def address
  data[:address]
end

#address2Object



49
50
51
# File 'lib/kentaa/api/resources/user.rb', line 49

def address2
  data[:address2]
end

#avatarObject



117
118
119
# File 'lib/kentaa/api/resources/user.rb', line 117

def avatar
  @avatar ||= Kentaa::Api::Resources::Avatar.new(config, options: options.merge(endpoint_path: "/users/#{id}"))
end

#avatar_urlObject



41
42
43
# File 'lib/kentaa/api/resources/user.rb', line 41

def avatar_url
  data[:avatar_url]
end

#birthdayObject



81
82
83
# File 'lib/kentaa/api/resources/user.rb', line 81

def birthday
  Date.parse(data[:birthday]) if data[:birthday]
end

#cityObject



69
70
71
# File 'lib/kentaa/api/resources/user.rb', line 69

def city
  data[:city]
end


93
94
95
96
97
# File 'lib/kentaa/api/resources/user.rb', line 93

def consent
  Kentaa::Api::Deprecation.warn('#consent is deprecated. Please use #consents instead.', caller)

  @consent ||= Kentaa::Api::Resources::Consent.new(data[:consent]) if data[:consent]
end

#consentsObject



99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/kentaa/api/resources/user.rb', line 99

def consents
  @consents ||= begin
    consents = []

    if data[:consents]
      data[:consents].each do |consent|
        consents << Kentaa::Api::Resources::Consent.new(consent)
      end
    end

    consents
  end
end

#countryObject



73
74
75
# File 'lib/kentaa/api/resources/user.rb', line 73

def country
  data[:country]
end

#emailObject



37
38
39
# File 'lib/kentaa/api/resources/user.rb', line 37

def email
  data[:email]
end

#first_nameObject



21
22
23
# File 'lib/kentaa/api/resources/user.rb', line 21

def first_name
  data[:first_name]
end

#genderObject



85
86
87
# File 'lib/kentaa/api/resources/user.rb', line 85

def gender
  data[:gender]
end

#house_numberObject



57
58
59
# File 'lib/kentaa/api/resources/user.rb', line 57

def house_number
  data[:house_number]
end

#house_number_additionObject



61
62
63
# File 'lib/kentaa/api/resources/user.rb', line 61

def house_number_addition
  data[:house_number_addition]
end

#infixObject



25
26
27
# File 'lib/kentaa/api/resources/user.rb', line 25

def infix
  data[:infix]
end

#last_nameObject



29
30
31
# File 'lib/kentaa/api/resources/user.rb', line 29

def last_name
  data[:last_name]
end

#localeObject



89
90
91
# File 'lib/kentaa/api/resources/user.rb', line 89

def locale
  data[:locale]
end

#nameObject



33
34
35
# File 'lib/kentaa/api/resources/user.rb', line 33

def name
  [first_name, infix, last_name].reject { |s| s.to_s.empty? }.join(' ')
end

#object_keyObject



9
10
11
# File 'lib/kentaa/api/resources/user.rb', line 9

def object_key
  "User_#{id}"
end

#phoneObject



77
78
79
# File 'lib/kentaa/api/resources/user.rb', line 77

def phone
  data[:phone]
end

#siteObject



13
14
15
# File 'lib/kentaa/api/resources/user.rb', line 13

def site
  Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
end

#site_idObject



17
18
19
# File 'lib/kentaa/api/resources/user.rb', line 17

def site_id
  data[:site_id]
end

#streetObject



53
54
55
# File 'lib/kentaa/api/resources/user.rb', line 53

def street
  data[:street]
end

#zipcodeObject



65
66
67
# File 'lib/kentaa/api/resources/user.rb', line 65

def zipcode
  data[:zipcode]
end