Skip to content

Instantly share code, notes, and snippets.

@klinkin
Last active October 23, 2017 16:29
Show Gist options
  • Save klinkin/0cbf1690b040c8d02deec96f4507e563 to your computer and use it in GitHub Desktop.
Save klinkin/0cbf1690b040c8d02deec96f4507e563 to your computer and use it in GitHub Desktop.
Пользовательское API сервиса Quelle.ru

Registers a new device on the server

(en) This method registers a user's device on the server when a user launches an application at the first time. After the registration the server sends:

  • unique identificator QUELLE-DUID in the UUID format
  • JWT token generated on the base of QUELLE-DUID

(ru) Метод для регистрации устройства пользователя на сервере при запуске первом запуске приложения. При регистрации на серверной стороне выдаются:

  • уникальный идентификатор QUELLE-DUID в формате UUID
  • JWT токен, который сгенерирован на основе этого QUELLE-DUID

На JWT есть стандарт https://tools.ietf.org/html/rfc7519 По-человечески написано тут https://auth0.com/docs/jwt

Request

REQUSET:
  TYPE:
    POST 
  PATH:
    api.quelle.ru/v1/usr/device
  Content-Type: 
    application-json
  BODY:
    {
      "deviceInfo": {
        "adid": "ffsdfsf43534534rrrrtret", -- (opt) advertising id (IDFA на iOS, GAID на Android)
        "platform": "ios", -- (req) platform, valid values: "android", "ios"
        "token": "ffsdfsf43534534rrrrtret", -- (opt) push-token for sending push-notificatons
        "uuid": "ffsdfsf43534534rrrrtret", -- (req) installation unique id  (IFV for iOS, UUID for Android generating by device)
        "timezone": "10800", -- (req) user’s timezone in seconds (to send push-notifications)
        "device": "iPhone7s", -- (req) device
        "os_version": "10.2", -- (req) version OS
        "app_version": "1.2.1", -- (req) version APP
        "locale": "ru" -- (req) language locale (we are going use it for texts in push notifications)
      },
      "location":   -- ( opt) coordinates
      {
        "lat": 37.4501173, -- (req) lat
        "lon": 55.5450368 -- (req) lon
      }
    }

Comments:

  • req - parameter is required
  • opt - parameter is optional
  • adid - can contains zero’s for example "00000-000000-0000000-000000", if If the user has disabled advertising ad tracking
  • token - can be empty if user hasn’t given permission to send him push-notifications
  • location - can be empty if user hasn’t given permission to get his location

Response

RESPONSE: 
  HTTP STATUS CODE 201 -- the code 201 returns in case of successful device registration

  HEADERS:
    Authorization -- token is setted here and must be used in all API parts
    Example:
      Authorization: sdfsdfdf9824986245945dfsfsdfdsf.dsfsdfsdfsdf

    QUELLE-DUID: -- device uuid, it will be sent in mobile analytics services
    Example:
      QUELLE-DUID: 48358437568-345345-345-345fgfdg-435-dfg
  BODY:
    none

(en) ADID (IDFA / GAID) and push-token can change during application life time, that’s why we need to update them on the server-side. The request is calles at each application start and sends all updated device IDs. As a result of the request, Authorization token can be updated. As with the POST request, the request is considered successful if the second hundred codes (2xx) are returned.

(ru) Так как ADID (IDFA / GAID) и пуш-токен могут меняться во время жизни приложения нужно уметь обновлять их на сервере. Запрос выполняется на каждом старте приложения и присылает все обновлённые идентификаторы устройства. В результате запроса может быть обновлён Authorization токен. Как и в случае с POST-запросом, запрос считается успешно выполненым, если возвращается коды второй сотни(2xx).

Запрос на обновление идентификаторов устройства(IFA, GAID, push-токен)

REQUSET:
  TYPE:
    PATCH
  PATH:
    api.quelle.ru/v1/usr/device
  Content-Type: 
    application-json
  Headers
    Authorization: <token> jwt token
  BODY:
    {
      "deviceInfo": {
        "adid": "ffsdfsf43534534rrrrtret",
        "token" "ffsdfsf43534534rrrrtret",
        "timezone": "10800",
        "os_version": "10.2",
        "app_version": "1.2.1",
        "locale": "ru"
      },
      "location": {
        "lat": 37.4501173,
        "lon": 55.5450368
      }
    }

Ответ

RESPONSE: 
  HTTP STATUS CODE 204 -- the code 204 returns in case of successful id updates

  HEADERS:
    Authorization
    Example:
      Authorization: sdfsdfdf9824986245945dfsfsdfdsf.dsfsdfsdfsdf

    QUELLE-DUID:
    Example:
      QUELLE-DUID: 48358437568-345345-345-345fgfdg-435-dfg
  BODY:
    none

Authentication

Request

REQUSET: 
  TYPE:
    POST 
  PATH:
    api.quelle.ru/v1/usr/signin
  Content-Type: 
    application-json
  Headers
    Authorization: <token> jwt token
  BODY:
    {
      "email": "mike@applicatura.com",
      "password": "123rtyrty"
    }

Ответ

RESPONSE: 
  HTTP STATUS CODE 200 -- the code 200 returns in case of successful authentication

  HEADERS:
    Authorization
    Example:
      Authorization: sdfsdfdf9824986245945dfsfsdfdsf.dsfsdfsdfsdf

    QUELLE-UID:
    Example:
      QUELLE-UID: 123
  BODY:
    none

New User Registration

(en) This method registers a new user on the server After the registration (a user has been created) the server sends:

  • unique identificator QUELLE-UID in the UUID format
  • JWT token generated on the base of QUELLE-UID

(ru) Метод для регистрации пользователя на сервере. При регистрации на серверной стороне создается новый пользователь, в ответ сервер возвращает:

  • уникальный идентификатор QUELLE-UID в формате UUID
  • новый JWT токен, который сгенерирован на основе этого QUELLE-UID

Request

REQUSET:
  TYPE:
    POST 
  PATH:
    api.quelle.ru/v1/usr/signup
  Content-Type: 
    application-json
  Headers
    Authorization: <token> jwt token
  BODY:
    {
      "sirname": "Климин",
      "firstname": "Михаил",
      "secondname": "Валерьевич",
      "email": "mike@applicatura.com",
      "password": "123rtyrty",
      "password_repeat": "123rtyrty",
      "advertize": true
    }

Ответ сервера

RESPONSE: 
  HTTP STATUS CODE 201

  HEADERS:
    Authorization
    Example:
      Authorization: sdfsdfdf9824986245945dfsfsdfdsf.dsfsdfsdfsdf

    QUELLE-UID:
    Example:
      QUELLE-UID: 123
    BODY:
      none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment