No Description

Adphi 48ab9598dd Update README.md 1 year ago
functions 5f40efc62b Add Cancel other users when user confirmed and event complete 1 year ago
.gitignore d5c7b6a4f7 Add /event/search 1 year ago
README.md 48ab9598dd Update README.md 1 year ago
firebase.json 5d1abf3da4 Added RestAPI Methods template, Implemented event/match :o) 1 year ago

README.md

Steeryfit-Firebase Functions et Rest API

Todo:

  • Lier au Firebase de Steeryfit
  • Notifier les participants lors de la mise à jour d'un événement.
  • Gestion des erreurs.

Documentation

Lier à Firebase

Installer nodejs et npm.

$ npm install -g firebase-tools

A la racine du dossier :

$ firebase login

Lier le projet à Firebase :

$ firebase use --add

Chosir le projet Steeryfit.

Installer les dépendances :

cd functions; npm install; cd -

Pour déployer les fonctions sur Firebase:

$ firebase deploy

ou

$ firebase deploy --only functions:<le nom de la fonction>

pour déployer uniquement une fonction particulère.

https://firebase.google.com/docs/cli/


Steeryfit Rest API

Only Available (for now) for events handling.

Authentication


For each request the Firebase ID token needs to be passed as a Bearer token in the Authorization HTTP header like this: Authorization: Bearer <Firebase ID Token>

Search Event


  • URL

/event/search

  • Method:

GET

  • URL Params

Required:

none (Default query based on User preferences)

or

latitude=[int] search center latitude

longitude=[int] search center longitude

```distance=[int]```  search distance in meters

**Optional:**

```sport=[string]``` sport: RUN | RACKET | BIKE | BALL | GOLF | WALK

```level=[string]``` level: BEGINNER | INTERMEDIATE | ADVANCE

```time=[long]```
  • Success Response:

    • Code: 200
      Content: Array of event

    example:

    [
    {
        "address": "1 Place de la Bourse, 31000 Toulouse, France",
        "confirmParticipantsCount": 1,
        "creatorUid": "1WAc9rMF5XSwc5IkEjw3z02JQVz1",
        "date": 1517051329921,
        "duration": 3600000,
        "gender": "MIXTE",
        "genderEnum": "MIXTE",
        "info": "Golf",
        "level": "INTERMEDIATE",
        "location": {
            "latitude": 43.6015277,
            "longitude": 1.4421026
        },
        "name": "Test golf",
        "participants": {
            "a4rvTeTi0fZtKyzfLQyJLZidrIp1": false
        },
        "sport": "GOLF",
        "time": 1517051329921,
        "uid": "-L2e2jWCJKkQhyIo2YUu",
        "usersLimit": 11
    },
    {
        "address": "1 Place de la Bourse, 31000 Toulouse, France",
        "confirmParticipantsCount": 1,
        "creatorUid": "1WAc9rMF5XSwc5IkEjw3z02JQVz1",
        "date": 1517051718315,
        "duration": 3600000,
        "gender": "MIXTE",
        "genderEnum": "MIXTE",
        "info": "Vhui",
        "level": "INTERMEDIATE",
        "location": {
            "latitude": 43.6015277,
            "longitude": 1.4421026
        },
        "name": "Gggg",
        "sport": "GOLF",
        "time": 1517051718315,
        "uid": "-L2e4CwoIveaCPRd2NyP",
        "usersLimit": 11
    }
    ]
    
  • Error Response:

    • Code: 400 BAD REQUEST
      Content: {status: 'error', message: 'Missing one of these arguments : latitude, longitude or distance'}

OR

  • Code: 403 UNAUTHORIZED

Event Match


  • URL

    /event/match?id=event_id

  • Method:

GET

  • URL Params

Required:

id=[string] event uid

  • Success Response:

    • Code: 200
      Content: Created conversation Object in JSON example :
      json { "eventUid" : "-L2Et_w107KDsTFjvSJQ", "uid" : "-L2EuS38opcCGRExJ9H4", "users" : { "2mlOkeO9cFhv1CoAcJ8wdxbakdv2" : true, "a4rvTeTi0fZtKyzfLQyJLZidrIp1" : true }, "usersData" : { "2mlOkeO9cFhv1CoAcJ8wdxbakdv2" : { "avatar" : "https://firebasestorage.googleapis.com/v0/b/steeryfit-3999d.appspot.com/o/Avatars%2F2mlOkeO9cFhv1CoAcJ8wdxbakdv2?alt=media&token=79018fe2-8df7-43c5-8501-c7e71d812a99", "name" : "Walda" }, "a4rvTeTi0fZtKyzfLQyJLZidrIp1" : { "avatar" : "https://firebasestorage.googleapis.com/v0/b/steeryfit-3999d.appspot.com/o/Avatars%2Fa4rvTeTi0fZtKyzfLQyJLZidrIp1?alt=media&token=43339473-a6ac-4403-9adc-27f0ae3df2c7", "name" : "Adphi" } } }
  • Error Response: (not yet implemented)

    • Code: 404 NOT FOUND
      Content:

OR

  • Code: 403 UNAUTHORIZED


Accept / Reject Participation


  • URL

Accept Participation :

/event/confirm?id=event_id&user=user_id

Reject Event :

/event/reject?id=event_id&user=user_id

  • Method:

GET

  • URL Params

Required:

id=[string] event uid user=[string] user uid

  • Success Response:

    • Code: 200
      Content: {status: 'success'}
  • Error Response: (not yet implemented)

    • Code: 404 NOT FOUND
      Content:

OR

  • Code: 403 UNAUTHORIZED

Cancel Participation / Cancel Event


  • URL

Cancel Participation :

/event/cancel?id=event_id

Delete Event :

/event/delete?id=event_id

  • Method:

GET

  • URL Params

Required:

id=[string] event uid

  • Success Response:

    • Code: 200
      Content: {status: 'success'}
  • Error Response: (not yet implemented)

    • Code: 404 NOT FOUND
      Content:

OR

  • Code: 403 UNAUTHORIZED