Skip to content

Commit

Permalink
Merge pull request #24 from josemoracard/jose1-README
Browse files Browse the repository at this point in the history
fixed text README
  • Loading branch information
tommygonzaleza authored Jan 24, 2024
2 parents 5c8c6f9 + 7d61920 commit d9e2a9b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 50 deletions.
35 changes: 11 additions & 24 deletions README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,23 @@ Cada **miembro** de la familia Jackson debe ser un diccionario, equivalente a [O
+ first_name: String
+ last_name: String (Siempre Jackson)
+ age: Int > 0
+ lucky_numbers: Array of int
+ lucky_numbers: List of integers
```

La estructura de datos **family** será una clase con la siguiente estructura:

```python
class Family:

class FamilyStructure:
def __init__(self, last_name):
self.last_name = last_name
# ejemplo de lista de miembros
self._members = [{
"id": self._generateId(),
"first_name": "John",
"last_name": last_name
}]
self._next_id = 1
self._members = []

# solo lectura: Utiliza este método para generar ids aleatorias de miembros al agregarlos a la lista
def _generateId(self):
return randint(0, 99999999) # import random
# Este método genera un 'id' único al agregar miembros a la lista (no debes modificar esta función)
def _generate_id(self):
generated_id = self._next_id
self._next_id += 1
return generated_id

def add_member(self, member):
## Debes implementar este método
Expand All @@ -79,11 +76,6 @@ class Family:
## Recorre la lista y elimina el miembro con el id proporcionado
pass

def update_member(self, id, member):
## Debes implementar este método
## Recorre la lista y actualiza el miembro con el id proporcionado
pass

def get_member(self, id):
## Debes implementar este método
## Recorre la lista y obtén el miembro con el id proporcionado
Expand Down Expand Up @@ -158,22 +150,17 @@ POST /member

REQUEST BODY (content_type: application/json):
{
id: Int,
first_name: String,
age: Int,
lucky_numbers: [],
id: Int <!--- función número aleatorio -->
lucky_numbers: []
}

RESPONSE (content_type: application/json):

status_code 200 si se realizó con éxito, 400 si hubo un error por parte del cliente, 500 si el servidor encuentra un error

body: vacío
```

Ten en cuenta que el diccionario que envía la solicitud POST puede contener una propiedad y un valor para el `id` del miembro a crear.
- Si no lo incluye, tu API debe generar un `id` aleatorio al agregarlo a la familia.
- Si lo incluye, entonces este es el valor que deberás usar como `id` al agregarlo.

### 4) ELIMINA un miembro

Expand Down
37 changes: 11 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,23 @@ Every **member** of the Jackson family must be a dictionary - the equivalent of
+ first_name: String
+ last_name: String (Always Jackson)
+ age: Int > 0
+ lucky_numbers: Array of int
+ lucky_numbers: List of integers
```

The **family** data-structure will be a class with the following structure:

```python
class Family:

class FamilyStructure:
def __init__(self, last_name):
self.last_name = last_name
# example list of members
self._members = [{
"id": self._generateId(),
"first_name": "John",
"last_name": last_name
}]
self._next_id = 1
self._members = []

# read-only: Use this method to generate random member ids when adding members into the list
def _generateId(self):
return random.randint(0, 99999999) # import random
# This method generates a unique 'id' when adding members into the list (you shouldn't touch this function)
def _generate_id(self):
generated_id = self._next_id
self._next_id += 1
return generated_id

def add_member(self, member):
## You have to implement this method
Expand All @@ -81,11 +78,6 @@ class Family:
## Loop the list and delete the member with the given id
pass

def update_member(self, id, member):
## You have to implement this method
## Loop the list and update the member with the given id
pass

def get_member(self, id):
## You have to implement this method
## Loop all the members and return the one with the given id
Expand Down Expand Up @@ -162,23 +154,17 @@ POST /member

REQUEST BODY (content_type: application/json):
{
id: Int,
first_name: String,
age: Int,
lucky_numbers: [],
id: Int <!--- randomize function -->
lucky_numbers: []
}

RESPONSE (content_type: application/json):

status_code: 200 if success. 400 if a bad request (wrong info). 500 if the server encounters an error

body: empty
```

Keep in mind that POST request data dictionary may contain a key and a value for this new member `id`.
- If it does not, your API should randomly generate one when adding family members.
- If it does include it, that is the value to be used for such end.

### 4) DELETE one member

Which deletes a family member with `id == member_id`
Expand All @@ -193,7 +179,6 @@ status_code: 200 if success. 400 if a bad request (wrong info). 500 if the serve
body: {
done: True
}

```

## Requirements
Expand Down

0 comments on commit d9e2a9b

Please sign in to comment.