@@ -41,6 +41,8 @@ feature -- Access
4141 version : STRING_ 8
4242 -- Google Sheets version
4343
44+ spreadsheet_id : detachable STRING
45+
4446
4547feature -- Spreedsheets
4648
@@ -54,6 +56,22 @@ feature -- Spreedsheets
5456 attached last_response as l_response and then
5557 attached l_response .body as l_body
5658 then
59+ parse_last_response
60+ Result := l_body
61+ end
62+ end
63+
64+ get_from_id (a_spreadsheet_id : attached like spreadsheet_id ): detachable like last_response .body
65+ -- https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/get
66+ require
67+ not a_spreadsheet_id .is_empty
68+ do
69+ api_post_call (sheets_url (" spreadsheets/" + a_spreadsheet_id , Void ), Void , Void )
70+ check
71+ attached last_response as l_response and then
72+ attached l_response .body as l_body
73+ then
74+ parse_last_response
5775 Result := l_body
5876 end
5977 end
@@ -83,6 +101,39 @@ feature -- Parameters Factory
83101
84102feature -- Error Report
85103
104+ parse_last_response
105+ require
106+ attached last_response
107+ local
108+ l_json_parser : JSON_PARSER
109+ do
110+ check
111+ attached last_response as l_response
112+ then
113+ if attached l_response .body as l_body then
114+ create l_json_parser .make_with_string (l_body )
115+ l_json_parser .parse_content
116+ if l_json_parser .is_valid then
117+ if attached {JSON_OBJECT } l_json_parser .parsed_json_value as l_main_jso then
118+ if attached {JSON_OBJECT } l_main_jso .item (" error" ) as l_error_jso then
119+ if attached {JSON_NUMBER } l_error_jso .item (" code" ) as l_jso then
120+ print (" parse_last_response-> error code:" + l_jso .representation )
121+ end
122+ if attached {JSON_STRING } l_error_jso .item (" message" ) as l_jso then
123+ print (" parse_last_response-> error message:" + l_jso .unescaped_string_ 8 )
124+ end
125+ if attached {JSON_STRING } l_error_jso .item (" status" ) as l_jso then
126+ print (" parse_last_response-> error status:" + l_jso .unescaped_string_ 8 )
127+ end
128+ end
129+ end
130+ else
131+ print (" parse_last_response-> Error: Invalid json body content:" + l_body + " %N" )
132+ end
133+ end
134+ end
135+ end
136+
86137 has_error : BOOLEAN
87138 -- Last api call raise an error?
88139 do
0 commit comments