Class: SyoboiCalendar::Responses::BaseResponse
- Inherits:
-
Object
- Object
- SyoboiCalendar::Responses::BaseResponse
show all
- Includes:
- Enumerable
- Defined in:
- lib/syoboi_calendar/responses/base_response.rb
Instance Method Summary
collapse
Constructor Details
#initialize(faraday_response) ⇒ BaseResponse
Returns a new instance of BaseResponse.
7
8
9
|
# File 'lib/syoboi_calendar/responses/base_response.rb', line 7
def initialize(faraday_response)
@faraday_response = faraday_response
end
|
Instance Method Details
#body ⇒ String
12
13
14
|
# File 'lib/syoboi_calendar/responses/base_response.rb', line 12
def body
faraday_response.body
end
|
#code ⇒ Integer
17
18
19
|
# File 'lib/syoboi_calendar/responses/base_response.rb', line 17
def code
body[response_key]["Result"]["Code"].to_i
end
|
#each(&block) ⇒ Object
Note:
Implementation for Enumerable
22
23
24
|
# File 'lib/syoboi_calendar/responses/base_response.rb', line 22
def each(&block)
resources.each(&block)
end
|
#has_error? ⇒ Boolean
27
28
29
|
# File 'lib/syoboi_calendar/responses/base_response.rb', line 27
def has_error?
code != 200
end
|
32
33
34
|
# File 'lib/syoboi_calendar/responses/base_response.rb', line 32
def
faraday_response.
end
|
#message ⇒ String?
37
38
39
|
# File 'lib/syoboi_calendar/responses/base_response.rb', line 37
def message
body[response_key]["Result"]["Message"]
end
|
42
43
44
45
46
|
# File 'lib/syoboi_calendar/responses/base_response.rb', line 42
def resources
sources.map do |source|
resource_class.new(source)
end
end
|
#status ⇒ Integer
49
50
51
|
# File 'lib/syoboi_calendar/responses/base_response.rb', line 49
def status
faraday_response.status
end
|