class Textmagic::REST::Users

Public Class Methods

new(path, client) click to toggle source
Calls superclass method Textmagic::REST::ListResource::new
  # File lib/textmagic-ruby/rest/users.rb
4 def initialize(path, client)
5   super path[0..-2], client
6 end

Public Instance Methods

create(params={}) click to toggle source

Creating is not supporred.

    # File lib/textmagic-ruby/rest/users.rb
114 def create(params={})
115   raise '`create` method is not supported for this resource.'
116 end
delete(uid) click to toggle source

Deleting is not supported.

    # File lib/textmagic-ruby/rest/users.rb
107 def delete(uid)
108   raise '`delete` method is not supported for this resource.'
109 end
get() click to toggle source
   # File lib/textmagic-ruby/rest/users.rb
 8 def get
 9   response = @client.get "#{@path}", {}
10   @instance_class.new "#{@path}", @client, response
11 end
list(params={}) click to toggle source

Listing is not supported.

   # File lib/textmagic-ruby/rest/users.rb
79 def list(params={})
80   raise '`list` method is not supported for this resource.'
81 end
messaging_stat(params={}) click to toggle source

Return messaging statistics. Returns an array of hashes each contains messaging stats by given period.

The following params keys are supported:

by

Group results by specified period: `off`, `day`, `month` or `year`. Default is `off`.

start

Start date in unix timestamp format. Default is 7 days ago.

end

End date in unix timestamp format. Default is now.

Example:

@msg_stat = client.users.messaging_stat
   # File lib/textmagic-ruby/rest/users.rb
47 def messaging_stat(params={})
48   path = '/stats/messaging'
49   response = @client.get path, params
50 end
sources(params={}) click to toggle source

Get all available sender settings which could be used in “from” parameter of POST messages method. Returns Source object, contains arrays of allowed sender ids, shared and dedicated numbers.

The following params keys are supported:

country

Return sender settings available in specified country only. Optional.

Example:

@allowed = client.users.sources
   # File lib/textmagic-ruby/rest/users.rb
25 def sources(params={})
26   path = '/sources'
27   response = @client.get path, params
28   Source.new path, @client, response
29 end
spending_stat(params={}) click to toggle source

Return account spending statistics. Returns a PaginateResource object contains array of SpendingStat objects.

The following params keys are supported:

page

Fetch specified results page. Defaults 1

limit

How many results on page. Defaults 10

start

Start date in unix timestamp format. Default is 7 days ago.

end

End date in unix timestamp format. Default is now.

Example:

@spend_stat = client.users.spending_stat
   # File lib/textmagic-ruby/rest/users.rb
70 def spending_stat(params={})
71   path = '/stats/spending'
72   response = @client.get path, params
73   PaginateResource.new path, @client, response, SpendingStat
74 end
update(params={}) click to toggle source

Get current user info. Returns true if success.

The following params keys are supported:

first_name

User first name. Required.

last_name

User last name. Required.

company

User company. Required.

Example:

r = client.users.update {:first_name => 'Joye', :last_name => 'Tribbiani', :company => 'TextMagic'}
    # File lib/textmagic-ruby/rest/users.rb
 99 def update(params={})
100   response = @client.put "#{@path}", params
101   @instance_class.new "#{@path}", @client, response
102 end