Class: MitakeApi::Message
- Inherits:
-
Object
- Object
- MitakeApi::Message
- Defined in:
- lib/mitake_api/message.rb
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
-
#initialize(message) ⇒ Message
constructor
A new instance of Message.
- #response ⇒ Object
- #response=(response) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(message) ⇒ Message
Returns a new instance of Message.
5 6 7 |
# File 'lib/mitake_api/message.rb', line 5 def initialize() @message = end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
3 4 5 |
# File 'lib/mitake_api/message.rb', line 3 def @message end |
Instance Method Details
#response ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/mitake_api/message.rb', line 14 def response response_arr = @response.body.split(/[\r\n]+/) hash = {} hash[:uuid] = response_arr.shift.gsub(/\[|\]/, '') response_arr.each do |value| key_value = value.split('=') hash[key_value[0].underscore.to_sym] = key_value[1] if key_value[0] == 'statuscode' hash[:response_message] = I18n.t(key_value[1], scope: %i[mitake_api status_flag]) end end hash end |
#response=(response) ⇒ Object
9 10 11 12 |
# File 'lib/mitake_api/message.rb', line 9 def response=(response) @response = response .response = self.response end |
#to_h ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/mitake_api/message.rb', line 29 def to_h { dstaddr: .to, dlvtime: .deliver_at.try(:strftime, '%Y%m%d%H%M%S') || '', smbody: .content, clientid: .uuid } end |