Skip to content

API Documentation

Open Rousseau edited this page Oct 27, 2020 · 2 revisions

API Documentation

The API currently has 10 endpoints: Auth, authenticate, authenticate (submitTwoFactorCode), authenticate (twoFactorExtraAction), Token, Events feed, Direct Uploads, Blog Instant Article & GraphQL query.

Registration

For registration the App redirects to this url:

https://sso.rousseau.movimento5stelle.it/auth/realms/rousseau/protocol/openid-connect/registrations?

Registration Flow Video

Click here to Watch Video

Headers

"client_id": <string>,
"redirect_uri": <string>,
"response_mode": <string>,
"response_type": <string>,
"scope": <string>

BODY

// As per register screen on web
"body" = {

"name":<string>,
"surename":<string>,
"dateofbirth":<string>,
"sex":<string>,
"email":<string>,
"password":<string>,
"country":<string>,
"residence_data":<string>,
"phonenumber":<string>,

},

Response

{
“loginUrl”: <string>,
“forgotPasswordUrl”: <string>,
“errors”: [
{
<string>
},
{
<string>
}
]
}

Forgot Password

For Forgot Password the App redirects to this url:

https://sso.rousseau.movimento5stelle.it/auth/realms/rousseau/protocol/openid-connect/forgotpassword?

Headers

"client_id": <string>,
"redirect_uri": <string>,
"response_mode": <string>,
"response_type": <string>,
"scope": <string>

BODY

// As per Forgot screen on web
"body" = {


"email":<string>,

},

Response

{
“forgotPasswordUrl”: <string>,
“errors”: [
{
<string>
},
{
<string>
}
]
}

Auth

Method Route Description
GET /protocol/openid-connect/auth Get Authentication token from keyloack server

Headers

"nonce": <string>,
"state": <string>,
"client_id": <string>,
"redirect_uri": <string>,
"response_mode": <string>,
"response_type": <string>,
"scope": <string>

Response

{
“loginUrl”: <string>,
“registerUrl”: <string>,
“forgotPasswordUrl”: <string>,
“errors”: [
{
<string>
},
{
<string>
}
]
}

authenticate

Method Route Description
POST /login-actions/authenticate Authenticate user

Headers

"session_code": <string>,
"execution": <string>,
"tab_id": <string>,
"client_id": <string>

Response

{
“loginUrl”: <string>,
“errors”: [
{
<string>
},
{
<string>
}
]
}

authenticate (submitTwoFactorCode)

Method Route Description
POST /login-actions/authenticate Submit the sms code

Headers

"session_code": <string>,
"execution": <string>,
"tab_id": <string>,
"client_id": <string>

BODY

"body" = {
"smsCode":<string>
},

Response

{
“loginUrl”: <string>,
“errors”: [
{
<string>
},
{
<string>
}
]
}

authenticate (twoFactorExtraAction)

Method Route Description
POST /login-actions/authenticate Extra action for two factor authentication, resend or voice call

Headers

"session_code": <string>,
"execution": <string>,
"tab_id": <string>,
"client_id": <string>,
"action": <string>,

Response

{
“loginUrl”: <string>,
“errors”: [
{
<string>
},
{
<string>
}
]
}

Token

Method Route Description
POST /protocol/openid-connect/token Get token

Headers

"code": <string>,
"refresh_token": <string>,
"client_id": <string>,
"redirect_uri": <string>,
"grant_type": <string>

Response

{
"access_token": instance.accessToken,
"expires_in": instance.expiresIn,
"refresh_expires_in": instance.refreshExpiresIn,
"refresh_token": instance.refreshToken,
"token_type": instance.tokenType,
"not-before-policy": instance.notBeforePolicy,
"session_state": instance.sessionState,
"scope": instance.scope,
"error": instance.error,
"error_description": instance.errorDescription,
“errors”: [
{
<string>
},
{
<string>
}
]
}

Events feed

BASE URL

https://partecipa.ilblogdellestelle.it
Method Route Description
GET /wp-json/app/events_feed Get event feeds based on the region

Headers

"region": <String>

Response

{
"events": [
{
"title": <String>,
"subtitle": <String>,
"campaign": <String>,
"squareImage": <String>,
"coverImage": <String>,
"permalink": <String>,
"marker": <String>,
"newDescription": <String>,
"legacyDescription": <String>,
"dates": {
"date": <String>,
"start": <String>,
"end": <String>,
"timestamp": <String>,
},
"place": {
"formatted_address": <String>
}
}
]
}

Direct Uploads

BASE URL

https://partecipa.ilblogdellestelle.it
Method Route Description
POST /files/direct_uploads Upload files on the server

Headers

"blob": {
"byteSize": <String>,
"checksum": <String>,
"filename": <String>,
"contentType": <String>
}

Response

{
"id": <Double>,
"key": <String>,
"filename": <String>,
"contentType": <String>,
"byteSize": <Double>,
"checksum": <String>,
"createdAt": <String>,
"signedId": <String>,
"directUpload": {
"url": <String>
}

}

Blog Instant Article

BASE URL

https://partecipa.ilblogdellestelle.it
Method Route Description
GET /wp-json/mobile_api/v1/ia_posts Get the list of blogs

Headers

"offset": <String>,
"per_page": <String>

Response

{
"id": <Int>,
"title": <String>,
"image": <String>,
"date": <DateTime>,
"text": <String>,
"summary": <String>,
"url": <String>,
"slug": <String>,
"author": {
"name": <String>,
"avatar": <String>,
},
"category": {
"name": <String>
}
}

Blog Instant Article

Method Route Description
GET /wp-json/mobile_api/v1/ia_post Get detail of a blog

Headers

"slug": <String>

Response

{
"id": <Int>,
"title": <String>,
"image": <String>,
"date": <DateTime>,
"text": <String>,
"summary": <String>,
"url": <String>,
"slug": <String>,
"author": {
"name": <String>,
"avatar": <String>,
},
"category": {
"name": <String>
}
}

Poll

The endpoint for Poll & Vote are same the difference is in the GraphQL queries.

BASE URL

https://partecipa.ilblogdellestelle.it
Route Description
/graphql Used for voting

Get All Polls Query

String listPolls = '''
query listPolls {
polls(orderAttribute: show_starting_date, orderDirection: DESC) {
id
slug
title
status
alreadyVoted
showStartingDate
voteStartingDate
voteEndingDate
announcementLink
resultsLink
alerts {
message
}
options {
id
__typename
...on EntityOption {
entity {
__typename
}
}
}
}
}
''';

Poll detail Query

String pollDetail = '''
query pollDetail(\$pollId: ID!) {
poll(id: \$pollId) {
id
slug
title
status
description
alreadyVoted
showStartingDate
voteStartingDate
voteEndingDate
announcementLink
resultsLink
optionType
maxSelectableOptionsNumber
options {
id
__typename
...on TextOption {
text
}
...on EntityOption {
entity {
__typename
...on User {
id
slug
fullName
overseaseCity
profile {
age
placeOfResidence {
comuneName
provinciaName
}
picture {
originalUrl
}
}
badges {
code
active
name
}
}
}
}
}
}
}
''';

Poll answer submit query

mutation pollAnswerSubmit(pollId <String>, optionIds List<String>) {
user {
pollAnswerSubmit(pollId <String>, optionIds List<String>) {
errors
}
}
}

Response

returns boolean