Class: EventMachine::Smsified::Base
- Inherits:
-
Object
- Object
- EventMachine::Smsified::Base
- Defined in:
- lib/em-smsified/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#auth ⇒ Object
readonly
Returns the value of attribute auth.
-
#base_uri ⇒ Object
readonly
Returns the value of attribute base_uri.
-
#destination_address ⇒ Object
readonly
Returns the value of attribute destination_address.
-
#sender_address ⇒ Object
readonly
Returns the value of attribute sender_address.
Instance Method Summary collapse
-
#delete(url, headers) ⇒ Object
HTTP DELETE’s a request.
-
#get(url, headers) ⇒ Object
HTTP GET’s a request.
-
#initialize(options) ⇒ Base
constructor
Intantiate a new class to work with OneAPI.
-
#post(url, body, headers) ⇒ Object
HTTP POST’s a request.
Constructor Details
#initialize(options) ⇒ Base
Intantiate a new class to work with OneAPI
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/em-smsified/base.rb', line 21 def initialize() raise ArgumentError, 'an options Hash is required' if !.instance_of?(Hash) raise ArgumentError, ':username required' if [:username].nil? raise ArgumentError, ':password required' if [:password].nil? @base_uri = [:base_uri] || SMSIFIED_ONEAPI_PUBLIC_URI @auth = { :username => [:username], :password => [:password] } @destination_address = [:destination_address] @sender_address = [:sender_address] end |
Instance Attribute Details
#auth ⇒ Object (readonly)
Returns the value of attribute auth.
7 8 9 |
# File 'lib/em-smsified/base.rb', line 7 def auth @auth end |
#base_uri ⇒ Object (readonly)
Returns the value of attribute base_uri.
7 8 9 |
# File 'lib/em-smsified/base.rb', line 7 def base_uri @base_uri end |
#destination_address ⇒ Object (readonly)
Returns the value of attribute destination_address.
7 8 9 |
# File 'lib/em-smsified/base.rb', line 7 def destination_address @destination_address end |
#sender_address ⇒ Object (readonly)
Returns the value of attribute sender_address.
7 8 9 |
# File 'lib/em-smsified/base.rb', line 7 def sender_address @sender_address end |
Instance Method Details
#delete(url, headers) ⇒ Object
HTTP DELETE’s a request
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/em-smsified/base.rb', line 55 def delete(url, headers) conn = create_connection_object(url) http = conn.delete(:head => (headers, @auth)) action = proc do response = Response.new(http.response.parsed, http)#.response.raw) yield response if block_given? end http.callback &action http.errback &action end |
#get(url, headers) ⇒ Object
HTTP GET’s a request
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/em-smsified/base.rb', line 37 def get(url, headers) conn = create_connection_object(url) http = conn.get(:head => (headers, @auth)) action = proc do response = Response.new(http.response.parsed, http)#.response.raw) yield response if block_given? end http.callback &action http.errback &action end |
#post(url, body, headers) ⇒ Object
HTTP POST’s a request
73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/em-smsified/base.rb', line 73 def post(url, body, headers) conn = create_connection_object(url) http = conn.post(:body => body, :head => (headers, @auth)) action = proc do response = Response.new(http.response.parsed, http)#.response.raw) yield response if block_given? end http.callback &action http.errback &action end |