Coder Social home page Coder Social logo

2023-05-5-crud-operations's Introduction

Contentful Management Api Training

A sample 'ticket' given by Melanie Bouic for me to practice with CMA:


The ticket

Contentful Platform

  • Create a content model on contentful platform: Name "product" with the following fields: 
Field name Field value Required
Title short text true
Path short text
Label short tet
Introduction long text
shop reference accepting only specific values -"Shop"  with appearance: "entry Link"

Scripting

Creation of script

  1. Communication with contentful management API
  2. Populate the contentType with 1 content:
Field name Field value
title sensitve pampers
path pampers.com/sensitive
label wipes
introduction { introduction }

{ introduction } : Pampers Swaddlers diapers are the number one choice of hospitals, based on, protection, comfort, dryness and more. Buy now at Pampers.com

  1. A function to create a field name "slug" - short text with the value found in the title field. Published the content. 
  2. create a log file (log.txt) in the following format  DATE: Wed May 03 2023 10:47:22 GMT+0400 (Mauritius Standard Time) Published "filed Name"- id: "ID"
  3. Create another another field called "US shop" in boolean type with default value true
  4. append your log file with successful or unsuccessful response (in the same format above)
  5. Delete the field "Shop"  append your log file with successful or unsuccessful response (in the same format above)

How to run the script

The main function is where you would run your tasks

Operations

Operations Function Parameters Return
Connect to CMA connect env
Create an entry createEntry env, entry
Create a field createField env, field
Update a field updateField env, field
Delete a field deleteField env, field

**Note: **

Re-running the script as it is would cause an error, which will be catched in a catch statement and be logged to log.txt. Plausible scenario: Creating the same field twice.

  • Since, the function createField does not check if the field already exists, an error will be caught and logged.

Thank you for your attention, If you have any suggestions, please let me know. 😃

2023-05-5-crud-operations's People

Contributors

adityaramdoneerapp avatar spacember avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.