Base entity module for all Razorpay resources.
This module provides the foundation for all Razorpay resource structs, similar to how Ruby SDK uses inheritance for entities.
Summary
Functions
Lists entities for a given resource type.
Dynamically creates a struct for a given entity type.
Fetches an entity by ID for a given resource type.
Creates an entity struct from a map.
Converts an entity to a map, filtering out nil values.
Types
Functions
@spec all(atom(), map()) :: {:ok, [struct()]} | {:error, RazorpayEx.Error.t()}
Lists entities for a given resource type.
Similar to Ruby SDK's class.all method.
Dynamically creates a struct for a given entity type.
This mimics Ruby SDK's dynamic class creation based on entity names.
Examples
RazorpayEx.Entity.build("payment", %{"id" => "pay_123", "amount" => 5000})
@spec fetch(String.t(), atom()) :: {:ok, struct()} | {:error, RazorpayEx.Error.t()}
Fetches an entity by ID for a given resource type.
Similar to Ruby SDK's instance.fetch method.
Creates an entity struct from a map.
Examples
RazorpayEx.Entity.from_map(%{"id" => "pay_123", "entity" => "payment"})
Converts an entity to a map, filtering out nil values.