Ruby (using net/http)
Prerequisites
- ezePing API Key, available instantly after creating an account. You can copy it from here (opens in a new tab).
- Event Category Name is the category to which you want to send this event. If you haven't created an event category yet, you can create a new category here (opens in a new tab).
Payload
You can send any payload, as long as it is in a valid JSON format.
json
'fields': {
'amount': 50,
'plan': 'PRO',
'email': 'user@email.com'
}
Installation
Ruby
require 'net/http'
require 'uri'
require 'json'
url = URI.parse('https://www.ezeping.com/api/v1/events')
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
data = {
category: '<YOUR_CATEGORY_NAME>',
fields: {
field1: 'value1', # For example, user ID
field2: 'value2' # For example, user email
}
}
request = Net::HTTP::Post.new(url.path, {
'Authorization' => 'Bearer <YOUR_API_KEY>',
'Content-Type' => 'application/json'
})
request.body = data.to_json
response = http.request(request)
if response.code.to_i == 200
puts "Request was successful: #{response.body}"
else
puts "Request failed with status: #{response.code}"
end