|
1 | 1 | Rebol [
|
2 | 2 | Title: "Google"
|
3 | 3 | Purpose: "Google Web API access (experimental)"
|
4 |
| - Date: 14-Jul-2023 |
| 4 | + Date: 13-May-2024 |
5 | 5 | Author: @Oldes
|
6 | 6 | File: %google.reb
|
7 | 7 | Name: 'google
|
8 | 8 | Type: 'module
|
9 |
| - Version: 0.0.5 |
| 9 | + Version: 0.0.6 |
10 | 10 | Require: 'httpd
|
11 | 11 | Note: {
|
12 | 12 | Useful info:
|
@@ -39,7 +39,7 @@ config: function[
|
39 | 39 | ctx/client-secret: ask/hide "Client Secret: "
|
40 | 40 | ][ ;; when user hits ESC...
|
41 | 41 | sys/log/error 'GOOGLE "Missing credentials!"
|
42 |
| - return #() |
| 42 | + return make map! [] |
43 | 43 | ]
|
44 | 44 | ;; All scopes?
|
45 | 45 | ctx/scopes: [
|
@@ -239,14 +239,12 @@ refresh: function[
|
239 | 239 | store-config ctx
|
240 | 240 | ]
|
241 | 241 |
|
242 |
| -request: func [ |
| 242 | +request: function/with [ |
243 | 243 | method [word!]
|
244 | 244 | what [any-string!]
|
245 | 245 | data [any-type!]
|
246 |
| - /local ctx header result |
247 | 246 | ][
|
248 |
| - header: clear #() |
249 |
| - |
| 247 | + clear header |
250 | 248 | try/with [
|
251 | 249 | ctx: config
|
252 | 250 | unless ctx/token [ctx: authorize ctx] ;; resolve the token
|
@@ -276,6 +274,8 @@ request: func [
|
276 | 274 | sys/log/error 'GOOGLE system/state/last-error
|
277 | 275 | none
|
278 | 276 | ]
|
| 277 | +][ |
| 278 | + header: make map! 6 |
279 | 279 | ]
|
280 | 280 |
|
281 | 281 | api-get: func [what [any-string!] ][request 'GET what none]
|
@@ -406,26 +406,26 @@ gmail: function [request [ref! block!]][
|
406 | 406 | ;; https://www.googleapis.com/auth/gmail.metadata
|
407 | 407 |
|
408 | 408 | ;; Returns something like:
|
409 |
| - ;; #( |
| 409 | + ;; #[ |
410 | 410 | ;; emailAddress: "some@email"
|
411 | 411 | ;; messagesTotal: 1234
|
412 | 412 | ;; threadsTotal: 23
|
413 | 413 | ;; historyId: "16337600"
|
414 |
| - ;; ) |
| 414 | + ;; ] |
415 | 415 | )
|
416 | 416 | |
|
417 | 417 | 'messages (
|
418 | 418 | keep api-get https://gmail.googleapis.com/gmail/v1/users/me/messages
|
419 | 419 |
|
420 | 420 | ;; Returns something like:
|
421 |
| - ;; #( |
422 |
| - ;; messages: [#( |
| 421 | + ;; #[ |
| 422 | + ;; messages: [#[ |
423 | 423 | ;; id: "18949a4bbc4cce97"
|
424 | 424 | ;; threadId: "189446292fce7946"
|
425 | 425 | ;; )]
|
426 | 426 | ;; nextPageToken: "05405932033369967487"
|
427 | 427 | ;; resultSizeEstimate: 201
|
428 |
| - ;; ) |
| 428 | + ;; ] |
429 | 429 | )
|
430 | 430 | | 'message set id: string! (
|
431 | 431 | keep api-get join https://gmail.googleapis.com/gmail/v1/users/me/messages/ id
|
@@ -469,7 +469,7 @@ photos: context [
|
469 | 469 | length [integer!]
|
470 | 470 | ][
|
471 | 471 | url: https://photoslibrary.googleapis.com/v1/mediaItems:search
|
472 |
| - req: #() ;; no copy, because it is reused for all requests |
| 472 | + req: make map! 4 ;; no copy, because it is reused for all requests |
473 | 473 | req/albumId: album
|
474 | 474 | req/pageSize: either part [min 100 length][100]
|
475 | 475 | nextPageToken: none
|
|
0 commit comments