Class: IletimerkeziSdk::Responses::BaseResponse
- Inherits:
-
Object
- Object
- IletimerkeziSdk::Responses::BaseResponse
- Defined in:
- lib/iletimerkezi_sdk/responses/base_response.rb
Direct Known Subclasses
AccountResponse, BlacklistResponse, ReportResponse, SenderResponse, SmsResponse, SummaryResponse
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
Instance Method Summary collapse
- #get_data ⇒ Object
- #get_message ⇒ Object
- #get_status_code ⇒ Object
-
#initialize(response_body, http_status_code) ⇒ BaseResponse
constructor
A new instance of BaseResponse.
- #ok? ⇒ Boolean
Constructor Details
#initialize(response_body, http_status_code) ⇒ BaseResponse
Returns a new instance of BaseResponse.
6 7 8 9 10 11 12 13 |
# File 'lib/iletimerkezi_sdk/responses/base_response.rb', line 6 def initialize(response_body, http_status_code) @status_code = http_status_code @message = response_body.dig('response', 'status', 'message') || 'Unknown error' @data = response_body['response'] || {} @successful = http_status_code == 200 customize_data end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object (private)
39 40 41 42 43 |
# File 'lib/iletimerkezi_sdk/responses/base_response.rb', line 39 def method_missing(method_name, *args) key = method_name.to_s return @data[key] if @data.key?(key) super end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
4 5 6 |
# File 'lib/iletimerkezi_sdk/responses/base_response.rb', line 4 def data @data end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
4 5 6 |
# File 'lib/iletimerkezi_sdk/responses/base_response.rb', line 4 def @message end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
4 5 6 |
# File 'lib/iletimerkezi_sdk/responses/base_response.rb', line 4 def status_code @status_code end |
Instance Method Details
#get_data ⇒ Object
27 28 29 |
# File 'lib/iletimerkezi_sdk/responses/base_response.rb', line 27 def get_data @data end |
#get_message ⇒ Object
23 24 25 |
# File 'lib/iletimerkezi_sdk/responses/base_response.rb', line 23 def @message end |
#get_status_code ⇒ Object
19 20 21 |
# File 'lib/iletimerkezi_sdk/responses/base_response.rb', line 19 def get_status_code @status_code end |
#ok? ⇒ Boolean
15 16 17 |
# File 'lib/iletimerkezi_sdk/responses/base_response.rb', line 15 def ok? @successful end |