vihaya-events 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +527 -61
- data/lib/vihaya/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2cf2e4426f093da66a4a1e774e526bb9c0344bb947a51d1ac8aaf092ebf19915
|
|
4
|
+
data.tar.gz: 2b51e967d193f5d0c6d2e162d5f8fb4fa48a05f89ae7b754c5defbdefab4d085
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 33f73e1555cfe6fdce8621fde104dee4c3dde06fc2150f53127e4f98bea768402b278b57fc23897e0ff59aee36a8a37c8cf8e75a7425081c3d7f6451179e23f5
|
|
7
|
+
data.tar.gz: 2441c05ee26e601ef990d2154f9c93532c2fbce8adad2e5adbc0b35912f0f9d1174c9e06cefedead5b3648c5c5b31cfe2633e77a08844d3b632acec7f194aa4d
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## 0.1.1 — 2026-04-11
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
- Expanded `README.md` into a comprehensive long-form guide with framework
|
|
9
|
+
integration examples (Rails, Sinatra, Sidekiq, Hanami, CLI), full API
|
|
10
|
+
reference, mega events / sub-events guide, Razorpay payment flow, security
|
|
11
|
+
best practices, FAQ, and cross-links to all seven Vihaya SDKs.
|
|
12
|
+
|
|
13
|
+
No code changes — this is a documentation-only release.
|
|
14
|
+
|
|
5
15
|
## 0.1.0 — 2026-04-08
|
|
6
16
|
|
|
7
17
|
First public release on RubyGems.
|
data/README.md
CHANGED
|
@@ -1,131 +1,478 @@
|
|
|
1
|
-
# Vihaya
|
|
1
|
+
# Vihaya SDK for Ruby — Official `vihaya-events` Gem
|
|
2
2
|
|
|
3
3
|
[](https://rubygems.org/gems/vihaya-events)
|
|
4
|
+
[](https://rubygems.org/gems/vihaya-events)
|
|
4
5
|
[](LICENSE)
|
|
6
|
+
[](https://www.ruby-lang.org/)
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
Built on the Ruby standard library (`net/http` + `json`) with **zero runtime
|
|
8
|
-
dependencies**, and feature parity with the JavaScript, Flutter, and Python
|
|
9
|
-
SDKs.
|
|
8
|
+
> **`vihaya-events`** is the official Ruby SDK for the **[Vihaya Events](https://vihaya.app)** platform. Build event listings, attendee registration flows, Razorpay payment verification, ticketing dashboards, Rails apps, Sinatra apps, Hanami services, Sidekiq background jobs, and CLI tools — all with idiomatic Ruby ergonomics and **zero runtime dependencies**.
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
**Vihaya** is the modern events platform for India — a single stack for event organisers, ticketing, sponsor management, attendee registration, live check-in, and real-time analytics. This gem is the fastest way to integrate the Vihaya Events API (`https://events.vihaya.app`) into any Ruby 3.0+ codebase.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Table of contents
|
|
15
|
+
|
|
16
|
+
- [What is Vihaya?](#-what-is-vihaya)
|
|
17
|
+
- [Why the Vihaya Ruby SDK?](#-why-the-vihaya-ruby-sdk)
|
|
18
|
+
- [The Vihaya SDK family](#-the-vihaya-sdk-family-7-languages)
|
|
19
|
+
- [Installation](#-installation)
|
|
20
|
+
- [Get your Vihaya API key](#-get-your-vihaya-api-key)
|
|
21
|
+
- [Quick start](#-quick-start)
|
|
22
|
+
- [Configuration](#-configuration)
|
|
23
|
+
- [Core concepts](#-core-concepts)
|
|
24
|
+
- [Usage guide](#-usage-guide)
|
|
25
|
+
- [Framework integrations](#-framework-integrations)
|
|
26
|
+
- [Mega events & sub-events](#-mega-events--sub-events)
|
|
27
|
+
- [Razorpay payment flow](#-razorpay-payment-flow)
|
|
28
|
+
- [API reference](#-api-reference)
|
|
29
|
+
- [Error handling](#-error-handling)
|
|
30
|
+
- [Security best practices](#-security-best-practices)
|
|
31
|
+
- [FAQ](#-faq)
|
|
32
|
+
- [Keywords](#-keywords)
|
|
33
|
+
- [Development](#-development)
|
|
34
|
+
- [Contributing](#-contributing)
|
|
35
|
+
- [License](#-license)
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 🇮🇳 What is Vihaya?
|
|
40
|
+
|
|
41
|
+
**Vihaya** is an all-in-one events platform for India, built for organisers who run college fests, hackathons, conferences, workshops, meetups, bootcamps, summits, and corporate events. The Vihaya platform provides:
|
|
42
|
+
|
|
43
|
+
- 🎟️ **Event creation & ticketing** with pricing tiers, promo codes, and a hosted checkout.
|
|
44
|
+
- 🏢 **Mega events** — bundle dozens of sub-events under one parent fest.
|
|
45
|
+
- 💳 **Razorpay payments** — end-to-end with server-side signature verification.
|
|
46
|
+
- 📋 **Custom registration fields** — T-shirt size, college, team members, dietary preferences, accommodation.
|
|
47
|
+
- 👥 **Attendee management** — real-time registrations, broadcasts, CSV exports.
|
|
48
|
+
- 📱 **Live check-in** with mobile QR scanning.
|
|
49
|
+
- 👩🏫 **Speakers, agenda, sponsors, FAQs.**
|
|
50
|
+
- 📊 **Analytics** — registrations, revenue, funnel tracking.
|
|
51
|
+
|
|
52
|
+
This **`vihaya-events`** Ruby gem lets developers embed the Vihaya Events API into Rails apps, Sinatra microservices, Hanami projects, Sidekiq jobs, Jekyll plugins, Bridgetown sites, Pakyow apps, and any Ruby script.
|
|
53
|
+
|
|
54
|
+
Production URL: **`https://events.vihaya.app`** · Marketing site: **`https://vihaya.app`** · Developer dashboard: **`https://events.vihaya.app/profile/developer`**
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## ✨ Why the Vihaya Ruby SDK?
|
|
59
|
+
|
|
60
|
+
- **📦 Zero runtime dependencies** — built entirely on the Ruby standard library (`net/http` + `json`). No Faraday, no HTTParty, no Typhoeus, no transitive dependency tree to audit.
|
|
61
|
+
- **💎 Idiomatic Ruby** — snake_case everywhere, predicate methods (`event.mega_event?`, `sub.free?`), keyword arguments, blocks-friendly.
|
|
62
|
+
- **🪄 Tiny** — 10 tests, 44 assertions, runs in milliseconds against an in-process TCP stub server.
|
|
63
|
+
- **🔐 Type-safe-ish** — every response is a typed value object with attribute readers.
|
|
64
|
+
- **🧩 Rails ready** — drop into a Rails initializer or Sidekiq worker without ceremony.
|
|
65
|
+
- **🛡️ MFA-protected** — `rubygems_mfa_required = true` so every release is two-factor authenticated.
|
|
66
|
+
- **💳 Razorpay ready** — `vh.events.register` → Razorpay → `vh.payments.verify`.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## 🌍 The Vihaya SDK family (7 languages)
|
|
71
|
+
|
|
72
|
+
| Language | Package | Repository | Install |
|
|
73
|
+
| --- | --- | --- | --- |
|
|
74
|
+
| 💎 **Ruby** | [`vihaya-events`](https://rubygems.org/gems/vihaya-events) | [Vishnu252005/vihaya-sdk-ruby](https://github.com/Vishnu252005/vihaya-sdk-ruby) | `gem install vihaya-events` |
|
|
75
|
+
| 🟨 **JavaScript / TypeScript** | [`vihaya-sdk`](https://www.npmjs.com/package/vihaya-sdk) | [Vishnu252005/vihaya-sdk](https://github.com/Vishnu252005/vihaya-sdk) | `npm install vihaya-sdk` |
|
|
76
|
+
| 🐍 **Python** | [`vihaya-events`](https://pypi.org/project/vihaya-events/) | [Vishnu252005/vihaya-sdk-python](https://github.com/Vishnu252005/vihaya-sdk-python) | `pip install vihaya-events` |
|
|
77
|
+
| 🦫 **Go** | [`vihaya-sdk-go`](https://pkg.go.dev/github.com/Vishnu252005/vihaya-sdk-go) | [Vishnu252005/vihaya-sdk-go](https://github.com/Vishnu252005/vihaya-sdk-go) | `go get github.com/Vishnu252005/vihaya-sdk-go` |
|
|
78
|
+
| ☕ **Java** | [`vihaya-sdk-java`](https://jitpack.io/#Vishnu252005/vihaya-sdk-java) | [Vishnu252005/vihaya-sdk-java](https://github.com/Vishnu252005/vihaya-sdk-java) | JitPack / Gradle / Maven |
|
|
79
|
+
| 🐘 **PHP** | [`vihaya/events`](https://packagist.org/packages/vihaya/events) | [Vishnu252005/vihaya-sdk-php](https://github.com/Vishnu252005/vihaya-sdk-php) | `composer require vihaya/events` |
|
|
80
|
+
| 📱 **Flutter / Dart** | [`vihaya_sdk_flutter`](https://pub.dev/packages/vihaya_sdk_flutter) | [Vishnu252005/vihaya-sdk-flutter](https://github.com/Vishnu252005/vihaya-sdk-flutter) | `flutter pub add vihaya_sdk_flutter` |
|
|
81
|
+
|
|
82
|
+
All Vihaya SDKs target the same API base URL (`https://events.vihaya.app`), authenticate with the same `x-api-key` header, and expose the same methods.
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## 📦 Installation
|
|
87
|
+
|
|
88
|
+
Install the gem directly:
|
|
12
89
|
|
|
13
90
|
```bash
|
|
14
91
|
gem install vihaya-events
|
|
15
92
|
```
|
|
16
93
|
|
|
17
|
-
Or add it to your Gemfile
|
|
94
|
+
Or add it to your `Gemfile`:
|
|
18
95
|
|
|
19
96
|
```ruby
|
|
20
97
|
gem "vihaya-events"
|
|
21
98
|
```
|
|
22
99
|
|
|
23
|
-
|
|
100
|
+
Then run:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
bundle install
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Requirements:
|
|
107
|
+
|
|
108
|
+
- **Ruby 3.0, 3.1, 3.2, 3.3, 3.4+**
|
|
109
|
+
- No other dependencies — pure stdlib
|
|
110
|
+
|
|
111
|
+
Gem name: **`vihaya-events`**. Require path: **`vihaya`**.
|
|
112
|
+
|
|
113
|
+
```ruby
|
|
114
|
+
require "vihaya"
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## 🔑 Get your Vihaya API key
|
|
120
|
+
|
|
121
|
+
1. Sign up or log in at **[events.vihaya.app](https://events.vihaya.app)**.
|
|
122
|
+
2. Open the **[Developer Dashboard](https://events.vihaya.app/profile/developer)**.
|
|
123
|
+
3. Click **Generate API Key** and copy the `vh_live_...` token.
|
|
124
|
+
4. Store it in `ENV["VIHAYA_API_KEY"]`, Rails credentials, or a secrets manager — never commit it.
|
|
24
125
|
|
|
25
|
-
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## 🚀 Quick start
|
|
26
129
|
|
|
27
130
|
```ruby
|
|
28
131
|
require "vihaya"
|
|
29
132
|
|
|
30
|
-
vh = Vihaya::Client.new("
|
|
133
|
+
vh = Vihaya::Client.new(ENV.fetch("VIHAYA_API_KEY"))
|
|
31
134
|
|
|
32
135
|
vh.events.list.each do |event|
|
|
33
|
-
puts "#{event.title} — #{event.location}"
|
|
136
|
+
puts "#{event.title} — #{event.location} on #{event.date}"
|
|
137
|
+
end
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Register an attendee
|
|
141
|
+
|
|
142
|
+
```ruby
|
|
143
|
+
registration = Vihaya::RegisterData.new(
|
|
144
|
+
name: "Anjali Mehta",
|
|
145
|
+
email: "anjali@example.com",
|
|
146
|
+
phone: "+919820012345",
|
|
147
|
+
custom_fields: {
|
|
148
|
+
"T-Shirt Size" => "L",
|
|
149
|
+
"College" => "Vihaya Institute"
|
|
150
|
+
}
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
result = vh.events.register("evt_8x42j9", registration)
|
|
154
|
+
|
|
155
|
+
if result[:isPaid]
|
|
156
|
+
puts "Razorpay order: #{result[:orderId]}"
|
|
157
|
+
else
|
|
158
|
+
puts "Free registration: #{result[:registrationId]}"
|
|
34
159
|
end
|
|
35
160
|
```
|
|
36
161
|
|
|
37
|
-
|
|
162
|
+
### Verify a Razorpay payment
|
|
163
|
+
|
|
164
|
+
```ruby
|
|
165
|
+
vh.payments.verify(
|
|
166
|
+
payment_id: "pay_O8K2...",
|
|
167
|
+
order_id: result[:orderId],
|
|
168
|
+
signature: "signature_from_razorpay"
|
|
169
|
+
)
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
---
|
|
38
173
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
174
|
+
## ⚙️ Configuration
|
|
175
|
+
|
|
176
|
+
```ruby
|
|
177
|
+
vh = Vihaya::Client.new(
|
|
178
|
+
ENV.fetch("VIHAYA_API_KEY"),
|
|
179
|
+
base_url: "https://events.vihaya.app", # override for staging
|
|
180
|
+
headers: { "X-Trace-Id" => "abc123" },
|
|
181
|
+
timeout: 60 # seconds
|
|
182
|
+
)
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
| Option | Default | Description |
|
|
186
|
+
| --- | --- | --- |
|
|
187
|
+
| `api_key` (positional) | — | Required. Sent as `x-api-key`. |
|
|
188
|
+
| `base_url:` | `https://events.vihaya.app` | API base URL. Override for staging. |
|
|
189
|
+
| `headers:` | `{}` | Extra headers attached to every request. |
|
|
190
|
+
| `timeout:` | `30` | Per-request timeout in seconds. |
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## 🧭 Core concepts
|
|
195
|
+
|
|
196
|
+
- **Events** — the root record. Title, description, date, venue, tiers, custom fields, speakers, agenda, sponsors, FAQs, sub-events.
|
|
197
|
+
- **Mega events** — parent events containing sub-events. Detect with `event.mega_event?`, iterate via `event.sub_events`.
|
|
198
|
+
- **Registrations** — free or paid attendee entries with optional custom fields and team members.
|
|
199
|
+
- **Payments** — Razorpay orders created during `events.register`, verified via `payments.verify`.
|
|
200
|
+
- **API key** — `vh_live_...` token from the [developer dashboard](https://events.vihaya.app/profile/developer).
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## 📚 Usage guide
|
|
205
|
+
|
|
206
|
+
### Fetch a full event
|
|
42
207
|
|
|
43
208
|
```ruby
|
|
44
209
|
event = vh.events.get("evt_8x42j9")
|
|
45
210
|
|
|
46
211
|
puts event.title
|
|
47
212
|
puts "Mode: #{event.event_mode} Timezone: #{event.timezone}"
|
|
213
|
+
puts "Location: #{event.location}"
|
|
214
|
+
puts "Date: #{event.date} #{event.time}"
|
|
48
215
|
|
|
49
216
|
event.speaker_list.each do |speaker|
|
|
50
|
-
puts "- #{speaker.name} (#{speaker.role})"
|
|
217
|
+
puts "- #{speaker.name} (#{speaker.role}) @ #{speaker.company}"
|
|
51
218
|
end
|
|
52
219
|
|
|
53
220
|
event.agenda_list.each do |item|
|
|
54
221
|
puts "[#{item.time}] #{item.title}"
|
|
55
222
|
end
|
|
56
223
|
|
|
224
|
+
event.sponsors.each do |sponsor|
|
|
225
|
+
puts "#{sponsor.name} (#{sponsor.tier})"
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
event.faqs.each do |faq|
|
|
229
|
+
puts "Q: #{faq.question}\nA: #{faq.answer}\n\n"
|
|
230
|
+
end
|
|
231
|
+
|
|
57
232
|
event.special_prices.each do |tier|
|
|
58
233
|
puts " #{tier.name}: ₹#{tier.amount}"
|
|
59
234
|
end
|
|
235
|
+
|
|
236
|
+
event.custom_fields.each do |field|
|
|
237
|
+
puts " #{field.name} [#{field.type}] required=#{field.required}"
|
|
238
|
+
end
|
|
60
239
|
```
|
|
61
240
|
|
|
62
|
-
###
|
|
241
|
+
### List & filter events
|
|
242
|
+
|
|
243
|
+
```ruby
|
|
244
|
+
events = vh.events.list
|
|
63
245
|
|
|
64
|
-
|
|
65
|
-
|
|
246
|
+
upcoming = events.select { |e| Date.parse(e.date) > Date.today }
|
|
247
|
+
mega = events.select(&:mega_event?)
|
|
248
|
+
free = events.select(&:free?)
|
|
249
|
+
online = events.select { |e| e.event_mode == "online" }
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### Register with tiers, promo codes, and custom fields
|
|
66
253
|
|
|
67
254
|
```ruby
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
255
|
+
data = Vihaya::RegisterData.new(
|
|
256
|
+
name: "Priya Raj",
|
|
257
|
+
email: "priya@example.com",
|
|
258
|
+
phone: "+919820012345",
|
|
259
|
+
tier: "Early Bird",
|
|
260
|
+
promo_code: "LAUNCH10",
|
|
261
|
+
custom_fields: {
|
|
262
|
+
"College" => "IIT Bombay",
|
|
263
|
+
"T-Shirt Size" => "M",
|
|
264
|
+
"Year of Study" => "3rd"
|
|
265
|
+
}
|
|
266
|
+
)
|
|
267
|
+
|
|
268
|
+
vh.events.register("evt_conf_2026", data)
|
|
74
269
|
```
|
|
75
270
|
|
|
76
|
-
|
|
271
|
+
### Register a hackathon team
|
|
77
272
|
|
|
78
273
|
```ruby
|
|
79
|
-
|
|
80
|
-
name:
|
|
81
|
-
email: "
|
|
274
|
+
result = vh.events.register("evt_hackathon_2026",
|
|
275
|
+
name: "Team Lead",
|
|
276
|
+
email: "lead@example.com",
|
|
82
277
|
phone: "+919820012345",
|
|
83
|
-
|
|
278
|
+
teamName: "Byte Squad",
|
|
279
|
+
teamMembers: [
|
|
280
|
+
{ name: "Alice", email: "alice@example.com", phone: "+91..." },
|
|
281
|
+
{ name: "Bob", email: "bob@example.com", phone: "+91..." },
|
|
282
|
+
{ name: "Carol", email: "carol@example.com", phone: "+91..." }
|
|
283
|
+
]
|
|
84
284
|
)
|
|
285
|
+
```
|
|
85
286
|
|
|
86
|
-
|
|
287
|
+
You can pass a plain `Hash` instead of `RegisterData` — use camelCase keys for that path since the SDK sends it as-is.
|
|
87
288
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
## 🎨 Framework integrations
|
|
292
|
+
|
|
293
|
+
### Rails — initializer
|
|
294
|
+
|
|
295
|
+
```ruby
|
|
296
|
+
# config/initializers/vihaya.rb
|
|
297
|
+
require "vihaya"
|
|
298
|
+
|
|
299
|
+
VIHAYA = Vihaya::Client.new(Rails.application.credentials.vihaya[:api_key])
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### Rails — controller
|
|
303
|
+
|
|
304
|
+
```ruby
|
|
305
|
+
class EventsController < ApplicationController
|
|
306
|
+
def index
|
|
307
|
+
@events = VIHAYA.events.list
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
def show
|
|
311
|
+
@event = VIHAYA.events.get(params[:id])
|
|
312
|
+
rescue Vihaya::Error => e
|
|
313
|
+
redirect_to events_path, alert: e.message
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
def register
|
|
317
|
+
result = VIHAYA.events.register(
|
|
318
|
+
params[:id],
|
|
319
|
+
Vihaya::RegisterData.new(**registration_params)
|
|
320
|
+
)
|
|
321
|
+
render json: result
|
|
322
|
+
rescue Vihaya::Error => e
|
|
323
|
+
render json: { error: e.message }, status: e.status || 500
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
private
|
|
327
|
+
|
|
328
|
+
def registration_params
|
|
329
|
+
params.permit(:name, :email, :phone, custom_fields: {})
|
|
330
|
+
end
|
|
98
331
|
end
|
|
99
332
|
```
|
|
100
333
|
|
|
101
|
-
|
|
102
|
-
|
|
334
|
+
### Sinatra
|
|
335
|
+
|
|
336
|
+
```ruby
|
|
337
|
+
require "sinatra"
|
|
338
|
+
require "vihaya"
|
|
339
|
+
require "json"
|
|
103
340
|
|
|
104
|
-
|
|
341
|
+
vh = Vihaya::Client.new(ENV.fetch("VIHAYA_API_KEY"))
|
|
105
342
|
|
|
106
|
-
|
|
343
|
+
get "/events" do
|
|
344
|
+
content_type :json
|
|
345
|
+
vh.events.list.map(&:to_h).to_json
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
post "/events/:id/register" do
|
|
349
|
+
content_type :json
|
|
350
|
+
data = JSON.parse(request.body.read, symbolize_names: true)
|
|
351
|
+
vh.events.register(params[:id], Vihaya::RegisterData.new(**data)).to_json
|
|
352
|
+
end
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
### Sidekiq background job
|
|
107
356
|
|
|
108
357
|
```ruby
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
358
|
+
class ProcessRegistrationJob
|
|
359
|
+
include Sidekiq::Job
|
|
360
|
+
|
|
361
|
+
def perform(event_id, payload)
|
|
362
|
+
vh = Vihaya::Client.new(ENV.fetch("VIHAYA_API_KEY"))
|
|
363
|
+
vh.events.register(event_id, Vihaya::RegisterData.new(**payload.symbolize_keys))
|
|
364
|
+
end
|
|
365
|
+
end
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
### Hanami action
|
|
369
|
+
|
|
370
|
+
```ruby
|
|
371
|
+
module Web
|
|
372
|
+
module Actions
|
|
373
|
+
module Events
|
|
374
|
+
class Register < Web::Action
|
|
375
|
+
def handle(req, res)
|
|
376
|
+
vh = Vihaya::Client.new(ENV.fetch("VIHAYA_API_KEY"))
|
|
377
|
+
result = vh.events.register(req.params[:id], req.params.to_h)
|
|
378
|
+
res.body = result.to_json
|
|
379
|
+
end
|
|
380
|
+
end
|
|
381
|
+
end
|
|
382
|
+
end
|
|
383
|
+
end
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
### Standalone CLI script
|
|
387
|
+
|
|
388
|
+
```ruby
|
|
389
|
+
#!/usr/bin/env ruby
|
|
390
|
+
require "vihaya"
|
|
391
|
+
|
|
392
|
+
vh = Vihaya::Client.new(ENV.fetch("VIHAYA_API_KEY"))
|
|
393
|
+
|
|
394
|
+
vh.events.list.each do |event|
|
|
395
|
+
puts "#{event.title.ljust(40)} #{event.date} #{event.location}"
|
|
396
|
+
end
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
---
|
|
400
|
+
|
|
401
|
+
## 🏢 Mega events & sub-events
|
|
402
|
+
|
|
403
|
+
```ruby
|
|
404
|
+
fest = vh.events.get("evt_mega_fest_2026")
|
|
405
|
+
|
|
406
|
+
if fest.mega_event?
|
|
407
|
+
puts "#{fest.title} — #{fest.sub_events.size} sub-events"
|
|
408
|
+
|
|
409
|
+
fest.sub_events.each do |sub|
|
|
410
|
+
price = sub.free? ? "Free" : "₹#{sub.price}"
|
|
411
|
+
puts " - #{sub.title} (#{price})"
|
|
412
|
+
|
|
413
|
+
sub.custom_fields.each do |field|
|
|
414
|
+
puts " * #{field.name} [#{field.type}]"
|
|
415
|
+
end
|
|
416
|
+
end
|
|
114
417
|
end
|
|
115
418
|
```
|
|
116
419
|
|
|
117
|
-
|
|
420
|
+
Register for a specific sub-event:
|
|
421
|
+
|
|
422
|
+
```ruby
|
|
423
|
+
vh.events.register("evt_sub_workshop_ml",
|
|
424
|
+
Vihaya::RegisterData.new(
|
|
425
|
+
name: "Rahul",
|
|
426
|
+
email: "rahul@example.com",
|
|
427
|
+
phone: "+91..."
|
|
428
|
+
)
|
|
429
|
+
)
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
---
|
|
433
|
+
|
|
434
|
+
## 💳 Razorpay payment flow
|
|
435
|
+
|
|
436
|
+
1. **Backend** — `vh.events.register(id, data)` → Vihaya creates a Razorpay order and returns `:orderId`.
|
|
437
|
+
2. **Frontend** — launch Razorpay Checkout with that order ID.
|
|
438
|
+
3. **Razorpay callback** — hands back `razorpay_payment_id`, `razorpay_order_id`, `razorpay_signature`.
|
|
439
|
+
4. **Backend** — `vh.payments.verify(...)` confirms the signature and marks the registration paid.
|
|
440
|
+
|
|
441
|
+
```ruby
|
|
442
|
+
result = vh.events.register("evt_conf_2026",
|
|
443
|
+
Vihaya::RegisterData.new(
|
|
444
|
+
name: "Attendee",
|
|
445
|
+
email: "a@example.com",
|
|
446
|
+
phone: "+91..."
|
|
447
|
+
)
|
|
448
|
+
)
|
|
449
|
+
order_id = result[:orderId]
|
|
450
|
+
|
|
451
|
+
# Frontend: Razorpay Checkout with order_id ...
|
|
452
|
+
|
|
453
|
+
vh.payments.verify(
|
|
454
|
+
payment_id: razorpay_payment_id,
|
|
455
|
+
order_id: razorpay_order_id,
|
|
456
|
+
signature: razorpay_signature
|
|
457
|
+
)
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
> **⚠️ Always verify payments on the server.** Never trust a signature checked only in the browser.
|
|
461
|
+
|
|
462
|
+
---
|
|
463
|
+
|
|
464
|
+
## 📖 API reference
|
|
118
465
|
|
|
119
466
|
### `Vihaya::Client.new(api_key, base_url: ..., headers: {}, timeout: 30)`
|
|
120
467
|
|
|
121
|
-
The main client. `api_key` is required; everything else is keyword.
|
|
468
|
+
The main client. `api_key` is required and positional; everything else is keyword.
|
|
122
469
|
|
|
123
470
|
### `vh.events`
|
|
124
471
|
|
|
125
472
|
| Method | Returns | Description |
|
|
126
473
|
| --- | --- | --- |
|
|
127
474
|
| `list` | `Array<Vihaya::Event>` | All events on the authenticated account. |
|
|
128
|
-
| `get(event_id)` | `Vihaya::Event` | Full metadata for one event. |
|
|
475
|
+
| `get(event_id)` | `Vihaya::Event` | Full metadata for one event — tiers, custom fields, speakers, agenda, sponsors, FAQs, sub-events. |
|
|
129
476
|
| `register(event_id, data)` | `Hash` | Submit a registration. `data` can be `RegisterData` or `Hash`. |
|
|
130
477
|
|
|
131
478
|
### `vh.payments`
|
|
@@ -134,19 +481,138 @@ The main client. `api_key` is required; everything else is keyword.
|
|
|
134
481
|
| --- | --- | --- |
|
|
135
482
|
| `verify(payment_id:, order_id:, signature:, amount: nil)` | `Hash` | Server-side Razorpay signature verification. |
|
|
136
483
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
484
|
+
### Models (module `Vihaya`)
|
|
485
|
+
|
|
486
|
+
- `Vihaya::Event` — root event with all metadata + predicate methods (`mega_event?`, `free?`, `online?`)
|
|
487
|
+
- `Vihaya::Speaker`, `Vihaya::Sponsor`, `Vihaya::AgendaItem`, `Vihaya::FAQItem`, `Vihaya::Contact`
|
|
488
|
+
- `Vihaya::CustomField`, `Vihaya::SpecialPrice`, `Vihaya::PromoCode`
|
|
489
|
+
- `Vihaya::RegisterData` — registration payload with keyword constructor
|
|
490
|
+
- `Vihaya::Error` — raised on every API failure
|
|
491
|
+
|
|
492
|
+
---
|
|
493
|
+
|
|
494
|
+
## 🚨 Error handling
|
|
495
|
+
|
|
496
|
+
All API failures raise `Vihaya::Error` with the HTTP status and raw body:
|
|
497
|
+
|
|
498
|
+
```ruby
|
|
499
|
+
begin
|
|
500
|
+
vh.events.get("evt_does_not_exist")
|
|
501
|
+
rescue Vihaya::Error => e
|
|
502
|
+
puts "#{e.message} (status=#{e.status})"
|
|
503
|
+
puts e.data.inspect
|
|
504
|
+
|
|
505
|
+
case e.status
|
|
506
|
+
when 404 then puts "Not found"
|
|
507
|
+
when 401, 403 then puts "Auth error"
|
|
508
|
+
when 429 then puts "Rate limited"
|
|
509
|
+
end
|
|
510
|
+
end
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
---
|
|
514
|
+
|
|
515
|
+
## 🛡️ Security best practices
|
|
516
|
+
|
|
517
|
+
> **Never hard-code a `vh_live_...` key in code that ships to a client.**
|
|
518
|
+
|
|
519
|
+
- Use `ENV`, Rails encrypted credentials (`Rails.application.credentials.vihaya`), `dotenv`, or a secrets manager.
|
|
520
|
+
- Call `events.register` and `payments.verify` from backend code only.
|
|
521
|
+
- Always verify Razorpay signatures server-side.
|
|
522
|
+
- Rotate keys via the [Vihaya developer dashboard](https://events.vihaya.app/profile/developer) if you suspect a leak.
|
|
523
|
+
- Use separate keys for staging and production.
|
|
524
|
+
|
|
525
|
+
---
|
|
526
|
+
|
|
527
|
+
## ❓ FAQ
|
|
528
|
+
|
|
529
|
+
### What is Vihaya?
|
|
530
|
+
|
|
531
|
+
Vihaya is an events platform for India — ticketing, registrations, payments, check-in, analytics, and attendee management. Platform: [vihaya.app](https://vihaya.app). Dashboard: [events.vihaya.app](https://events.vihaya.app).
|
|
532
|
+
|
|
533
|
+
### Why does the gem name differ from the require path?
|
|
534
|
+
|
|
535
|
+
You install with `gem install vihaya-events` but require with `require "vihaya"`. The gem name reflects what it does on the platform; the require path is short and ergonomic.
|
|
536
|
+
|
|
537
|
+
### Does the SDK support Faraday / HTTParty / Typhoeus?
|
|
140
538
|
|
|
141
|
-
|
|
539
|
+
No — and that's intentional. Pure stdlib means no transitive dependencies, smaller install footprint, and no version conflicts with whatever HTTP library your Rails app already uses.
|
|
540
|
+
|
|
541
|
+
### Does it work with Sidekiq, Resque, GoodJob?
|
|
542
|
+
|
|
543
|
+
Yes — the client is just a Ruby object. Build it once at startup, share it across workers.
|
|
544
|
+
|
|
545
|
+
### Does Vihaya support Razorpay test mode?
|
|
546
|
+
|
|
547
|
+
Yes — use a test API key from the Vihaya developer dashboard.
|
|
548
|
+
|
|
549
|
+
### Can I pass a plain Hash instead of `RegisterData`?
|
|
550
|
+
|
|
551
|
+
Yes. `RegisterData` is a convenience wrapper. A plain Hash works too — just use camelCase keys (`teamMembers`, `customFields`, etc.) on that path.
|
|
552
|
+
|
|
553
|
+
---
|
|
554
|
+
|
|
555
|
+
## 🔎 Keywords
|
|
556
|
+
|
|
557
|
+
`vihaya` · `vihaya sdk` · `vihaya ruby` · `vihaya events` · `vihaya gem` · `vihaya-events` · `vihaya rails` · `vihaya sinatra` · `vihaya hanami` · `ruby events api` · `ruby ticketing gem` · `rails events sdk` · `ruby razorpay events` · `vihaya razorpay ruby` · `events api india ruby` · `event management gem` · `sidekiq vihaya` · `vihaya client ruby` · `rubygems vihaya` · `events.vihaya.app ruby` · `vihaya official ruby sdk`
|
|
558
|
+
|
|
559
|
+
---
|
|
560
|
+
|
|
561
|
+
## 🛠️ Development
|
|
142
562
|
|
|
143
563
|
```bash
|
|
144
564
|
git clone https://github.com/Vishnu252005/vihaya-sdk-ruby.git
|
|
145
565
|
cd vihaya-sdk-ruby
|
|
146
|
-
ruby test/test_client.rb
|
|
147
|
-
gem build vihaya-events.gemspec
|
|
566
|
+
ruby test/test_client.rb # Minitest suite (10 tests, 44 assertions)
|
|
567
|
+
gem build vihaya-events.gemspec # build the .gem file
|
|
148
568
|
```
|
|
149
569
|
|
|
150
|
-
|
|
570
|
+
The test suite uses an in-process TCP stub server — no Bundler, WebMock, or VCR required, no network calls.
|
|
571
|
+
|
|
572
|
+
> **Ruby version note:** the gemspec requires Ruby ≥ 3.0. Use `/opt/homebrew/opt/ruby/bin/ruby` on macOS — system Ruby (`/usr/bin/ruby` 2.6) is too old.
|
|
573
|
+
|
|
574
|
+
---
|
|
575
|
+
|
|
576
|
+
## 🤝 Contributing
|
|
577
|
+
|
|
578
|
+
Contributions to the Vihaya Ruby SDK are very welcome. The project is open source and MIT-licensed.
|
|
579
|
+
|
|
580
|
+
1. Fork [Vishnu252005/vihaya-sdk-ruby](https://github.com/Vishnu252005/vihaya-sdk-ruby).
|
|
581
|
+
2. Create a feature branch.
|
|
582
|
+
3. Run `ruby test/test_client.rb`.
|
|
583
|
+
4. Commit, push, and open a Pull Request.
|
|
584
|
+
|
|
585
|
+
### Reporting issues
|
|
586
|
+
|
|
587
|
+
Found a bug or have a feature request? Open an issue at [github.com/Vishnu252005/vihaya-sdk-ruby/issues](https://github.com/Vishnu252005/vihaya-sdk-ruby/issues).
|
|
588
|
+
|
|
589
|
+
---
|
|
590
|
+
|
|
591
|
+
## 📄 License
|
|
592
|
+
|
|
593
|
+
MIT © Vihaya. See [LICENSE](LICENSE).
|
|
594
|
+
|
|
595
|
+
---
|
|
596
|
+
|
|
597
|
+
## 💬 Support
|
|
598
|
+
|
|
599
|
+
- 📧 Email: **support@vihaya.app**
|
|
600
|
+
- 🌐 Website: **[vihaya.app](https://vihaya.app)**
|
|
601
|
+
- 🛠️ Dashboard: **[events.vihaya.app](https://events.vihaya.app)**
|
|
602
|
+
- 👨💻 Developer docs: **[events.vihaya.app/profile/developer/docs](https://events.vihaya.app/profile/developer/docs)**
|
|
603
|
+
- 💎 RubyGems: **[rubygems.org/gems/vihaya-events](https://rubygems.org/gems/vihaya-events)**
|
|
604
|
+
- 🐛 Issues: **[github.com/Vishnu252005/vihaya-sdk-ruby/issues](https://github.com/Vishnu252005/vihaya-sdk-ruby/issues)**
|
|
605
|
+
|
|
606
|
+
Built with ❤️ by the Vihaya team.
|
|
607
|
+
|
|
608
|
+
---
|
|
609
|
+
|
|
610
|
+
### Related Vihaya SDK repositories
|
|
151
611
|
|
|
152
|
-
|
|
612
|
+
- **Ruby:** [vihaya-sdk-ruby](https://github.com/Vishnu252005/vihaya-sdk-ruby) — *you are here*
|
|
613
|
+
- **JavaScript / TypeScript:** [vihaya-sdk](https://github.com/Vishnu252005/vihaya-sdk)
|
|
614
|
+
- **Python:** [vihaya-sdk-python](https://github.com/Vishnu252005/vihaya-sdk-python)
|
|
615
|
+
- **Go:** [vihaya-sdk-go](https://github.com/Vishnu252005/vihaya-sdk-go)
|
|
616
|
+
- **Java:** [vihaya-sdk-java](https://github.com/Vishnu252005/vihaya-sdk-java)
|
|
617
|
+
- **PHP:** [vihaya-sdk-php](https://github.com/Vishnu252005/vihaya-sdk-php)
|
|
618
|
+
- **Flutter:** [vihaya-sdk-flutter](https://github.com/Vishnu252005/vihaya-sdk-flutter)
|
data/lib/vihaya/version.rb
CHANGED