Skip to content

Add documentMeta parameter in RoutingClient createNew method Β #118

@dan12411

Description

@dan12411

As previous issue, could I add documentMeta in createNew method ? πŸ™‹πŸΌβ€β™‚οΈ

For example:

  /// Creates a new resource in the collection of type [type].
  /// The server is responsible for assigning the resource id.
  ///
  /// Optional arguments:
  /// - [attributes] - resource attributes
  /// - [one] - resource to-one relationships
  /// - [many] - resource to-many relationships
  /// - [meta] - resource meta data
  /// - [documentMeta] - document meta
  /// - [headers] - any extra HTTP headers
  Future<ResourceCreated> createNew(
    String type, {
    Map<String, Object?> attributes = const {},
    Map<String, Identifier> one = const {},
    Map<String, Iterable<Identifier>> many = const {},
    Map<String, Object?> meta = const {},
    Map<String, Object?> documentMeta = const {},
    Map<String, String> headers = const {},
  }) async {
    final response = await send(
        baseUri.collection(type),
        Request.post(OutboundDataDocument.newResource(NewResource(type)
          ..attributes.addAll(attributes)
          ..relationships.addAll({
            ...one.map((key, value) => MapEntry(key, ToOne(value))),
            ...many.map((key, value) => MapEntry(key, ToMany(value))),
          })
          ..meta.addAll(meta))
          ..meta.addAll(documentMeta))
          ..headers.addAll(headers));

body json example:

{
  "meta": {
    "password": "12345678"
  },
  "data": {
    "type": "users",
    "attributes": {
      "email": "example@mail.com"
    },
    "relationships": {
      "agreement": {
        "data": {
          "type": "agreements",
          "id": "2002"
        }
      },
      "devices": {
        "data": [
          {
            "type": "devices",
            "id": "xxxx-xxx-xx-x-1xxxxx"
          }
        ]
      }
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions