Skip to content

Commit 1119e1a

Browse files
authored
Merge branch 'master' into pg_dev
2 parents 6353a06 + 3ee7fed commit 1119e1a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2646
-427
lines changed

sheets/Readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
Eiffel API for Google Sheets API
22
https://developers.google.com/sheets/api/reference/rest
3+
https://help.form.io/integrations/googledrive/
4+
35

46

57
OAuth2.0 Client credentials

sheets/src/eg_sheets_api.e

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,48 @@ feature -- Spreedsheets Operations
6464
end
6565
end
6666

67-
get_from_id (a_spreadsheet_id: attached like spreadsheet_id): detachable like last_response.body
67+
get_from_id (a_spreadsheet_id: attached like spreadsheet_id; a_params: detachable EG_SPREADSHEET_PARAMETERS): detachable like last_response.body
68+
-- POST /spreadsheets/`a_spreadsheet_id'
69+
note
70+
EIS:"name=get.spreedsheets", "src=https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/get", "protocol=uri"
71+
require
72+
not a_spreadsheet_id.is_empty
73+
local
74+
l_file: PLAIN_TEXT_FILE
75+
l_qry_params: STRING_TABLE [STRING]
76+
do
77+
78+
logger.write_information ("get_from_id-> Now getting sheet from id:" + a_spreadsheet_id)
79+
80+
api_get_call (sheets_url ("spreadsheets/" + a_spreadsheet_id, Void), a_params)
81+
check
82+
attached last_response as l_response and then
83+
attached l_response.body as l_body
84+
then
85+
parse_last_response
86+
if l_response.status = {HTTP_STATUS_CODE}.ok then
87+
Result := l_body
88+
89+
debug
90+
create l_file.make_create_read_write ("/tmp/hitme_sheet_json-get_from_id.json")
91+
logger.write_information ("get_from_id->Writing body into " + l_file.path.utf_8_name)
92+
l_file.close
93+
l_file.wipe_out
94+
l_file.open_append
95+
96+
l_file.put_string (l_body)
97+
l_file.close
98+
end
99+
elseif l_response.status = {HTTP_STATUS_CODE}.not_found then
100+
logger.write_error ("get_from_id-> Not found:" + l_response.status.out + " %NBody: " + l_body)
101+
else
102+
logger.write_error ("get_from_id-> Status code invalid:" + l_response.status.out + " %NBody: " + l_body)
103+
end
104+
end
105+
end
106+
107+
108+
get_from_id2 (a_spreadsheet_id: attached like spreadsheet_id): detachable like last_response.body
68109
-- POST /spreadsheets/`a_spreadsheet_id'
69110
note
70111
EIS:"name=get.spreedsheets", "src=https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/get", "protocol=uri"
@@ -305,6 +346,7 @@ feature {NONE} -- Implementation
305346
logger.write_debug ("internal_api_call-> a_api_url:" + a_api_url + " method:" + a_method)
306347
-- TODO improve this, so we can check the required scopes before we
307348
-- do an api call.
349+
-- TODO add a class with the valid scopes.
308350
create config.make_default ("", "")
309351
config.set_scope ("https://www.googleapis.com/auth/spreadsheets")
310352

@@ -313,8 +355,8 @@ feature {NONE} -- Implementation
313355
create api_service.make (create {OAUTH_20_GOOGLE_API}, config)
314356
--| TODO improve cypress service creation procedure to make configuration optional.
315357

316-
print ("%N===Google OAuth Workflow using OAuth access token for the owner of the application ===%N")
317358
--| TODO rewrite prints as logs
359+
logger.write_debug ("%N===Google OAuth Workflow using OAuth access token for the owner of the application ===%N")
318360

319361
-- Create the access token that will identifies the user making the request.
320362
create l_access_token.make_token_secret (access_token, "NOT_NEEDED")
@@ -337,14 +379,14 @@ feature {NONE} -- Implementation
337379
request.add_header ("Content-Type", "application/json; charset=UTF-8")
338380
request.add_payload (a_payload)
339381
else
340-
request.add_header ("Content-length", "")
382+
request.add_header ("Content-length", "0")
341383
end
342384

343385
api_service.sign_request (ll_access_token, request)
344386

345387
logger.write_debug ("internal_api_call->uri:'" + request.uri + "'")
346388
if attached request.upload_file as l_s then
347-
logger.write_debug ("internal_api_call->upload file:'" + l_s + "'")
389+
logger.write_debug ("internal_api_call->upload file:'" + l_s.out + "'")
348390
end
349391
if attached {OAUTH_RESPONSE} request.execute as l_response then
350392
last_response := l_response
@@ -454,7 +496,7 @@ feature {NONE} -- Implementation
454496
create l_raw_file.make_open_read (l_upload_data.file_name.absolute_path.name)
455497
if l_raw_file.exists then
456498
logger.write_debug ("upload_data-> Content-type: '" + l_upload_data.content_type + "'")
457-
logger.write_debug ("upload_data-> upload file name: '" + l_upload_data.file_name.absolute_path.name + "'")
499+
logger.write_debug ("upload_data-> upload file name: '" + l_upload_data.file_name.absolute_path.name.out + "'")
458500
request.add_header ("Content-Type", l_upload_data.content_type)
459501
request.set_upload_filename (l_upload_data.file_name.absolute_path.name)
460502
request.add_form_parameter("source", l_upload_data.file_name.name.as_string_32)

sheets/src/eg_sheets_i.e

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,22 @@ feature -- Status Report
2323

2424
feature -- Post
2525

26-
create_spreedsheet: EG_SPREEDSHEET
26+
create_spreedsheet: EG_SPREADSHEET
2727
-- Creates a spreadsheet, returning the newly created spreadsheet.
2828
note
2929
EIS:"name=create.spreedsheets", "src=https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/create", "protocol=uri"
3030
deferred
3131
end
3232

33+
feature -- Get
34+
35+
get_from_id (a_spreadsheet_id: STRING_8; a_params: detachable EG_SPREADSHEET_PARAMETERS): detachable EG_SPREADSHEET
36+
note
37+
EIS:"name=get.spreedsheets", "src=https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/get", "protocol=uri"
38+
require
39+
valid_id: not a_spreadsheet_id.is_empty
40+
deferred
41+
end
42+
3343

3444
end

0 commit comments

Comments
 (0)