Class: KillBillClient::Model::UserRoles

Inherits:
UserRolesAttributes show all
Defined in:
lib/killbill_client/models/user_roles.rb

Constant Summary

Constants inherited from Resource

Resource::KILLBILL_API_PAGINATION_PREFIX, Resource::KILLBILL_API_PREFIX

Instance Attribute Summary

Attributes inherited from Resource

#clazz, #etag, #response, #session_id, #uri

Instance Method Summary collapse

Methods inherited from Resource

#==, #_to_hash, attribute, create_alias, delete, extract_session_id, from_json, from_response, get, has_many, has_one, #hash, head, #initialize, instantiate_record_from_json, post, put, #refresh, require_multi_tenant_options!, #to_hash, #to_json

Constructor Details

This class inherits a constructor from KillBillClient::Model::Resource

Instance Method Details

#create(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/killbill_client/models/user_roles.rb', line 5

def create(user = nil, reason = nil, comment = nil, options = {})
  created_user = self.class.post "#{Security::KILLBILL_API_SECURITY_PREFIX}/users",
                                 to_json,
                                 {},
                                 {
                                     :user => user,
                                     :reason => reason,
                                     :comment => comment,
                                 }.merge(options)
  created_user.refresh(options)
end

#destroy(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'lib/killbill_client/models/user_roles.rb', line 30

def destroy(user = nil, reason = nil, comment = nil, options = {})
  self.class.delete "#{Security::KILLBILL_API_SECURITY_PREFIX}/users/#{username}",
                    {},
                    {},
                    {
                        :user => user,
                        :reason => reason,
                        :comment => comment,
                    }.merge(options)
end

#update(user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/killbill_client/models/user_roles.rb', line 17

def update(user = nil, reason = nil, comment = nil, options = {})
  url = password.nil? ? "#{Security::KILLBILL_API_SECURITY_PREFIX}/users/#{username}/roles" : "#{Security::KILLBILL_API_SECURITY_PREFIX}/users/#{username}/password"
  updated_user = self.class.put url,
                                to_json,
                                {},
                                {
                                    :user => user,
                                    :reason => reason,
                                    :comment => comment,
                                }.merge(options)
  updated_user.refresh(options)
end