Class: Growatt::RequestPagination::DataPager
- Inherits:
-
WrAPI::RequestPagination::DefaultPager
- Object
- WrAPI::RequestPagination::DefaultPager
- Growatt::RequestPagination::DataPager
- Defined in:
- lib/growatt/pagination.rb
Overview
Custom data pager for processing API responses. Inherits from ‘WrAPI::RequestPagination::DefaultPager` and extracts relevant data from responses.
Class Method Summary collapse
-
.data(body) ⇒ Hash
Extracts the relevant data from the API response body.
Class Method Details
.data(body) ⇒ Hash
Extracts the relevant data from the API response body.
21 22 23 24 25 26 27 28 29 |
# File 'lib/growatt/pagination.rb', line 21 def self.data(body) # If the body is a Hash, return the 'back' key if it exists if body.is_a? Hash body['back'] || body else # If the body is a String, parse it as JSON JSON.parse(body) end end |