Class: Pingram::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/pingram/client_wrapper.rb

Overview

High-level Pingram client: holds API key and base URL, exposes tag APIs and send.

Examples:

Webhook verification

event = Pingram::WebhookVerification.construct_event(
  payload: request.body.read,
  signature: request.env['HTTP_X_PINGRAM_SIGNATURE'],
  timestamp: request.env['HTTP_X_PINGRAM_TIMESTAMP'],
  secret: ENV['PINGRAM_WEBHOOK_SECRET']
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key:, base_url: nil) ⇒ Client

Returns a new instance of Client.

Parameters:

  • api_key (String) —

    API key (e.g. pingram_sk_...) or JWT

  • base_url (String, nil) (defaults to: nil) —

    Optional override for base URL (e.g. https://api.pingram.io)



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/pingram/client_wrapper.rb', line 87

def initialize(api_key:, base_url: nil)
  @api_key = api_key
  @base_url = base_url
  @config = Pingram::Configuration.default.dup
  @config.access_token = api_key
  @config.host = base_url.to_s.sub(%r{/$}, '') if base_url && !base_url.to_s.empty?
  @api_client = Pingram::ApiClient.new(@config)

  @account = Pingram::AccountApi.new(@api_client)

  @accounts = Pingram::AccountsApi.new(@api_client)

  @addresses = Pingram::AddressesApi.new(@api_client)

  @broadcasts = Pingram::BroadcastsApi.new(@api_client)

  @components = Pingram::ComponentsApi.new(@api_client)

  @default_api = Pingram::DefaultApi.new(@api_client)

  @domains = Pingram::DomainsApi.new(@api_client)

  @editor = Pingram::EditorApi.new(@api_client)

  @email = Pingram::EmailApi.new(@api_client)

  @environments = Pingram::EnvironmentsApi.new(@api_client)

  @health = Pingram::HealthApi.new(@api_client)

  @insights = Pingram::InsightsApi.new(@api_client)

  @keys = Pingram::KeysApi.new(@api_client)

  @library = Pingram::LibraryApi.new(@api_client)

  @logs = Pingram::LogsApi.new(@api_client)

  @members = Pingram::MembersApi.new(@api_client)

  @numbers = Pingram::NumbersApi.new(@api_client)

  @profile = Pingram::ProfileApi.new(@api_client)

  @registrations = Pingram::RegistrationsApi.new(@api_client)

  @sender = Pingram::SenderApi.new(@api_client)

  @sms = Pingram::SmsApi.new(@api_client)

  @sub_notifications = Pingram::SubNotificationsApi.new(@api_client)

  @templates = Pingram::TemplatesApi.new(@api_client)

  @types = Pingram::TypesApi.new(@api_client)

  @user = Pingram::UserApi.new(@api_client)

  @users = Pingram::UsersApi.new(@api_client)

  @voice = Pingram::VoiceApi.new(@api_client)

  @webhooks = Pingram::WebhooksApi.new(@api_client)

end

Instance Attribute Details

#api_key ⇒ String (readonly)

Returns API key (e.g. pingram_sk_...).

Returns:

  • (String) —

    API key (e.g. pingram_sk_...)



80
81
82
# File 'lib/pingram/client_wrapper.rb', line 80

def api_key
  @api_key
end

#base_url ⇒ String? (readonly)

Returns Override base URL (default from Configuration).

Returns:

  • (String, nil) —

    Override base URL (default from Configuration)



83
84
85
# File 'lib/pingram/client_wrapper.rb', line 83

def base_url
  @base_url
end

Instance Method Details

#account ⇒ Pingram::AccountApi

Returns:



155
156
157
# File 'lib/pingram/client_wrapper.rb', line 155

def 
  @account
end

#accounts ⇒ Pingram::AccountsApi



161
162
163
# File 'lib/pingram/client_wrapper.rb', line 161

def accounts
  @accounts
end

#addresses ⇒ Pingram::AddressesApi



167
168
169
# File 'lib/pingram/client_wrapper.rb', line 167

def addresses
  @addresses
end

#broadcasts ⇒ Pingram::BroadcastsApi



173
174
175
# File 'lib/pingram/client_wrapper.rb', line 173

def broadcasts
  @broadcasts
end

#components ⇒ Pingram::ComponentsApi



179
180
181
# File 'lib/pingram/client_wrapper.rb', line 179

def components
  @components
end

#default_api ⇒ Pingram::DefaultApi

Returns:



185
186
187
# File 'lib/pingram/client_wrapper.rb', line 185

def default_api
  @default_api
end

#domains ⇒ Pingram::DomainsApi

Returns:



191
192
193
# File 'lib/pingram/client_wrapper.rb', line 191

def domains
  @domains
end

#editor ⇒ Pingram::EditorApi

Returns:



197
198
199
# File 'lib/pingram/client_wrapper.rb', line 197

def editor
  @editor
end

#email ⇒ Pingram::EmailApi

Returns:



203
204
205
# File 'lib/pingram/client_wrapper.rb', line 203

def email
  @email
end

#environments ⇒ Pingram::EnvironmentsApi



209
210
211
# File 'lib/pingram/client_wrapper.rb', line 209

def environments
  @environments
end

#health ⇒ Pingram::HealthApi

Returns:



215
216
217
# File 'lib/pingram/client_wrapper.rb', line 215

def health
  @health
end

#insights ⇒ Pingram::InsightsApi



221
222
223
# File 'lib/pingram/client_wrapper.rb', line 221

def insights
  @insights
end

#keys ⇒ Pingram::KeysApi

Returns:



227
228
229
# File 'lib/pingram/client_wrapper.rb', line 227

def keys
  @keys
end

#library ⇒ Pingram::LibraryApi

Returns:



233
234
235
# File 'lib/pingram/client_wrapper.rb', line 233

def library
  @library
end

#logs ⇒ Pingram::LogsApi

Returns:



239
240
241
# File 'lib/pingram/client_wrapper.rb', line 239

def logs
  @logs
end

#members ⇒ Pingram::MembersApi

Returns:



245
246
247
# File 'lib/pingram/client_wrapper.rb', line 245

def members
  @members
end

#numbers ⇒ Pingram::NumbersApi

Returns:



251
252
253
# File 'lib/pingram/client_wrapper.rb', line 251

def numbers
  @numbers
end

#profile ⇒ Pingram::ProfileApi

Returns:



257
258
259
# File 'lib/pingram/client_wrapper.rb', line 257

def profile
  @profile
end

#registrations ⇒ Pingram::RegistrationsApi



263
264
265
# File 'lib/pingram/client_wrapper.rb', line 263

def registrations
  @registrations
end

#send(body) ⇒ Object

Send a notification. Delegates to DefaultApi#call_send (Ruby renames send to call_send).

Parameters:

  • body (Object) —

    Request body (e.g. Pingram::SenderPostBody or Hash)

Returns:

  • (Object) —

    Response (e.g. Pingram::SenderPostResponse)



326
327
328
# File 'lib/pingram/client_wrapper.rb', line 326

def send(body)
  @default_api.call_send(body)
end

#sender ⇒ Pingram::SenderApi

Returns:



269
270
271
# File 'lib/pingram/client_wrapper.rb', line 269

def sender
  @sender
end

#sms ⇒ Pingram::SmsApi

Returns:



275
276
277
# File 'lib/pingram/client_wrapper.rb', line 275

def sms
  @sms
end

#sub_notifications ⇒ Pingram::SubNotificationsApi



281
282
283
# File 'lib/pingram/client_wrapper.rb', line 281

def sub_notifications
  @sub_notifications
end

#templates ⇒ Pingram::TemplatesApi



287
288
289
# File 'lib/pingram/client_wrapper.rb', line 287

def templates
  @templates
end

#types ⇒ Pingram::TypesApi

Returns:



293
294
295
# File 'lib/pingram/client_wrapper.rb', line 293

def types
  @types
end

#user ⇒ Pingram::UserApi

Returns:



299
300
301
# File 'lib/pingram/client_wrapper.rb', line 299

def user
  @user
end

#users ⇒ Pingram::UsersApi

Returns:



305
306
307
# File 'lib/pingram/client_wrapper.rb', line 305

def users
  @users
end

#voice ⇒ Pingram::VoiceApi

Returns:



311
312
313
# File 'lib/pingram/client_wrapper.rb', line 311

def voice
  @voice
end

#webhooks ⇒ Pingram::WebhooksApi



317
318
319
# File 'lib/pingram/client_wrapper.rb', line 317

def webhooks
  @webhooks
end