Skip to content

Commit 5b93b54

Browse files
Merge pull request #10 from contentstack/development
Development
2 parents 5cb289f + ee2ae57 commit 5b93b54

File tree

10 files changed

+228
-147
lines changed

10 files changed

+228
-147
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ test/.test_coverage.dart/
3333
.pub-cache/
3434
.pub/
3535
build/
36+
coverage/
3637

3738
# Android related
3839
**/android/**/gradle-wrapper.jar

.vscode/launch.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

AUTHERS.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1+
## Below is a list of people and organizations that have contributed to the
12

2-
# Below is a list of people and organizations that have contributed to the
3+
[Contentstack LLC](http://contentstack.com/).
34

4-
# Contentstack-Dart project. Names should be added to the list like so
5-
6-
Contentstack LLC.
7-
Shailesh Mishra <[email protected]>
5+
Contentstack <[email protected]>
6+
Shailesh Mishra <[email protected]>

CHANGELOG.md

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,45 @@
11
# CHANGELOG
22

3-
## [0.1.1] - Publish content fallback
4-
##### Dec-08-2020
5-
#### New Features:
6-
[Entry] - Publish fallback method added
7-
[Query] - Publish fallback method added
8-
[Asset] - Publish fallback method added
9-
[Assets] - Publish fallback method added
10-
11-
-----------------------------
12-
13-
## [0.1.0] - Initial release
14-
##### __May-11-2020 -initial release__
3+
## `v0.2.0 - Support of IncludeEmbeddedItems()`
4+
5+
### __APR-05-2021__
6+
7+
#### v0.2.0 New Features
8+
9+
`Entry` - IncludeEmbeddedItems method added
10+
11+
`Query` - IncludeEmbeddedItems method added
12+
13+
_______________________
14+
15+
## `v0.1.1 - Publish content fallback`
16+
17+
### __Dec-08-2020__
18+
19+
#### v0.1.1 New Features
20+
21+
`Entry` - Publish fallback method added
22+
23+
`Query` - Publish fallback method added
24+
25+
`Asset` - Publish fallback method added
26+
27+
`Assets` - Publish fallback method added
28+
29+
_______________________
30+
31+
## `v0.1.0 - Initial release`
32+
33+
### __May-11-2020__
34+
1535
#### Initial release for the contentstack-dart-sdk for Content Delivery API
1636

17-
-----------------------------
37+
_______________________
38+
39+
## `v0.0.1 - Beta release`
40+
41+
### __May-08-2020__
1842

19-
## [0.0.1] - Beta release
20-
##### **May-08-2020 -beta release**
2143
#### Beta release for the contentstack-dart-sdk for Content Delivery API
22-
-----------------------------
44+
45+
_______________________

example/example.md

Lines changed: 83 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,17 @@ To integrate your Flutter project with Contentstack, install the pub dependency
3434

3535
Add this to your package's pubspec.yaml file:
3636

37-
dependencies:
38-
contentstack: any
37+
```dart
38+
dependencies:
39+
contentstack: any
40+
```
3941

4042
You can install packages from the command line:
4143
with Flutter:
4244

43-
$ flutter pub get
45+
```dart
46+
$ flutter pub get
47+
```
4448

4549
### Import package
4650

@@ -52,92 +56,108 @@ Now in your dart or flutter code, you can use
5256

5357
To initialize the SDK, specify application context, stack’s API Key, delivery token, and name of the environment where will publish your content, as shown in the snippet below:
5458

55-
import 'package:contentstack/contentstack.dart' as contentstack;
56-
57-
final stack = contentstack.Stack("apiKey", "deliveryToken", "environment");
58-
59+
```dart
60+
import 'package:contentstack/contentstack.dart' as contentstack;
61+
final stack = contentstack.Stack("apiKey", "deliveryToken", "environment");
62+
```
5963
## Basic Queries
6064

6165
To retrieve a single entry from a content type use the code snippet given below:
6266

6367
### Make call to get single entry by entry uid
6468

65-
final stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment');
66-
final entry = stack.contentType('content_type_uid').entry(entryUid: 'entry_uid');
67-
await entry.fetch().then((response) {
68-
print(response.toString());
69-
}).catchError((error) {
70-
print(error.message.toString());
71-
});
69+
```dart
70+
final stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment');
71+
final entry = stack.contentType('content_type_uid').entry(entryUid: 'entry_uid');
72+
await entry.fetch().then((response) {
73+
print(response.toString());
74+
}).catchError((error) {
75+
print(error.message.toString());
76+
});
77+
```
7278

7379
Or, You can get generic objects as well
7480

75-
final stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment');
76-
final entry = stack.contentType('content_type_uid').entry(entryUid: 'entry_uid');
77-
await entry.fetch<EntryModel, Null>().then((response) {
78-
print(response.title);
79-
}).catchError((error) {
80-
print(error.message.toString());
81-
});
81+
```dart
82+
final stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment');
83+
final entry = stack.contentType('content_type_uid').entry(entryUid: 'entry_uid');
84+
await entry.fetch<EntryModel, Null>().then((response) {
85+
print(response.title);
86+
}).catchError((error) {
87+
print(error.message.toString());
88+
});
89+
90+
```
8291

8392
### Get Multiple Entries
8493

8594
To retrieve multiple entries of a particular content type, use the code snippet given below:
8695

87-
final stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment');
88-
final query = stack.contentType('content_type_uid').entry().query();
89-
await query.find().then((response) {
90-
print(response.toString());
91-
}).catchError((error) {
92-
print(error.message.toString());
93-
});
96+
```dart
97+
final stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment');
98+
final query = stack.contentType('content_type_uid').entry().query();
99+
await query.find().then((response) {
100+
print(response.toString());
101+
}).catchError((error) {
102+
print(error.message.toString());
103+
});
104+
```
94105

95106
Or, You can get List of generic objects
96107

97-
final stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment');
98-
final query = stack.contentType('content_type_uid').entry().query();
99-
await query.find<List<EntryModel>, EntryModel>().then((response) {
100-
print(response.toString());
101-
}).catchError((error) {
102-
print(error.message.toString());
103-
});
108+
```dart
109+
final stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment');
110+
final query = stack.contentType('content_type_uid').entry().query();
111+
await query.find<List<EntryModel>, EntryModel>().then((response) {
112+
print(response.toString());
113+
}).catchError((error) {
114+
print(error.message.toString());
115+
});
116+
```
104117

105118
### Make call to get single asset by asset uid
106119

107-
final stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment');
108-
await stack.asset('asset_uid').fetch().then((response) {
109-
print(response.toString());
110-
}).catchError((error) {
111-
print(error.message.toString());
112-
});
120+
```dart
121+
final stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment');
122+
await stack.asset('asset_uid').fetch().then((response) {
123+
print(response.toString());
124+
}).catchError((error) {
125+
print(error.message.toString());
126+
});
127+
```
113128

114129
Or, You can get generic objects as well
115130

116-
final stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment');
117-
await stack.asset('asset_uid').fetch<AssetModel, Null>().then((response) {
118-
print(response.toString());
119-
}).catchError((error) {
120-
print(error.message.toString());
121-
});
131+
```dart
132+
final stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment');
133+
await stack.asset('asset_uid').fetch<AssetModel, Null>().then((response) {
134+
print(response.toString());
135+
}).catchError((error) {
136+
print(error.message.toString());
137+
});
138+
```
122139

123140
### Make call to apply query on asset
124141

125-
final stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment');
126-
final assetQuery = stack.assetQuery();
127-
assetQuery..includeDimension()..relativeUrls();
128-
await assetQuery.find().then((response) {
129-
print(response.toString());
130-
}).catchError((error) {
131-
print(error.message.toString());
132-
});
142+
```dart
143+
final stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment');
144+
final assetQuery = stack.assetQuery();
145+
assetQuery..includeDimension()..relativeUrls();
146+
await assetQuery.find().then((response) {
147+
print(response.toString());
148+
}).catchError((error) {
149+
print(error.message.toString());
150+
});
151+
```
133152

134153
Or, You can get List of generic objects
135154

136-
final stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment');
137-
final assetQuery = stack.assetQuery();
138-
assetQuery..includeDimension()..relativeUrls();
139-
await assetQuery.find<List<AssetModel>, Null>().then((response) {
140-
print(response.toString());
141-
}).catchError((error) {
142-
print(error.message.toString());
143-
});
155+
```dart
156+
final stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment');
157+
final assetQuery = stack.assetQuery();
158+
assetQuery..includeDimension()..relativeUrls();
159+
await assetQuery.find<List<AssetModel>, Null>().then((response) {
160+
print(response.toString());
161+
}).catchError((error) {
162+
print(error.message.toString());
163+
});

lib/client.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ class HttpClient extends http.BaseClient {
99
final http.Client _client;
1010
final Stack stack;
1111
final Map<String, String> stackHeaders;
12+
// Request timout period 30 Seconds
13+
static const timeout = 30;
1214

1315
factory HttpClient(Map<String, String> headers,
1416
{http.Client client, Stack stack}) {
@@ -29,7 +31,9 @@ class HttpClient extends http.BaseClient {
2931
Future<T> sendRequest<T, K>(Uri uri) async {
3032
stackHeaders['Content-Type'] = 'application/json';
3133
stackHeaders['X-User-Agent'] = 'contentstack-dart/0.1.1';
32-
final response = await http.get(uri, headers: stackHeaders);
34+
final response = await http
35+
.get(uri, headers: stackHeaders)
36+
.timeout(const Duration(seconds: timeout));
3337
Object bodyJson;
3438
try {
3539
bodyJson = jsonDecode(response.body);

lib/src/entry_queryable.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,21 @@ class EntryQueryable {
7676
parameter['include_fallback'] = 'true';
7777
}
7878

79+
///
80+
/// includeEmbeddedItems instance of Entry
81+
/// Include Embedded Objects (Entries and Assets) along with entry/entries details
82+
///
83+
/// [Example for Entry class]
84+
/// ```
85+
/// final stack = contentstack.Stack('apiKey','deliveryToken','environment');
86+
/// final entry = stack.contentType("contentTypeUid").entry("entryUid");
87+
/// entry = entry.includeEmbeddedItems()
88+
/// ```
89+
///
90+
void includeEmbeddedItems() {
91+
parameter['include_embedded_items[]'] = 'BASE';
92+
}
93+
7994
///
8095
/// Include Reference:
8196
/// When you fetch an entry of a content type that has a reference field,

lib/src/query.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,21 @@ class Query extends BaseQuery {
114114
queryParameter['include_fallback'] = true.toString();
115115
}
116116

117+
///
118+
/// includeEmbeddedItems instance of Query
119+
/// Include Embedded Objects (Entries and Assets) along with entry/entries details
120+
///
121+
/// [Example for Entry class]
122+
/// ```
123+
/// final stack = contentstack.Stack('apiKey, 'deliveryKey, 'environment);
124+
/// final query = stack.contentType('contentTypeUid').entry().query();
125+
/// query = query.includeEmbeddedItems()
126+
/// ```
127+
///
128+
void includeEmbeddedItems() {
129+
queryParameter['include_embedded_items[]'] = 'BASE';
130+
}
131+
117132
//
118133
// Entry Queryable functions:
119134
///

0 commit comments

Comments
 (0)