Class: Youroom::AddUser

Inherits:
Request show all
Defined in:
lib/youroom_api/request/add_user.rb

Instance Attribute Summary collapse

Attributes inherited from Request

#access_token

Attributes inherited from Base

#host, #port, #url

Instance Method Summary collapse

Methods inherited from Request

#create_entry, #create_participation, #create_room, #create_user, #delete, #destroy_entry, #destroy_participation, #get, #get_all_timeline, #get_attachment, #get_entry, #get_my_group, #get_picture, #get_room_list, #get_room_timeline, #get_unread_timeline, #get_user_list, #get_verify_credentials, #mark_read, #mark_unread, #post

Constructor Details

#initialize(access_token, billing_id, attributes, url = BASE_URL) ⇒ AddUser

Returns a new instance of AddUser.



5
6
7
8
9
10
# File 'lib/youroom_api/request/add_user.rb', line 5

def initialize(access_token, billing_id, attributes, url=BASE_URL)
  required_structure(billing_id, String, Fixnum)
  required_structure(attributes, Hash)
  @billing_id, @attributes = billing_id.to_s, attributes
  super(access_token, url)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object

TODO: refactoring



24
25
26
# File 'lib/youroom_api/request/add_user.rb', line 24

def method_missing(name, *args)
  attributes[name.to_sym]
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



3
4
5
# File 'lib/youroom_api/request/add_user.rb', line 3

def attributes
  @attributes
end

#billing_idObject (readonly)

Returns the value of attribute billing_id.



3
4
5
# File 'lib/youroom_api/request/add_user.rb', line 3

def billing_id
  @billing_id
end

Instance Method Details

#paramsObject



16
17
18
19
20
21
# File 'lib/youroom_api/request/add_user.rb', line 16

def params
  { :billing_user => { :name => name,
                       :user_attributes => { :email => email,
                                             :password => password,
                                             :password_confirmation => password_confirmation }}}.optimize
end

#pathObject



12
13
14
# File 'lib/youroom_api/request/add_user.rb', line 12

def path
  File.join(url, 'billings', billing_id, 'billing_users?format=json')
end