Skip to content

Instantly share code, notes, and snippets.

@marcellkiss
Last active February 18, 2016 13:56
Show Gist options
  • Save marcellkiss/1e94c6171c85d0fb87c7 to your computer and use it in GitHub Desktop.
Save marcellkiss/1e94c6171c85d0fb87c7 to your computer and use it in GitHub Desktop.

Frontend - Backend damage report structure differences

  • instructions: just documents
  • participants: insured, witness, witnesses
  • damage_picker: this is new (damage_location array)
  • additionals: we can reduce it

Backend damage report structure

{
    "type": "object",
    "properties": { // damage_picker is needed
        "date": {
            "type": "object",
            "properties": {
                "today": {
                    "type": "string"
                },
                "date": {
                    "type": "string"
                }
            }
        },
        "datacheck": {
            "type": "object",
            "properties": {
                "vehicle": {
                    "type": "object",
                    "properties": {
                        "policy_number": {
                            "type": "string"
                        },
                        "insured_vehicles": {
                            "type": "string"
                        },
                        "insurer": {
                            "type": "string"
                        },
                        "number_plate": {
                            "type": "string"
                        }
                    }
                },
                "person": {
                    "type": "object",
                    "properties": {
                        "tel1": {
                            "type": "string"
                        },
                        "vorname": {
                            "type": "string"
                        },
                        "nachname": {
                            "type": "string"
                        },
                        "email": {
                            "type": "string"
                        },
                        "ort": {
                            "type": "string"
                        },
                        "plz": {
                            "type": "string"
                        },
                        "strasse": {
                            "type": "string"
                        },
                        "tel2": {
                            "type": "string"
                        }
                    }
                }
            }
        },
        "participants": { // Here we have insured, witness, witnesses
            "type": "array",
            "items": { 
                "type": "object",
                "properties": {
                    "tel1": {
                        "type": "string"
                    },
                    "vorname": {
                        "type": "string"
                    },
                    "nachname": {
                        "type": "string"
                    },
                    "email": {
                        "type": "string"
                    },
                    "ort": {
                        "type": "string"
                    },
                    "plz": {
                        "type": "string"
                    },
                    "strasse": {
                        "type": "string"
                    },
                    "tel2": {
                        "type": "string"
                    }
                }
            }
        },
        "location": {
            "type": "object",
            "properties": {
                "address": {
                    "type": "string"
                },
                "use_phone_location": {
                    "type": "boolean"
                },
                "location": {
                    "type": "string"
                },
                "notes": {
                    "type": "string"
                }
            }
        },
        "additionals": {
            "type": "object",
            "properties": {
                "photos": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                },
                "damage_location": { // No need
                    "type": "string"
                },
                "damage_type": { // No need
                    "type": "string"
                },
                "injured": {
                    "type": "boolean"
                },
                "police_called": {
                    "type": "boolean"
                }
            }
        },
        "instructions": { // We need just documents
            "type": "object",
            "properties": {
                "policy_number": {
                    "type": "string"
                },
                "number_plate": {
                    "type": "string"
                },
                "insurer": {
                    "type": "string"
                }
            }
        }
    }
}

Frontend damage report example

{
  "datacheck": {
    "nachname": "Nutzer",
    "vorname": "Nadine",
    "strasse": "Südstr. 25",
    "plz": "50997",
    "ort": "Köln",
    "tel1": "02232/993585",
    "tel2": "0173/5252977",
    "email": "nadine.nutzer@made.de",
    "number_plate": "😍",
    "insurer": "😍",
    "policy_number": "😍"
  },
  "instructions": {
    "documents": []
  },
  "participants": {
    "insured": {
      "nachname": "lastname",
      "vorname": "vorname",
      "strasse": "street",
      "plz": "ZIP",
      "ort": "Place",
      "tel1": "Phone private",
      "tel2": "Phone",
      "email": "mail"
    },
    "witness": {
      "nachname": "lastname",
      "vorname": "vorname",
      "strasse": "street",
      "plz": "ZIP",
      "ort": "Place",
      "tel1": "Phone private",
      "tel2": "Phone",
      "email": "mail"
    },
    "witnesses": [
      {
        "nachname": "lastname",
        "vorname": "vorname",
        "strasse": "street",
        "plz": "ZIP",
        "ort": "Place",
        "tel1": "Phone private",
        "tel2": "Phone",
        "email": "mail"
      }
    ]
  },
  "date": {
    "today": 1455792163454,
    "date": "2009-10-30T23:00:00.000Z"
  },
  "location": {
    "address": "Dreistuecken",
    "location": "Hamburg",
    "use_phone_location": false,
    "notes": "Something happened",
    "area": ""
  },
  "damage_picker": {
    "damage_location": [
      {
        "damaged": false,
        "id": "topLeft",
        "class": "top top--left"
      },
      {
        "damaged": true,
        "id": "topCenter",
        "class": "top top--center"
      },
      {
        "damaged": false,
        "id": "topRight",
        "class": "top top--right"
      },
      {
        "damaged": false,
        "id": "bottomLeft",
        "class": "bottom bottom--left"
      },
      {
        "damaged": false,
        "id": "bottomCenter",
        "class": "bottom bottom--center"
      },
      {
        "damaged": false,
        "id": "bottomRight",
        "class": "bottom bottom--right"
      },
      {
        "damaged": false,
        "id": "leftTop",
        "class": "left left--top"
      },
      {
        "damaged": true,
        "id": "leftTop2",
        "class": "left left--top2"
      },
      {
        "damaged": false,
        "id": "leftMiddle",
        "class": "left left--middle"
      },
      {
        "damaged": false,
        "id": "leftBottom2",
        "class": "left left--bottom2"
      },
      {
        "damaged": false,
        "id": "leftBottom",
        "class": "left left--bottom"
      },
      {
        "damaged": false,
        "id": "rightTop",
        "class": "right right--top"
      },
      {
        "damaged": true,
        "id": "rightTop2",
        "class": "right right--top2"
      },
      {
        "damaged": false,
        "id": "rightMiddle",
        "class": "right right--middle"
      },
      {
        "damaged": false,
        "id": "rightBottom2",
        "class": "right right--bottom2"
      },
      {
        "damaged": false,
        "id": "rightBottom",
        "class": "right right--bottom"
      }
    ],
    "injured": false,
    "police_called": false,
    "damage_type": 0,
    "photos": []
  },
  "additionals": {
    "injured": true,
    "police_called": true,
    "damage_type": 5,
    "photos": []
  },
  "summary": {
    "description": "",
    "hohe": "0 €",
  }
}

NOTE: discussion of the summary state is needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment