plex_pin_auth/util/parser

This module is for decoding JSON objects from HTTP requests. Designed specifically for the Plex API.

Types

Represents a single plex error that would be returned from the API

pub type PlexError {
  PlexError(code: Int, message: String, status: Int)
}

Constructors

  • PlexError(code: Int, message: String, status: Int)

Represents the location object returns from get-pin API

pub type PlexLocation {
  PlexLocation(
    code: String,
    european_union_member: Bool,
    continent_code: String,
    country: String,
    city: String,
    time_zone: String,
    postal_code: Option(String),
    in_privacy_restricted_country: Bool,
    subdivisions: String,
    coordinates: String,
  )
}

Constructors

  • PlexLocation(
      code: String,
      european_union_member: Bool,
      continent_code: String,
      country: String,
      city: String,
      time_zone: String,
      postal_code: Option(String),
      in_privacy_restricted_country: Bool,
      subdivisions: String,
      coordinates: String,
    )

Represents the object response from the get-pin API

pub type PlexPin {
  PlexPin(
    id: Int,
    code: String,
    product: String,
    trusted: Bool,
    qr: String,
    client_identifier: String,
    location: PlexLocation,
    expires_in: Int,
    created_at: String,
    expires_at: String,
    auth_token: Option(String),
    new_registration: Option(Bool),
  )
}

Constructors

  • PlexPin(
      id: Int,
      code: String,
      product: String,
      trusted: Bool,
      qr: String,
      client_identifier: String,
      location: PlexLocation,
      expires_in: Int,
      created_at: String,
      expires_at: String,
      auth_token: Option(String),
      new_registration: Option(Bool),
    )

Functions

pub fn decode_error_json(
  json_string: String,
) -> Result(PlexError, DecodeError)

Returns a single PlexError from a JSON string that represents a list of PlexError

pub fn decode_pin_json(
  json_string: String,
) -> Result(PlexPin, DecodeError)

Returns a PlexPin from a JSON string that represents a PlexPin

Search Document