private function paginate ($type, $offset, $limit)
    {
        // Ensure the limit is within range.
        if ($limit < 1) {
            $limit = 1;
        } elseif ($limit > 20) {
            $limit = 20;
        }

        // Send query.
        $json = json_decode(
            $this->client->send(
                new Request(
                    'POST',
                    'https://api.weixin.qq.com/cgi-bin/material/batchget_material',
                    [],
                    json_encode([
                        'type'   => $type,
                        'offset' => $offset,
                        'count'  => $limit,
                    ])
                )
            )->getBody()
        );

        // Ensure response formatting.
        if (! isset($json->total_count, $json->item)) {
            throw new Exception("bad response: expecting properties `total_count`, `item_count`, `item`");
        }
        
        return $json;
    }