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



79
80
81
82
83
84
85
86
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
# File 'lib/pingram/client_wrapper.rb', line 79

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)

  @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)

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

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

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

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

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

  @sms = Pingram::SmsApi.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)



72
73
74
# File 'lib/pingram/client_wrapper.rb', line 72

def api_key
  @api_key
end

#base_url ⇒ String? (readonly)



75
76
77
# File 'lib/pingram/client_wrapper.rb', line 75

def base_url
  @base_url
end

Instance Method Details

#account ⇒ Pingram::AccountApi



139
140
141
# File 'lib/pingram/client_wrapper.rb', line 139

def 
  @account
end

#accounts ⇒ Pingram::AccountsApi



145
146
147
# File 'lib/pingram/client_wrapper.rb', line 145

def accounts
  @accounts
end

#addresses ⇒ Pingram::AddressesApi



151
152
153
# File 'lib/pingram/client_wrapper.rb', line 151

def addresses
  @addresses
end

#components ⇒ Pingram::ComponentsApi



157
158
159
# File 'lib/pingram/client_wrapper.rb', line 157

def components
  @components
end

#default_api ⇒ Pingram::DefaultApi



163
164
165
# File 'lib/pingram/client_wrapper.rb', line 163

def default_api
  @default_api
end

#domains ⇒ Pingram::DomainsApi



169
170
171
# File 'lib/pingram/client_wrapper.rb', line 169

def domains
  @domains
end

#editor ⇒ Pingram::EditorApi



175
176
177
# File 'lib/pingram/client_wrapper.rb', line 175

def editor
  @editor
end

#email ⇒ Pingram::EmailApi



181
182
183
# File 'lib/pingram/client_wrapper.rb', line 181

def email
  @email
end

#environments ⇒ Pingram::EnvironmentsApi



187
188
189
# File 'lib/pingram/client_wrapper.rb', line 187

def environments
  @environments
end

#health ⇒ Pingram::HealthApi



193
194
195
# File 'lib/pingram/client_wrapper.rb', line 193

def health
  @health
end

#insights ⇒ Pingram::InsightsApi



199
200
201
# File 'lib/pingram/client_wrapper.rb', line 199

def insights
  @insights
end

#keys ⇒ Pingram::KeysApi



205
206
207
# File 'lib/pingram/client_wrapper.rb', line 205

def keys
  @keys
end

#logs ⇒ Pingram::LogsApi



211
212
213
# File 'lib/pingram/client_wrapper.rb', line 211

def logs
  @logs
end

#members ⇒ Pingram::MembersApi



217
218
219
# File 'lib/pingram/client_wrapper.rb', line 217

def members
  @members
end

#numbers ⇒ Pingram::NumbersApi



223
224
225
# File 'lib/pingram/client_wrapper.rb', line 223

def numbers
  @numbers
end

#profile ⇒ Pingram::ProfileApi



229
230
231
# File 'lib/pingram/client_wrapper.rb', line 229

def profile
  @profile
end

#send(body) ⇒ Object

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



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

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

#sender ⇒ Pingram::SenderApi



235
236
237
# File 'lib/pingram/client_wrapper.rb', line 235

def sender
  @sender
end

#sms ⇒ Pingram::SmsApi



241
242
243
# File 'lib/pingram/client_wrapper.rb', line 241

def sms
  @sms
end

#templates ⇒ Pingram::TemplatesApi



247
248
249
# File 'lib/pingram/client_wrapper.rb', line 247

def templates
  @templates
end

#types ⇒ Pingram::TypesApi



253
254
255
# File 'lib/pingram/client_wrapper.rb', line 253

def types
  @types
end

#user ⇒ Pingram::UserApi



259
260
261
# File 'lib/pingram/client_wrapper.rb', line 259

def user
  @user
end

#users ⇒ Pingram::UsersApi



265
266
267
# File 'lib/pingram/client_wrapper.rb', line 265

def users
  @users
end

#voice ⇒ Pingram::VoiceApi



271
272
273
# File 'lib/pingram/client_wrapper.rb', line 271

def voice
  @voice
end

#webhooks ⇒ Pingram::WebhooksApi



277
278
279
# File 'lib/pingram/client_wrapper.rb', line 277

def webhooks
  @webhooks
end