signalhouse-sms 1.5.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 +7 -0
- data/Gemfile +5 -0
- data/README.md +286 -0
- data/lib/signalhouse_sms/client.rb +45 -0
- data/lib/signalhouse_sms/domains/agents.rb +598 -0
- data/lib/signalhouse_sms/domains/auth.rb +79 -0
- data/lib/signalhouse_sms/domains/billing.rb +111 -0
- data/lib/signalhouse_sms/domains/brands.rb +226 -0
- data/lib/signalhouse_sms/domains/campaigns.rb +315 -0
- data/lib/signalhouse_sms/domains/groups.rb +95 -0
- data/lib/signalhouse_sms/domains/landings.rb +115 -0
- data/lib/signalhouse_sms/domains/messages.rb +501 -0
- data/lib/signalhouse_sms/domains/notifications.rb +35 -0
- data/lib/signalhouse_sms/domains/numbers.rb +330 -0
- data/lib/signalhouse_sms/domains/onboarding.rb +63 -0
- data/lib/signalhouse_sms/domains/registrations.rb +140 -0
- data/lib/signalhouse_sms/domains/shortlinks.rb +44 -0
- data/lib/signalhouse_sms/domains/subgroups.rb +64 -0
- data/lib/signalhouse_sms/domains/subscriptions.rb +97 -0
- data/lib/signalhouse_sms/domains/templates.rb +155 -0
- data/lib/signalhouse_sms/domains/tickets.rb +65 -0
- data/lib/signalhouse_sms/domains/users.rb +99 -0
- data/lib/signalhouse_sms/domains/voice/analytics.rb +29 -0
- data/lib/signalhouse_sms/domains/voice/call_logs.rb +67 -0
- data/lib/signalhouse_sms/domains/voice/calls.rb +61 -0
- data/lib/signalhouse_sms/domains/voice/global_voice_settings.rb +41 -0
- data/lib/signalhouse_sms/domains/voice/number_routes.rb +63 -0
- data/lib/signalhouse_sms/domains/voice/programmable_voice_profiles.rb +126 -0
- data/lib/signalhouse_sms/domains/voice/sip_profiles.rb +112 -0
- data/lib/signalhouse_sms/domains/voice/sip_trunks.rb +91 -0
- data/lib/signalhouse_sms/domains/voice/tokens.rb +30 -0
- data/lib/signalhouse_sms/domains/voice.rb +42 -0
- data/lib/signalhouse_sms/domains/webhooks.rb +79 -0
- data/lib/signalhouse_sms/errors.rb +18 -0
- data/lib/signalhouse_sms/http_client.rb +193 -0
- data/lib/signalhouse_sms/version.rb +5 -0
- data/lib/signalhouse_sms.rb +30 -0
- data/signalhouse-sms.gemspec +23 -0
- metadata +84 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 7839cdbf04383a2e3e68cabdc8502b0b1e3afb2b4d453a22d36fda2b223d1074
|
|
4
|
+
data.tar.gz: 47256138b86018a0f440f20f2e27f917bc006ea210243d0c791c4b9aeaa4d62a
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: fb0aef43119826e3d3e52b7fc7ff4d34b09c83d885bed508e2037c1327ef25a2d89888e69d29ec71e8d1aba7dd5b033049087c2b351ce74c5a4c401d72fbcfad
|
|
7
|
+
data.tar.gz: b43758fe7f2e721ed11dbc98affa398380c155638fce3249d60b66b1523440e2f05ba8d61c71cbaed543ce4dfc8718bfbcc0dcb1eebf86fe60d0e28cddf55d33
|
data/Gemfile
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
# SignalHouse Ruby SDK
|
|
2
|
+
|
|
3
|
+
Official Ruby SDK for the [SignalHouse](https://signalhouse.io) SMS/MMS messaging API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add to your Gemfile:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem "signalhouse-sms"
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Then run:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
bundle install
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Or install directly:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
gem install signalhouse-sms
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
### Initialize the Client
|
|
28
|
+
|
|
29
|
+
```ruby
|
|
30
|
+
require "signalhouse_sms"
|
|
31
|
+
|
|
32
|
+
client = SignalHouseSms::Client.new(
|
|
33
|
+
api_key: "your-api-key",
|
|
34
|
+
base_url: "https://v2.signalhouse.io"
|
|
35
|
+
)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
For admin operations (SignalHouse internal staff):
|
|
39
|
+
|
|
40
|
+
```ruby
|
|
41
|
+
client = SignalHouseSms::Client.new(
|
|
42
|
+
api_key: "your-api-key",
|
|
43
|
+
base_url: "https://v2.signalhouse.io",
|
|
44
|
+
enable_admin: true
|
|
45
|
+
)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Login
|
|
49
|
+
|
|
50
|
+
```ruby
|
|
51
|
+
result = client.auth.login(email: "user@example.com", password: "password123")
|
|
52
|
+
|
|
53
|
+
if result["success"]
|
|
54
|
+
token = result["data"]["token"]
|
|
55
|
+
puts "Logged in! Token: #{token}"
|
|
56
|
+
else
|
|
57
|
+
puts "Login failed: #{result["error"]}"
|
|
58
|
+
end
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Send an SMS
|
|
62
|
+
|
|
63
|
+
```ruby
|
|
64
|
+
result = client.messages.send_sms(
|
|
65
|
+
sender_phone_number: "15551234567",
|
|
66
|
+
recipient_phone_numbers: ["15559876543"],
|
|
67
|
+
message_body: "Hello from SignalHouse!",
|
|
68
|
+
token: "your-jwt-token"
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
puts result
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Send an MMS with Images
|
|
75
|
+
|
|
76
|
+
```ruby
|
|
77
|
+
image_file = {
|
|
78
|
+
filename: "photo.jpg",
|
|
79
|
+
io: File.open("photo.jpg", "rb"),
|
|
80
|
+
content_type: "image/jpeg"
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
result = client.messages.send_mms(
|
|
84
|
+
sender_phone_number: "15551234567",
|
|
85
|
+
recipient_phone_numbers: ["15559876543"],
|
|
86
|
+
message_body: "Check out this photo!",
|
|
87
|
+
images: [image_file],
|
|
88
|
+
token: "your-jwt-token"
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
puts result
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### List Phone Numbers
|
|
95
|
+
|
|
96
|
+
```ruby
|
|
97
|
+
result = client.numbers.get_phone_numbers(
|
|
98
|
+
group_id: "G0000001",
|
|
99
|
+
page: 1,
|
|
100
|
+
limit: 20,
|
|
101
|
+
token: "your-jwt-token"
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
if result["success"]
|
|
105
|
+
result["data"]["data"].each do |number|
|
|
106
|
+
puts number["phoneNumber"]
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Purchase Phone Numbers
|
|
112
|
+
|
|
113
|
+
```ruby
|
|
114
|
+
result = client.numbers.purchase_phone_number(
|
|
115
|
+
phone_numbers: ["15551234567"],
|
|
116
|
+
subgroup_id: "SG000001",
|
|
117
|
+
token: "your-jwt-token"
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
puts result
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Create a Brand
|
|
124
|
+
|
|
125
|
+
```ruby
|
|
126
|
+
result = client.brands.create_brand(
|
|
127
|
+
brand_data: {
|
|
128
|
+
subgroupId: "SG000001",
|
|
129
|
+
entityType: "PRIVATE_PROFIT",
|
|
130
|
+
displayName: "My Brand",
|
|
131
|
+
companyName: "My Company Inc",
|
|
132
|
+
ein: "123456789",
|
|
133
|
+
phone: "15551234567",
|
|
134
|
+
street: "123 Main St",
|
|
135
|
+
city: "New York",
|
|
136
|
+
state: "NY",
|
|
137
|
+
postalCode: "10001",
|
|
138
|
+
country: "US",
|
|
139
|
+
email: "contact@mycompany.com",
|
|
140
|
+
vertical: "TECHNOLOGY"
|
|
141
|
+
},
|
|
142
|
+
token: "your-jwt-token"
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
puts result
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Check a Toll-Free Business Verification
|
|
149
|
+
|
|
150
|
+
When `required` is true and `status` is `NOT_STARTED`, submit the business verification with `submit_business_verification` before creating the group's first toll-free brand. Some groups verify each subgroup's business separately: a platform whose subgroups are separate businesses, set up by Signal House. For those groups `subgroup_id` is required, on both methods, and the response includes `subgroupId`.
|
|
151
|
+
|
|
152
|
+
```ruby
|
|
153
|
+
result = client.brands.get_business_verification(
|
|
154
|
+
group_id: "G0000001",
|
|
155
|
+
subgroup_id: "SG000001", # required when the group verifies each subgroup's business separately
|
|
156
|
+
token: "your-jwt-token"
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
if result["success"]
|
|
160
|
+
puts result["data"]["status"]
|
|
161
|
+
end
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Using Token Override
|
|
165
|
+
|
|
166
|
+
All methods accept a `token:` keyword to override the API key for that specific request. This is useful when making requests on behalf of authenticated users:
|
|
167
|
+
|
|
168
|
+
```ruby
|
|
169
|
+
# Use the client's api_key (default)
|
|
170
|
+
result = client.brands.get_brands
|
|
171
|
+
|
|
172
|
+
# Override with a specific user token
|
|
173
|
+
result = client.brands.get_brands(token: "user-jwt-token")
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Custom Headers
|
|
177
|
+
|
|
178
|
+
All methods accept a `headers:` keyword to add custom headers:
|
|
179
|
+
|
|
180
|
+
```ruby
|
|
181
|
+
result = client.brands.get_brands(
|
|
182
|
+
token: "user-jwt-token",
|
|
183
|
+
headers: { "X-Request-Id" => "abc123" }
|
|
184
|
+
)
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Admin Methods
|
|
188
|
+
|
|
189
|
+
When `enable_admin: true` is set, admin-scoped methods are available on domains that support them:
|
|
190
|
+
|
|
191
|
+
```ruby
|
|
192
|
+
client = SignalHouseSms::Client.new(
|
|
193
|
+
api_key: "admin-api-key",
|
|
194
|
+
base_url: "https://v2.signalhouse.io",
|
|
195
|
+
enable_admin: true
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
# Admin: list all groups
|
|
199
|
+
client.groups.admin.get_groups(page: 1, limit: 50, token: admin_token)
|
|
200
|
+
|
|
201
|
+
# Admin: approve a campaign
|
|
202
|
+
client.campaigns.admin.approve_campaign(campaign_id: "C123", token: admin_token)
|
|
203
|
+
|
|
204
|
+
# Admin: create subscription template
|
|
205
|
+
client.subscriptions.admin.create_template(
|
|
206
|
+
template_data: { templateName: "Pro Plan", monthlyFee: 50_000_000 },
|
|
207
|
+
token: admin_token
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
# Admin: create internal user
|
|
211
|
+
client.users.admin.create_internal_user(
|
|
212
|
+
data: { email: "admin@signalhouse.io", role: "signalhouse_admin" },
|
|
213
|
+
token: admin_token
|
|
214
|
+
)
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Available Domains
|
|
218
|
+
|
|
219
|
+
| Domain | Accessor | Methods |
|
|
220
|
+
|--------|----------|---------|
|
|
221
|
+
| Auth | `client.auth` | `login`, `reset_password`, `get_auth_history` |
|
|
222
|
+
| Billing | `client.billing` | `get_transaction_history`, `get_wallet`, `update_wallet`, `get_payment_methods`, `add_funds`, `add_payment_method`, `remove_payment_method`, `get_invoice_details`, `get_fees` |
|
|
223
|
+
| Brands | `client.brands` | `get_brands`, `get_external_vetting`, `create_brand`, `get_business_verification`, `submit_business_verification`, `get_toll_free_isv_account` (staff only), `set_toll_free_isv_account` (staff only), `transfer_brand`, `create_external_vetting`, `update_brand`, `revet_brand`, `delete_brand` |
|
|
224
|
+
| Campaigns | `client.campaigns` | `get_campaigns`, `create_campaign`, `update_campaign`, `delete_campaign` |
|
|
225
|
+
| Campaigns Admin | `client.campaigns.admin` | `approve_campaign`, `reject_campaign` |
|
|
226
|
+
| Groups | `client.groups` | `get_group`, `update_group` |
|
|
227
|
+
| Groups Admin | `client.groups.admin` | `get_groups`, `create_group`, `delete_group` |
|
|
228
|
+
| Landings | `client.landings` | `get_landings`, `get_public_landing`, `create_landing`, `update_landing`, `get_landing_by_brand_id`, `delete_landing` |
|
|
229
|
+
| Messages | `client.messages` | `get_messages`, `get_analytics`, `send_sms`, `send_mms`, `send_group_message`, `get_p2p_batch` |
|
|
230
|
+
| Notifications | `client.notifications` | `get_notifications`, `update_notification_status`, `delete_notification` |
|
|
231
|
+
| Numbers | `client.numbers` | `get_phone_numbers`, `get_number_health`, `get_available_phone_numbers`, `purchase_phone_number`, `update_phone_number`, `get_caller_name`, `set_caller_name`, `delete_caller_name`, `port_in_phone_number`, `assign_phone_number_to_campaign`, `unassign_phone_numbers_from_campaigns`, `delete_phone_numbers`, `transfer_phone_numbers`, `search_npa_nxx`, `lookup_locations` |
|
|
232
|
+
| Shortlinks | `client.shortlinks` | `get_shortlink_redirect`, `get_shortlink` |
|
|
233
|
+
| Subgroups | `client.subgroups` | `get_subgroups`, `create_subgroup`, `update_subgroup`, `delete_subgroup` |
|
|
234
|
+
| Subscriptions | `client.subscriptions` | `get_subscriptions`, `subscribe`, `unsubscribe` |
|
|
235
|
+
| Subscriptions Admin | `client.subscriptions.admin` | `get_templates`, `create_template`, `update_template`, `delete_template`, `create_custom_subscription` |
|
|
236
|
+
| Templates | `client.templates` | `create`, `list`, `get`, `update`, `publish`, `archive`, `versions`, `validate`, `capabilities`, `upload_media` |
|
|
237
|
+
| Users | `client.users` | `get_users`, `create_user`, `create_service_user`, `update_user`, `delete_user`, `get_notification_preferences`, `update_notification_preferences` |
|
|
238
|
+
| Users Admin | `client.users.admin` | `get_users`, `create_internal_user` |
|
|
239
|
+
| Webhooks | `client.webhooks` | `get_webhooks`, `create_webhook`, `update_webhook`, `delete_webhook` |
|
|
240
|
+
|
|
241
|
+
## Error Handling
|
|
242
|
+
|
|
243
|
+
```ruby
|
|
244
|
+
begin
|
|
245
|
+
result = client.messages.send_sms(
|
|
246
|
+
sender_phone_number: "15551234567",
|
|
247
|
+
recipient_phone_numbers: ["15559876543"],
|
|
248
|
+
message_body: "Hello!"
|
|
249
|
+
)
|
|
250
|
+
rescue SignalHouseSms::ValidationError => e
|
|
251
|
+
puts "Validation error: #{e.message} (status: #{e.status})"
|
|
252
|
+
rescue SignalHouseSms::Error => e
|
|
253
|
+
puts "SignalHouse error: #{e.message} (status: #{e.status})"
|
|
254
|
+
end
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
## Response Format
|
|
258
|
+
|
|
259
|
+
All methods return a standardized hash:
|
|
260
|
+
|
|
261
|
+
**Success:**
|
|
262
|
+
```ruby
|
|
263
|
+
{
|
|
264
|
+
"success" => true,
|
|
265
|
+
"data" => { ... }, # Parsed JSON response body
|
|
266
|
+
"status" => 200 # HTTP status code
|
|
267
|
+
}
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
**Error:**
|
|
271
|
+
```ruby
|
|
272
|
+
{
|
|
273
|
+
"success" => false,
|
|
274
|
+
"error" => "Error message",
|
|
275
|
+
"status" => 400 # HTTP status code
|
|
276
|
+
}
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
## Requirements
|
|
280
|
+
|
|
281
|
+
- Ruby >= 3.0.0
|
|
282
|
+
- No external dependencies (uses `net/http` and `json` from stdlib)
|
|
283
|
+
|
|
284
|
+
## License
|
|
285
|
+
|
|
286
|
+
MIT
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "securerandom"
|
|
4
|
+
|
|
5
|
+
module SignalHouseSms
|
|
6
|
+
class Client
|
|
7
|
+
attr_reader :agents, :auth, :billing, :brands, :campaigns, :groups, :landings,
|
|
8
|
+
:messages, :notifications, :numbers, :registrations, :onboarding,
|
|
9
|
+
:shortlinks, :subgroups, :subscriptions, :templates, :tickets, :users, :voice, :webhooks
|
|
10
|
+
|
|
11
|
+
# Initialize a new SignalHouse client.
|
|
12
|
+
#
|
|
13
|
+
# @param api_key [String] Your SignalHouse API key (Bearer token)
|
|
14
|
+
# @param base_url [String] The base URL of the SignalHouse API
|
|
15
|
+
# @param enable_admin [Boolean] Whether to enable admin-only methods
|
|
16
|
+
def initialize(api_key:, base_url:, enable_admin: false)
|
|
17
|
+
raise SignalHouseSms::ValidationError.new("api_key") if api_key.nil? || api_key.to_s.strip.empty?
|
|
18
|
+
raise SignalHouseSms::ValidationError.new("base_url") if base_url.nil? || base_url.to_s.strip.empty?
|
|
19
|
+
|
|
20
|
+
json_client = HttpClient.new(base_url: base_url, api_key: api_key, multipart: false)
|
|
21
|
+
multipart_client = HttpClient.new(base_url: base_url, api_key: api_key, multipart: true)
|
|
22
|
+
|
|
23
|
+
@agents = Agents.new(json_client, enable_admin)
|
|
24
|
+
@auth = Auth.new(json_client, enable_admin)
|
|
25
|
+
@billing = Billing.new(json_client, enable_admin)
|
|
26
|
+
@brands = Brands.new(json_client, multipart_client, enable_admin)
|
|
27
|
+
@campaigns = Campaigns.new(json_client, multipart_client, enable_admin)
|
|
28
|
+
@groups = Groups.new(json_client, enable_admin)
|
|
29
|
+
@landings = Landings.new(json_client, multipart_client, enable_admin)
|
|
30
|
+
@messages = Messages.new(json_client, multipart_client, enable_admin)
|
|
31
|
+
@notifications = Notifications.new(json_client, enable_admin)
|
|
32
|
+
@numbers = Numbers.new(json_client, multipart_client, enable_admin)
|
|
33
|
+
@registrations = Registrations.new(json_client, enable_admin)
|
|
34
|
+
@onboarding = Onboarding.new(json_client, enable_admin)
|
|
35
|
+
@shortlinks = Shortlinks.new(json_client, enable_admin)
|
|
36
|
+
@subgroups = Subgroups.new(json_client, enable_admin)
|
|
37
|
+
@subscriptions = Subscriptions.new(json_client, enable_admin)
|
|
38
|
+
@templates = Templates.new(json_client, multipart_client, enable_admin)
|
|
39
|
+
@tickets = Tickets.new(json_client, enable_admin)
|
|
40
|
+
@users = Users.new(json_client, enable_admin)
|
|
41
|
+
@voice = Voice.new(json_client, enable_admin)
|
|
42
|
+
@webhooks = Webhooks.new(json_client, enable_admin)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|