swagger: "2.0"
info:
  description: "This microservice is responsible for collecting artist metrics from social platforms and saving them to Snowflake."
  version: "1.0.0"
  title: "OWS social analytics API spec"
host: "qa-ows-social-analytics.theorchard.io"
tags:
- name: "collector"
  description: ""
- name: "artist"
  description: ""
- name: "social-profile"
  description: ""
- name: "search-artists"
- name: "last-viewed-artists"
paths:
  /health:
    get:
      tags:
      - "collector"
      summary: "Show collector status."
      description: "Show how many social profiles currently need collecting and the last processed date for any social profile."
      operationId: "collector_health"
      produces:
      - "application/json"
      responses:
        200:
          description: "200 OK"
          schema:
            $ref: "#/definitions/HealthStatus"
        404:
          description: "404 Not Found.No social profiles exist."
  /artist/{artist_id}/social-profiles:
    get:
      tags:
      - "artist"
      summary: "Get social profiles for an artist."
      description: ""
      operationId: "get_artist_social_profiles"
      produces:
      - "application/json"
      parameters:
      - in: "path"
        name: "artist_id"
        description: "The artist id for which to query social profiles"
        required: true
        type: "string"
      responses:
        200:
          description: "200 OK"
          schema:
            type: "object"
            properties:
              items:
                type: "array"
                items:
                  $ref: "#/definitions/SocialProfile"
        400:
          description: "400 Bad Request"
        404:
          description: "404 Not found"
  /artist/{artist_id}/latest-metrics:
    get:
      tags:
      - "artist"
      summary: "Get all metrics for the social profiles of this artist"
      description: ""
      operationId: "getArtistMetrics"
      produces:
      - "application/json"
      parameters:
      - in: "path"
        name: "artist_id"
        description: "The artist id"
        required: true
        type: "string"
      responses:
        200:
          description: "200 OK"
          schema:
            type: "object"
            properties:
              items:
                type: "array"
                items:
                  $ref: "#/definitions/MetricResponse"
        400:
          description: "400 Bad Request"
        404:
          description: "404 Not found"
  /social-profile:
    post:
      tags:
      - "social-profile"
      summary: "Create a social profile"
      description: ""
      operationId: "create_or_update_social_profile"
      consumes:
      - "application/json"
      produces:
      - "application/json"
      parameters:
      - in: "header"
        name: "Orchard-User-Id"
        description: "Orchard user id"
        type: "string"
      - in: "body"
        name: "body"
        description: "The data with which to create a social profile"
        required: true
        schema:
          $ref: "#/definitions/SuggestParams"
      responses:
        200:
          description: "200 OK"
          schema:
            type: "array"
            items:
              $ref: "#/definitions/SocialProfile"
        400:
          description: "400 Bad Request"
        404:
          description: "404 Not found"
  /social-profile/suggestions:
    post:
      tags:
      - "social-profile"
      summary: "Suggest social profiles"
      description: ""
      operationId: "social_profile_suggestions"
      consumes:
      - "application/json"
      produces:
      - "application/json"
      parameters:
      - in: "body"
        name: "body"
        description: "Artist and platform for which to suggest social profiles"
        required: true
        schema:
          $ref: "#/definitions/SuggestParams"
      responses:
        200:
          description: "200 OK"
          schema:
            $ref: "#/definitions/SuggestResponse"
        400:
          description: "400 Bad Request"
        404:
          description: "404 Not found"
  /social-profile/facebook-suggestions/{profile_name}:
    get:
      tags:
      - "social-profile"
      summary: "Get a recommendation for an artist's facebook profile"
      description: ""
      operationId: "recommend_facebook_profile"
      produces:
      - "application/json"
      parameters:
      - in: "path"
        name: "profile_name"
        description: "The profile name"
        required: true
        type: "string"
      responses:
        200:
          description: "200 OK"
          schema:
            $ref: "#/definitions/SuggestResponse"
        400:
          description: "400 Bad Request"
        404:
          description: "404 Not found"
  /social-profile/spotify-suggestions/{profile_name}:
    get:
      tags:
      - "social-profile"
      summary: "Get a recommendation for an artist's Spotify profile"
      description: ""
      operationId: "recommend_spotify_profile"
      produces:
      - "application/json"
      parameters:
      - in: "path"
        name: "profile_name"
        description: "The profile name"
        required: true
        type: "string"
      responses:
        200:
          description: "200 OK"
          schema:
            $ref: "#/definitions/SuggestResponse"
        400:
          description: "400 Bad Request"
        404:
          description: "404 Not found"
  /social-profile/instagram-suggestions/{profile_name}:
    get:
      tags:
      - "social-profile"
      summary: "Get a recommendation for an artist's Instagram profile"
      description: ""
      operationId: "recommend_instagram_profile"
      produces:
      - "application/json"
      parameters:
      - in: "path"
        name: "profile_name"
        description: "The profile name"
        required: true
        type: "string"
      responses:
        200:
          description: "200 OK"
          schema:
            $ref: "#definitions/SuggestResponse"
        400:
          description: "400 Bad Request"
        404:
          description: "404 Not found"
  /social-profile/{social_profile_id}/platform/{platform_id}/metric/{metric_id}:
    get:
      tags:
      - "social-profile"
      summary: ""
      description: "Get time series data for one metric for a given period of time"
      operationId: "get_time_series_data_for_platform"
      produces:
      - "application/json"
      parameters:
      - in: "path"
        name: "social_profile_id"
        description: ""
        required: true
        type: "string"
      - in: "path"
        name: "platform_id"
        description: ""
        required: true
        type: "string"
      - in: "path"
        name: "metric_id"
        description: ""
        required: true
        type: "string"
      - in: "query"
        name: "start_date"
        description: "The start of the period for which to query time series data"
        required: true
        type: "string"
        format: "date-time"
      - in: "query"
        name: "end_date"
        description: "The end of the period for which to query time series data"
        required: true
        type: "string"
        format: "date-time"
      responses:
        200:
          description: "200 OK"
          schema:
            type: "object"
            properties:
              items:
                type: "array"
                items:
                  $ref: "#/definitions/MetricResponse"
        400:
          description: "400 Bad Request"
  /search-artists:
    get:
      tags:
      - "search-artists"
      summary: ""
      description: "test"
      produces:
      - "application/json"
      parameters:
      - in: "header"
        name: "Grass-Account-Type"
        type: "string"
      - in: "header"
        name: "Grass-Account-Id"
        type: "string"
      - in: "query"
        name: "token"
        type: "string"
      - in: "query"
        name: "context"
        type: "string"
      - in: "query"
        name: "term"
        type: "string"
      responses:
        200:
          description: "200 OK"
          schema:
            type: "object"
            properties:
              items:
                type: "array"
                items:
                  $ref: "#/definitions/SearchArtistResponse"
        400:
          description: "400 Bad Request"
        404:
          description: "404 Not Found"
  /last-viewed-artists:
    get:
      tags:
      - "last-viewed-artists"
      operationId: "get_artists_for_account"
      summary: ""
      description: "Get artists for an account and its total followers"
      produces:
      - "application/json"
      parameters:
      - in: "header"
        name: "Orchard-User-Id"
        type: "string"
      responses:
        200:
          description: "200 OK"
      # parameters:
definitions:
  HealthStatus:
    type: "object"
    properties:
      total_count:
        type: "integer"
        format: "int64"
      already_collected_count:
        type: "integer"
        format: "int64"
      to_be_collected_count:
        type: "integer"
        format: "int64"
      already_collected:
        type: "object"
      to_be_collected:
        type: "object"
  SocialProfile:
    type: "object"
    properties:
      social_profile_id:
        type: "integer"
        format: "int64"
      platform:
        type: "string"
      platform_id:
        type: "string"
      platform_name:
        type: "string"
      collection_scheduled_time:
        type: "string"
        format: "date-time"
      last_collected_date:
        type: "string"
        format: "date-time"
      created_date:
        type: "string"
        format: "date-time"
      updated_date:
        type: "string"
        format: "date-time"
      created_by:
        type: "string"
      updated_by:
        type: "string"
  SuggestParams:
    type: "object"
    properties:
      platform:
        type: "string"
      platform_name:
        type: "string"
  SuggestResponse:
    type: "object"
    properties:
      platform:
        type: "string"
      platform_id:
        type: "string"
      is_verified:
        type: "boolean"
      metric_value:
        type: "integer"
        format: "int64"
  MetricResponse:
    type: "object"
    properties:
      activity_datetime:
        type: "string"
        format: "date-time"
      platform:
        type: "string"
      metric_name:
        type: "string"
      metric_value:
        type: "number"
        format: "float"
  SearchArtistResponse:
    type: "object"
    properties:
      artist_id:
        type: "integer"
        format: "int64"
      artist_name:
        type: "string"
      is_linked:
        type: "boolean"