Skip to content

Commit af0fd52

Browse files
committed
Merge branch 'pg_dev' of github.com:EiffelWebFramework/EGSuite into pg_dev
2 parents 68bb3a9 + 3c14e33 commit af0fd52

Some content is hidden

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

49 files changed

+2573
-60
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ EIFGENs
44

55
system.log
66
token.access
7+
78
sheets/test/eiftmp*
9+
credentials.json
10+

sheets/Readme.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# Eiffel API for Google Sheets API
2-
1+
Eiffel API for Google Sheets API
32
https://developers.google.com/sheets/api/reference/rest
43

54

@@ -11,4 +10,4 @@ To begin, obtain OAuth 2.0 client credentials from the [Browser Quickstart](http
1110
- EG_SHEETS_API -- It's the low level interface that sends and receives HTTP messages..
1211
- EG_SHEETS_JSON -- it's the implementation where we map from the HTTP messages encoded in JSON format to the Eiffel side. (and vice versa).
1312

14-
Then in the object cluster we have the Eiffel objects representing the API domain.
13+
Then in the object cluster we have the Eiffel objects representing the API domain.

sheets/src/eg_sheets_api.e

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ note
55

66
class
77
EG_SHEETS_API
8-
98
inherit
109
LOGGABLE
1110

@@ -16,7 +15,6 @@ feature {NONE} -- Initialization
1615

1716
make (a_access_token: READABLE_STRING_32)
1817
do
19-
default_create
2018
-- Using a code verifier
2119
access_token := a_access_token
2220
enable_version_4
@@ -46,6 +44,7 @@ feature -- Access
4644
version: STRING_8
4745
-- Google Sheets version
4846

47+
feature -- Spreedsheets
4948
spreadsheet_id: detachable STRING
5049

5150

@@ -61,7 +60,6 @@ feature -- Spreedsheets Operations
6160
attached last_response as l_response and then
6261
attached l_response.body as l_body
6362
then
64-
parse_last_response
6563
Result := l_body
6664
end
6765
end
@@ -195,7 +193,6 @@ feature -- Parameters Factory
195193
end
196194
end
197195

198-
199196
feature -- Error Report
200197

201198
parse_last_response

sheets/src/json/eg_sheets_json.e

Lines changed: 211 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,234 @@ feature -- Post
4040
note
4141
EIS:"name=create.spreedsheets", "src=https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/create", "protocol=uri"
4242
do
43-
create Result.make ("", "")
43+
create Result
4444
if attached eg_sheets_api.create_spreedsheet as s then
4545
if attached parsed_json (s) as j then
46+
Result := eg_spreadsheet (Void, j)
4647
else
4748
-- set error
4849
end
4950
end
5051
end
5152

53+
feature -- Error
54+
55+
last_error: detachable STRING
56+
-- Last error message.
57+
-- maybe we can create an specific EG_ERROR.
5258

5359
feature -- Implementation Factory
5460

5561
eg_spreadsheet (a_spreadsheet: detachable like eg_spreadsheet; a_json: JSON_VALUE): EG_SPREEDSHEET
5662
--
5763
do
58-
create Result.make ("", "")
64+
if a_spreadsheet /= Void then
65+
Result := a_spreadsheet
66+
else
67+
create Result
68+
end
69+
if attached string_value_from_json (a_json, "spreadsheetId") as l_id then
70+
Result.set_id (l_id)
71+
end
72+
if attached string_value_from_json (a_json, "spreadsheetUrl") as l_url then
73+
Result.set_url (l_url)
74+
end
75+
Result.set_protperty (eg_spreadsheet_properties (a_json))
76+
if attached {JSON_ARRAY} json_value (a_json, "sheets") as l_sheets then
77+
across l_sheets as ic loop
78+
end
79+
end
80+
if attached {JSON_ARRAY} json_value (a_json, "namedRanges") as l_named_ranges then
81+
end
82+
if attached {JSON_ARRAY} json_value (a_json, "developerMetadata") as l_developer_metadata then
83+
-- TODO
84+
end
85+
86+
87+
end
88+
89+
feature {NONE} -- JSON To Eiffel
90+
91+
eg_spreadsheet_properties (a_json: JSON_VALUE): EG_SPREADSHEET_PROPERTIES
92+
--
93+
local
94+
l_cell_format: EG_CELL_FORMAT
95+
do
96+
create Result
97+
if attached {JSON_OBJECT} json_value (a_json, "properties") as l_properties then
98+
if attached string_value_from_json (l_properties, "title") as l_title then
99+
Result.set_title (l_title)
100+
end
101+
if attached string_value_from_json (l_properties, "locale") as l_locale then
102+
Result.set_locale (l_locale)
103+
end
104+
if attached string_value_from_json (l_properties, "autoRecalc") as l_auto_recalc then
105+
if l_auto_recalc.is_case_insensitive_equal ("ON_CHANGE") then
106+
Result.auto_recalc.set_on_change
107+
elseif l_auto_recalc.is_case_insensitive_equal ("MINUTE") then
108+
Result.auto_recalc.set_minute
109+
elseif l_auto_recalc.is_case_insensitive_equal ("HOUR") then
110+
Result.auto_recalc.set_hour
111+
end
112+
end
113+
if attached string_value_from_json (l_properties, "timeZone") as l_time_zone then
114+
Result.set_time_zone (l_time_zone)
115+
end
116+
if attached {JSON_OBJECT} json_value (l_properties, "defaultFormat") as l_default_format then
117+
end
118+
end
59119
end
60120

61121

122+
default_format (a_json: JSON_OBJECT): EG_CELL_FORMAT
123+
do
124+
create Result
125+
126+
if attached {JSON_OBJECT} json_value (a_json, "backgroundColor") as l_background_color then
127+
Result.set_background_color (eg_color (l_background_color))
128+
end
129+
if attached {JSON_OBJECT} json_value (a_json, "padding") as l_padding then
130+
Result.set_padding (padding (l_padding))
131+
end
132+
if attached string_value_from_json (a_json, "verticalAlignment") as l_alignment then
133+
if l_alignment.is_case_insensitive_equal ("BOTTOM") then
134+
Result.vertical_alignment.set_bottom
135+
elseif l_alignment.is_case_insensitive_equal ("MIDDLE") then
136+
Result.vertical_alignment.set_middle
137+
elseif l_alignment.is_case_insensitive_equal ("TOP") then
138+
Result.vertical_alignment.set_top
139+
end
140+
end
141+
if attached string_value_from_json (a_json, "wrapStrategy") as l_wrap_strategy then
142+
if l_wrap_strategy.is_case_insensitive_equal ("OVERFLOW_CELL") then
143+
Result.wrap_strategy.set_overflow_cell
144+
end
145+
if l_wrap_strategy.is_case_insensitive_equal ("LEGACY_WRAP") then
146+
Result.wrap_strategy.set_legacy_wrap
147+
elseif l_wrap_strategy.is_case_insensitive_equal ("CLIP") then
148+
Result.wrap_strategy.set_clip
149+
elseif l_wrap_strategy.is_case_insensitive_equal ("WRAP") then
150+
Result.wrap_strategy.set_wrap
151+
end
152+
end
153+
if attached {JSON_OBJECT} json_value (a_json, "textFormat") as l_text_format then
154+
Result.set_text_format (text_format (l_text_format))
155+
end
156+
if attached {JSON_OBJECT} json_value (a_json, "backgroundColorStyle") as l_background_color_style then
157+
Result.set_background_color_style (eg_color_style (l_background_color_style))
158+
end
159+
end
160+
161+
eg_color (a_json: JSON_OBJECT): EG_COLOR
162+
do
163+
create Result
164+
if attached integer_value_from_json (a_json, "red") as l_val then
165+
Result.set_red (l_val)
166+
elseif attached real_value_from_json (a_json, "red") as l_val then
167+
Result.set_red (l_val)
168+
end
169+
if attached integer_value_from_json (a_json, "green") as l_val then
170+
Result.set_green (l_val)
171+
elseif attached real_value_from_json (a_json, "green") as l_val then
172+
Result.set_green (l_val)
173+
end
174+
if attached integer_value_from_json (a_json, "blue") as l_val then
175+
Result.set_blue (l_val)
176+
elseif attached real_value_from_json (a_json, "blue") as l_val then
177+
Result.set_blue (l_val)
178+
end
179+
if attached integer_value_from_json (a_json, "alpha") as l_val then
180+
Result.set_alpha (l_val)
181+
elseif attached real_value_from_json (a_json, "alpha") as l_val then
182+
Result.set_alpha (l_val)
183+
end
184+
end
185+
186+
padding (a_json: JSON_OBJECT): EG_PADDING
187+
do
188+
create Result
189+
if attached integer_value_from_json (a_json, "top") as l_val then
190+
Result.set_top (l_val)
191+
end
192+
if attached integer_value_from_json (a_json, "right") as l_val then
193+
Result.set_right (l_val)
194+
end
195+
if attached integer_value_from_json (a_json, "bottom") as l_val then
196+
Result.set_bottom (l_val)
197+
end
198+
if attached integer_value_from_json (a_json, "left") as l_val then
199+
Result.set_left (l_val)
200+
end
201+
end
202+
203+
text_format (a_json: JSON_OBJECT): EG_TEXT_FORMAT
204+
do
205+
create Result
206+
if attached {JSON_OBJECT} json_value (a_json, "foregroundColor") as l_foreground_color then
207+
Result.set_foreground_color (eg_color (l_foreground_color))
208+
end
209+
if attached {JSON_OBJECT} json_value (a_json, "foregroundColorStyle") as l_foreground_color_style then
210+
Result.set_foreground_color_style (eg_color_style (l_foreground_color_style))
211+
end
212+
if attached string_value_from_json (a_json, "fontFamily") as l_font_family then
213+
Result.set_font_family (l_font_family)
214+
end
215+
if attached integer_value_from_json (a_json, "fontSize") as l_font_size then
216+
Result.set_font_size (l_font_size)
217+
end
218+
if attached boolean_value_from_json (a_json, "bold") as l_bold then
219+
Result.set_bold (l_bold)
220+
end
221+
if attached boolean_value_from_json (a_json, "italic") as l_italic then
222+
Result.set_italic (l_italic)
223+
end
224+
if attached boolean_value_from_json (a_json, "strikethrough") as l_strikethrough then
225+
Result.set_strikethrough (l_strikethrough)
226+
end
227+
if attached boolean_value_from_json (a_json, "underline") as l_underline then
228+
Result.set_strikethrough (l_underline)
229+
end
230+
end
231+
232+
eg_color_style (a_json: JSON_OBJECT): EG_COLOR_STYLE
233+
local
234+
l_tc: EG_THEME_COLOR
235+
do
236+
create Result
237+
if attached {JSON_OBJECT} json_value (a_json, "rgbColor") as l_rgbcolor then
238+
Result.set_rgb (eg_color (l_rgbcolor))
239+
elseif
240+
attached string_value_from_json (a_json, "themeColor") as l_theme_color
241+
then
242+
create l_tc
243+
if l_theme_color.is_case_insensitive_equal ("TEXT") then
244+
l_tc.set_text
245+
elseif l_theme_color.is_case_insensitive_equal ("BACKGROUND") then
246+
l_tc.set_background
247+
elseif l_theme_color.is_case_insensitive_equal ("ACCENT1") then
248+
l_tc.set_accent1
249+
elseif l_theme_color.is_case_insensitive_equal ("ACCENT2") then
250+
l_tc.set_accent2
251+
elseif l_theme_color.is_case_insensitive_equal ("ACCENT3") then
252+
l_tc.set_accent3
253+
elseif l_theme_color.is_case_insensitive_equal ("ACCENT4") then
254+
l_tc.set_accent4
255+
elseif l_theme_color.is_case_insensitive_equal ("ACCENT5") then
256+
l_tc.set_accent5
257+
elseif l_theme_color.is_case_insensitive_equal ("ACCENT6") then
258+
l_tc.set_accent6
259+
elseif l_theme_color.is_case_insensitive_equal ("LINK") then
260+
l_tc.set_link
261+
end
262+
Result.set_theme_color (l_tc)
263+
end
264+
end
265+
266+
eg_sheets (a_json: JSON_VALUE): EG_SHEET
267+
do
268+
create Result
269+
end
270+
62271

63272
feature {NONE} -- Implementation
64273

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
note
2+
description: "A banded (alternating colors) range in a sheet."
3+
date: "$Date$"
4+
revision: "$Revision$"
5+
EIS: "name=Banded Range", "src=https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/sheets#bandedrange", "protocol=uri"
6+
class
7+
EG_BANDED_RANGE
8+
9+
end
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
note
2+
description: "[
3+
The default filter associated with a sheet.
4+
5+
JSON representation
6+
{
7+
"range": {
8+
object (GridRange)
9+
},
10+
"sortSpecs": [
11+
{
12+
object (SortSpec)
13+
}
14+
],
15+
"criteria": {
16+
string: {
17+
object(FilterCriteria)
18+
},
19+
...
20+
}
21+
}
22+
23+
]"
24+
author: ""
25+
date: "$Date$"
26+
revision: "$Revision$"
27+
28+
class
29+
EG_BASIC_FILTER
30+
31+
end

sheets/src/objects/eg_border.e

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
note
2+
description: "Summary description for {EG_BORDER}."
3+
author: ""
4+
date: "$Date$"
5+
revision: "$Revision$"
6+
7+
class
8+
EG_BORDER
9+
10+
end

0 commit comments

Comments
 (0)