0.0
The project is in a healthy, maintained state
A Ruby SDK for interacting with the Metrifox platform API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 2.8
~> 3.0
~> 3.0

Runtime

~> 2.0
~> 0.3
~> 0.12
 Project Readme

MetrifoxSDK Ruby Gem

A Ruby SDK for interacting with the Metrifox platform API.

Installation

Add this line to your application's Gemfile:

gem 'metrifox-sdk'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install metrifox-sdk

Usage

Configuration

require 'metrifox-sdk'

# Initialize with configuration
MetrifoxSDK.init({ api_key: "your-api-key"})

# Or set environment variable
ENV["METRIFOX_API_KEY"] = "your-api-key"
METRIFOX_SDK = MetrifoxSDK.init

Access Control

# Check feature access
response = METRIFOX_SDK.usages.check_access({
  feature_key: "premium_feature",
  customer_key: "customer_123"
})

puts response["can_access"] # true/false

Usage Tracking

# Record usage event
response = METRIFOX_SDK.usages.record_usage({
  customer_key: "customer_123",
  event_name: "api_call",
  amount: 1
})

Customer Management

# Create customer
customer_data = {
  customer_key: "customer_123",
  customer_type: "BUSINESS",
  primary_email: "customer@example.com",
  legal_name: "Acme Corp",
  display_name: "ACME"
}

response = METRIFOX_SDK.customers.create(customer_data)

# Update customer
update_data = {
  display_name: "ACME Corporation",
  website_url: "https://acme.com"
}

response = METRIFOX_SDK.customers.update("customer_123", update_data)

# Get customer
response = METRIFOX_SDK.customers.get_customer({ customer_key: "customer_123" })

# Get customer details
response = METRIFOX_SDK.customers.get_details({ customer_key: "customer_123" })

# List customers
response = MetrifoxSDK.customers.list

# List customers with pagination
response = MetrifoxSDK.customers.list({ page: 2, per_page: 10 })

# List customers with filters
response = MetrifoxSDK.customers.list({ 
  search_term: "TechStart",
  customer_type: "BUSINESS",
  date_created: "2025-09-01"
})

# List customers with combined pagination and filters
response = MetrifoxSDK.customers.list({ 
  page: 1,
  per_page: 5,
  search_term: "John",
  customer_type: "INDIVIDUAL"
})

# Delete customer
response = MetrifoxSDK.customers.delete_customer({ customer_key: "customer_123" })

CSV Upload

# Upload customers via CSV
response = METRIFOX_SDK.customers.upload_csv("/path/to/customers.csv")

puts response["data"]["total_customers"]
puts response["data"]["successful_upload_count"]

Using Client Instance

response = METRIFOX_SDK.usages.check_access({
  feature_key: "premium_feature",
  customer_key: "customer_123"
})

Type Safety with Structs

The SDK provides structured types for better type safety:

# Using structured request objects
access_request = MetrifoxSDK::Types::AccessCheckRequest.new(
  feature_key: "premium_feature",
  customer_key: "customer_123"
)

response = METRIFOX_SDK.usages.check_access(access_request)

# Customer creation with structured data
customer_request = MetrifoxSDK::Types::CustomerCreateRequest.new(
  customer_key: "customer_123",
  customer_type: MetrifoxSDK::Types::CustomerType::BUSINESS,
  primary_email: "customer@example.com",
  legal_name: "Acme Corp"
)

response = METRIFOX_SDK.customers.create(customer_request)

Error Handling

begin
  response = METRIFOX_SDK.usages.check_access({
    feature_key: "premium_feature",
    customer_key: "customer_123"
  })
rescue MetrifoxSDK::APIError => e
  puts "API Error: #{e.message}"
rescue MetrifoxSDK::ConfigurationError => e
  puts "Configuration Error: #{e.message}"
end

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/yourusername/metrifox_ruby_sdk.

License

The gem is available as open source under the terms of the MIT License.