Class: MitakeApi::Client
- Inherits:
-
Object
- Object
- MitakeApi::Client
- Defined in:
- lib/mitake_api/client.rb
Instance Attribute Summary collapse
-
#charset ⇒ Object
readonly
Returns the value of attribute charset.
-
#mitake_msg ⇒ Object
readonly
Returns the value of attribute mitake_msg.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(settings) ⇒ Client
constructor
A new instance of Client.
- #send_message(message) ⇒ Object
Constructor Details
#initialize(settings) ⇒ Client
Returns a new instance of Client.
8 9 10 11 12 13 14 |
# File 'lib/mitake_api/client.rb', line 8 def initialize(settings) @username = settings[:username] @password = settings[:password] @charset = settings[:charset] || 'UTF8' @callback_url = settings[:callback_url] @url = "https://#{settings[:url]&.gsub(%r{https?://}, '')}" end |
Instance Attribute Details
#charset ⇒ Object (readonly)
Returns the value of attribute charset.
6 7 8 |
# File 'lib/mitake_api/client.rb', line 6 def charset @charset end |
#mitake_msg ⇒ Object (readonly)
Returns the value of attribute mitake_msg.
6 7 8 |
# File 'lib/mitake_api/client.rb', line 6 def mitake_msg @mitake_msg end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
6 7 8 |
# File 'lib/mitake_api/client.rb', line 6 def response @response end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
6 7 8 |
# File 'lib/mitake_api/client.rb', line 6 def url @url end |
Instance Method Details
#send_message(message) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/mitake_api/client.rb', line 16 def () @mitake_msg = Message.new() mitake_msg.response = connection.post('api/mtk/SmSend') do |req| req.params = { CharsetURL: charset } req.headers = { 'Content-Type' => 'application/x-www-form-urlencoded' } req.body = URI.encode_www_form(credentials.merge(mitake_msg.to_h)) end end |