Class: Serwersms

Inherits:
Object
  • Object
show all
Defined in:
lib/serwersms.rb

Defined Under Namespace

Classes: Accounts, Blacklist, Contacts, Error, Files, Groups, Messages, Payments, Phones, Premium, Senders, Stats, Subaccounts, Templates

Constant Summary collapse

@@api_url =
'http://api2.serwersms.pl/'
@@system =
'client_ruby'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username, password) ⇒ Serwersms

Returns a new instance of Serwersms.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/serwersms.rb', line 21

def initialize(username, password)
    @username     = username
    @password     = password
    @messages     = Messages.new(self)
    @files        = Files.new(self)
    @premium      = Premium.new(self)
    @accounts     = Accounts.new(self)
    @senders      = Senders.new(self)
    @groups       = Groups.new(self)
    @contacts     = Contacts.new(self)
    @phones       = Phones.new(self)
    @subaccounts  = Subaccounts.new(self)
    @blacklist    = Blacklist.new(self)
    @payments     = Payments.new(self)
    @stats        = Stats.new(self)
    @templates    = Templates.new(self)
    @error        = Error.new(self)
end

Instance Attribute Details

#accountsObject

Returns the value of attribute accounts.



9
10
11
# File 'lib/serwersms.rb', line 9

def accounts
  @accounts
end

#blacklistObject

Returns the value of attribute blacklist.



15
16
17
# File 'lib/serwersms.rb', line 15

def blacklist
  @blacklist
end

#contactsObject

Returns the value of attribute contacts.



12
13
14
# File 'lib/serwersms.rb', line 12

def contacts
  @contacts
end

#errorObject

Returns the value of attribute error.



19
20
21
# File 'lib/serwersms.rb', line 19

def error
  @error
end

#filesObject

Returns the value of attribute files.



7
8
9
# File 'lib/serwersms.rb', line 7

def files
  @files
end

#groupsObject

Returns the value of attribute groups.



11
12
13
# File 'lib/serwersms.rb', line 11

def groups
  @groups
end

#messagesObject

Returns the value of attribute messages.



6
7
8
# File 'lib/serwersms.rb', line 6

def messages
  @messages
end

#paymentsObject

Returns the value of attribute payments.



16
17
18
# File 'lib/serwersms.rb', line 16

def payments
  @payments
end

#phonesObject

Returns the value of attribute phones.



13
14
15
# File 'lib/serwersms.rb', line 13

def phones
  @phones
end

#premiumObject

Returns the value of attribute premium.



8
9
10
# File 'lib/serwersms.rb', line 8

def premium
  @premium
end

#sendersObject

Returns the value of attribute senders.



10
11
12
# File 'lib/serwersms.rb', line 10

def senders
  @senders
end

#statsObject

Returns the value of attribute stats.



17
18
19
# File 'lib/serwersms.rb', line 17

def stats
  @stats
end

#subaccountsObject

Returns the value of attribute subaccounts.



14
15
16
# File 'lib/serwersms.rb', line 14

def subaccounts
  @subaccounts
end

#templatesObject

Returns the value of attribute templates.



18
19
20
# File 'lib/serwersms.rb', line 18

def templates
  @templates
end

Instance Method Details

#call(url, params = {}) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/serwersms.rb', line 40

def call(url, params = {})
    uri = URI.parse(@@api_url+url)
    https = Net::HTTP.new(uri.host,uri.port)
    req = Net::HTTP::Post.new(uri.path,{'Content-Type' => 'application/json'})
    params['username'] = @username
    params['password'] = @password
    params['system']   = @@system
    req.body = params.to_json
    res = https.request(req)
    
    return res.body
end