This repository has been archived by the owner on Dec 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Migrate from lago‐ruby‐client
Vincent Pochet edited this page Sep 1, 2023
·
4 revisions
gem 'lago-ruby-client'
becomes:
gem 'lago_ruby'
require 'lago-ruby-client'
client = Lago::Api::Client.new({api_key: '__YOUR_API_KEY__'})
must be replaced by one of:
require 'lago_ruby'
LagoAPI.configure do |config|
config.access_token = '__YOUR_API_KEY__'
# NOTE: if using a self hosted lago instance
config.host = 'your-base-url.com'
end
require 'lago_ruby'
lago_config = LagoAPI::Configuration.new
lago_config.access_token = '__YOUR_API_KEY__'
# NOTE: if using a self hosted lago instance
lago_config.host = 'your-base-url.com'
client.events.create(
transaction_id: "__UNIQUE_ID__",
external_customer_id: "__CUSTOMER_ID__",
external_subscription_id: "__SUBSCRIPTION_ID__",
code: "__BILLABLE_METRIC_CODE__",
timestamp: Time.now.to_i,
properties: {
custom_field: 12
}
)
must be replaced by:
api_instance = LagoAPI::EventsApi.new
# Optionaly
client = LagoAPI::ApiClient.new(config)
api_instance = LagoAPI::EventsApi.new(client)
# Init the event payload
event_input = LagoAPI::EventInput.new(
event: LagoAPI::EventInputEvent.new(
transaction_id: "transaction_1234567890",
external_customer_id: "__CUSTOMER_ID__",
external_subscription_id: "__SUBSCRIPTION_ID__",
code: "__BILLABLE_METRIC_CODE__",
timestamp: Time.now.to_i,
properties: { custom_field: 12 }
)
)
begin
api_instance.create_event(event_input)
rescue LagoAPI::ApiError => e
# Handle error
end
Check the API endpoints documentation to migrate other API call.