Class: Itexmo::Sms

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

Overview

sms

Constant Summary collapse

API_ENDPOINT =
'https://www.itexmo.com/php_api'.freeze
PARAMETERS =
{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSms

Returns a new instance of Sms.



12
13
14
15
# File 'lib/itexmo/sms.rb', line 12

def initialize
  @api_code = Itexmo.configuration.api_code
  PARAMETERS['apicode'] = api_code
end

Instance Attribute Details

#api_codeObject

Returns the value of attribute api_code.



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

def api_code
  @api_code
end

Class Method Details

.delete_all_outgoingObject



38
39
40
41
# File 'lib/itexmo/sms.rb', line 38

def self.delete_all_outgoing
  instance = new
  instance.delete_all_outgoing
end

.delete_message_via_id(originator) ⇒ Object



92
93
94
95
# File 'lib/itexmo/sms.rb', line 92

def self.delete_message_via_id(originator)
  instance = new
  instance.delete_message_via_id(originator)
end

.delete_message_via_originator(originator) ⇒ Object



78
79
80
81
# File 'lib/itexmo/sms.rb', line 78

def self.delete_message_via_originator(originator)
  instance = new
  instance.delete_message_via_originator(originator)
end

.delete_messages_allObject



104
105
106
107
# File 'lib/itexmo/sms.rb', line 104

def self.delete_messages_all
  instance = new
  instance.delete_messages_all
end

.display_messagesObject



50
51
52
53
# File 'lib/itexmo/sms.rb', line 50

def self.display_messages
  instance = new
  instance.display_messages
end

.display_messages_via_originator(originator) ⇒ Object



64
65
66
67
# File 'lib/itexmo/sms.rb', line 64

def self.display_messages_via_originator(originator)
  instance = new
  instance.display_messages_via_originator(originator)
end

.display_outgoing(sortby = 'asc') ⇒ Object



26
27
28
29
# File 'lib/itexmo/sms.rb', line 26

def self.display_outgoing(sortby = 'asc')
  instance = new
  instance.display_outgoing(sortby)
end

Instance Method Details

#delete_all_outgoingObject



31
32
33
34
35
36
# File 'lib/itexmo/sms.rb', line 31

def delete_all_outgoing
  uri = URI(API_ENDPOINT + '/delete_outgoing_all.php')
  uri.query = URI.encode_www_form(PARAMETERS)
  request   = Net::HTTP.get_response(uri)
  ResponseHelper.parse(request.body)
end

#delete_message_via_id(id) ⇒ Object



83
84
85
86
87
88
89
90
# File 'lib/itexmo/sms.rb', line 83

def delete_message_via_id(id)
  PARAMETERS[:id] = id
  uri       = URI(API_ENDPOINT + '/delete_message_via_id.php')
  uri.query = URI.encode_www_form(PARAMETERS)
  request   = Net::HTTP.get_response(uri)
  PARAMETERS.except!(:id)
  ResponseHelper.parse(request.body)
end

#delete_message_via_originator(originator) ⇒ Object



69
70
71
72
73
74
75
76
# File 'lib/itexmo/sms.rb', line 69

def delete_message_via_originator(originator)
  PARAMETERS[:originator] = originator
  uri       = URI(API_ENDPOINT + '/delete_message_via_originator.php')
  uri.query = URI.encode_www_form(PARAMETERS)
  request   = Net::HTTP.get_response(uri)
  PARAMETERS.except!(:originator)
  ResponseHelper.parse(request.body)
end

#delete_messages_allObject



97
98
99
100
101
102
# File 'lib/itexmo/sms.rb', line 97

def delete_messages_all
  uri = URI(API_ENDPOINT + '/delete_messages_all.php')
  uri.query = URI.encode_www_form(PARAMETERS)
  request   = Net::HTTP.get_response(uri)
  ResponseHelper.parse(request.body)
end

#display_messagesObject



43
44
45
46
47
48
# File 'lib/itexmo/sms.rb', line 43

def display_messages
  uri = URI(API_ENDPOINT + '/display_messages.php')
  uri.query = URI.encode_www_form(PARAMETERS)
  request   = Net::HTTP.get_response(uri)
  ResponseHelper.parse(request.body)
end

#display_messages_via_originator(originator) ⇒ Object



55
56
57
58
59
60
61
62
# File 'lib/itexmo/sms.rb', line 55

def display_messages_via_originator(originator)
  PARAMETERS[:originator] = originator
  uri       = URI(API_ENDPOINT + '/display_messages_via_originator.php')
  uri.query = URI.encode_www_form(PARAMETERS)
  request   = Net::HTTP.get_response(uri)
  PARAMETERS.except!(:originator)
  ResponseHelper.parse(request.body)
end

#display_outgoing(sortby = 'asc') ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/itexmo/sms.rb', line 17

def display_outgoing(sortby = 'asc')
  PARAMETERS[:sortby] = sortby
  uri                  = URI(API_ENDPOINT + '/display_outgoing.php')
  uri.query            = URI.encode_www_form(PARAMETERS)
  request              = Net::HTTP.get_response(uri)
  PARAMETERS.except!(:sortby)
  ResponseHelper.parse(request.body)
end