Types
GumroadClient = ref object
GumroadClientError = object of CatchableError
GumroadScope = enum scopeAccount = "account", ## full access to all API endpoints scopeViewProfile = "view_profile", ## read-only access to the user's profile information scopeEditProducts = "edit_products", ## read and write access to the user's products scopeViewSales = "view_sales", ## read-only access to the user's sales data scopeViewPayouts = "view_payouts", ## read-only access to the user's payout information scopeViewTaxData = "view_tax_data", ## read-only access to the user's tax data scopeMarkSalesAsShipped = "mark_sales_as_shipped", ## write access to mark the user's products' sales as shipped scopeEditSales = "edit_sales" ## write access to refund the user's products' sales and ## resend purchase receipts to customers
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: var QueryTable): string {....raises: [KeyError], tags: [], forbids: [].}
- Convert query QueryTable to string
proc addAccessToken(query: var QueryTable; client: GumroadClient) {....raises: [], tags: [], forbids: [].}
- Add access_token to query if present.
proc configureOAuth(client: GumroadClient; clientId, clientSecret: string) {. ...raises: [], tags: [], forbids: [].}
- Stores OAuth app credentials used for automatic token refresh.
proc exchangeCodeForToken(clientId, clientSecret, code, redirectUri: string): Future[ JsonNode] {....stackTrace: false, raises: [Exception, ValueError, KeyError, HttpRequestError, LibraryError, SslError, OSError, IOError, ProtocolError, JsonParsingError], tags: [RootEffect, ReadIOEffect, TimeEffect, WriteIOEffect], forbids: [].}
- Exchanges an authorization code for an access token.
proc getAuthorizationUrl(clientId, redirectUri: string; scopes: seq[GumroadScope]; state = ""): string {. ...raises: [], tags: [], forbids: [].}
- Constructs the Gumroad OAuth2 authorization URL.
proc httpDelete(client: GumroadClient; endpoint: string): Future[AsyncResponse] {. ...stackTrace: false, raises: [Exception, ValueError, KeyError, HttpRequestError, LibraryError, SslError, OSError, IOError, ProtocolError, JsonParsingError], tags: [RootEffect, ReadIOEffect, TimeEffect, WriteIOEffect], forbids: [].}
- DELETE with automatic token refresh on 401.
proc httpGet(client: GumroadClient; endpoint: string): Future[AsyncResponse] {. ...stackTrace: false, raises: [Exception, ValueError, KeyError, HttpRequestError, LibraryError, SslError, OSError, IOError, ProtocolError, JsonParsingError], tags: [RootEffect, ReadIOEffect, TimeEffect, WriteIOEffect], forbids: [].}
- GET with automatic token refresh on 401.
proc httpGet(client: GumroadClient; endpoint: string; query: var QueryTable): Future[ AsyncResponse] {....stackTrace: false, raises: [Exception, ValueError, KeyError, HttpRequestError, LibraryError, SslError, OSError, IOError, ProtocolError, JsonParsingError], tags: [RootEffect, ReadIOEffect, TimeEffect, WriteIOEffect], forbids: [].}
- GET with automatic token refresh on 401.
proc httpPost(client: GumroadClient; endpoint: string): Future[AsyncResponse] {. ...stackTrace: false, raises: [Exception, ValueError, KeyError, HttpRequestError, LibraryError, SslError, OSError, IOError, ProtocolError, JsonParsingError], tags: [RootEffect, ReadIOEffect, TimeEffect, WriteIOEffect], forbids: [].}
- POST with automatic token refresh on 401.
proc httpPost(client: GumroadClient; endpoint: string; query: var QueryTable): Future[ AsyncResponse] {....stackTrace: false, raises: [Exception, ValueError, KeyError, HttpRequestError, LibraryError, SslError, OSError, IOError, ProtocolError, JsonParsingError], tags: [RootEffect, ReadIOEffect, TimeEffect, WriteIOEffect], forbids: [].}
- POST with automatic token refresh on 401.
proc httpPost[T](client: GumroadClient; endpoint: string; body: T): Future[ AsyncResponse] {....stackTrace: false.}
- POST with automatic token refresh on 401.
proc httpPut(client: GumroadClient; endpoint: string; query: var QueryTable): Future[ AsyncResponse] {....stackTrace: false, raises: [Exception, ValueError, KeyError, HttpRequestError, LibraryError, SslError, OSError, IOError, ProtocolError, JsonParsingError], tags: [RootEffect, ReadIOEffect, TimeEffect, WriteIOEffect], forbids: [].}
- PUT with automatic token refresh on 401.
proc httpPut[T](client: GumroadClient; endpoint: string; body: T): Future[ AsyncResponse] {....stackTrace: false.}
- PUT with automatic token refresh on 401.
proc initGumroadClient(): GumroadClient {....raises: [KeyError], tags: [], forbids: [].}
- Creates a new GumroadClient with the provided API key. The API key is included in the Authorization header as a Bearer token for authentication with the Gumroad service.
proc refreshAccessToken(clientId, clientSecret, refreshToken: string): Future[ JsonNode] {....stackTrace: false, raises: [Exception, ValueError, KeyError, HttpRequestError, LibraryError, SslError, OSError, IOError, ProtocolError, JsonParsingError], tags: [RootEffect, ReadIOEffect, TimeEffect, WriteIOEffect], forbids: [].}
- Refreshes the access token using a refresh token.
proc setTokens(client: GumroadClient; accessToken, refreshToken: string; expiresIn: Option[int] = none(int)) {....raises: [], tags: [], forbids: [].}
- Set OAuth tokens on the client.