Class: Textmagic::REST::Subaccounts

Inherits:
ListResource show all
Defined in:
lib/textmagic-ruby/rest/subaccounts.rb

Instance Method Summary collapse

Methods inherited from ListResource

#initialize, #inspect

Methods included from Utils

#key_map, #resource, #to_camel_case, #to_underscore_case

Constructor Details

This class inherits a constructor from Textmagic::REST::ListResource

Instance Method Details

#create(params = {}) ⇒ Object

Invite new subaccount. Returns True if success.

The following params keys are supported:

email

Subaccount email. Required.

role

Subaccount role: ‘A` for administrator or `U` for regular user. Required.

Example:

@subaccount = client.subaccounts.create {:email => '[email protected]', :role => 'A'}


55
56
57
# File 'lib/textmagic-ruby/rest/subaccounts.rb', line 55

def create(params={})
  self.send_invite params
end

#delete(uid) ⇒ Object

Close the subaccount. Returns true if success.

uid

Subaccount ID. Required.

Example:

r = client.subaccounts.delete 123123


93
94
95
# File 'lib/textmagic-ruby/rest/subaccounts.rb', line 93

def delete(uid)
  super uid
end

#get(uid) ⇒ Object

Get subaccount by ID. Returns Subaccount object.

uid

Subaccount ID. Required.

Example:

@subaccount = client.subaccounts.get 123131


15
16
17
# File 'lib/textmagic-ruby/rest/subaccounts.rb', line 15

def get(uid)
  super uid
end

#list(params = {}) ⇒ Object

Get all user subaccounts. Returns PaginateResource object, contains array of Subaccount objects.

The following params keys are supported:

page

Fetch specified results page. Defaults 1

limit

How many results on page. Defaults 10

Example:

@subaccounts = client.subaccounts.list


33
34
35
36
37
38
# File 'lib/textmagic-ruby/rest/subaccounts.rb', line 33

def list(params={})
  [:search, 'search'].each do |search|
    params.delete search
  end
  super params
end

#send_invite(params = {}) ⇒ Object

Invite new subaccount. Alias for ‘create’ method. Returns True if success.

The following params keys are supported:

email

Subaccount email. Required.

role

Subaccount role: ‘A` for administrator or `U` for regular user. Required.

Example:

@subaccount = client.subaccounts.send_invite {:email => '[email protected]', :role => 'A'}


73
74
75
# File 'lib/textmagic-ruby/rest/subaccounts.rb', line 73

def send_invite(params={})
  response = @client.post "#{@path}", params
end

#update(uid, params = {}) ⇒ Object

Updating is not supported.



80
81
82
# File 'lib/textmagic-ruby/rest/subaccounts.rb', line 80

def update(uid, params={})
  raise '`update` method is not supported for this resource.'
end