Method: OnSIP::User::ClassMethods#add

Defined in:
lib/onsip/models/user.rb

#add(organization, attrs = {}) {|response| ... } ⇒ User

Adds a User to an Organization

reference at developer.onsip.com/admin-api/Users/#user-add

attrs = => ‘docs’,

'Name' => 'Docs',
'Email' => '[email protected]',
'AuthUsername' => 'example',
'Password' => 'mysuperpassword',
'PasswordConfirm' => 'mysuperpassword'

User.add(organization, attrs)

Examples:

Add User

Yields:

  • (response)

Returns:

  • (User)

    The created User.



148
149
150
151
152
153
154
155
156
157
# File 'lib/onsip/models/user.rb', line 148

def add(organization, attrs = {})
  params = attrs.merge({'Action' => 'UserAdd',
                        'SessionId' => OnSIP.session.id,
                        'OrganizationId' => organization.id,
                        'Domain' => organization.attributes.Domain,
                        'Output' => 'json'})
  response = OnSIP.connection.get('/api', params, {})
  yield response if block_given?
  process_add_user_response response
end