paddle/api

Types

ApiResponseData[T] = object
  data*: T
  meta*: JsonNode
PaddleApiResponse[T] = object of RootObj
  data*: T
  meta*: PaddleApiResponseMeta
PaddleApiResponseMeta = object
  request_id*: string
  pagination*: PaddleApiResponseMetaPagination
PaddleApiResponseMetaPagination = object
  per_page*: uint8 ## Number of entities per page for this response. May differ from the
                   ## number requested if the requested number is greater than the maximum
  next*: string ## URL containing the query parameters of the original request, along with the
                ## after parameter that marks the starting point of the next page. Always returned,
                ## even if has_more is false.
  has_more*: bool            ## Whether this response has another page of results after this one.
  estimated_total*: uint8 ## An estimate of the total number of entities matching the query.
                          ## May differ from the actual total.
Keys used for working with paginated results
PaddleBaseObject = object of RootObj
  id*: PaddleEntryID
  status*: PaddleItemStatus  ## The status of this entity
  custom_data*: JsonNode     ## Your own structured key-value data
  import_meta*: JsonNode     ## Import information for this entity. null if this entity is not imported.
Base object for all entities returned by the Paddle API
PaddleClient = object
Represents a client for making API requests to the Paddle service
PaddleClientError = object of CatchableError
PaddleEntryID = string
The unique identifier for an entity, prefixed with a three-letter code indicating the type of entity, e.g. pro_ for products, pri_ for prices, etc.
PaddleItemStatus = enum
  active = "active", archived = "archived"
PaddleItemType = enum
  standard = "standard", custom = "custom"
PaddleTaxCategory = enum
  standard = "standard", ## Return entities with the tax category of standard. Software products that
                          ## are pre-written and can be downloaded and installed onto a local device.
  digitalGoods = "digital-goods", ## Return entities with the tax category of digital-goods. Non-customizable digital files or media
                                   ## (not software) acquired with an up front payment that can be accessed without any
                                   ## physical product being delivered.
  ebooks = "ebooks", ## Return entities with the tax category of ebooks. Digital books and educational
                      ## material which is sold with permanent rights for use by the customer.
  implementationServices = "implementation-services", ## Return entities with the tax category of implementation-services. Remote
                                                       ## configuration, set-up, and integrating software on behalf of a customer.
  professionalServices = "professional-services", ## Return entities with the tax category of professional-services. Services
                                                   ## that involve the application of your expertise and specialized knowledge
                                                   ## of a software product.
  saas = "saas", ## Return entities with the tax category of saas. Products that allow users to
                  ## connect to and use online or cloud-based applications over the Internet.
  softwareProgrammingServices = "software-programming-services", ## Return entities with the tax category of software-programming-services.
                                                                  ## Services that can be used to customize and white label software products.
  trainingServices = "training-services", ## Return entities with the tax category of training-services.
                                           ## Training and education services related to software products.
  websiteHosting = "website-hosting" ## Return entities with the tax category of website-hosting. Cloud storage
                                     ## service for personal or corporate information, assets, or intellectual property.
QueryTable = OrderedTable[string, string]
A table for storing query parameters to be included in API requests. The keys and values are both strings.

Procs

proc `$`(query: QueryTable): string {....raises: [KeyError], tags: [], forbids: [].}
Convert query QueryTable to string
proc dumpHook(s: var string; v: DateTime) {....raises: [TimeFormatParseError],
    tags: [], forbids: [].}
proc httpGet(client: PaddleClient; endpoint: string): Future[AsyncResponse] {.
    ...stackTrace: false, raises: [Exception, ValueError, HttpRequestError,
                                LibraryError, SslError, OSError, IOError,
                                ProtocolError, KeyError],
    tags: [RootEffect, ReadIOEffect, TimeEffect], forbids: [].}
Makes a GET request to the specified endpoint of the Paddle API using the provided PaddleClient
proc httpGet(client: PaddleClient; endpoint: string; query: QueryTable): Future[
    AsyncResponse] {....stackTrace: false, raises: [Exception, ValueError,
    KeyError, HttpRequestError, LibraryError, SslError, OSError, IOError,
    ProtocolError], tags: [RootEffect, ReadIOEffect, TimeEffect], forbids: [].}
Makes a GET request to the specified endpoint of the Paddle API using the provided PaddleClient
proc httpPatch[T](client: PaddleClient; endpoint: string; body: T): Future[
    AsyncResponse] {....stackTrace: false.}
Makes a PATCH request to the specified endpoint of the Paddle API using the provided PaddleClient and JSON body
proc httpPost(client: PaddleClient; endpoint: string): Future[AsyncResponse] {.
    ...stackTrace: false, raises: [Exception, ValueError, HttpRequestError,
                                LibraryError, SslError, OSError, IOError,
                                ProtocolError, KeyError],
    tags: [RootEffect, ReadIOEffect, TimeEffect], forbids: [].}
Makes a POST request to the specified endpoint of the Paddle API using the provided PaddleClient and JSON body
proc httpPost[T](client: PaddleClient; endpoint: string; body: T): Future[
    AsyncResponse] {....stackTrace: false.}
Makes a POST request to the specified endpoint of the Paddle API using the provided PaddleClient and JSON body
proc initPaddleClient(apiKey: string): PaddleClient {....raises: [KeyError],
    tags: [], forbids: [].}
Creates a new PaddleClient with the provided API key. The API key is included in the Authorization header as a Bearer token for authentication with the Paddle service.
proc isEmpty[T](response: PaddleApiResponse[seq[T]]): bool
Returns true if the response contains no products, false otherwise
proc len[T](response: PaddleApiResponse[seq[T]]): int
Returns the number of products in the response
proc parseHook(parser: var json.JsonParser; v: var DateTime) {.
    ...raises: [OpenParserJsonError, ValueError, TimeParseError],
    tags: [TimeEffect], forbids: [].}