Skip to content

Commit 9f806dc

Browse files
authored
Merge pull request #18 from CodeBeamOrg/dev
Update README.md
2 parents a19db1f + a667af0 commit 9f806dc

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

README.md

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,22 @@ Welcome to all contributors!
1919

2020
## Usage
2121
### Preliminary: Set your google account and your project credentials
22-
Nothing special with this package.
23-
### Step 1: Inject HttpClientFactory
22+
Set your google client. This process has no special thing with this library. [Read the details.](https://developers.google.com/identity/gsi/web/guides/get-google-api-clientid)
23+
<br /> Add the credential into appsettings.json file like the below example. (Not obligatory, but ClientId, ClientSecret and RedirectUrl is required for some features to use this library simpler.)
24+
```json
25+
{
26+
"GoogleClient": {
27+
"client_id": "[CLIENT_ID]",
28+
"project_id": "",
29+
"auth_uri": "",
30+
"token_uri": "",
31+
"auth_provider_x509_cert_url": "",
32+
"client_secret": "[CLIENT_SECRET]",
33+
"redirect_url": "[REDIRECT_URL]"
34+
}
35+
}
36+
```
37+
### Step 1: Inject Services
2438

2539
Add Services into program.cs
2640
```cs
@@ -29,10 +43,12 @@ builder.Services.AddCodeBeamGoogleApiServices();
2943

3044
For blazor component files
3145
```razor
46+
@inject AuthService AuthService
3247
@inject CalendarService CalendarService
3348
```
34-
For cs files
49+
OR - For cs files
3550
```cs
51+
[Inject] AuthService AuthService { get; set; }
3652
[Inject] CalendarService CalendarService { get; set; }
3753
```
3854

@@ -66,7 +82,7 @@ private async Task RequestCode()
6682
```
6783
#### Step 2. Get Access Token With Obtained Authorization Code in Step 1
6884
These codes should be in the callback page.
69-
Blazor Component
85+
<br /> Blazor Component
7086
```razor
7187
@page "/v1/browser-callback"
7288
```
@@ -108,3 +124,19 @@ private void AddEvent()
108124
string result = CalendarService.AddEvent(googleCalendarEvent, CalendarService.FindCalendarId(CalendarValueType.Summary, "Test Calendar"));
109125
}
110126
```
127+
128+
## How To Get and Process Lists (Like Calendar and Event)
129+
When you call the api to return a list of items (like calendars or events) it returns a root class. These classes can be find in the library. You can use the "items" property to reach list of items.
130+
<br />
131+
<br />
132+
#### The Models
133+
- GoogleCalendarListRoot -> The root calendar model which is a proper for `GetCalendars()` method result
134+
- GoogleCalendarListModel -> The calendar model. GoogleCalendarListRoot.items has a `List<GoogleCalendarListModel>`
135+
- GoogleCalendarEventRoot -> The root event model which is a proper for `GetEvents()` method result
136+
- GoogleCalendarEventModel -> The event model. GoogleCalendarEventRoot.items has a `List<GoogleCalendarEventModel>`
137+
138+
#### Usage
139+
```cs
140+
var result = CalendarService.GetCalendars();
141+
GoogleCalendarListRoot _calendars = JsonSerializer.Deserialize<GoogleCalendarListRoot>(result); // _calendars.items has the list of calendars.
142+
```

0 commit comments

Comments
 (0)