Documentation ¶
Index ¶
- Constants
- func GetLastMonth() (string, string)
- func NewHttpClient(logger tls_client.Logger) tls_client.HttpClient
- type ActionMap
- type CreateSecretKeyResponse
- type DailyCost
- type DashboardLoginResponse
- type DeleteSecretKeyResponse
- type GetAccessTokenRequest
- type GetAccessTokenResponse
- type GetSecretKeysResponse
- type Key
- type Org
- type Orgs
- type PaymentHistoryResponse
- type PaymentMethodResponse
- type Session
- type SubscriptionResponse
- type UsageResponse
- type User
- type UserClient
- func (u *UserClient) AccessToken() string
- func (u *UserClient) CreateSecretKey(name string) (CreateSecretKeyResponse, error)
- func (u *UserClient) DashboardOnBoarding() (DashboardLoginResponse, error)
- func (u *UserClient) DashboardSubscription() (SubscriptionResponse, error)
- func (u *UserClient) DeleteSecretKey(key Key) (DeleteSecretKeyResponse, error)
- func (u *UserClient) GetInvoices() (PaymentHistoryResponse, error)
- func (u *UserClient) GetSecretKeys() (GetSecretKeysResponse, error)
- func (u *UserClient) LastResponse() *http.Response
- func (u *UserClient) LoginWithAccessToken() (DashboardLoginResponse, error)
- func (u *UserClient) LoginWithAuth0(Username, Password string) error
- func (u *UserClient) Logout() error
- func (u *UserClient) PaymentHistory() (PaymentHistoryResponse, error)
- func (u *UserClient) PaymentMethod() (PaymentMethodResponse, error)
- func (u *UserClient) RawCheckPassword(state string, username string, password string) (string, int, error)
- func (u *UserClient) RawCheckUsername(state string, username string) (int, error)
- func (u *UserClient) RawDashboardLogin(AccessToken string) (string, int, error)
- func (u *UserClient) RawGetAccessToken(code string) (string, int, error)
- func (u *UserClient) RawGetAuthorizedUrl(csrfToken string) (string, int, error)
- func (u *UserClient) RawGetStateByAuthorizedUrl(authorizedUrl string) (string, int, error)
- func (u *UserClient) SessionKey() string
- func (u *UserClient) UsageWithSecretKey(sk, StartDate, EndDate string) (UsageResponse, error)
- func (u *UserClient) UsageWithSessionToken(StartDate, EndDate string) (UsageResponse, error)
- func (u *UserClient) WithCustomHttpClient(client tls_client.HttpClient) *UserClient
Constants ¶
View Source
const ( PlatformApiPrefix = "/platform" PlatformApiUrlPrefix = "https://api.openai.com" AuthorizationHeader = "Authorization" XAuthorizationHeader = "X-Authorization" ContentType = "application/x-www-form-urlencoded" UserAgent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36" Auth0Url = "https://auth0.openai.com" LoginUsernameUrl = Auth0Url + "/u/login/identifier?state=" LoginPasswordUrl = Auth0Url + "/u/login/password?state=" ParseUserInfoErrorMessage = "Failed to parse user login info." GetAuthorizedUrlErrorMessage = "Failed to get authorized url." GetStateErrorMessage = "Failed to get state." EmailInvalidErrorMessage = "Email is not valid." EmailOrPasswordInvalidErrorMessage = "Email or password is not correct." GetAccessTokenErrorMessage = "Failed to get access token." GetArkoseTokenErrorMessage = "Failed to get arkose token." EmailKey = "email" AccountDeactivatedErrorMessage = "Account %s is deactivated." ReadyHint = "Service go-chatgpt-api is ready." )
Variables ¶
This section is empty.
Functions ¶
func GetLastMonth ¶ added in v0.2.0
func NewHttpClient ¶
func NewHttpClient(logger tls_client.Logger) tls_client.HttpClient
Types ¶
type CreateSecretKeyResponse ¶
type DashboardLoginResponse ¶
type DeleteSecretKeyResponse ¶
type DeleteSecretKeyResponse struct {
Result string `json:"result"`
}
type GetAccessTokenRequest ¶
type GetAccessTokenResponse ¶
type GetSecretKeysResponse ¶
type Org ¶
type Org struct { Object string `json:"object"` ID string `json:"id"` Created int `json:"created"` Title string `json:"title"` Name string `json:"name"` Description interface{} `json:"description"` Personal bool `json:"personal"` IsDefault bool `json:"is_default"` Role string `json:"role"` Groups []interface{} `json:"groups"` }
type PaymentHistoryResponse ¶ added in v0.2.0
type PaymentHistoryResponse struct { Object string `json:"object"` Data []struct { Object string `json:"object"` ID string `json:"id"` Number string `json:"number"` AmountDue int `json:"amount_due"` AmountPaid int `json:"amount_paid"` Tax int `json:"tax"` TotalExcludingTax int `json:"total_excluding_tax"` Total int `json:"total"` Created int `json:"created"` PdfURL string `json:"pdf_url"` HostedInvoiceURL string `json:"hosted_invoice_url"` CollectionMethod string `json:"collection_method"` DueDate interface{} `json:"due_date"` Status string `json:"status"` } `json:"data"` }
type PaymentMethodResponse ¶ added in v0.2.0
type PaymentMethodResponse struct { Object string `json:"object"` Data []struct { Object string `json:"object"` ID string `json:"id"` Type string `json:"type"` Card struct { Brand string `json:"brand"` Last4 string `json:"last4"` ExpMonth int `json:"exp_month"` ExpYear int `json:"exp_year"` Country string `json:"country"` } `json:"card"` IsDefault bool `json:"is_default"` } `json:"data"` }
type SubscriptionResponse ¶ added in v0.2.0
type SubscriptionResponse struct { Object string `json:"object"` HasPaymentMethod bool `json:"has_payment_method"` Canceled bool `json:"canceled"` CanceledAt interface{} `json:"canceled_at"` Delinquent interface{} `json:"delinquent"` AccessUntil int `json:"access_until"` SoftLimit int `json:"soft_limit"` HardLimit int `json:"hard_limit"` SystemHardLimit int `json:"system_hard_limit"` SoftLimitUsd float64 `json:"soft_limit_usd"` HardLimitUsd float64 `json:"hard_limit_usd"` SystemHardLimitUsd float64 `json:"system_hard_limit_usd"` Plan struct { Title string `json:"title"` ID string `json:"id"` } `json:"plan"` Primary bool `json:"primary"` AccountName string `json:"account_name"` PoNumber interface{} `json:"po_number"` BillingEmail interface{} `json:"billing_email"` TaxIds interface{} `json:"tax_ids"` BillingAddress struct { City string `json:"city"` Line1 string `json:"line1"` Line2 string `json:"line2"` State string `json:"state"` Country string `json:"country"` PostalCode string `json:"postal_code"` } `json:"billing_address"` BusinessAddress interface{} `json:"business_address"` }
type UsageResponse ¶ added in v0.2.0
type User ¶
type User struct { Object string `json:"object"` ID string `json:"id"` Email string `json:"email"` Name string `json:"name"` Picture string `json:"picture"` Created int `json:"created"` Groups []interface{} `json:"groups"` Session Session `json:"session"` Orgs Orgs `json:"orgs"` IntercomHash string `json:"intercom_hash"` Amr []interface{} `json:"amr"` }
type UserClient ¶
type UserClient struct {
// contains filtered or unexported fields
}
func NewUserPlatformClient ¶
func NewUserPlatformClient(accessToken string) *UserClient
NewUserPlatformClient called NewHttpClient with log.
func (*UserClient) AccessToken ¶
func (u *UserClient) AccessToken() string
func (*UserClient) CreateSecretKey ¶
func (u *UserClient) CreateSecretKey(name string) (CreateSecretKeyResponse, error)
func (*UserClient) DashboardOnBoarding ¶
func (u *UserClient) DashboardOnBoarding() (DashboardLoginResponse, error)
func (*UserClient) DashboardSubscription ¶ added in v0.2.0
func (u *UserClient) DashboardSubscription() (SubscriptionResponse, error)
func (*UserClient) DeleteSecretKey ¶
func (u *UserClient) DeleteSecretKey(key Key) (DeleteSecretKeyResponse, error)
func (*UserClient) GetInvoices ¶ added in v0.2.0
func (u *UserClient) GetInvoices() (PaymentHistoryResponse, error)
func (*UserClient) GetSecretKeys ¶
func (u *UserClient) GetSecretKeys() (GetSecretKeysResponse, error)
func (*UserClient) LastResponse ¶ added in v0.2.0
func (u *UserClient) LastResponse() *http.Response
func (*UserClient) LoginWithAccessToken ¶
func (u *UserClient) LoginWithAccessToken() (DashboardLoginResponse, error)
func (*UserClient) LoginWithAuth0 ¶
func (u *UserClient) LoginWithAuth0(Username, Password string) error
func (*UserClient) Logout ¶
func (u *UserClient) Logout() error
func (*UserClient) PaymentHistory ¶ added in v0.2.0
func (u *UserClient) PaymentHistory() (PaymentHistoryResponse, error)
func (*UserClient) PaymentMethod ¶ added in v0.2.0
func (u *UserClient) PaymentMethod() (PaymentMethodResponse, error)
func (*UserClient) RawCheckPassword ¶ added in v0.2.0
func (*UserClient) RawCheckUsername ¶ added in v0.2.0
func (u *UserClient) RawCheckUsername(state string, username string) (int, error)
func (*UserClient) RawDashboardLogin ¶ added in v0.2.0
func (u *UserClient) RawDashboardLogin(AccessToken string) (string, int, error)
func (*UserClient) RawGetAccessToken ¶ added in v0.2.0
func (u *UserClient) RawGetAccessToken(code string) (string, int, error)
func (*UserClient) RawGetAuthorizedUrl ¶ added in v0.2.0
func (u *UserClient) RawGetAuthorizedUrl(csrfToken string) (string, int, error)
func (*UserClient) RawGetStateByAuthorizedUrl ¶ added in v0.2.0
func (u *UserClient) RawGetStateByAuthorizedUrl(authorizedUrl string) (string, int, error)
func (*UserClient) SessionKey ¶
func (u *UserClient) SessionKey() string
func (*UserClient) UsageWithSecretKey ¶ added in v0.2.0
func (u *UserClient) UsageWithSecretKey(sk, StartDate, EndDate string) (UsageResponse, error)
func (*UserClient) UsageWithSessionToken ¶ added in v0.2.0
func (u *UserClient) UsageWithSessionToken(StartDate, EndDate string) (UsageResponse, error)
func (*UserClient) WithCustomHttpClient ¶ added in v0.2.0
func (u *UserClient) WithCustomHttpClient(client tls_client.HttpClient) *UserClient
Source Files ¶
Click to show internal directories.
Click to hide internal directories.