Module: Booqable::Resources

Included in:
Client
Defined in:
lib/booqable/resources.rb

Overview

Resource-related methods for Client

This module dynamically defines methods for each resource listed in the ‘resources.json` file. Each resource method returns a ResourceProxy that provides standard CRUD operations for that resource type.

The resources.json file can contain either simple strings or hash mappings for aliases. For example:

This would define the following methods on Client:

  • ‘orders` - returns ResourceProxy for orders

  • ‘customers` - returns ResourceProxy for customers

  • ‘order_status_transitions` - returns ResourceProxy for order_status_transitions

  • ‘transitions` - alias for order_status_transitions

Examples:

resources.json structure

[
  "orders",
  "customers",
  { "order_status_transitions": "transitions" }
]

Using resource methods

client = Booqable::Client.new

# Access orders resource
orders = client.orders
all_orders = orders.list

# Access customers resource
customers = client.customers
customer = customers.find("123")

# Access order status transitions directly
order_status_transitions = client.order_status_transitions

# Access order status transitions with alias
transitions = client.transitions

See Also:

Constant Summary collapse

RESOURCES_FILE_PATH =

Path to the resources definition file

File.join(File.dirname(__FILE__), "resources.json")
ALL_RESOURCES =

All resources loaded from the resources.json file

JSON.parse(File.read(RESOURCES_FILE_PATH))