Skip to content

Credit Check Status

Returns an enum that describes if a deposit is needed or not. The enum will be based on the customer's credit score compared against our minimum required credit score threshold.

Note: Credit check is required for our postpay products. The customer will have the option to waive the credit check if they can pay the deposit fee or legally qualifies for a waiver (will have to give us a call).

Authentication Required

Requires CAN_CREATE_ACCOUNTS permission.

Arguments

  • accountNumber: String!

Returns

1
2
3
4
5
query creditCheckStatus($accountNumber: String!) {
  creditCheckStatus(accountNumber: $accountNumber) {
    status
  }
}
Expected error messages
  • If the given account number is invalid or not found it returns - Unauthorized.
  • If your organization doesn't have the permission to view this account's credit check status, it returns - You are not authorized to view this account's credit score status.

Example

1
2
3
4
5
query creditCheckStatus($accountNumber: String!) {
  creditCheckStatus(accountNumber: $accountNumber) {
    status
  }
}
1
2
3
4
# Input variables
{
  "accountNumber":"A-12345"
}
from typing import Optional, Tuple

import requests

# API_URL = "https://api.oeus-kraken.energy/v1/graphql/" # prod
API_URL = "https://api.oeus-kraken.systems/v1/graphql/"  # test


class OctopusAPIError(Exception):
    pass


def setup_authenticated_request(
    email: str,
    password: str,
    refresh_token: Optional[str] = None,
) -> dict:
    mutation = """
    mutation getKrakenToken($input:ObtainJSONWebTokenInput!) {
          obtainKrakenToken(input: $input) {
            token
            refreshToken
          }
        }
    """

    if refresh_token:
        variables = {"input": {"refreshToken": refresh_token}}
    else:
        variables = {"input": {"email": email, "password": password}}

    session = requests.Session()
    response = session.post(
        url=API_URL, json={"query": mutation, "variables": variables}
    )

    if response.status_code == 200:
        json_response = response.json()

        if "errors" in json_response:
            raise OctopusAPIError(json_response["errors"][0]["message"])
        else:
            jwt_token = json_response["data"]["obtainKrakenToken"]["token"]
            return {"Authorization": f"JWT {jwt_token}"}

    raise OctopusAPIError("Failed to receive a token.")

QUERY = """
    query creditCheckStatus($accountNumber: String!) {
        creditCheckStatus(accountNumber: $accountNumber) {
            status
        }
    }
"""

VARIABLES = {
  "accountNumber":"A-12345"
}

session = requests.Session()

# Authenticate as an account user.
headers = setup_authenticated_request(
    email="ADD_EMAIL_HERE", password="ADD_PASSWORD_HERE"
)

session.headers.update(headers)

response = session.post(url=API_URL, json={"query": QUERY, "variables": VARIABLES})
pprint.pprint(response.json())
1
2
3
4
5
6
7
{
    "data": {
        "creditCheckStatus": {
          "status": PASSED
        }
    }
}
Back to top