# Content resource

Canonical page: https://docs.ovok.com/flutter-sdk/reference/ovok_sdk/content-resource

{/* Generated by scripts/generate_reference.dart; do not edit. */}

## ContentResource [#contentresource]

```dart
class ContentResource
```

Project content items, by type, language and key. Reached through `ovok.content`.

Every request throws an `OvokException` subclass when it fails.

### Constructors [#constructors]

#### ContentResource.new [#contentresourcenew]

```dart
ContentResource(HttpClient _http)
```

Built by `Ovok`; use `ovok.content` instead.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `_http` | `HttpClient` | positional |  |

### Methods [#methods]

#### ContentResource.search [#contentresourcesearch]

```dart
Future<JsonMap> search(
  String type,
  String language, [
  QueryParams params = const {},
])
```

Searches the `type` items in `language`.

Calls `GET cms/{type}/{language}` with `params`.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `type` | `String` | positional |  |
| `language` | `String` | positional |  |
| `params` | `QueryParams` | optional positional | `const {}` |

Returns `Future<Map<String, dynamic>>`.

#### ContentResource.retrieve [#contentresourceretrieve]

```dart
Future<JsonMap> retrieve(
  String type,
  String language,
  String key,
)
```

Retrieves one item. Calls `GET cms/{type}/{language}/{key}`.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `type` | `String` | positional |  |
| `language` | `String` | positional |  |
| `key` | `String` | positional |  |

Returns `Future<Map<String, dynamic>>`.

#### ContentResource.create [#contentresourcecreate]

```dart
Future<JsonMap> create(
  String type,
  String language,
  JsonMap body,
)
```

Creates an item. Calls `POST cms/{type}/{language}`.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `type` | `String` | positional |  |
| `language` | `String` | positional |  |
| `body` | `JsonMap` | positional |  |

Returns `Future<Map<String, dynamic>>`.

#### ContentResource.update [#contentresourceupdate]

```dart
Future<JsonMap> update(
  String type,
  String language,
  String key,
  JsonMap body,
)
```

Replaces one item. Calls `PUT cms/{type}/{language}/{key}`.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `type` | `String` | positional |  |
| `language` | `String` | positional |  |
| `key` | `String` | positional |  |
| `body` | `JsonMap` | positional |  |

Returns `Future<Map<String, dynamic>>`.

#### ContentResource.delete [#contentresourcedelete]

```dart
Future<void> delete(
  String type,
  String language,
  String key,
)
```

Deletes one item. Calls `DELETE cms/{type}/{language}/{key}`.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `type` | `String` | positional |  |
| `language` | `String` | positional |  |
| `key` | `String` | positional |  |

Returns `Future<void>`.

#### ContentResource.map [#contentresourcemap]

```dart
Future<JsonMap> map(
  String type,
  String language, [
  QueryParams params = const {},
])
```

Pairs each default-language item with its `language` translation.

Calls `GET cms/{type}/map/{language}` with `params`.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `type` | `String` | positional |  |
| `language` | `String` | positional |  |
| `params` | `QueryParams` | optional positional | `const {}` |

Returns `Future<Map<String, dynamic>>`.

#### ContentResource.copyFromParent [#contentresourcecopyfromparent]

```dart
Future<JsonMap> copyFromParent(
  String type,
  String language,
  String key,
)
```

Copies one item from the parent project.

Calls `POST cms/{type}/{language}/{key}/copy-from-parent-project`.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `type` | `String` | positional |  |
| `language` | `String` | positional |  |
| `key` | `String` | positional |  |

Returns `Future<Map<String, dynamic>>`.

#### ContentResource.copyAllFromParent [#contentresourcecopyallfromparent]

```dart
Future<JsonMap> copyAllFromParent(String type, String language)
```

Copies every `type` item in `language` from the parent project.

Calls `POST cms/{type}/{language}/copy-from-parent-project`.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `type` | `String` | positional |  |
| `language` | `String` | positional |  |

Returns `Future<Map<String, dynamic>>`.
