Documentation
¶
Overview ¶
Package ramp provides a production-grade Go client for the Ramp Developer API v1.
Quick Start ¶
client, err := ramp.New(ramp.Config{
ClientID: os.Getenv("RAMP_CLIENT_ID"),
ClientSecret: os.Getenv("RAMP_CLIENT_SECRET"),
Scopes: []string{"transactions:read", "cards:read", "users:read"},
})
if err != nil {
log.Fatal(err)
}
// Paginate all SYNC_READY transactions
iter := client.Transactions.List(ctx, transaction.ListParams{
SyncStatus: ramp.Ptr(transaction.SyncStatusSyncReady),
})
for iter.Next(ctx) {
txn := iter.Item()
fmt.Println(txn.ID, txn.Amount)
}
if err := iter.Err(); err != nil {
log.Fatal(err)
}
Package ramp re-exports shared types for consumer convenience. Consumers can use ramp.Money, ramp.SyncStatus etc. directly.
Index ¶
- Constants
- func IsAuth(err error) bool
- func IsNotFound(err error) bool
- func IsRateLimit(err error) bool
- func IsValidation(err error) bool
- func Ptr[T any](v T) *T
- type AccountingFieldSelection
- type Address
- type Client
- type Config
- type DeferredTaskRef
- type DeferredTaskStatus
- type Error
- type ErrorType
- type ListParams
- type Money
- type Page
- type PagedResponse
- type PolicyViolation
- type SyncStatus
Constants ¶
const ( ErrorTypeAuthentication = shared.ErrorTypeAuthentication ErrorTypeAuthorization = shared.ErrorTypeAuthorization ErrorTypeNotFound = shared.ErrorTypeNotFound ErrorTypeValidation = shared.ErrorTypeValidation ErrorTypeRateLimit = shared.ErrorTypeRateLimit ErrorTypeServer = shared.ErrorTypeServer ErrorTypeTimeout = shared.ErrorTypeTimeout ErrorTypeNetwork = shared.ErrorTypeNetwork ErrorTypeDeferred = shared.ErrorTypeDeferred ErrorTypeUnknown = shared.ErrorTypeUnknown )
const ( // DefaultBaseURL is the Ramp production API base URL. DefaultBaseURL = "https://api.ramp.com" // SandboxBaseURL is the Ramp sandbox API base URL. SandboxBaseURL = "https://demo-api.ramp.com" )
const ( SyncStatusNotReady = shared.SyncStatusNotReady SyncStatusSyncReady = shared.SyncStatusSyncReady SyncStatusSynced = shared.SyncStatusSynced SyncStatusFailed = shared.SyncStatusFailed )
const ( DeferredTaskStarted = shared.DeferredTaskStarted DeferredTaskInProgress = shared.DeferredTaskInProgress DeferredTaskSuccess = shared.DeferredTaskSuccess DeferredTaskError = shared.DeferredTaskError )
Variables ¶
This section is empty.
Functions ¶
func IsNotFound ¶
IsNotFound reports whether err is a Ramp 404 error.
func IsRateLimit ¶
IsRateLimit reports whether err is a Ramp 429 rate-limit error.
func IsValidation ¶
IsValidation reports whether err is a Ramp 400 validation error.
Types ¶
type AccountingFieldSelection ¶
type AccountingFieldSelection = shared.AccountingFieldSelection
AccountingFieldSelection represents a selected accounting dimension value.
type Client ¶
type Client struct {
// Accounting manages GL accounts, custom fields, sync operations, and ERP connections.
Accounting *accounting.Service
// AuditLogs provides read access to the audit event log.
AuditLogs *auditlog.Service
// Bills manages the accounts-payable bill lifecycle.
Bills *bill.Service
// Business provides read access to the business entity.
Business *business.Service
// Cards manages virtual and physical card issuance and lifecycle.
Cards *card.Service
// Cashbacks provides read access to cashback records.
Cashbacks *cashback.Service
// Departments manages department CRUD.
Departments *department.Service
// Limits manages spend controls (limits) CRUD and termination.
Limits *limit.Service
// Locations manages location CRUD.
Locations *location.Service
// Merchants provides read access to merchant records.
Merchants *merchant.Service
// Reimbursements provides read access to reimbursement records.
Reimbursements *reimbursement.Service
// SpendPrograms provides read access to spend program records.
SpendPrograms *spendprogram.Service
// Statements provides read access to billing statements.
Statements *statement.Service
// Transactions manages transaction reads and field updates.
Transactions *transaction.Service
// Users manages user CRUD, invitation lifecycle, and activation.
Users *user.Service
// Vendors provides read access to vendor records.
Vendors *vendor.Service
// Webhooks manages webhook registration CRUD.
Webhooks *webhook.Service
// contains filtered or unexported fields
}
Client is the root Ramp API client. All resource namespaces are fields. Client is safe for concurrent use by multiple goroutines.
func New ¶
New constructs a new Ramp client using the client_credentials OAuth2 flow. The client fetches and caches tokens automatically, refreshing before expiry.
func NewWithToken ¶
NewWithToken constructs a Ramp client with a pre-obtained access token. Useful for CLI tools, testing, or when managing token storage externally.
func (*Client) ExchangeAuthCode ¶
ExchangeAuthCode exchanges an OAuth2 authorization code for an access token. Use this for the partner / multi-tenant authorization_code flow.
type Config ¶
type Config struct {
// ClientID is the OAuth2 client ID. Required.
ClientID string
// ClientSecret is the OAuth2 client secret. Required.
ClientSecret string
// Scopes is the list of OAuth2 scopes to request.
Scopes []string
// BaseURL overrides the default production API URL.
// Use ramp.SandboxBaseURL for sandbox testing.
BaseURL string
// HTTPTimeout is the per-request HTTP timeout (default: 30s).
HTTPTimeout time.Duration
// MaxRetries is the maximum number of retry attempts on transient errors (default: 3).
MaxRetries int
// RetryBaseDelay is the base delay for exponential backoff (default: 500ms).
RetryBaseDelay time.Duration
// Logger is an optional structured logger. Defaults to slog.Default().
Logger *slog.Logger
}
Config holds all configuration options for the Ramp client.
type DeferredTaskRef ¶
type DeferredTaskRef = shared.DeferredTaskRef
DeferredTaskRef holds the ID of a submitted deferred task.
type DeferredTaskStatus ¶
type DeferredTaskStatus = shared.DeferredTaskStatus
DeferredTaskStatus is the execution state of an asynchronous deferred operation.
type ListParams ¶
type ListParams = shared.ListParams
ListParams is the base struct for paginated list requests.
type PagedResponse ¶
PagedResponse is the generic envelope for all list endpoints. Note: this is a concrete re-declaration, not an alias, for Go 1.22 compatibility.
type PolicyViolation ¶
type PolicyViolation = shared.PolicyViolation
PolicyViolation represents a policy rule that was violated on a transaction.
type SyncStatus ¶
type SyncStatus = shared.SyncStatus
SyncStatus is the ERP sync state for a syncable object.
Directories
¶
| Path | Synopsis |
|---|---|
|
domain
|
|
|
accounting
Package accounting provides the Ramp Accounting domain service.
|
Package accounting provides the Ramp Accounting domain service. |
|
auditlog
Package auditlog provides the Ramp Audit Logs domain service.
|
Package auditlog provides the Ramp Audit Logs domain service. |
|
bill
Package bill provides the Ramp Bills (Accounts Payable) domain service.
|
Package bill provides the Ramp Bills (Accounts Payable) domain service. |
|
business
Package business provides the Ramp Business domain service.
|
Package business provides the Ramp Business domain service. |
|
card
Package card provides the Ramp Cards domain service.
|
Package card provides the Ramp Cards domain service. |
|
cashback
Package cashback provides the Ramp Cashbacks domain service.
|
Package cashback provides the Ramp Cashbacks domain service. |
|
department
Package department provides the Ramp Departments domain service.
|
Package department provides the Ramp Departments domain service. |
|
entity
Package entity provides the Ramp Entities domain service.
|
Package entity provides the Ramp Entities domain service. |
|
limit
Package limit provides the Ramp Limits (Spend Controls) domain service.
|
Package limit provides the Ramp Limits (Spend Controls) domain service. |
|
location
Package location provides the Ramp Locations domain service.
|
Package location provides the Ramp Locations domain service. |
|
merchant
Package merchant provides the Ramp Merchants domain service.
|
Package merchant provides the Ramp Merchants domain service. |
|
reimbursement
Package reimbursement provides the Ramp Reimbursements domain service.
|
Package reimbursement provides the Ramp Reimbursements domain service. |
|
spendprogram
Package spendprogram provides the Ramp Spend Programs domain service.
|
Package spendprogram provides the Ramp Spend Programs domain service. |
|
statement
Package statement provides the Ramp Statements domain service.
|
Package statement provides the Ramp Statements domain service. |
|
transaction
Package transaction provides the Ramp Transactions domain service.
|
Package transaction provides the Ramp Transactions domain service. |
|
user
Package user provides the Ramp Users domain service.
|
Package user provides the Ramp Users domain service. |
|
vendor
Package vendor provides the Ramp Vendors domain service.
|
Package vendor provides the Ramp Vendors domain service. |
|
webhook
Package webhook provides the Ramp Webhooks domain service.
|
Package webhook provides the Ramp Webhooks domain service. |
|
internal
|
|
|
httpclient
Package httpclient provides the HTTP transport layer for the Ramp SDK.
|
Package httpclient provides the HTTP transport layer for the Ramp SDK. |
|
oauth
Package oauth implements OAuth 2.0 token management for the Ramp API.
|
Package oauth implements OAuth 2.0 token management for the Ramp API. |
|
pagination
Package pagination provides a generic cursor-based page iterator.
|
Package pagination provides a generic cursor-based page iterator. |
|
poller
Package poller implements async deferred-task polling for the Ramp API.
|
Package poller implements async deferred-task polling for the Ramp API. |
|
Package shared contains value types shared across all ramp-go packages.
|
Package shared contains value types shared across all ramp-go packages. |
|
Package testutil provides test helpers, mock HTTP servers, and fixtures for unit testing the ramp-go SDK without real API calls.
|
Package testutil provides test helpers, mock HTTP servers, and fixtures for unit testing the ramp-go SDK without real API calls. |
|
Package webhooks provides HMAC-SHA256 webhook signature verification and typed event dispatch for Ramp webhook payloads.
|
Package webhooks provides HMAC-SHA256 webhook signature verification and typed event dispatch for Ramp webhook payloads. |