Customers
Customers — methods, parameters, and examples for easy-sdk (gem).
A Customer is the identity Easy Labs uses to associate payment
instruments, orders, subscriptions, and wallets. Most resources accept
either a customer-shaped payload inline or an identity_id referencing a
previously created customer.
Accessed via client.customers.
Methods
create(**body)
POST /customer. Body is a hash of customer fields — at minimum email,
first_name, last_name.
customer = client.customers.create(
first_name: "Ada",
last_name: "Lovelace",
email: "ada@example.com"
)update(id, **body)
PATCH /customer/:id. Pass only the fields you want to change.
client.customers.update(customer[:id], phone: "+15555550100")retrieve(id)
GET /customer/:id.
client.customers.retrieve("cust_…")list(limit: nil, offset: nil, ids: nil)
GET /customer. Standard pagination keywords (see Pagination).
page = client.customers.list(limit: 50)
page = client.customers.list(ids: ["cust_a", "cust_b"])payment_instruments(id)
GET /customer/:id/instruments. Every payment instrument tokenised
against this customer.
client.customers.payment_instruments("cust_…")orders(id, limit: nil, offset: nil, ids: nil)
GET /customer/:id/orders.
client.customers.orders("cust_…", limit: 25)subscriptions(id, status: nil, limit: nil, offset: nil, ids: nil)
GET /customer/:id/subscriptions. Optional status: filter
(active, paused, canceled, …).
client.customers.subscriptions("cust_…", status: "active")wallets(id, limit: nil, offset: nil, ids: nil)
GET /customer/:id/wallets. Crypto wallet records associated with the
customer.
client.customers.wallets("cust_…")Object shape
The response is a Ruby Hash with symbol keys mirroring the API
payload — :id, :first_name, :last_name, :email, :phone,
:created_at, :updated_at, :tags, …
See the API reference for the canonical schema; the SDK passes payloads through as-is.
Examples
Create or update by email
def upsert_customer(client, email:, **fields)
existing = client.customers.list(limit: 1).dig(:data, 0) # filter on email server-side when supported
if existing && existing[:email] == email
client.customers.update(existing[:id], **fields)
else
client.customers.create(email: email, **fields)
end
endList active subscriptions for a customer
client.customers
.subscriptions("cust_…", status: "active")
.fetch(:data, [])
.each { |sub| puts "#{sub[:id]} — #{sub[:plan_name]}" }Walk every customer
offset = 0
loop do
page = client.customers.list(limit: 100, offset: offset)
rows = page[:data] || []
rows.each { |c| puts c[:email] }
break if rows.size < 100
offset += rows.size
end